001/* 002 * (C) Copyright 2006-2007 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 * Nuxeo - initial API and implementation 018 * 019 * $Id$ 020 */ 021 022package org.nuxeo.ecm.platform.filemanager.service.extension; 023 024import org.nuxeo.common.xmap.annotation.XNode; 025import org.nuxeo.common.xmap.annotation.XObject; 026import org.nuxeo.ecm.core.api.NuxeoException; 027import org.nuxeo.ecm.platform.filemanager.service.FileManagerService; 028import org.nuxeo.runtime.model.Descriptor; 029 030@XObject("folderImporter") 031public class FolderImporterDescriptor implements Descriptor { 032 033 @XNode("@name") 034 protected String name; 035 036 /** 037 * @deprecated since 11.1. 038 */ 039 @Deprecated(since = "11.1") 040 @XNode("@class") 041 protected String className; 042 043 @XNode("@class") 044 protected Class<? extends FolderImporter> klass; 045 046 public String getName() { 047 return name; 048 } 049 050 /** 051 * @deprecated since 11.1. 052 */ 053 @Deprecated(since = "11.1") 054 public String getClassName() { 055 return className; 056 } 057 058 /** 059 * @since 11.1 060 */ 061 public FolderImporter newInstance() { 062 try { 063 FolderImporter folderImporter = klass.getDeclaredConstructor().newInstance(); 064 folderImporter.setName(name); 065 return folderImporter; 066 } catch (ReflectiveOperationException e) { 067 throw new NuxeoException(e); 068 } 069 } 070 071 @Override 072 public String getId() { 073 return name; 074 } 075}