Cleanly split CMIS interfaces from CMIS implementation.

- org.alfresco.cmis => public interfaces
- org.alfresco.cmis.mapping / dictionary / search => implementation

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13808 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2009-04-02 13:50:10 +00:00
parent af2b4f43c4
commit ee67b1f7de
64 changed files with 873 additions and 582 deletions

View File

@@ -1,162 +0,0 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.cmis.dictionary;
import java.util.Date;
import javax.transaction.Status;
import javax.transaction.UserTransaction;
import junit.framework.TestCase;
import org.alfresco.cmis.CMISService;
import org.alfresco.cmis.mapping.CMISMapping;
import org.alfresco.cmis.search.CMISQueryService;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.ApplicationContextHelper;
import org.springframework.context.ApplicationContext;
/**
* Base CMIS test
* Basic TX control and authentication
*
* @author andyh
*
*/
public abstract class BaseCMISTest extends TestCase
{
private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
protected CMISMapping cmisMapping;
protected CMISService cmisService;
protected CMISDictionaryService cmisDictionaryService;
protected DictionaryService dictionaryService;
protected TransactionService transactionService;
protected AuthenticationComponent authenticationComponent;
protected UserTransaction testTX;
protected NodeService nodeService;
protected NodeRef rootNodeRef;
protected FileFolderService fileFolderService;
protected ServiceRegistry serviceRegistry;
protected NamespaceService namespaceService;
protected CMISQueryService cmisQueryService;
private AuthenticationService authenticationService;
private MutableAuthenticationDao authenticationDAO;
protected SearchService searchService;
protected ContentService contentService;
public void setUp() throws Exception
{
serviceRegistry = (ServiceRegistry) ctx.getBean("ServiceRegistry");
cmisDictionaryService = (CMISDictionaryService) ctx.getBean("CMISDictionaryService");
cmisMapping = (CMISMapping) ctx.getBean("CMISMapping");
cmisQueryService = (CMISQueryService) ctx.getBean("CMISQueryService");
cmisService = (CMISService) ctx.getBean("CMISService");
dictionaryService = (DictionaryService) ctx.getBean("dictionaryService");
nodeService = (NodeService) ctx.getBean("nodeService");
fileFolderService = (FileFolderService) ctx.getBean("fileFolderService");
namespaceService = (NamespaceService) ctx.getBean("namespaceService");
transactionService = (TransactionService) ctx.getBean("transactionComponent");
authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
searchService = (SearchService) ctx.getBean("searchService");
contentService = (ContentService) ctx.getBean("contentService");
authenticationService = (AuthenticationService) ctx.getBean("authenticationService");
authenticationDAO = (MutableAuthenticationDao) ctx.getBean("authenticationDao");
testTX = transactionService.getUserTransaction();
testTX.begin();
this.authenticationComponent.setSystemUserAsCurrentUser();
String storeName = "CMISTest-" + getStoreName() + "-" + (new Date().getTime());
StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, storeName);
rootNodeRef = nodeService.getRootNode(storeRef);
if(authenticationDAO.userExists("cmis"))
{
authenticationService.deleteAuthentication("cmis");
}
authenticationService.createAuthentication("cmis", "cmis".toCharArray());
}
private String getStoreName()
{
String testName = getName();
testName = testName.replace("_", "-");
testName = testName.replace("%", "-");
return testName;
}
protected void runAs(String userName)
{
authenticationService.authenticate(userName, userName.toCharArray());
assertNotNull(authenticationService.getCurrentUserName());
}
@Override
protected void tearDown() throws Exception
{
if (testTX.getStatus() == Status.STATUS_ACTIVE)
{
testTX.rollback();
}
AuthenticationUtil.clearCurrentSecurityContext();
super.tearDown();
}
}

View File

@@ -33,6 +33,12 @@ import java.util.Map;
import java.util.TreeMap;
import org.alfresco.cmis.CMISDataTypeEnum;
import org.alfresco.cmis.CMISDictionaryService;
import org.alfresco.cmis.CMISPropertyDefinition;
import org.alfresco.cmis.CMISPropertyId;
import org.alfresco.cmis.CMISScope;
import org.alfresco.cmis.CMISTypeDefinition;
import org.alfresco.cmis.CMISTypeId;
import org.alfresco.cmis.mapping.CMISMapping;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.dictionary.DictionaryDAO;

View File

@@ -33,6 +33,10 @@ import java.util.LinkedList;
import java.util.Map;
import org.alfresco.cmis.CMISContentStreamAllowedEnum;
import org.alfresco.cmis.CMISPropertyDefinition;
import org.alfresco.cmis.CMISPropertyId;
import org.alfresco.cmis.CMISTypeDefinition;
import org.alfresco.cmis.CMISTypeId;
import org.alfresco.cmis.dictionary.CMISAbstractDictionaryService.DictionaryRegistry;
import org.alfresco.cmis.mapping.CMISMapping;
import org.alfresco.error.AlfrescoRuntimeException;
@@ -117,7 +121,7 @@ public class CMISAbstractTypeDefinition implements CMISTypeDefinition, Serializa
String propertyName = cmisMapping.getCmisPropertyName(propertyQName);
String propertyId = cmisMapping.getCmisPropertyId(propertyQName);
CMISPropertyId cmisPropertyId = new CMISPropertyId(propertyName, propertyId, propertyQName);
return new CMISPropertyDefinition(cmisMapping, cmisPropertyId, propDef, this);
return new CMISBasePropertyDefinition(cmisMapping, cmisPropertyId, propDef, this);
}
/**

View File

@@ -1,368 +1,372 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.cmis.dictionary;
import java.io.Serializable;
import java.util.Collection;
import java.util.HashSet;
import org.alfresco.cmis.CMISCardinalityEnum;
import org.alfresco.cmis.CMISDataTypeEnum;
import org.alfresco.cmis.CMISUpdatabilityEnum;
import org.alfresco.cmis.mapping.CMISMapping;
import org.alfresco.cmis.property.AbstractPropertyAccessor;
import org.alfresco.cmis.property.PropertyAccessor;
import org.alfresco.cmis.property.PropertyLuceneBuilder;
import org.alfresco.repo.dictionary.IndexTokenisationMode;
import org.alfresco.repo.dictionary.constraint.ListOfValuesConstraint;
import org.alfresco.repo.dictionary.constraint.StringLengthConstraint;
import org.alfresco.repo.search.impl.lucene.analysis.DateTimeAnalyser;
import org.alfresco.repo.search.impl.lucene.analysis.DoubleAnalyser;
import org.alfresco.repo.search.impl.lucene.analysis.FloatAnalyser;
import org.alfresco.repo.search.impl.lucene.analysis.IntegerAnalyser;
import org.alfresco.repo.search.impl.lucene.analysis.LongAnalyser;
import org.alfresco.repo.search.impl.lucene.analysis.PathAnalyser;
import org.alfresco.repo.search.impl.lucene.analysis.VerbatimAnalyser;
import org.alfresco.service.cmr.dictionary.Constraint;
import org.alfresco.service.cmr.dictionary.ConstraintDefinition;
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
/**
* CMIS Property Definition
*
* @author andyh
*/
public class CMISPropertyDefinition implements Serializable
{
private static final long serialVersionUID = -8119257313852558466L;
// Properties of Property
private CMISTypeDefinition typeDef;
private CMISPropertyId propertyId;
private String displayName;
private String description;
private CMISDataTypeEnum propertyType;
private CMISCardinalityEnum cardinality;
private int maximumLength = -1;
private String schemaURI = null;
private String encoding = null;
private Collection<CMISChoice> choices = new HashSet<CMISChoice>();
private boolean isOpenChoice = false;
private boolean required;
private String defaultValue;
private CMISUpdatabilityEnum updatability;
private boolean queryable;
private boolean orderable;
private AbstractPropertyAccessor propertyAccessor;
/**
* Construct
*
* @param cmisMapping
* @param propertyId
* @param propDef
* @param typeDef
*/
public CMISPropertyDefinition(CMISMapping cmisMapping, CMISPropertyId propertyId, PropertyDefinition propDef, CMISTypeDefinition typeDef)
{
this.propertyId = propertyId;
this.typeDef = typeDef;
displayName = (propDef.getTitle() != null) ? propDef.getTitle() : propertyId.getName();
description = propDef.getDescription();
propertyType = cmisMapping.getDataType(propDef.getDataType());
cardinality = propDef.isMultiValued() ? CMISCardinalityEnum.MULTI_VALUED : CMISCardinalityEnum.SINGLE_VALUED;
for (ConstraintDefinition constraintDef : propDef.getConstraints())
{
Constraint constraint = constraintDef.getConstraint();
if (constraint instanceof ListOfValuesConstraint)
{
int position = 1; // CMIS is 1 based (according to XSDs)
ListOfValuesConstraint lovc = (ListOfValuesConstraint) constraint;
for (String allowed : lovc.getAllowedValues())
{
CMISChoice choice = new CMISChoice(allowed, allowed, position++);
choices.add(choice);
}
}
if (constraint instanceof StringLengthConstraint)
{
StringLengthConstraint slc = (StringLengthConstraint) constraint;
maximumLength = slc.getMaxLength();
}
}
required = propDef.isMandatory();
defaultValue = propDef.getDefaultValue();
updatability = propDef.isProtected() ? CMISUpdatabilityEnum.READ_ONLY : CMISUpdatabilityEnum.READ_AND_WRITE;
queryable = propDef.isIndexed();
if (queryable)
{
IndexTokenisationMode indexTokenisationMode = IndexTokenisationMode.TRUE;
if (propDef.getIndexTokenisationMode() != null)
{
indexTokenisationMode = propDef.getIndexTokenisationMode();
}
switch (indexTokenisationMode)
{
case BOTH:
case FALSE:
orderable = true;
break;
case TRUE:
default:
String analyserClassName = propDef.getDataType().getAnalyserClassName();
if (analyserClassName.equals(DateTimeAnalyser.class.getCanonicalName())
|| analyserClassName.equals(DoubleAnalyser.class.getCanonicalName()) || analyserClassName.equals(FloatAnalyser.class.getCanonicalName())
|| analyserClassName.equals(IntegerAnalyser.class.getCanonicalName()) || analyserClassName.equals(LongAnalyser.class.getCanonicalName())
|| analyserClassName.equals(PathAnalyser.class.getCanonicalName()) || analyserClassName.equals(VerbatimAnalyser.class.getCanonicalName()))
{
orderable = true;
}
else
{
orderable = false;
}
}
}
else
{
orderable = false;
}
propertyAccessor = cmisMapping.getPropertyAccessor(propertyId);
}
/**
* Get Property Id
*
* @return
*/
public CMISPropertyId getPropertyId()
{
return propertyId;
}
/**
* Get Owning Type
*
* @return
*/
public CMISTypeDefinition getOwningType()
{
return typeDef;
}
/**
* Get the display name
*
* @return
*/
public String getDisplayName()
{
return displayName;
}
/**
* Get the description
*
* @return
*/
public String getDescription()
{
return description;
}
/**
* Get the property type
*
* @return
*/
public CMISDataTypeEnum getDataType()
{
return propertyType;
}
/**
* Get the cardinality
*
* @return
*/
public CMISCardinalityEnum getCardinality()
{
return cardinality;
}
/**
* For variable length properties, get the maximum length allowed. Unsupported.
*
* @return
*/
public int getMaximumLength()
{
return maximumLength;
}
/**
* For properties of type CMISPropertyType.XML the schema to which the property must conform. Unsupported
*
* @return - the schema URI
*/
public String getSchemaURI()
{
return schemaURI;
}
/**
* For properties of type CMISPropertyType.XML the encoding used for the property value
*
* @return the encoding
*/
public String getEncoding()
{
return encoding;
}
/**
* Get the choices available as values for this property TODO: not implemented yet
*
* @return
*/
public Collection<CMISChoice> getChoices()
{
return choices;
}
/**
* Is this a choice where a user can enter other values (ie a list with common options)
*
* @return
*/
public boolean isOpenChoice()
{
return isOpenChoice;
}
/**
* Is this property required?
*
* @return
*/
public boolean isRequired()
{
return required;
}
/**
* get the default value as a String
*
* @return
*/
public String getDefaultValue()
{
return defaultValue;
}
/**
* Is this property updatable?
*
* @return
*/
public CMISUpdatabilityEnum getUpdatability()
{
return updatability;
}
/**
* Is this property queryable?
*
* @return
*/
public boolean isQueryable()
{
return queryable;
}
/**
* Is this property orderable in queries?
*
* @return
*/
public boolean isOrderable()
{
return orderable;
}
/**
* Gets the property accessor (for reading / writing values)
*
* @return
*/
public PropertyAccessor getPropertyAccessor()
{
return propertyAccessor;
}
/**
* Gets the property Lucene builder
*
* @return
*/
public PropertyLuceneBuilder getPropertyLuceneBuilder()
{
return propertyAccessor;
}
/*
* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{
StringBuilder builder = new StringBuilder();
builder.append("CMISPropertyDefinition[");
builder.append("OwningTypeId=").append(getOwningType().getTypeId()).append(", ");
builder.append("PropertyName=").append(getPropertyId().getName()).append(", ");
builder.append("PropertyId=").append(getPropertyId().getId()).append(", ");
builder.append("PropertyQName=").append(getPropertyId().getQName()).append(", ");
builder.append("DisplayName=").append(getDisplayName()).append(", ");
builder.append("Description=").append(getDescription()).append(", ");
builder.append("PropertyType=").append(getDataType()).append(", ");
builder.append("Cardinality=").append(getCardinality()).append(", ");
builder.append("MaximumLength=").append(getMaximumLength()).append(", ");
builder.append("SchemaURI=").append(getSchemaURI()).append(", ");
builder.append("Encoding=").append(getEncoding()).append(", ");
builder.append("Choices=").append(getChoices()).append(", ");
builder.append("IsOpenChoice=").append(isOpenChoice()).append(", ");
builder.append("Required=").append(isRequired()).append(", ");
builder.append("Default=").append(getDefaultValue()).append(", ");
builder.append("Updatable=").append(getUpdatability()).append(", ");
builder.append("Queryable=").append(isQueryable()).append(", ");
builder.append("Orderable=").append(isOrderable());
builder.append("]");
return builder.toString();
}
}
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.cmis.dictionary;
import java.io.Serializable;
import java.util.Collection;
import java.util.HashSet;
import org.alfresco.cmis.CMISCardinalityEnum;
import org.alfresco.cmis.CMISChoice;
import org.alfresco.cmis.CMISDataTypeEnum;
import org.alfresco.cmis.CMISPropertyDefinition;
import org.alfresco.cmis.CMISPropertyId;
import org.alfresco.cmis.CMISTypeDefinition;
import org.alfresco.cmis.CMISUpdatabilityEnum;
import org.alfresco.cmis.CMISPropertyAccessor;
import org.alfresco.cmis.CMISPropertyLuceneBuilder;
import org.alfresco.cmis.mapping.AbstractPropertyAccessor;
import org.alfresco.cmis.mapping.CMISMapping;
import org.alfresco.repo.dictionary.IndexTokenisationMode;
import org.alfresco.repo.dictionary.constraint.ListOfValuesConstraint;
import org.alfresco.repo.dictionary.constraint.StringLengthConstraint;
import org.alfresco.repo.search.impl.lucene.analysis.DateTimeAnalyser;
import org.alfresco.repo.search.impl.lucene.analysis.DoubleAnalyser;
import org.alfresco.repo.search.impl.lucene.analysis.FloatAnalyser;
import org.alfresco.repo.search.impl.lucene.analysis.IntegerAnalyser;
import org.alfresco.repo.search.impl.lucene.analysis.LongAnalyser;
import org.alfresco.repo.search.impl.lucene.analysis.PathAnalyser;
import org.alfresco.repo.search.impl.lucene.analysis.VerbatimAnalyser;
import org.alfresco.service.cmr.dictionary.Constraint;
import org.alfresco.service.cmr.dictionary.ConstraintDefinition;
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
/**
* CMIS Property Definition
*
* @author andyh
*/
public class CMISBasePropertyDefinition implements CMISPropertyDefinition, Serializable
{
private static final long serialVersionUID = -8119257313852558466L;
// Properties of Property
private CMISTypeDefinition typeDef;
private CMISPropertyId propertyId;
private String displayName;
private String description;
private CMISDataTypeEnum propertyType;
private CMISCardinalityEnum cardinality;
private int maximumLength = -1;
private String schemaURI = null;
private String encoding = null;
private Collection<CMISChoice> choices = new HashSet<CMISChoice>();
private boolean isOpenChoice = false;
private boolean required;
private String defaultValue;
private CMISUpdatabilityEnum updatability;
private boolean queryable;
private boolean orderable;
private AbstractPropertyAccessor propertyAccessor;
/**
* Construct
*
* @param cmisMapping
* @param propertyId
* @param propDef
* @param typeDef
*/
public CMISBasePropertyDefinition(CMISMapping cmisMapping, CMISPropertyId propertyId, PropertyDefinition propDef, CMISTypeDefinition typeDef)
{
this.propertyId = propertyId;
this.typeDef = typeDef;
displayName = (propDef.getTitle() != null) ? propDef.getTitle() : propertyId.getName();
description = propDef.getDescription();
propertyType = cmisMapping.getDataType(propDef.getDataType());
cardinality = propDef.isMultiValued() ? CMISCardinalityEnum.MULTI_VALUED : CMISCardinalityEnum.SINGLE_VALUED;
for (ConstraintDefinition constraintDef : propDef.getConstraints())
{
Constraint constraint = constraintDef.getConstraint();
if (constraint instanceof ListOfValuesConstraint)
{
int position = 1; // CMIS is 1 based (according to XSDs)
ListOfValuesConstraint lovc = (ListOfValuesConstraint) constraint;
for (String allowed : lovc.getAllowedValues())
{
CMISChoice choice = new CMISChoice(allowed, allowed, position++);
choices.add(choice);
}
}
if (constraint instanceof StringLengthConstraint)
{
StringLengthConstraint slc = (StringLengthConstraint) constraint;
maximumLength = slc.getMaxLength();
}
}
required = propDef.isMandatory();
defaultValue = propDef.getDefaultValue();
updatability = propDef.isProtected() ? CMISUpdatabilityEnum.READ_ONLY : CMISUpdatabilityEnum.READ_AND_WRITE;
queryable = propDef.isIndexed();
if (queryable)
{
IndexTokenisationMode indexTokenisationMode = IndexTokenisationMode.TRUE;
if (propDef.getIndexTokenisationMode() != null)
{
indexTokenisationMode = propDef.getIndexTokenisationMode();
}
switch (indexTokenisationMode)
{
case BOTH:
case FALSE:
orderable = true;
break;
case TRUE:
default:
String analyserClassName = propDef.getDataType().getAnalyserClassName();
if (analyserClassName.equals(DateTimeAnalyser.class.getCanonicalName())
|| analyserClassName.equals(DoubleAnalyser.class.getCanonicalName()) || analyserClassName.equals(FloatAnalyser.class.getCanonicalName())
|| analyserClassName.equals(IntegerAnalyser.class.getCanonicalName()) || analyserClassName.equals(LongAnalyser.class.getCanonicalName())
|| analyserClassName.equals(PathAnalyser.class.getCanonicalName()) || analyserClassName.equals(VerbatimAnalyser.class.getCanonicalName()))
{
orderable = true;
}
else
{
orderable = false;
}
}
}
else
{
orderable = false;
}
propertyAccessor = cmisMapping.getPropertyAccessor(propertyId);
}
/**
* Get Property Id
*
* @return
*/
public CMISPropertyId getPropertyId()
{
return propertyId;
}
/**
* Get Owning Type
*
* @return
*/
public CMISTypeDefinition getOwningType()
{
return typeDef;
}
/**
* Get the display name
*
* @return
*/
public String getDisplayName()
{
return displayName;
}
/**
* Get the description
*
* @return
*/
public String getDescription()
{
return description;
}
/**
* Get the property type
*
* @return
*/
public CMISDataTypeEnum getDataType()
{
return propertyType;
}
/**
* Get the cardinality
*
* @return
*/
public CMISCardinalityEnum getCardinality()
{
return cardinality;
}
/**
* For variable length properties, get the maximum length allowed. Unsupported.
*
* @return
*/
public int getMaximumLength()
{
return maximumLength;
}
/**
* For properties of type CMISPropertyType.XML the schema to which the property must conform. Unsupported
*
* @return - the schema URI
*/
public String getSchemaURI()
{
return schemaURI;
}
/**
* For properties of type CMISPropertyType.XML the encoding used for the property value
*
* @return the encoding
*/
public String getEncoding()
{
return encoding;
}
/**
* Get the choices available as values for this property TODO: not implemented yet
*
* @return
*/
public Collection<CMISChoice> getChoices()
{
return choices;
}
/**
* Is this a choice where a user can enter other values (ie a list with common options)
*
* @return
*/
public boolean isOpenChoice()
{
return isOpenChoice;
}
/**
* Is this property required?
*
* @return
*/
public boolean isRequired()
{
return required;
}
/**
* get the default value as a String
*
* @return
*/
public String getDefaultValue()
{
return defaultValue;
}
/**
* Is this property updatable?
*
* @return
*/
public CMISUpdatabilityEnum getUpdatability()
{
return updatability;
}
/**
* Is this property queryable?
*
* @return
*/
public boolean isQueryable()
{
return queryable;
}
/**
* Is this property orderable in queries?
*
* @return
*/
public boolean isOrderable()
{
return orderable;
}
/**
* Gets the property accessor (for reading / writing values)
*
* @return
*/
public CMISPropertyAccessor getPropertyAccessor()
{
return propertyAccessor;
}
/**
* Gets the property Lucene builder
*
* @return
*/
public CMISPropertyLuceneBuilder getPropertyLuceneBuilder()
{
return propertyAccessor;
}
/*
* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{
StringBuilder builder = new StringBuilder();
builder.append("CMISPropertyDefinition[");
builder.append("OwningTypeId=").append(getOwningType().getTypeId()).append(", ");
builder.append("PropertyName=").append(getPropertyId().getName()).append(", ");
builder.append("PropertyId=").append(getPropertyId().getId()).append(", ");
builder.append("PropertyQName=").append(getPropertyId().getQName()).append(", ");
builder.append("DisplayName=").append(getDisplayName()).append(", ");
builder.append("Description=").append(getDescription()).append(", ");
builder.append("PropertyType=").append(getDataType()).append(", ");
builder.append("Cardinality=").append(getCardinality()).append(", ");
builder.append("MaximumLength=").append(getMaximumLength()).append(", ");
builder.append("SchemaURI=").append(getSchemaURI()).append(", ");
builder.append("Encoding=").append(getEncoding()).append(", ");
builder.append("Choices=").append(getChoices()).append(", ");
builder.append("IsOpenChoice=").append(isOpenChoice()).append(", ");
builder.append("Required=").append(isRequired()).append(", ");
builder.append("Default=").append(getDefaultValue()).append(", ");
builder.append("Updatable=").append(getUpdatability()).append(", ");
builder.append("Queryable=").append(isQueryable()).append(", ");
builder.append("Orderable=").append(isOrderable());
builder.append("]");
return builder.toString();
}
}

View File

@@ -1,133 +0,0 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.cmis.dictionary;
import java.io.Serializable;
import java.util.Collection;
import java.util.HashSet;
/**
* Choice for property definitions
*
* @author andyh
*
*/
public class CMISChoice
{
private String name;
Serializable value;
private int index;
private Collection<CMISChoice> choices = new HashSet<CMISChoice>();
public CMISChoice(String name, Serializable value, int index)
{
this.name = name;
this.value = value;
this.index = index;
}
/**
* Get the name of the choice
* @return
*/
public String getName()
{
return name;
}
/**
* Get the value when chosen
* @return
*/
public Serializable getValue()
{
return value;
}
/**
* Get the index that determined the choices position amongst it siblings
* @return
*/
public int getIndex()
{
return index;
}
/**
* Get sub-choices
* @return
*/
public Collection<CMISChoice> getChildren()
{
return choices;
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + index;
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}
@Override
public boolean equals(Object obj)
{
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
final CMISChoice other = (CMISChoice) obj;
if (index != other.index)
return false;
if (name == null)
{
if (other.name != null)
return false;
}
else if (!name.equals(other.name))
return false;
return true;
}
public String toString()
{
StringBuilder builder = new StringBuilder();
builder.append("[Choice ");
builder.append("name=").append(getName()).append(",");
builder.append("index=").append(getIndex()).append(",");
builder.append("value=").append(getValue()).append(",");
builder.append("children=").append(getChildren());
builder.append("]");
return builder.toString();
}
}

View File

@@ -1,93 +0,0 @@
/*
* Copyright (C) 2005-2009 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.cmis.dictionary;
import org.alfresco.cmis.mapping.CMISMapping;
import org.alfresco.model.ContentModel;
/**
* CMIS <-> Alfresco mappings
*
* @author andyh
*/
public interface CMISDictionaryModel
{
/**
* Type id for CMIS documents, from the spec.
*/
public static String DOCUMENT_OBJECT_TYPE = "Document";
/**
* Type is for CMIS folders, from the spec.
*/
public static String FOLDER_OBJECT_TYPE = "Folder";
/**
* Type Id for CMIS Relationships, from the spec.
*/
public static String RELATIONSHIP_OBJECT_TYPE = "Relationship";
/**
* Type Id for CMIS Policies, from the spec.
*/
public static String POLICY_OBJECT_TYPE = "Policy";
// TODO: spec issue - objectTypeEnum is lower cased - object type ids are repository specific in spec
public static CMISTypeId DOCUMENT_TYPE_ID = new CMISTypeId(CMISScope.DOCUMENT, DOCUMENT_OBJECT_TYPE.toLowerCase(), ContentModel.TYPE_CONTENT);
public static CMISTypeId FOLDER_TYPE_ID = new CMISTypeId(CMISScope.FOLDER, FOLDER_OBJECT_TYPE.toLowerCase(), ContentModel.TYPE_FOLDER);
public static CMISTypeId RELATIONSHIP_TYPE_ID = new CMISTypeId(CMISScope.RELATIONSHIP, RELATIONSHIP_OBJECT_TYPE.toLowerCase(), CMISMapping.RELATIONSHIP_QNAME);
public static CMISTypeId POLICY_TYPE_ID = new CMISTypeId(CMISScope.POLICY, POLICY_OBJECT_TYPE.toLowerCase(), CMISMapping.POLICY_QNAME);
// CMIS properties
public static String PROP_OBJECT_ID = "ObjectId";
public static String PROP_URI = "Uri";
public static String PROP_OBJECT_TYPE_ID = "ObjectTypeId";
public static String PROP_CREATED_BY = "CreatedBy";
public static String PROP_CREATION_DATE = "CreationDate";
public static String PROP_LAST_MODIFIED_BY = "LastModifiedBy";
public static String PROP_LAST_MODIFICATION_DATE = "LastModificationDate";
public static String PROP_CHANGE_TOKEN = "ChangeToken";
public static String PROP_NAME = "Name";
public static String PROP_IS_IMMUTABLE = "IsImmutable";
public static String PROP_IS_LATEST_VERSION = "IsLatestVersion";
public static String PROP_IS_MAJOR_VERSION = "IsMajorVersion";
public static String PROP_IS_LATEST_MAJOR_VERSION = "IsLatestMajorVersion";
public static String PROP_VERSION_LABEL = "VersionLabel";
public static String PROP_VERSION_SERIES_ID = "VersionSeriesId";
public static String PROP_IS_VERSION_SERIES_CHECKED_OUT = "IsVersionSeriesCheckedOut";
public static String PROP_VERSION_SERIES_CHECKED_OUT_BY = "VersionSeriesCheckedOutBy";
public static String PROP_VERSION_SERIES_CHECKED_OUT_ID = "VersionSeriesCheckedOutId";
public static String PROP_CHECKIN_COMMENT = "CheckinComment";
public static String PROP_CONTENT_STREAM_ALLOWED = "ContentStreamAllowed";
public static String PROP_CONTENT_STREAM_LENGTH = "ContentStreamLength";
public static String PROP_CONTENT_STREAM_MIME_TYPE = "ContentStreamMimeType";
public static String PROP_CONTENT_STREAM_FILENAME = "ContentStreamFilename";
public static String PROP_CONTENT_STREAM_URI = "ContentStreamUri";
public static String PROP_PARENT_ID = "ParentId";
public static String PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS = "AllowedChildObjectTypeIds";
public static String PROP_SOURCE_ID = "SourceId";
public static String PROP_TARGET_ID = "TargetId";
}

View File

@@ -1,104 +0,0 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.cmis.dictionary;
import java.util.Collection;
import org.alfresco.cmis.CMISDataTypeEnum;
import org.alfresco.service.namespace.QName;
/**
* Service to query the CMIS meta model
*
* @author davidc
*/
public interface CMISDictionaryService
{
/**
* Find type for type id
* @param typeId
* @return
*/
public CMISTypeDefinition findType(CMISTypeId typeId);
/**
* Find type for type id
*
* @param typeId
* @return
*/
public CMISTypeDefinition findType(String typeId);
/**
* Find type for Alfresco class name. Optionally, constrain match to one of specified CMIS scopes
*
* @param clazz
* @param matchingScopes
* @return
*/
public CMISTypeDefinition findTypeForClass(QName clazz, CMISScope... matchingScopes);
/**
* Find type for table
*
* @param tableName
* @return
*/
public CMISTypeDefinition findTypeForTable(String tableName);
/**
* Get all Types
*
* @return
*/
public Collection<CMISTypeDefinition> getAllTypes();
/**
* Find property. Optionally constrain match to specified type.
*
* @param property
* @param matchingType
* @return
*/
public CMISPropertyDefinition findProperty(QName property, CMISTypeDefinition matchingType);
/**
* Find property. Optionally constrain match to specified type.
*
* @param property
* @param matchingType
* @return
*/
public CMISPropertyDefinition findProperty(String property, CMISTypeDefinition matchingType);
/**
* Find data type
*
* @param dataType
* @return
*/
public CMISDataTypeEnum findDataType(QName dataType);
}

View File

@@ -24,6 +24,10 @@
*/
package org.alfresco.cmis.dictionary;
import org.alfresco.cmis.CMISPropertyDefinition;
import org.alfresco.cmis.CMISTypeDefinition;
import org.alfresco.cmis.mapping.BaseCMISTest;
public class CMISDictionaryTest extends BaseCMISTest
{
public void testBasicTypes()

View File

@@ -27,6 +27,9 @@ package org.alfresco.cmis.dictionary;
import java.util.List;
import org.alfresco.cmis.CMISContentStreamAllowedEnum;
import org.alfresco.cmis.CMISDictionaryModel;
import org.alfresco.cmis.CMISScope;
import org.alfresco.cmis.CMISTypeId;
import org.alfresco.cmis.mapping.CMISMapping;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.dictionary.AspectDefinition;

View File

@@ -24,6 +24,9 @@
*/
package org.alfresco.cmis.dictionary;
import org.alfresco.cmis.CMISDictionaryModel;
import org.alfresco.cmis.CMISScope;
import org.alfresco.cmis.CMISTypeId;
import org.alfresco.cmis.mapping.CMISMapping;
import org.alfresco.service.cmr.dictionary.ClassDefinition;
import org.alfresco.service.namespace.QName;

View File

@@ -26,6 +26,8 @@ package org.alfresco.cmis.dictionary;
import java.util.Collection;
import org.alfresco.cmis.CMISScope;
import org.alfresco.cmis.CMISTypeId;
import org.alfresco.cmis.mapping.CMISMapping;
import org.alfresco.service.cmr.dictionary.ClassDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryService;

View File

@@ -26,6 +26,9 @@ package org.alfresco.cmis.dictionary;
import java.util.Collection;
import org.alfresco.cmis.CMISDictionaryModel;
import org.alfresco.cmis.CMISScope;
import org.alfresco.cmis.CMISTypeId;
import org.alfresco.cmis.dictionary.CMISAbstractDictionaryService.DictionaryRegistry;
import org.alfresco.cmis.mapping.CMISMapping;
import org.alfresco.service.cmr.dictionary.ClassDefinition;

View File

@@ -1,138 +0,0 @@
/*
* Copyright (C) 2005-2009 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.cmis.dictionary;
import java.io.Serializable;
import org.alfresco.service.namespace.QName;
/**
* CMIS Property Id
*
* @author davidc
*/
public class CMISPropertyId implements Serializable
{
private static final long serialVersionUID = 4094778633095367606L;
// Id properties
private String propertyName;
private String propertyId;
private QName qName;
/**
* Construct
*
* @param propertyName
* @param propertyId
* @param qName
*/
public CMISPropertyId(String propertyName, String propertyId, QName qName)
{
this.propertyName = propertyName;
this.propertyId = propertyId;
this.qName = qName;
}
/**
* Get property name
*
* @return
*/
public String getName()
{
return propertyName;
}
/**
* Get property id
*
* @return
*/
public String getId()
{
return propertyId;
}
/**
* Get the Alfresco model QName associated with the property
*
* @return alfresco QName
*/
public QName getQName()
{
return qName;
}
/*
* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{
return getName();
}
/*
* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + ((propertyName == null) ? 0 : propertyName.hashCode());
return result;
}
/*
* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj)
{
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
final CMISPropertyId other = (CMISPropertyId) obj;
if (propertyName == null)
{
if (other.propertyName != null)
return false;
}
else if (!propertyName.equals(other.propertyName))
return false;
return true;
}
}

View File

@@ -29,6 +29,12 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.alfresco.cmis.CMISDictionaryModel;
import org.alfresco.cmis.CMISPropertyDefinition;
import org.alfresco.cmis.CMISPropertyId;
import org.alfresco.cmis.CMISScope;
import org.alfresco.cmis.CMISTypeDefinition;
import org.alfresco.cmis.CMISTypeId;
import org.alfresco.cmis.dictionary.CMISAbstractDictionaryService.DictionaryRegistry;
import org.alfresco.cmis.mapping.CMISMapping;
import org.alfresco.error.AlfrescoRuntimeException;

View File

@@ -1,76 +0,0 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.cmis.dictionary;
import java.util.HashMap;
import java.util.Map;
/**
* The scope for a CMIS name
*
* Alfresco has different name spaces for relationships and objects.
* This scope resolves any ambiguity.
* This ambiguity is resolved in the CMIS type id mapping.
*
* @author andyh
*
*/
public enum CMISScope
{
OBJECT ('O'),
RELATIONSHIP ('R'),
DOCUMENT ('D'),
FOLDER ('F'),
POLICY ('P'),
UNKNOWN ('U');
private static Map<Character, CMISScope> discriminatorMap = new HashMap<Character, CMISScope>(10);
static
{
for (CMISScope scope : CMISScope.values())
{
discriminatorMap.put(scope.discriminator, scope);
}
}
private char discriminator;
CMISScope(char discriminator)
{
this.discriminator = discriminator;
}
public char discriminator()
{
return discriminator;
}
public static CMISScope toScope(char discrimator)
{
return discriminatorMap.get(discrimator);
}
}

View File

@@ -26,6 +26,8 @@ package org.alfresco.cmis.dictionary;
import java.util.Collection;
import org.alfresco.cmis.CMISScope;
import org.alfresco.cmis.CMISTypeId;
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
import org.alfresco.service.cmr.dictionary.ClassDefinition;
import org.alfresco.service.namespace.QName;

View File

@@ -1,174 +0,0 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.cmis.dictionary;
import java.util.Collection;
import java.util.Map;
import org.alfresco.cmis.CMISContentStreamAllowedEnum;
/**
* The base type definition for CMIS
*
* @author andyh
*/
public interface CMISTypeDefinition
{
/**
* @return true => type definition is for public consumption
*/
public boolean isPublic();
/**
* Get the unique identifier for the type
*
* @return - the type id
*/
public CMISTypeId getTypeId();
/**
* Get the table name used for queries against the type. This is also a unique identifier for the type. The string
* conforms to SQL table naming conventions. TODO: Should we impose a maximum length and if so how do we avoid
* collisions from truncations?
*
* @return the sql table name
*/
public String getQueryName();
/**
* Get the display name for the type.
*
* @return - the display name
*/
public String getDisplayName();
/**
* Get the type for the parent
*
* @return - the parent type id
*/
public CMISTypeDefinition getParentType();
/**
* Get the sub-types
*
* @param descendants
* @return
*/
public Collection<CMISTypeDefinition> getSubTypes(boolean descendants);
/**
* Get the root type
*
* @return
*/
public CMISTypeDefinition getRootType();
/**
* Get the description for the type
*
* @return - the description
*/
public String getDescription();
/**
* Can objects of this type be created?
*
* @return
*/
public boolean isCreatable();
/**
* Are objects of this type fileable?
*
* @return
*/
public boolean isFileable();
/**
* Is this type queryable? If not, the type may not appear in the FROM clause of a query. This property of the type
* is not inherited in the type hierarchy. It is set on each type.
*
* @return true if queryable
*/
public boolean isQueryable();
/**
* Are objects of this type controllable.
*
* @return
*/
public boolean isControllable();
/**
* Are objects of this type included in super type queries
*
* @return
*/
public boolean isIncludeInSuperTypeQuery();
/**
* Is this type versionable? If true this implies all instances of the type are versionable.
*
* @return true if versionable
*/
public boolean isVersionable();
/**
* Is a content stream allowed for this type? It may be disallowed, optional or mandatory.
*
* @return
*/
public CMISContentStreamAllowedEnum getContentStreamAllowed();
/**
* For an association, get the collection of valid source types. For non-associations the collection will be empty.
*
* @return
*/
public Collection<CMISTypeDefinition> getAllowedSourceTypes();
/**
* For an association, get the collection of valid target types. For non-associations the collection will be empty.
*
* @return
*/
public Collection<CMISTypeDefinition> getAllowedTargetTypes();
/**
* Gets the property definitions for this type (owned and inherited)
*
* @return property definitions
*/
public Map<CMISPropertyId, CMISPropertyDefinition> getPropertyDefinitions();
/**
* Gets the property definitions owned by this type
*
* @return
*/
public Map<CMISPropertyId, CMISPropertyDefinition> getOwnedPropertyDefinitions();
}

View File

@@ -1,146 +0,0 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.cmis.dictionary;
import java.io.Serializable;
import org.alfresco.cmis.mapping.CMISMapping;
import org.alfresco.service.namespace.QName;
/**
* CMIS Type Id
*
* @author andyh
*
*/
public class CMISTypeId implements Serializable
{
private static final long serialVersionUID = -4709046883083948302L;
private String typeId;
private CMISScope scope;
private QName qName;
/**
* Construct
*
* @param scope
* @param typeId
* @param qName
*/
public CMISTypeId(CMISScope scope, String typeId, QName qName)
{
this.scope = scope;
this.typeId = typeId;
this.qName = qName;
}
/**
* Get the CMIS type id string
* @return
*/
public String getId()
{
return typeId;
}
/**
* Get the scope for the type (Doc, Folder, Relationship or unknown)
* @return
*/
public CMISScope getScope()
{
return scope;
}
/**
* Get the Alfresco model QName associated with the type
*
* @return alfresco QName
*/
public QName getQName()
{
return qName;
}
/**
* Get the root type id
* @return
*/
public CMISTypeId getRootTypeId()
{
switch (scope)
{
case DOCUMENT:
return CMISDictionaryModel.DOCUMENT_TYPE_ID;
case FOLDER:
return CMISDictionaryModel.FOLDER_TYPE_ID;
case RELATIONSHIP:
return CMISDictionaryModel.RELATIONSHIP_TYPE_ID;
case POLICY:
return CMISDictionaryModel.POLICY_TYPE_ID;
case OBJECT:
return CMISMapping.OBJECT_TYPE_ID;
case UNKNOWN:
default:
return null;
}
}
public String toString()
{
return getId();
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + ((typeId == null) ? 0 : typeId.hashCode());
return result;
}
@Override
public boolean equals(Object obj)
{
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
final CMISTypeId other = (CMISTypeId) obj;
if (typeId == null)
{
if (other.typeId != null)
return false;
}
else if (!typeId.equals(other.typeId))
return false;
return true;
}
}