mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
- Incorporate JCR project into Repository project
- Single configuration entry point for JCR and non-JCR clients (i.e. application-context.xml) - Addition of build-war, incremental-war build targets (no deploy) - Remove build of JCR TCK war file by default git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2777 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
139
source/java/org/alfresco/jcr/dictionary/ClassMap.java
Normal file
139
source/java/org/alfresco/jcr/dictionary/ClassMap.java
Normal file
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* Copyright (C) 2005 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Mozilla Public License version 1.1
|
||||
* with a permitted attribution clause. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfresco.org/legal/license.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
package org.alfresco.jcr.dictionary;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.jcr.RepositoryException;
|
||||
|
||||
import org.alfresco.jcr.session.SessionImpl;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
|
||||
/**
|
||||
* Responsible for mapping Alfresco Classes to JCR Types / Mixins and vice versa.
|
||||
*
|
||||
* @author David Caruana
|
||||
*/
|
||||
public class ClassMap
|
||||
{
|
||||
/** Map of Alfresco Class to JCR Class */
|
||||
private static Map<QName, QName> JCRToAlfresco = new HashMap<QName, QName>();
|
||||
static
|
||||
{
|
||||
JCRToAlfresco.put(NodeTypeImpl.MIX_REFERENCEABLE, ContentModel.ASPECT_REFERENCEABLE);
|
||||
JCRToAlfresco.put(NodeTypeImpl.MIX_LOCKABLE, ContentModel.ASPECT_LOCKABLE);
|
||||
JCRToAlfresco.put(NodeTypeImpl.MIX_VERSIONABLE, ContentModel.ASPECT_VERSIONABLE);
|
||||
}
|
||||
|
||||
/** Map of JCR Class to Alfresco Class */
|
||||
private static Map<QName, QName> AlfrescoToJCR = new HashMap<QName, QName>();
|
||||
static
|
||||
{
|
||||
AlfrescoToJCR.put(ContentModel.ASPECT_REFERENCEABLE, NodeTypeImpl.MIX_REFERENCEABLE);
|
||||
AlfrescoToJCR.put(ContentModel.ASPECT_LOCKABLE, NodeTypeImpl.MIX_LOCKABLE);
|
||||
AlfrescoToJCR.put(ContentModel.ASPECT_VERSIONABLE, NodeTypeImpl.MIX_VERSIONABLE);
|
||||
}
|
||||
|
||||
/** Map of JCR to Alfresco "Add Aspect" Behaviours */
|
||||
private static Map<QName, AddMixin> addMixin = new HashMap<QName, AddMixin>();
|
||||
static
|
||||
{
|
||||
addMixin.put(ContentModel.ASPECT_VERSIONABLE, new VersionableMixin());
|
||||
}
|
||||
|
||||
/** Map of JCR to Alfresco "Remove Aspect" Behaviours */
|
||||
private static Map<QName, RemoveMixin> removeMixin = new HashMap<QName, RemoveMixin>();
|
||||
static
|
||||
{
|
||||
removeMixin.put(ContentModel.ASPECT_VERSIONABLE, new VersionableMixin());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert an Alfresco Class to a JCR Type
|
||||
*
|
||||
* @param jcrType JCR Type
|
||||
* @return Alfresco Class
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
public static QName convertTypeToClass(QName jcrType)
|
||||
{
|
||||
return JCRToAlfresco.get(jcrType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an Alfresco Class to a JCR Type
|
||||
*
|
||||
* @param alfrescoClass Alfresco Class
|
||||
* @return JCR Type
|
||||
* @throws RepositoryException
|
||||
*/
|
||||
public static QName convertClassToType(QName alfrescoClass)
|
||||
{
|
||||
return JCRToAlfresco.get(alfrescoClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get 'Add Mixin' JCR behaviour
|
||||
*
|
||||
* @param alfrescoClass
|
||||
* @return AddMixin behaviour
|
||||
*/
|
||||
public static AddMixin getAddMixin(QName alfrescoClass)
|
||||
{
|
||||
return addMixin.get(alfrescoClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get 'Remove Mixin' JCR behaviour
|
||||
*
|
||||
* @param alfrescoClass
|
||||
* @return RemoveMixin behaviour
|
||||
*/
|
||||
public static RemoveMixin getRemoveMixin(QName alfrescoClass)
|
||||
{
|
||||
return removeMixin.get(alfrescoClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Mixin Behaviour
|
||||
*
|
||||
* Encapsulates mapping of JCR behaviour to Alfresco
|
||||
*/
|
||||
public interface AddMixin
|
||||
{
|
||||
public Map<QName, Serializable> preAddMixin(SessionImpl session, NodeRef nodeRef);
|
||||
public void postAddMixin(SessionImpl session, NodeRef nodeRef);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove Mixin Behaviour
|
||||
*
|
||||
* Encapsulates mapping of JCR behaviour to Alfresco
|
||||
*/
|
||||
public interface RemoveMixin
|
||||
{
|
||||
public void preRemoveMixin(SessionImpl session, NodeRef nodeRef);
|
||||
public void postRemoveMixin(SessionImpl session, NodeRef nodeRef);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user