001/* 002 * (C) Copyright 2006-2011 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Thomas Roger <[email protected]> 018 */ 019 020package org.nuxeo.ecm.platform.video.service; 021 022import java.util.HashMap; 023import java.util.Map; 024 025import org.nuxeo.runtime.model.ContributionFragmentRegistry; 026 027/** 028 * {@link ContributionFragmentRegistry} to register {@link AutomaticVideoConversion}. 029 * 030 * @author <a href="mailto:[email protected]">Thomas Roger</a> 031 * @since 5.5 032 */ 033public class AutomaticVideoConversionContributionHandler extends ContributionFragmentRegistry<AutomaticVideoConversion> { 034 035 public final Map<String, AutomaticVideoConversion> registry; 036 037 public AutomaticVideoConversionContributionHandler() { 038 registry = new HashMap<String, AutomaticVideoConversion>(); 039 } 040 041 @Override 042 public String getContributionId(AutomaticVideoConversion contrib) { 043 return contrib.getName(); 044 } 045 046 @Override 047 public void contributionUpdated(String id, AutomaticVideoConversion contrib, AutomaticVideoConversion newOrigContrib) { 048 if (contrib.isEnabled()) { 049 registry.put(id, contrib); 050 } else { 051 registry.remove(id); 052 } 053 } 054 055 @Override 056 public void contributionRemoved(String id, AutomaticVideoConversion origContrib) { 057 registry.remove(id); 058 } 059 060 @Override 061 public AutomaticVideoConversion clone(AutomaticVideoConversion object) { 062 try { 063 return object.clone(); 064 } catch (CloneNotSupportedException e) { 065 throw new Error(e); // cannot happens. 066 } 067 } 068 069 @Override 070 public void merge(AutomaticVideoConversion src, AutomaticVideoConversion dst) { 071 dst.setEnabled(src.isEnabled()); 072 } 073 074}