Merge DEV/SEAMIST4 to HEAD (part 2 of 2)

12421 Tidy up and trivial code changes mostly relating to code style.
            Good exercise for learning code though.
            Tests re-run successfully.
            Ready for merge to HEAD.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@12666 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2009-01-09 15:41:55 +00:00
parent 01bf05db58
commit 17ef0c24ad
18 changed files with 864 additions and 1023 deletions

View File

@@ -22,14 +22,16 @@
* the FLOSS exception, and it is also available here: * the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing" * http://www.alfresco.com/legal/licensing"
*/ */
package org.alfresco.repo.cmis.ws; package org.alfresco.repo.cmis;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.alfresco.repo.cmis.ws.FilterNotValidException;
/** /**
* Property filter class * Property filter supporting CMIS filter expression
* *
* @author Dmitry Lazurkin * @author Dmitry Lazurkin
* @author Dmitry Velichkevich * @author Dmitry Velichkevich
@@ -37,9 +39,7 @@ import java.util.regex.Pattern;
public class PropertyFilter public class PropertyFilter
{ {
private static final int MINIMAL_ALLOWED_STRUCTURE_SIZE = 1; private static final int MINIMAL_ALLOWED_STRUCTURE_SIZE = 1;
private static final String MATCH_ALL_FILTER = "*"; private static final String MATCH_ALL_FILTER = "*";
private static final Pattern PROPERTY_FILTER_REGEX = Pattern.compile("^(\\*)|([\\p{Alpha}\\p{Digit}_]+((,){1}( )*[\\p{Alpha}\\p{Digit}_]+)*)$"); private static final Pattern PROPERTY_FILTER_REGEX = Pattern.compile("^(\\*)|([\\p{Alpha}\\p{Digit}_]+((,){1}( )*[\\p{Alpha}\\p{Digit}_]+)*)$");
private Set<String> properties; private Set<String> properties;
@@ -54,34 +54,33 @@ public class PropertyFilter
*/ */
public PropertyFilter(String filter) throws FilterNotValidException public PropertyFilter(String filter) throws FilterNotValidException
{ {
if ((filter == null) || ((filter.length() < MINIMAL_ALLOWED_STRUCTURE_SIZE) ? (false) : (!PROPERTY_FILTER_REGEX.matcher(filter).matches()))) if (filter == null || filter.length() < MINIMAL_ALLOWED_STRUCTURE_SIZE ? false : !PROPERTY_FILTER_REGEX.matcher(filter).matches())
{ {
throw new FilterNotValidException("\"" + filter + "\" filter value is invalid"); throw new FilterNotValidException("\"" + filter + "\" filter value is invalid");
} }
if (!filter.equals(MATCH_ALL_FILTER) && (filter.length() >= MINIMAL_ALLOWED_STRUCTURE_SIZE)) if (!filter.equals(MATCH_ALL_FILTER) && filter.length() >= MINIMAL_ALLOWED_STRUCTURE_SIZE)
{ {
splitFilterOnTokens(filter.split(",")); splitFilterOnTokens(filter.split(","));
} }
} }
private void splitFilterOnTokens(String[] tokens)
{
properties = new HashSet<String>();
for (String token : tokens)
{
properties.add(token.trim().toLowerCase());
}
}
/** /**
* @param property property token name (e.g.: name (or Name), ObjectId (or: objectid, Objectid etc)) * @param property property token name (e.g.: name (or Name), ObjectId (or: objectid, Objectid etc))
* @return <b>true</b> returns if property is allowed by filter. In other case returns <b>false</b> * @return <b>true</b> returns if property is allowed by filter. In other case returns <b>false</b>
*/ */
public boolean allow(String property) public boolean allow(String property)
{ {
return (properties == null) || properties.contains(property.toLowerCase()); return properties == null || properties.contains(property.toLowerCase());
} }
private void splitFilterOnTokens(String[] tokens)
{
properties = new HashSet<String>();
for (String token : tokens)
{
properties.add(token.trim().toLowerCase());
}
}
} }

View File

@@ -22,10 +22,10 @@
* the FLOSS exception, and it is also available here: * the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing" * http://www.alfresco.com/legal/licensing"
*/ */
package org.alfresco.repo.cmis.ws.filtering; package org.alfresco.repo.cmis;
import org.alfresco.repo.cmis.PropertyFilter;
import org.alfresco.repo.cmis.ws.FilterNotValidException; import org.alfresco.repo.cmis.ws.FilterNotValidException;
import org.alfresco.repo.cmis.ws.PropertyFilter;
import junit.framework.TestCase; import junit.framework.TestCase;
@@ -58,9 +58,9 @@ public class PropertyFilterTest extends TestCase
private static final String INVALID_FILTER_WITH_DENIED_SYMBOL = "ObjectId; name"; private static final String INVALID_FILTER_WITH_DENIED_SYMBOL = "ObjectId; name";
private static final String INVALID_FILTER_WITH_LAST_INVALID_SYMBOL = "ObjectId, name*"; private static final String INVALID_FILTER_WITH_LAST_INVALID_SYMBOL = "ObjectId, name*";
public void testValidFilters() throws Exception public void testValidFilters() throws Exception
{ {
try try
{ {
allTokensValidAssertion(new PropertyFilter()); allTokensValidAssertion(new PropertyFilter());
@@ -83,7 +83,6 @@ public class PropertyFilterTest extends TestCase
public void testInvalidFilters() throws Exception public void testInvalidFilters() throws Exception
{ {
invalidFilterAssertion(INVALID_MATCHE_ALL_FILTER); invalidFilterAssertion(INVALID_MATCHE_ALL_FILTER);
invalidFilterAssertion(INVALID_FILTER_WITH_NAME); invalidFilterAssertion(INVALID_FILTER_WITH_NAME);
invalidFilterAssertion(INVALID_FILTER_WITH_SEVERAL_TOKENS); invalidFilterAssertion(INVALID_FILTER_WITH_SEVERAL_TOKENS);
@@ -97,7 +96,6 @@ public class PropertyFilterTest extends TestCase
private void nameAndObjectIdTokensAssertionValid(PropertyFilter propertyFilter) private void nameAndObjectIdTokensAssertionValid(PropertyFilter propertyFilter)
{ {
for (String token : FILTER_TOKENS) for (String token : FILTER_TOKENS)
{ {
assertTrue(propertyFilter.allow(token)); assertTrue(propertyFilter.allow(token));
@@ -111,7 +109,6 @@ public class PropertyFilterTest extends TestCase
private void onlyNameTokensAssertionValid(PropertyFilter propertyFilter) private void onlyNameTokensAssertionValid(PropertyFilter propertyFilter)
{ {
for (String token : FILTER_TOKENS) for (String token : FILTER_TOKENS)
{ {
if (!token.equalsIgnoreCase(NAME_TOKEN)) if (!token.equalsIgnoreCase(NAME_TOKEN))
@@ -130,7 +127,6 @@ public class PropertyFilterTest extends TestCase
private void allTokensValidAssertion(PropertyFilter propertyFilter) private void allTokensValidAssertion(PropertyFilter propertyFilter)
{ {
for (String token : FILTER_TOKENS) for (String token : FILTER_TOKENS)
{ {
assertTrue(propertyFilter.allow(token)); assertTrue(propertyFilter.allow(token));
@@ -144,7 +140,6 @@ public class PropertyFilterTest extends TestCase
private void invalidFilterAssertion(String filterValue) private void invalidFilterAssertion(String filterValue)
{ {
try try
{ {
new PropertyFilter(filterValue); new PropertyFilter(filterValue);
@@ -156,4 +151,5 @@ public class PropertyFilterTest extends TestCase
assertTrue(("Unexpected exception type was thrown: " + e.getClass().getName()), e instanceof FilterNotValidException); assertTrue(("Unexpected exception type was thrown: " + e.getClass().getName()), e instanceof FilterNotValidException);
} }
} }
} }

View File

@@ -64,7 +64,6 @@ public class AuthenticationTokenCallbackHandler implements CallbackHandler
private String getPassword(String userName) private String getPassword(String userName)
{ {
// TODO Auto-generated method stub
return userName; return userName;
} }

View File

@@ -33,6 +33,8 @@ import javax.activation.DataSource;
import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.ContentReader;
/** /**
* DataSource facade for an Alfresco Content Reader
*
* @author Dmitry Lazurkin * @author Dmitry Lazurkin
*/ */
public class ContentReaderDataSource implements DataSource public class ContentReaderDataSource implements DataSource
@@ -46,21 +48,33 @@ public class ContentReaderDataSource implements DataSource
this.name = name; this.name = name;
} }
/* (non-Javadoc)
* @see javax.activation.DataSource#getContentType()
*/
public String getContentType() public String getContentType()
{ {
return contentReader.getMimetype(); return contentReader.getMimetype();
} }
/* (non-Javadoc)
* @see javax.activation.DataSource#getInputStream()
*/
public InputStream getInputStream() throws IOException public InputStream getInputStream() throws IOException
{ {
return contentReader.getContentInputStream(); return contentReader.getContentInputStream();
} }
/* (non-Javadoc)
* @see javax.activation.DataSource#getName()
*/
public String getName() public String getName()
{ {
return name; return name;
} }
/* (non-Javadoc)
* @see javax.activation.DataSource#getOutputStream()
*/
public OutputStream getOutputStream() throws IOException public OutputStream getOutputStream() throws IOException
{ {
return null; return null;

View File

@@ -43,6 +43,7 @@ import org.alfresco.cmis.dictionary.CMISMapping;
import org.alfresco.cmis.property.CMISPropertyService; import org.alfresco.cmis.property.CMISPropertyService;
import org.alfresco.cmis.search.CMISQueryService; import org.alfresco.cmis.search.CMISQueryService;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.cmis.PropertyFilter;
import org.alfresco.repo.cmis.ws.utils.CmisObjectsUtils; import org.alfresco.repo.cmis.ws.utils.CmisObjectsUtils;
import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.version.VersionModel; import org.alfresco.repo.version.VersionModel;
@@ -72,7 +73,6 @@ import org.alfresco.service.namespace.QName;
public class DMAbstractServicePort public class DMAbstractServicePort
{ {
private static final String BASE_TYPE_PROPERTY_NAME = "BaseType"; private static final String BASE_TYPE_PROPERTY_NAME = "BaseType";
protected static final String INITIAL_VERSION_DESCRIPTION = "Initial version"; protected static final String INITIAL_VERSION_DESCRIPTION = "Initial version";
private DatatypeFactory _datatypeFactory; private DatatypeFactory _datatypeFactory;
@@ -89,9 +89,99 @@ public class DMAbstractServicePort
protected FileFolderService fileFolderService; protected FileFolderService fileFolderService;
protected CheckOutCheckInService checkOutCheckInService; protected CheckOutCheckInService checkOutCheckInService;
protected SearchService searchService; protected SearchService searchService;
protected CmisObjectsUtils cmisObjectsUtils; protected CmisObjectsUtils cmisObjectsUtils;
public void setCmisService(CMISService cmisService)
{
this.cmisService = cmisService;
}
public void setCmisPropertyService(CMISPropertyService cmisPropertyService)
{
this.cmisPropertyService = cmisPropertyService;
}
public void setCmisDictionaryService(CMISDictionaryService cmisDictionaryService)
{
this.cmisDictionaryService = cmisDictionaryService;
}
public void setCmisQueryService(CMISQueryService cmisQueryService)
{
this.cmisQueryService = cmisQueryService;
}
public void setDescriptorService(DescriptorService descriptorService)
{
this.descriptorService = descriptorService;
}
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
public void setVersionService(VersionService versionService)
{
this.versionService = versionService;
}
public void setFileFolderService(FileFolderService fileFolderService)
{
this.fileFolderService = fileFolderService;
}
public void setCheckOutCheckInService(CheckOutCheckInService checkOutCheckInService)
{
this.checkOutCheckInService = checkOutCheckInService;
}
public void setCmisObjectsUtils(CmisObjectsUtils cmisObjectsUtils)
{
this.cmisObjectsUtils = cmisObjectsUtils;
}
public void setSearchService(SearchService searchService)
{
this.searchService = searchService;
}
protected static PropertyFilter createPropertyFilter(String filter) throws FilterNotValidException
{
return (filter == null) ? (new PropertyFilter()) : (new PropertyFilter(filter));
}
protected static PropertyFilter createPropertyFilter(JAXBElement<String> element) throws FilterNotValidException
{
String filter = null;
if (element != null)
{
filter = element.getValue();
}
return createPropertyFilter(filter);
}
protected Cursor createCursor(int totalRows, BigInteger skipCount, BigInteger maxItems)
{
Page window = paging.createPageOrWindow(null, null, skipCount != null ? skipCount.intValue() : null, maxItems != null ? maxItems.intValue() : null);
return paging.createCursor(totalRows, window);
}
/**
* Converts Date object to XMLGregorianCalendar object
*
* @param date Date object
* @return XMLGregorianCalendar object
*/
protected XMLGregorianCalendar convert(Date date)
{
GregorianCalendar calendar = new GregorianCalendar();
calendar.setTime(date);
return getDatatypeFactory().newXMLGregorianCalendar(calendar);
}
private DatatypeFactory getDatatypeFactory() private DatatypeFactory getDatatypeFactory()
{ {
if (_datatypeFactory == null) if (_datatypeFactory == null)
@@ -117,12 +207,11 @@ public class DMAbstractServicePort
* @throws InvalidArgumentException * @throws InvalidArgumentException
* @throws FilterNotValidException * @throws FilterNotValidException
*/ */
protected void formatCommonResponse(PropertyFilter filter, List<NodeRef> sourceList, List<CmisObjectType> resultList) throws InvalidArgumentException, FilterNotValidException protected void createCmisObjectList(PropertyFilter filter, List<NodeRef> sourceList, List<CmisObjectType> resultList) throws InvalidArgumentException, FilterNotValidException
{ {
for (NodeRef objectNodeRef : sourceList) for (NodeRef objectNodeRef : sourceList)
{ {
resultList.add(convertAlfrescoObjectToCmisObject(objectNodeRef, filter)); resultList.add(createCmisObject(objectNodeRef, filter));
} }
} }
@@ -133,12 +222,10 @@ public class DMAbstractServicePort
* @param filter accepted properties filter * @param filter accepted properties filter
* @return converted to CMIS object Alfresco object * @return converted to CMIS object Alfresco object
*/ */
protected CmisObjectType convertAlfrescoObjectToCmisObject(Object identifier, PropertyFilter filter) protected CmisObjectType createCmisObject(Object identifier, PropertyFilter filter)
{ {
CmisObjectType result = new CmisObjectType(); CmisObjectType result = new CmisObjectType();
result.setProperties(getPropertiesType(identifier.toString(), filter)); result.setProperties(getPropertiesType(identifier.toString(), filter));
return result; return result;
} }
@@ -150,7 +237,6 @@ public class DMAbstractServicePort
*/ */
protected void assertExistFolder(NodeRef folderNodeRef) throws FolderNotValidException protected void assertExistFolder(NodeRef folderNodeRef) throws FolderNotValidException
{ {
if (!this.cmisObjectsUtils.isFolder(folderNodeRef)) if (!this.cmisObjectsUtils.isFolder(folderNodeRef))
{ {
throw new FolderNotValidException("OID for non-existent object or not folder object"); throw new FolderNotValidException("OID for non-existent object or not folder object");
@@ -171,6 +257,107 @@ public class DMAbstractServicePort
} }
} }
/**
* Get CMIS properties for object
*
* @param nodeRef node reference
* @param filter property filter
* @return properties
*/
protected CmisPropertiesType getPropertiesType(String identifier, PropertyFilter filter)
{
Map<String, Serializable> properties;
if (NodeRef.isNodeRef(identifier))
{
properties = cmisPropertyService.getProperties(new NodeRef(identifier));
}
else
{
properties = createBaseRelationshipProperties(new AssociationRef(identifier));
}
return getPropertiesType(properties, filter);
}
protected CmisPropertiesType getPropertiesType(Map<String, Serializable> alfrescoProperties, PropertyFilter filter)
{
CMISMapping cmisMapping = cmisDictionaryService.getCMISMapping();
String objectTypeId = (String) alfrescoProperties.get(CMISMapping.PROP_OBJECT_TYPE_ID);
QName cmisType = cmisMapping.getCmisTypeId(objectTypeId).getQName();
CmisPropertiesType properties = new CmisPropertiesType();
if (cmisMapping.isValidCmisDocument(cmisType))
{
addBooleanProperty(properties, filter, CMISMapping.PROP_IS_IMMUTABLE, alfrescoProperties);
addBooleanProperty(properties, filter, CMISMapping.PROP_IS_LATEST_VERSION, alfrescoProperties);
addBooleanProperty(properties, filter, CMISMapping.PROP_IS_MAJOR_VERSION, alfrescoProperties);
addBooleanProperty(properties, filter, CMISMapping.PROP_IS_LATEST_MAJOR_VERSION, alfrescoProperties);
addBooleanProperty(properties, filter, CMISMapping.PROP_IS_VERSION_SERIES_CHECKED_OUT, alfrescoProperties);
addDateTimeProperty(properties, filter, CMISMapping.PROP_CREATION_DATE, alfrescoProperties);
addDateTimeProperty(properties, filter, CMISMapping.PROP_LAST_MODIFICATION_DATE, alfrescoProperties);
addIDProperty(properties, filter, CMISMapping.PROP_OBJECT_ID, alfrescoProperties);
addIDProperty(properties, filter, CMISMapping.PROP_VERSION_SERIES_ID, alfrescoProperties);
addIDProperty(properties, filter, CMISMapping.PROP_VERSION_SERIES_CHECKED_OUT_ID, alfrescoProperties);
addIntegerProperty(properties, filter, CMISMapping.PROP_CONTENT_STREAM_LENGTH, alfrescoProperties);
addStringProperty(properties, filter, CMISMapping.PROP_NAME, alfrescoProperties);
addStringProperty(properties, filter, BASE_TYPE_PROPERTY_NAME, "document");
addStringProperty(properties, filter, CMISMapping.PROP_OBJECT_TYPE_ID, alfrescoProperties);
addStringProperty(properties, filter, CMISMapping.PROP_CREATED_BY, alfrescoProperties);
addStringProperty(properties, filter, CMISMapping.PROP_LAST_MODIFIED_BY, alfrescoProperties);
addStringProperty(properties, filter, CMISMapping.PROP_CONTENT_STREAM_MIME_TYPE, alfrescoProperties);
addStringProperty(properties, filter, CMISMapping.PROP_CONTENT_STREAM_FILENAME, alfrescoProperties);
addStringProperty(properties, filter, CMISMapping.PROP_VERSION_LABEL, alfrescoProperties);
addStringProperty(properties, filter, CMISMapping.PROP_VERSION_SERIES_CHECKED_OUT_BY, alfrescoProperties);
addStringProperty(properties, filter, CMISMapping.PROP_CHECKIN_COMMENT, alfrescoProperties);
addURIProperty(properties, filter, CMISMapping.PROP_CONTENT_STREAM_URI, alfrescoProperties);
}
else if (cmisMapping.isValidCmisFolder(cmisType))
{
addDateTimeProperty(properties, filter, CMISMapping.PROP_CREATION_DATE, alfrescoProperties);
addDateTimeProperty(properties, filter, CMISMapping.PROP_LAST_MODIFICATION_DATE, alfrescoProperties);
addIDProperty(properties, filter, CMISMapping.PROP_OBJECT_ID, alfrescoProperties);
addIDProperty(properties, filter, CMISMapping.PROP_PARENT_ID, alfrescoProperties);
addStringProperty(properties, filter, CMISMapping.PROP_NAME, alfrescoProperties);
addStringProperty(properties, filter, BASE_TYPE_PROPERTY_NAME, "folder");
addStringProperty(properties, filter, CMISMapping.PROP_OBJECT_TYPE_ID, alfrescoProperties);
addStringProperty(properties, filter, CMISMapping.PROP_CREATED_BY, alfrescoProperties);
addStringProperty(properties, filter, CMISMapping.PROP_LAST_MODIFIED_BY, alfrescoProperties);
}
else if (cmisMapping.isValidCmisRelationship(cmisType))
{
addStringProperty(properties, filter, CMISMapping.PROP_OBJECT_TYPE_ID, alfrescoProperties);
addIDProperty(properties, filter, CMISMapping.PROP_OBJECT_ID, alfrescoProperties);
addStringProperty(properties, filter, BASE_TYPE_PROPERTY_NAME, alfrescoProperties);
addStringProperty(properties, filter, CMISMapping.PROP_CREATED_BY, alfrescoProperties);
addDateTimeProperty(properties, filter, CMISMapping.PROP_CREATION_DATE, alfrescoProperties);
addIDProperty(properties, filter, CMISMapping.PROP_SOURCE_ID, alfrescoProperties);
addIDProperty(properties, filter, CMISMapping.PROP_TARGET_ID, alfrescoProperties);
}
return properties;
}
private Map<String, Serializable> createBaseRelationshipProperties(AssociationRef association)
{
Map<String, Serializable> result = new HashMap<String, Serializable>();
result.put(CMISMapping.PROP_OBJECT_TYPE_ID, cmisDictionaryService.getCMISMapping().getCmisType(association.getTypeQName()));
result.put(CMISMapping.PROP_OBJECT_ID, association.toString());
result.put(BASE_TYPE_PROPERTY_NAME, CMISMapping.RELATIONSHIP_TYPE_ID.getTypeId());
result.put(CMISMapping.PROP_CREATED_BY, AuthenticationUtil.getFullyAuthenticatedUser());
result.put(CMISMapping.PROP_CREATION_DATE, new Date());
result.put(CMISMapping.PROP_SOURCE_ID, association.getSourceRef());
result.put(CMISMapping.PROP_TARGET_ID, association.getTargetRef());
return result;
}
protected Map<String, Serializable> createVersionProperties(String versionDescription, VersionType versionType)
{
Map<String, Serializable> result = new HashMap<String, Serializable>();
result.put(Version.PROP_DESCRIPTION, versionDescription);
result.put(VersionModel.PROP_VERSION_TYPE, versionType);
return result;
}
private void addBooleanProperty(CmisPropertiesType properties, PropertyFilter filter, String name, Map<String, Serializable> alfrescoProperties) private void addBooleanProperty(CmisPropertiesType properties, PropertyFilter filter, String name, Map<String, Serializable> alfrescoProperties)
{ {
Serializable value = alfrescoProperties.get(name); Serializable value = alfrescoProperties.get(name);
@@ -254,81 +441,6 @@ public class DMAbstractServicePort
} }
} }
/**
* Get CMIS properties for object
*
* @param nodeRef node reference
* @param filter property filter
* @return properties
*/
public CmisPropertiesType getPropertiesType(String identifier, PropertyFilter filter)
{
Map<String, Serializable> properties = (NodeRef.isNodeRef(identifier)) ? (cmisPropertyService.getProperties(new NodeRef(identifier)))
: (createBaseRelationshipProperties(new AssociationRef(identifier)));
return getPropertiesType(properties, filter);
}
public CmisPropertiesType getPropertiesType(Map<String, Serializable> alfrescoProperties, PropertyFilter filter)
{
CMISMapping cmisMapping = cmisDictionaryService.getCMISMapping();
String objectTypeId = (String) alfrescoProperties.get(CMISMapping.PROP_OBJECT_TYPE_ID);
QName cmisType = cmisMapping.getCmisTypeId(objectTypeId).getQName();
CmisPropertiesType properties = new CmisPropertiesType();
if (cmisMapping.isValidCmisDocument(cmisType))
{
addBooleanProperty(properties, filter, CMISMapping.PROP_IS_IMMUTABLE, alfrescoProperties);
addBooleanProperty(properties, filter, CMISMapping.PROP_IS_LATEST_VERSION, alfrescoProperties);
addBooleanProperty(properties, filter, CMISMapping.PROP_IS_MAJOR_VERSION, alfrescoProperties);
addBooleanProperty(properties, filter, CMISMapping.PROP_IS_LATEST_MAJOR_VERSION, alfrescoProperties);
addBooleanProperty(properties, filter, CMISMapping.PROP_IS_VERSION_SERIES_CHECKED_OUT, alfrescoProperties);
addDateTimeProperty(properties, filter, CMISMapping.PROP_CREATION_DATE, alfrescoProperties);
addDateTimeProperty(properties, filter, CMISMapping.PROP_LAST_MODIFICATION_DATE, alfrescoProperties);
addIDProperty(properties, filter, CMISMapping.PROP_OBJECT_ID, alfrescoProperties);
addIDProperty(properties, filter, CMISMapping.PROP_VERSION_SERIES_ID, alfrescoProperties);
addIDProperty(properties, filter, CMISMapping.PROP_VERSION_SERIES_CHECKED_OUT_ID, alfrescoProperties);
addIntegerProperty(properties, filter, CMISMapping.PROP_CONTENT_STREAM_LENGTH, alfrescoProperties);
addStringProperty(properties, filter, CMISMapping.PROP_NAME, alfrescoProperties);
addStringProperty(properties, filter, BASE_TYPE_PROPERTY_NAME, "document");
addStringProperty(properties, filter, CMISMapping.PROP_OBJECT_TYPE_ID, alfrescoProperties);
addStringProperty(properties, filter, CMISMapping.PROP_CREATED_BY, alfrescoProperties);
addStringProperty(properties, filter, CMISMapping.PROP_LAST_MODIFIED_BY, alfrescoProperties);
addStringProperty(properties, filter, CMISMapping.PROP_CONTENT_STREAM_MIME_TYPE, alfrescoProperties);
addStringProperty(properties, filter, CMISMapping.PROP_CONTENT_STREAM_FILENAME, alfrescoProperties);
addStringProperty(properties, filter, CMISMapping.PROP_VERSION_LABEL, alfrescoProperties);
addStringProperty(properties, filter, CMISMapping.PROP_VERSION_SERIES_CHECKED_OUT_BY, alfrescoProperties);
addStringProperty(properties, filter, CMISMapping.PROP_CHECKIN_COMMENT, alfrescoProperties);
addURIProperty(properties, filter, CMISMapping.PROP_CONTENT_STREAM_URI, alfrescoProperties);
}
else if (cmisMapping.isValidCmisFolder(cmisType))
{
addDateTimeProperty(properties, filter, CMISMapping.PROP_CREATION_DATE, alfrescoProperties);
addDateTimeProperty(properties, filter, CMISMapping.PROP_LAST_MODIFICATION_DATE, alfrescoProperties);
addIDProperty(properties, filter, CMISMapping.PROP_OBJECT_ID, alfrescoProperties);
addIDProperty(properties, filter, CMISMapping.PROP_PARENT_ID, alfrescoProperties);
addStringProperty(properties, filter, CMISMapping.PROP_NAME, alfrescoProperties);
addStringProperty(properties, filter, BASE_TYPE_PROPERTY_NAME, "folder");
addStringProperty(properties, filter, CMISMapping.PROP_OBJECT_TYPE_ID, alfrescoProperties);
addStringProperty(properties, filter, CMISMapping.PROP_CREATED_BY, alfrescoProperties);
addStringProperty(properties, filter, CMISMapping.PROP_LAST_MODIFIED_BY, alfrescoProperties);
}
else if (cmisMapping.isValidCmisRelationship(cmisType))
{
addStringProperty(properties, filter, CMISMapping.PROP_OBJECT_TYPE_ID, alfrescoProperties);
addIDProperty(properties, filter, CMISMapping.PROP_OBJECT_ID, alfrescoProperties);
addStringProperty(properties, filter, BASE_TYPE_PROPERTY_NAME, alfrescoProperties);
addStringProperty(properties, filter, CMISMapping.PROP_CREATED_BY, alfrescoProperties);
addDateTimeProperty(properties, filter, CMISMapping.PROP_CREATION_DATE, alfrescoProperties);
addIDProperty(properties, filter, CMISMapping.PROP_SOURCE_ID, alfrescoProperties);
addIDProperty(properties, filter, CMISMapping.PROP_TARGET_ID, alfrescoProperties);
}
return properties;
}
/** /**
* Sets all <i>properties</i>' fields for specified node * Sets all <i>properties</i>' fields for specified node
* *
@@ -353,7 +465,7 @@ public class DMAbstractServicePort
* @param major need latest major version * @param major need latest major version
* @return latest version node reference * @return latest version node reference
*/ */
public NodeRef getLatestVersionNodeRef(NodeRef documentNodeRef, boolean major) protected NodeRef getLatestNode(NodeRef documentNodeRef, boolean major)
{ {
Version currentVersion = versionService.getCurrentVersion(documentNodeRef); Version currentVersion = versionService.getCurrentVersion(documentNodeRef);
NodeRef latestVersionNodeRef = documentNodeRef; NodeRef latestVersionNodeRef = documentNodeRef;
@@ -383,132 +495,13 @@ public class DMAbstractServicePort
return latestVersionNodeRef; return latestVersionNodeRef;
} }
public static PropertyFilter createPropertyFilter(String filter) throws FilterNotValidException protected NodeRef checkoutNode(NodeRef documentNodeReference)
{ {
return (filter == null) ? (new PropertyFilter()) : (new PropertyFilter(filter));
}
public static PropertyFilter createPropertyFilter(JAXBElement<String> element) throws FilterNotValidException
{
String filter = null;
if (element != null)
{
filter = element.getValue();
}
return createPropertyFilter(filter);
}
public Cursor createCursor(int totalRows, BigInteger skipCount, BigInteger maxItems)
{
Page window = paging.createPageOrWindow(null, null, skipCount != null ? skipCount.intValue() : null, maxItems != null ? maxItems.intValue() : null);
return paging.createCursor(totalRows, window);
}
/**
* Converts Date object to XMLGregorianCalendar object
*
* @param date Date object
* @return XMLGregorianCalendar object
*/
public XMLGregorianCalendar convert(Date date)
{
GregorianCalendar calendar = new GregorianCalendar();
calendar.setTime(date);
return getDatatypeFactory().newXMLGregorianCalendar(calendar);
}
public void setCmisService(CMISService cmisService)
{
this.cmisService = cmisService;
}
public void setCmisPropertyService(CMISPropertyService cmisPropertyService)
{
this.cmisPropertyService = cmisPropertyService;
}
public void setCmisDictionaryService(CMISDictionaryService cmisDictionaryService)
{
this.cmisDictionaryService = cmisDictionaryService;
}
public void setCmisQueryService(CMISQueryService cmisQueryService)
{
this.cmisQueryService = cmisQueryService;
}
public void setDescriptorService(DescriptorService descriptorService)
{
this.descriptorService = descriptorService;
}
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
public void setVersionService(VersionService versionService)
{
this.versionService = versionService;
}
public void setFileFolderService(FileFolderService fileFolderService)
{
this.fileFolderService = fileFolderService;
}
public void setCheckOutCheckInService(CheckOutCheckInService checkOutCheckInService)
{
this.checkOutCheckInService = checkOutCheckInService;
}
public void setCmisObjectsUtils(CmisObjectsUtils cmisObjectsUtils)
{
this.cmisObjectsUtils = cmisObjectsUtils;
}
public void setSearchService(SearchService searchService)
{
this.searchService = searchService;
}
private Map<String, Serializable> createBaseRelationshipProperties(AssociationRef association)
{
Map<String, Serializable> result = new HashMap<String, Serializable>();
result.put(CMISMapping.PROP_OBJECT_TYPE_ID, cmisDictionaryService.getCMISMapping().getCmisType(association.getTypeQName()));
result.put(CMISMapping.PROP_OBJECT_ID, association.toString());
result.put(BASE_TYPE_PROPERTY_NAME, CMISMapping.RELATIONSHIP_TYPE_ID.getTypeId());
result.put(CMISMapping.PROP_CREATED_BY, AuthenticationUtil.getFullyAuthenticatedUser());
result.put(CMISMapping.PROP_CREATION_DATE, new Date());
result.put(CMISMapping.PROP_SOURCE_ID, association.getSourceRef());
result.put(CMISMapping.PROP_TARGET_ID, association.getTargetRef());
return result;
}
protected Map<String, Serializable> createVersionProperties(String versionDescription, VersionType versionType)
{
Map<String, Serializable> result = new HashMap<String, Serializable>();
result.put(Version.PROP_DESCRIPTION, versionDescription);
result.put(VersionModel.PROP_VERSION_TYPE, versionType);
return result;
}
protected NodeRef performCheckouting(NodeRef documentNodeReference)
{
if (!this.nodeService.hasAspect(documentNodeReference, ContentModel.ASPECT_VERSIONABLE)) if (!this.nodeService.hasAspect(documentNodeReference, ContentModel.ASPECT_VERSIONABLE))
{ {
this.versionService.createVersion(documentNodeReference, createVersionProperties(INITIAL_VERSION_DESCRIPTION, VersionType.MAJOR)); this.versionService.createVersion(documentNodeReference, createVersionProperties(INITIAL_VERSION_DESCRIPTION, VersionType.MAJOR));
} }
return checkOutCheckInService.checkout(documentNodeReference); return checkOutCheckInService.checkout(documentNodeReference);
} }
} }

View File

@@ -27,6 +27,7 @@ package org.alfresco.repo.cmis.ws;
import org.alfresco.cmis.search.CMISQueryOptions; import org.alfresco.cmis.search.CMISQueryOptions;
import org.alfresco.cmis.search.CMISResultSet; import org.alfresco.cmis.search.CMISResultSet;
import org.alfresco.cmis.search.CMISResultSetRow; import org.alfresco.cmis.search.CMISResultSetRow;
import org.alfresco.repo.cmis.PropertyFilter;
/** /**
* Port for Discovery service. * Port for Discovery service.
@@ -67,10 +68,8 @@ public class DMDiscoveryServicePort extends DMAbstractServicePort implements Dis
} }
CMISResultSet resultSet = cmisQueryService.query(options); CMISResultSet resultSet = cmisQueryService.query(options);
QueryResponse response = new QueryResponse(); QueryResponse response = new QueryResponse();
response.setHasMoreItems(resultSet.hasMore()); response.setHasMoreItems(resultSet.hasMore());
for (CMISResultSetRow row : resultSet) for (CMISResultSetRow row : resultSet)
{ {
CmisObjectType object = new CmisObjectType(); CmisObjectType object = new CmisObjectType();

View File

@@ -51,16 +51,16 @@ public class DMMultiFilingServicePort extends DMAbstractServicePort implements M
* @throws RuntimeException * @throws RuntimeException
* @throws ConstraintViolationException * @throws ConstraintViolationException
*/ */
public void addObjectToFolder(String repositoryId, String objectId, String folderId) throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, public void addObjectToFolder(String repositoryId, String objectId, String folderId)
FolderNotValidException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, FolderNotValidException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
{ {
checkRepositoryId(repositoryId); checkRepositoryId(repositoryId);
NodeRef objectNodeRef = this.cmisObjectsUtils.getIdentifierInstance(objectId, AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT).getConvertedIdentifier(); NodeRef objectNodeRef = cmisObjectsUtils.getIdentifierInstance(objectId, AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT).getConvertedIdentifier();
NodeRef parentFolderNodeRef = this.cmisObjectsUtils.getIdentifierInstance(folderId, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier(); NodeRef parentFolderNodeRef = cmisObjectsUtils.getIdentifierInstance(folderId, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier();
// TODO: check for allowed child object types // TODO: check for allowed child object types
this.cmisObjectsUtils.addObjectToFolder(objectNodeRef, parentFolderNodeRef); cmisObjectsUtils.addObjectToFolder(objectNodeRef, parentFolderNodeRef);
} }
/** /**
@@ -79,20 +79,18 @@ public class DMMultiFilingServicePort extends DMAbstractServicePort implements M
* @throws RuntimeException * @throws RuntimeException
* @throws ConstraintViolationException * @throws ConstraintViolationException
*/ */
public void removeObjectFromFolder(String repositoryId, String objectId, String folderId) throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, public void removeObjectFromFolder(String repositoryId, String objectId, String folderId)
FolderNotValidException, OperationNotSupportedException, NotInFolderException, InvalidArgumentException, RuntimeException, ConstraintViolationException throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, FolderNotValidException, OperationNotSupportedException, NotInFolderException, InvalidArgumentException, RuntimeException, ConstraintViolationException
{ {
checkRepositoryId(repositoryId); checkRepositoryId(repositoryId);
NodeRef objectNodeReference = this.cmisObjectsUtils.getIdentifierInstance(objectId, AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT).getConvertedIdentifier(); NodeRef objectNodeReference = cmisObjectsUtils.getIdentifierInstance(objectId, AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT).getConvertedIdentifier();
NodeRef folderNodeReference = checkAndReceiveFolderIdentifier(folderId); NodeRef folderNodeReference = checkAndReceiveFolderIdentifier(folderId);
assertExistFolder(folderNodeReference); assertExistFolder(folderNodeReference);
checkObjectChildParentRelationships(objectNodeReference, folderNodeReference); checkObjectChildParentRelationships(objectNodeReference, folderNodeReference);
if (!this.cmisObjectsUtils.removeObject(objectNodeReference, folderNodeReference)) if (!cmisObjectsUtils.removeObject(objectNodeReference, folderNodeReference))
{ {
throw new NotInFolderException("The specified Object is not child of the specified Folder Object"); throw new NotInFolderException("The specified Object is not child of the specified Folder Object");
} }
@@ -100,23 +98,21 @@ public class DMMultiFilingServicePort extends DMAbstractServicePort implements M
private NodeRef checkAndReceiveFolderIdentifier(String folderIdentifier) throws OperationNotSupportedException private NodeRef checkAndReceiveFolderIdentifier(String folderIdentifier) throws OperationNotSupportedException
{ {
try try
{ {
return this.cmisObjectsUtils.getIdentifierInstance(folderIdentifier, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier(); return cmisObjectsUtils.getIdentifierInstance(folderIdentifier, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier();
} }
catch (Throwable e) catch (Throwable e)
{ {
throw new OperationNotSupportedException("Unfiling is not supported. Any Object can't be deleted from all Folders"); throw new OperationNotSupportedException("Unfiling is not supported. An Object can't be deleted from all Folders");
} }
} }
private void checkObjectChildParentRelationships(NodeRef objectNodeReference, NodeRef folderNodeReference) throws OperationNotSupportedException private void checkObjectChildParentRelationships(NodeRef objectNodeReference, NodeRef folderNodeReference) throws OperationNotSupportedException
{ {
if (cmisObjectsUtils.isPrimaryObjectParent(folderNodeReference, objectNodeReference))
if (this.cmisObjectsUtils.isPrimaryObjectParent(folderNodeReference, objectNodeReference))
{ {
throw new OperationNotSupportedException("Unfiling is not supported. User deleteObjectService instead"); throw new OperationNotSupportedException("Unfiling is not supported. Use deleteObjectService instead");
} }
} }
} }

View File

@@ -30,6 +30,7 @@ import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.alfresco.cmis.CMISTypesFilterEnum; import org.alfresco.cmis.CMISTypesFilterEnum;
import org.alfresco.repo.cmis.PropertyFilter;
import org.alfresco.repo.cmis.ws.utils.AlfrescoObjectType; import org.alfresco.repo.cmis.ws.utils.AlfrescoObjectType;
import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.web.util.paging.Cursor; import org.alfresco.repo.web.util.paging.Cursor;
@@ -47,9 +48,7 @@ import org.alfresco.service.cmr.repository.NodeRef;
public class DMNavigationServicePort extends DMAbstractServicePort implements NavigationServicePort public class DMNavigationServicePort extends DMAbstractServicePort implements NavigationServicePort
{ {
private static final String POLICIES_LISTING_UNSUPPORTED_EXCEPTION_MESSAGE = "Policies listing isn't supported"; private static final String POLICIES_LISTING_UNSUPPORTED_EXCEPTION_MESSAGE = "Policies listing isn't supported";
private static final int EQUALS_CONDITION_VALUE = 0; private static final int EQUALS_CONDITION_VALUE = 0;
private static final BigInteger FULL_DESCENDANTS_HIERARCHY_CONDITION = BigInteger.valueOf(-1l); private static final BigInteger FULL_DESCENDANTS_HIERARCHY_CONDITION = BigInteger.valueOf(-1l);
/** /**
@@ -72,14 +71,16 @@ public class DMNavigationServicePort extends DMAbstractServicePort implements Na
ConstraintViolationException, FilterNotValidException, OperationNotSupportedException, UpdateConflictException, FolderNotValidException, PermissionDeniedException ConstraintViolationException, FilterNotValidException, OperationNotSupportedException, UpdateConflictException, FolderNotValidException, PermissionDeniedException
{ {
checkRepositoryId(parameters.getRepositoryId()); checkRepositoryId(parameters.getRepositoryId());
PropertyFilter propertyFilter = createPropertyFilter(parameters.getFilter()); PropertyFilter propertyFilter = createPropertyFilter(parameters.getFilter());
NodeRef folderId = (NodeRef) (((parameters.getFolderID() != null) && (parameters.getFolderID().getValue() != null)) ? (this.cmisObjectsUtils.getIdentifierInstance( NodeRef folderId = null;
parameters.getFolderID().getValue(), AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier()) : (null)); String folderIdParam = parameters.getFolderID() == null ? null : parameters.getFolderID().getValue();
if (folderIdParam != null)
NodeRef[] nodeRefs = this.cmisService.getCheckedOut(AuthenticationUtil.getFullyAuthenticatedUser(), folderId, (folderId == null)); {
folderId = cmisObjectsUtils.getIdentifierInstance(folderIdParam, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier();
}
NodeRef[] nodeRefs = cmisService.getCheckedOut(AuthenticationUtil.getFullyAuthenticatedUser(), folderId, (folderId == null));
Cursor cursor = createCursor(nodeRefs.length, parameters.getSkipCount() != null ? parameters.getSkipCount().getValue() : null, Cursor cursor = createCursor(nodeRefs.length, parameters.getSkipCount() != null ? parameters.getSkipCount().getValue() : null,
parameters.getMaxItems() != null ? parameters.getMaxItems().getValue() : null); parameters.getMaxItems() != null ? parameters.getMaxItems().getValue() : null);
@@ -88,7 +89,7 @@ public class DMNavigationServicePort extends DMAbstractServicePort implements Na
for (int index = cursor.getStartRow(); index <= cursor.getEndRow(); index++) for (int index = cursor.getStartRow(); index <= cursor.getEndRow(); index++)
{ {
resultListing.add(convertAlfrescoObjectToCmisObject(nodeRefs[index].toString(), propertyFilter)); resultListing.add(createCmisObject(nodeRefs[index].toString(), propertyFilter));
} }
response.setHasMoreItems(cursor.getEndRow() < (nodeRefs.length - 1)); response.setHasMoreItems(cursor.getEndRow() < (nodeRefs.length - 1));
@@ -120,17 +121,15 @@ public class DMNavigationServicePort extends DMAbstractServicePort implements Na
{ {
PropertyFilter propertyFilter = createPropertyFilter(parameters.getFilter()); PropertyFilter propertyFilter = createPropertyFilter(parameters.getFilter());
NodeRef folderNodeRef = this.cmisObjectsUtils.getIdentifierInstance(parameters.getFolderId(), AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier(); NodeRef folderNodeRef = cmisObjectsUtils.getIdentifierInstance(parameters.getFolderId(), AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier();
NodeRef[] listing = null;
EnumTypesOfFileableObjects types = EnumTypesOfFileableObjects.ANY; EnumTypesOfFileableObjects types = EnumTypesOfFileableObjects.ANY;
if (parameters.getType() != null) if (parameters.getType() != null)
{ {
types = parameters.getType().getValue(); types = parameters.getType().getValue();
} }
NodeRef[] listing = null;
switch (types) switch (types)
{ {
case DOCUMENTS: case DOCUMENTS:
@@ -154,7 +153,7 @@ public class DMNavigationServicePort extends DMAbstractServicePort implements Na
for (int index = cursor.getStartRow(); index <= cursor.getEndRow(); index++) for (int index = cursor.getStartRow(); index <= cursor.getEndRow(); index++)
{ {
resultListing.add(convertAlfrescoObjectToCmisObject(listing[index].toString(), propertyFilter)); resultListing.add(createCmisObject(listing[index].toString(), propertyFilter));
} }
response.setHasMoreItems(cursor.getEndRow() < (listing.length - 1)); response.setHasMoreItems(cursor.getEndRow() < (listing.length - 1));
@@ -166,7 +165,7 @@ public class DMNavigationServicePort extends DMAbstractServicePort implements Na
* Gets the list of descendant objects contained at one or more levels in the tree rooted at the specified folder. Only the filter-selected properties associated with each * Gets the list of descendant objects contained at one or more levels in the tree rooted at the specified folder. Only the filter-selected properties associated with each
* object are returned. The content-stream is not returned. For paging through the children (depth of 1) only use {@link #getChildren(GetChildren parameters)}. * object are returned. The content-stream is not returned. For paging through the children (depth of 1) only use {@link #getChildren(GetChildren parameters)}.
* *
* @param parameters repositoryId: repository Id; folderId: folder Id; depth: 1 this folder only (Default), <20> N folders deep, -1 for all levels; filter: property filter; * @param parameters repositoryId: repository Id; folderId: folder Id; depth: 1 this folder only (Default), N folders deep, -1 for all levels; filter: property filter;
* includeAllowableActions; includeRelationships; * includeAllowableActions; includeRelationships;
* @return collection of CmisObjectType * @return collection of CmisObjectType
* @throws RuntimeException * @throws RuntimeException
@@ -182,22 +181,28 @@ public class DMNavigationServicePort extends DMAbstractServicePort implements Na
public GetDescendantsResponse getDescendants(GetDescendants parameters) throws RuntimeException, InvalidArgumentException, ObjectNotFoundException, public GetDescendantsResponse getDescendants(GetDescendants parameters) throws RuntimeException, InvalidArgumentException, ObjectNotFoundException,
ConstraintViolationException, FilterNotValidException, OperationNotSupportedException, UpdateConflictException, FolderNotValidException, PermissionDeniedException ConstraintViolationException, FilterNotValidException, OperationNotSupportedException, UpdateConflictException, FolderNotValidException, PermissionDeniedException
{ {
BigInteger depth = ((parameters.getDepth() != null) && (parameters.getDepth().getValue() != null)) ? (parameters.getDepth().getValue()) : (BigInteger.ONE);
checkRepositoryId(parameters.getRepositoryId()); checkRepositoryId(parameters.getRepositoryId());
PropertyFilter propertyFilter = createPropertyFilter(parameters.getFilter());
BigInteger depth = ((parameters.getDepth() != null) && (parameters.getDepth().getValue() != null)) ? (parameters.getDepth().getValue()) : (BigInteger.ONE);
checkDepthParameter(depth); checkDepthParameter(depth);
GetDescendantsResponse response = new GetDescendantsResponse(); GetDescendantsResponse response = new GetDescendantsResponse();
HierarchyReceiverStrategy receiver = createHierarchyReceiver(parameters.getType() != null ? parameters.getType() : EnumTypesOfFileableObjects.ANY, depth);
formatCommonResponse(createPropertyFilter(parameters.getFilter()), createHierarchyReceiver( createCmisObjectList(propertyFilter, receiver.receiveHierarchy(parameters.getFolderId()), response.getObject());
(parameters.getType() != null) ? (parameters.getType()) : (EnumTypesOfFileableObjects.ANY), depth).receiveHierarchy(parameters.getFolderId()), response.getObject());
// TODO: includeAllowableActions, includeRelationships // TODO: includeAllowableActions, includeRelationships
return response; return response;
} }
private void checkDepthParameter(BigInteger depth) throws InvalidArgumentException
{
if (depth.equals(BigInteger.ZERO) || (depth.compareTo(FULL_DESCENDANTS_HIERARCHY_CONDITION) < EQUALS_CONDITION_VALUE))
{
throw new InvalidArgumentException("The specified descendants depth is not valid. Valid depth values are: -1 (full hierarchy), N > 0");
}
}
/** /**
* Returns the parent folder object, and optionally all ancestor folder objects, above a specified folder object. * Returns the parent folder object, and optionally all ancestor folder objects, above a specified folder object.
* *
@@ -214,16 +219,16 @@ public class DMNavigationServicePort extends DMAbstractServicePort implements Na
* @throws FolderNotValidException * @throws FolderNotValidException
* @throws PermissionDeniedException * @throws PermissionDeniedException
*/ */
public GetFolderParentResponse getFolderParent(GetFolderParent parameters) throws RuntimeException, InvalidArgumentException, ObjectNotFoundException, public GetFolderParentResponse getFolderParent(GetFolderParent parameters)
ConstraintViolationException, FilterNotValidException, OperationNotSupportedException, UpdateConflictException, FolderNotValidException, PermissionDeniedException throws RuntimeException, InvalidArgumentException, ObjectNotFoundException, ConstraintViolationException, FilterNotValidException, OperationNotSupportedException, UpdateConflictException, FolderNotValidException, PermissionDeniedException
{ {
checkRepositoryId(parameters.getRepositoryId()); checkRepositoryId(parameters.getRepositoryId());
PropertyFilter propertyFilter = createPropertyFilter(parameters.getFilter());
GetFolderParentResponse response = new GetFolderParentResponse(); GetFolderParentResponse response = new GetFolderParentResponse();
formatCommonResponse(createPropertyFilter(parameters.getFilter()), receiveParentList(parameters.getFolderId(), (((parameters.getReturnToRoot() != null) && (parameters boolean returnToRoot = ((parameters.getReturnToRoot() != null) && (parameters.getReturnToRoot().getValue() != null)) ? (parameters.getReturnToRoot().getValue()) : false;
.getReturnToRoot().getValue() != null)) ? (parameters.getReturnToRoot().getValue()) : (false))), response.getObject()); List<NodeRef> parents = receiveParentList(parameters.getFolderId(), returnToRoot);
createCmisObjectList(propertyFilter, parents, response.getObject());
// TODO: includeAllowableActions, includeRelationships // TODO: includeAllowableActions, includeRelationships
@@ -245,108 +250,90 @@ public class DMNavigationServicePort extends DMAbstractServicePort implements Na
* @throws FolderNotValidException * @throws FolderNotValidException
* @throws PermissionDeniedException * @throws PermissionDeniedException
*/ */
public GetObjectParentsResponse getObjectParents(GetObjectParents parameters) throws RuntimeException, InvalidArgumentException, ObjectNotFoundException, public GetObjectParentsResponse getObjectParents(GetObjectParents parameters)
ConstraintViolationException, FilterNotValidException, OperationNotSupportedException, UpdateConflictException, FolderNotValidException, PermissionDeniedException throws RuntimeException, InvalidArgumentException, ObjectNotFoundException, ConstraintViolationException, FilterNotValidException, OperationNotSupportedException, UpdateConflictException, FolderNotValidException, PermissionDeniedException
{ {
// TODO: Policy // TODO: Policy
checkRepositoryId(parameters.getRepositoryId()); checkRepositoryId(parameters.getRepositoryId());
PropertyFilter propertyFilter = createPropertyFilter(parameters.getFilter());
GetObjectParentsResponse response = new GetObjectParentsResponse(); GetObjectParentsResponse response = new GetObjectParentsResponse();
formatCommonResponse(createPropertyFilter(parameters.getFilter()), receiveObjectParents((NodeRef) this.cmisObjectsUtils.getIdentifierInstance(parameters.getObjectId(), List<NodeRef> parents = receiveObjectParents((NodeRef) cmisObjectsUtils.getIdentifierInstance(parameters.getObjectId(), AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier());
AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier()), response.getObject()); createCmisObjectList(propertyFilter, parents, response.getObject());
// TODO: includeAllowableActions, includeRelationships // TODO: includeAllowableActions, includeRelationships
return response; return response;
} }
private void checkDepthParameter(BigInteger depth) throws InvalidArgumentException private List<NodeRef> receiveParentList(String targetChildIdentifier, boolean fullParentsHierarchy)
throws InvalidNodeRefException, InvalidArgumentException, ObjectNotFoundException
{ {
if (depth.equals(BigInteger.ZERO) || (depth.compareTo(FULL_DESCENDANTS_HIERARCHY_CONDITION) < EQUALS_CONDITION_VALUE))
{
throw new InvalidArgumentException("The specified descendants retriving depth is not valid. Valid depth values are: -1 (full hierarchy), N > 0");
}
}
private List<NodeRef> receiveParentList(String targetChildIdentifier, boolean fullParentsHierarchy) throws InvalidNodeRefException, InvalidArgumentException,
ObjectNotFoundException
{
List<NodeRef> result = new LinkedList<NodeRef>(); List<NodeRef> result = new LinkedList<NodeRef>();
if (targetChildIdentifier.equals(cmisService.getDefaultRootNodeRef().toString()))
if (targetChildIdentifier.equals(this.cmisService.getDefaultRootNodeRef().toString()))
{ {
return result; return result;
} }
NodeRef currentParent = receiveNextParentNodeReference((NodeRef) this.cmisObjectsUtils.getIdentifierInstance(targetChildIdentifier, AlfrescoObjectType.FOLDER_OBJECT) NodeRef currentParent = receiveNextParentNodeReference((NodeRef) cmisObjectsUtils.getIdentifierInstance(targetChildIdentifier, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier(), result);
.getConvertedIdentifier(), result);
return (fullParentsHierarchy) ? (receiveFullAncestorsHierachy(currentParent, result)) : (result); return (fullParentsHierarchy) ? (receiveFullAncestorsHierachy(currentParent, result)) : (result);
} }
private List<NodeRef> receiveFullAncestorsHierachy(NodeRef currentParent, List<NodeRef> parents) private List<NodeRef> receiveFullAncestorsHierachy(NodeRef currentParent, List<NodeRef> parents)
{ {
String lastAncestorIdentifier = cmisService.getDefaultRootNodeRef().toString();
String lastAncestorIdentifier = this.cmisService.getDefaultRootNodeRef().toString();
while ((currentParent != null) && !currentParent.toString().equals(lastAncestorIdentifier)) while ((currentParent != null) && !currentParent.toString().equals(lastAncestorIdentifier))
{ {
currentParent = receiveNextParentNodeReference(currentParent, parents); currentParent = receiveNextParentNodeReference(currentParent, parents);
} }
return parents; return parents;
} }
private NodeRef receiveNextParentNodeReference(NodeRef currentParent, List<NodeRef> parents) private NodeRef receiveNextParentNodeReference(NodeRef currentParent, List<NodeRef> parents)
{ {
currentParent = nodeService.getPrimaryParent(currentParent).getParentRef();
currentParent = this.nodeService.getPrimaryParent(currentParent).getParentRef();
if (currentParent != null) if (currentParent != null)
{ {
parents.add(currentParent); parents.add(currentParent);
} }
return currentParent; return currentParent;
} }
private List<NodeRef> receiveObjectParents(NodeRef objectId) throws InvalidArgumentException private List<NodeRef> receiveObjectParents(NodeRef objectId) throws InvalidArgumentException
{ {
List<NodeRef> parents = new LinkedList<NodeRef>(); List<NodeRef> parents = new LinkedList<NodeRef>();
for (ChildAssociationRef childParentAssociation : nodeService.getParentAssocs(objectId))
for (ChildAssociationRef childParentAssociation : this.nodeService.getParentAssocs(objectId))
{ {
parents.add(childParentAssociation.getParentRef()); parents.add(childParentAssociation.getParentRef());
} }
return parents; return parents;
} }
private HierarchyReceiverStrategy createHierarchyReceiver(EnumTypesOfFileableObjects returnObjectsType, BigInteger finalDepth) private HierarchyReceiverStrategy createHierarchyReceiver(EnumTypesOfFileableObjects returnObjectsType, BigInteger finalDepth)
{ {
if (finalDepth.equals(FULL_DESCENDANTS_HIERARCHY_CONDITION))
return (finalDepth.equals(FULL_DESCENDANTS_HIERARCHY_CONDITION)) ? (new FullHierarchyReceiver(returnObjectsType)) : (new LayerConstrainedHierarchyReceiver( {
returnObjectsType, finalDepth)); return new FullHierarchyReceiver(returnObjectsType);
}
else
{
return new LayerConstrainedHierarchyReceiver(returnObjectsType, finalDepth);
}
} }
private void separateDescendantsObjects(EnumTypesOfFileableObjects returnObjectsType, List<NodeRef> descendantsFolders, List<NodeRef> currentLayerFolders, private void separateDescendantsObjects(EnumTypesOfFileableObjects returnObjectsType, List<NodeRef> descendantsFolders, List<NodeRef> currentLayerFolders, List<NodeRef> currentLayerDocuments)
List<NodeRef> currentLayerDocuments)
{ {
for (NodeRef element : descendantsFolders) for (NodeRef element : descendantsFolders)
{ {
// TODO: OrderBy functionality processing. Instead Arrays.asList() it is necessary to add ordering processing method to store each new element where it should go // TODO: OrderBy functionality processing. Instead Arrays.asList() it is necessary to add ordering processing method to store each new element where it should go
currentLayerFolders.addAll(Arrays.asList(this.cmisService.getChildren(element, CMISTypesFilterEnum.FOLDERS))); currentLayerFolders.addAll(Arrays.asList(cmisService.getChildren(element, CMISTypesFilterEnum.FOLDERS)));
// TODO: OrderBy functionality processing. Instead Arrays.asList() it is necessary to add ordering processing method to store each new element where it should go // TODO: OrderBy functionality processing. Instead Arrays.asList() it is necessary to add ordering processing method to store each new element where it should go
if ((returnObjectsType == EnumTypesOfFileableObjects.ANY) || (returnObjectsType == EnumTypesOfFileableObjects.DOCUMENTS)) if ((returnObjectsType == EnumTypesOfFileableObjects.ANY) || (returnObjectsType == EnumTypesOfFileableObjects.DOCUMENTS))
{ {
currentLayerDocuments.addAll(Arrays.asList(this.cmisService.getChildren(element, CMISTypesFilterEnum.DOCUMENTS))); currentLayerDocuments.addAll(Arrays.asList(cmisService.getChildren(element, CMISTypesFilterEnum.DOCUMENTS)));
} }
} }
} }
@@ -354,7 +341,6 @@ public class DMNavigationServicePort extends DMAbstractServicePort implements Na
private List<NodeRef> performDescendantsResultObjectsStoring(EnumTypesOfFileableObjects returnObjectsType, List<NodeRef> resultList, List<NodeRef> descendantsFolders, private List<NodeRef> performDescendantsResultObjectsStoring(EnumTypesOfFileableObjects returnObjectsType, List<NodeRef> resultList, List<NodeRef> descendantsFolders,
List<NodeRef> currentLayerFolders, List<NodeRef> currentLayerDocuments) List<NodeRef> currentLayerFolders, List<NodeRef> currentLayerDocuments)
{ {
separateDescendantsObjects(returnObjectsType, descendantsFolders, currentLayerFolders, currentLayerDocuments); separateDescendantsObjects(returnObjectsType, descendantsFolders, currentLayerFolders, currentLayerDocuments);
if ((returnObjectsType == EnumTypesOfFileableObjects.ANY) || (returnObjectsType == EnumTypesOfFileableObjects.FOLDERS)) if ((returnObjectsType == EnumTypesOfFileableObjects.ANY) || (returnObjectsType == EnumTypesOfFileableObjects.FOLDERS))
@@ -380,19 +366,47 @@ public class DMNavigationServicePort extends DMAbstractServicePort implements Na
public List<NodeRef> receiveHierarchy(String rootFolderIdentifier) throws InvalidArgumentException; public List<NodeRef> receiveHierarchy(String rootFolderIdentifier) throws InvalidArgumentException;
} }
/**
* @see HierarchyReceiverStrategy
*/
private class FullHierarchyReceiver implements HierarchyReceiverStrategy
{
private EnumTypesOfFileableObjects returnObjectsType;
private List<NodeRef> descendantsFolders = new LinkedList<NodeRef>();
private List<NodeRef> resultList = new LinkedList<NodeRef>();
/**
* @param returnObjectsType flag that specifies objects of which type are need to be returned
*/
public FullHierarchyReceiver(EnumTypesOfFileableObjects returnObjectsType)
{
this.returnObjectsType = returnObjectsType;
}
/**
* Traverse Alfresco objects hierarchy until there is some Folder-objects can be found
*/
public List<NodeRef> receiveHierarchy(String rootFolderIdentifier) throws InvalidArgumentException
{
descendantsFolders.add((NodeRef) cmisObjectsUtils.getIdentifierInstance(rootFolderIdentifier, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier());
while (!descendantsFolders.isEmpty())
{
descendantsFolders = performDescendantsResultObjectsStoring(returnObjectsType, resultList, descendantsFolders, new LinkedList<NodeRef>(), new LinkedList<NodeRef>());
}
return resultList;
}
}
/** /**
* @see HierarchyReceiverStrategy * @see HierarchyReceiverStrategy
*/ */
private class LayerConstrainedHierarchyReceiver implements HierarchyReceiverStrategy private class LayerConstrainedHierarchyReceiver implements HierarchyReceiverStrategy
{ {
private List<NodeRef> descendantsFolders = new LinkedList<NodeRef>(); private List<NodeRef> descendantsFolders = new LinkedList<NodeRef>();
private EnumTypesOfFileableObjects returnObjectsType; private EnumTypesOfFileableObjects returnObjectsType;
private BigInteger finalDepth; private BigInteger finalDepth;
private BigInteger currentDepth = BigInteger.ZERO; private BigInteger currentDepth = BigInteger.ZERO;
private List<NodeRef> resultList = new LinkedList<NodeRef>(); private List<NodeRef> resultList = new LinkedList<NodeRef>();
/** /**
@@ -401,7 +415,6 @@ public class DMNavigationServicePort extends DMAbstractServicePort implements Na
*/ */
public LayerConstrainedHierarchyReceiver(EnumTypesOfFileableObjects returnObjectsType, BigInteger finalDepth) public LayerConstrainedHierarchyReceiver(EnumTypesOfFileableObjects returnObjectsType, BigInteger finalDepth)
{ {
this.returnObjectsType = returnObjectsType; this.returnObjectsType = returnObjectsType;
this.finalDepth = finalDepth; this.finalDepth = finalDepth;
} }
@@ -411,56 +424,16 @@ public class DMNavigationServicePort extends DMAbstractServicePort implements Na
*/ */
public List<NodeRef> receiveHierarchy(String rootFolderIdentifier) throws InvalidArgumentException public List<NodeRef> receiveHierarchy(String rootFolderIdentifier) throws InvalidArgumentException
{ {
descendantsFolders.add((NodeRef) cmisObjectsUtils.getIdentifierInstance(rootFolderIdentifier, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier());
this.descendantsFolders.add((NodeRef) cmisObjectsUtils.getIdentifierInstance(rootFolderIdentifier, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier());
do do
{ {
this.descendantsFolders = performDescendantsResultObjectsStoring(this.returnObjectsType, this.resultList, this.descendantsFolders, new LinkedList<NodeRef>(), descendantsFolders = performDescendantsResultObjectsStoring(this.returnObjectsType, this.resultList, this.descendantsFolders, new LinkedList<NodeRef>(), new LinkedList<NodeRef>());
new LinkedList<NodeRef>()); currentDepth = currentDepth.add(BigInteger.ONE);
} while (!descendantsFolders.isEmpty() && (currentDepth.compareTo(this.finalDepth) < EQUALS_CONDITION_VALUE));
this.currentDepth = this.currentDepth.add(BigInteger.ONE);
} while (!this.descendantsFolders.isEmpty() && (this.currentDepth.compareTo(this.finalDepth) < EQUALS_CONDITION_VALUE));
return this.resultList; return this.resultList;
} }
} }
/**
* @see HierarchyReceiverStrategy
*/
private class FullHierarchyReceiver implements HierarchyReceiverStrategy
{
private EnumTypesOfFileableObjects returnObjectsType;
private List<NodeRef> descendantsFolders = new LinkedList<NodeRef>();
private List<NodeRef> resultList = new LinkedList<NodeRef>();
/**
* @param returnObjectsType flag that specifies objects of which type are need to be returned
*/
public FullHierarchyReceiver(EnumTypesOfFileableObjects returnObjectsType)
{
this.returnObjectsType = returnObjectsType;
}
/**
* This method of this class bypass Alfresco objects hierarchy until there is some Folder-objects can be found
*/
public List<NodeRef> receiveHierarchy(String rootFolderIdentifier) throws InvalidArgumentException
{
this.descendantsFolders.add((NodeRef) cmisObjectsUtils.getIdentifierInstance(rootFolderIdentifier, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier());
while (!this.descendantsFolders.isEmpty())
{
this.descendantsFolders = performDescendantsResultObjectsStoring(this.returnObjectsType, this.resultList, this.descendantsFolders, new LinkedList<NodeRef>(),
new LinkedList<NodeRef>());
}
return this.resultList;
}
}
} }

View File

@@ -38,6 +38,7 @@ import org.alfresco.repo.security.permissions.AccessDeniedException;
import org.alfresco.cmis.dictionary.CMISMapping; import org.alfresco.cmis.dictionary.CMISMapping;
import org.alfresco.cmis.dictionary.CMISTypeId; import org.alfresco.cmis.dictionary.CMISTypeId;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.cmis.PropertyFilter;
import org.alfresco.repo.cmis.ws.DeleteTreeResponse.FailedToDelete; import org.alfresco.repo.cmis.ws.DeleteTreeResponse.FailedToDelete;
import org.alfresco.repo.cmis.ws.utils.AlfrescoObjectType; import org.alfresco.repo.cmis.ws.utils.AlfrescoObjectType;
import org.alfresco.repo.cmis.ws.utils.CmisObjectsUtils; import org.alfresco.repo.cmis.ws.utils.CmisObjectsUtils;
@@ -65,12 +66,22 @@ import org.alfresco.service.namespace.QName;
public class DMObjectServicePort extends DMAbstractServicePort implements ObjectServicePort public class DMObjectServicePort extends DMAbstractServicePort implements ObjectServicePort
{ {
private static final int SINGLE_PARENT_CONDITION = 1; private static final int SINGLE_PARENT_CONDITION = 1;
private static final String VERSION_DELIMETER = "."; private static final String VERSION_DELIMETER = ".";
private PermissionService permissionService; private PermissionService permissionService;
private DictionaryService dictionaryService; private DictionaryService dictionaryService;
public void setPermissionService(PermissionService permissionService)
{
this.permissionService = permissionService;
}
public void setDictionaryService(DictionaryService dictionaryService)
{
this.dictionaryService = dictionaryService;
}
/** /**
* Creates a document object of the specified type, and optionally adds the document to a folder * Creates a document object of the specified type, and optionally adds the document to a folder
* *
@@ -92,8 +103,8 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
* @throws RuntimeException * @throws RuntimeException
* @throws ConstraintViolationException * @throws ConstraintViolationException
*/ */
public String createDocument(String repositoryId, String typeId, CmisPropertiesType properties, String folderId, CmisContentStreamType contentStream, public String createDocument(String repositoryId, String typeId, CmisPropertiesType properties, String folderId, CmisContentStreamType contentStream, EnumVersioningState versioningState)
EnumVersioningState versioningState) throws PermissionDeniedException, UpdateConflictException, StorageException, StreamNotSupportedException, FolderNotValidException, throws PermissionDeniedException, UpdateConflictException, StorageException, StreamNotSupportedException, FolderNotValidException,
OperationNotSupportedException, TypeNotFoundException, InvalidArgumentException, RuntimeException, ConstraintViolationException OperationNotSupportedException, TypeNotFoundException, InvalidArgumentException, RuntimeException, ConstraintViolationException
{ {
checkRepositoryId(repositoryId); checkRepositoryId(repositoryId);
@@ -107,7 +118,7 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
throw new ConstraintViolationException("Invalid document type " + typeId); throw new ConstraintViolationException("Invalid document type " + typeId);
} }
NodeRef parentNodeRef = receiveMandatoryFolderNodeReference(folderId); NodeRef parentNodeRef = safeGetFolderNodeRef(folderId);
String documentName = (String) propertiesMap.get(CMISMapping.PROP_NAME); String documentName = (String) propertiesMap.get(CMISMapping.PROP_NAME);
if (documentName == null) if (documentName == null)
@@ -144,23 +155,20 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
switch (versioningState) switch (versioningState)
{ {
case CHECKEDOUT: case CHECKEDOUT:
newDocumentNodeRef = performCheckouting(newDocumentNodeRef); newDocumentNodeRef = checkoutNode(newDocumentNodeRef);
break; break;
case MAJOR: case MAJOR:
this.versionService.createVersion(newDocumentNodeRef, createVersionProperties(INITIAL_VERSION_DESCRIPTION, VersionType.MAJOR)); this.versionService.createVersion(newDocumentNodeRef, createVersionProperties(INITIAL_VERSION_DESCRIPTION, VersionType.MAJOR));
break; break;
case MINOR: case MINOR:
this.versionService.createVersion(newDocumentNodeRef, createVersionProperties(INITIAL_VERSION_DESCRIPTION, VersionType.MINOR)); this.versionService.createVersion(newDocumentNodeRef, createVersionProperties(INITIAL_VERSION_DESCRIPTION, VersionType.MINOR));
break; break;
} }
String versionLabel = (String) cmisPropertyService.getProperty(newDocumentNodeRef, CMISMapping.PROP_VERSION_LABEL); String versionLabel = (String) cmisPropertyService.getProperty(newDocumentNodeRef, CMISMapping.PROP_VERSION_LABEL);
return versionLabel != null && versionLabel.contains(VERSION_DELIMETER) ?
return ((versionLabel instanceof String) && versionLabel.contains(VERSION_DELIMETER)) ? (newDocumentNodeRef.toString() + CmisObjectsUtils.NODE_REFERENCE_ID_DELIMETER + versionLabel) newDocumentNodeRef.toString() + CmisObjectsUtils.NODE_REFERENCE_ID_DELIMETER + versionLabel :
: (newDocumentNodeRef.toString()); newDocumentNodeRef.toString();
} }
/** /**
@@ -180,25 +188,22 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
* @throws RuntimeException * @throws RuntimeException
* @throws ConstraintViolationException * @throws ConstraintViolationException
*/ */
public String createFolder(String repositoryId, String typeId, CmisPropertiesType properties, String folderId) throws PermissionDeniedException, UpdateConflictException, public String createFolder(String repositoryId, String typeId, CmisPropertiesType properties, String folderId)
FolderNotValidException, OperationNotSupportedException, TypeNotFoundException, InvalidArgumentException, RuntimeException, ConstraintViolationException throws PermissionDeniedException, UpdateConflictException, FolderNotValidException, OperationNotSupportedException, TypeNotFoundException, InvalidArgumentException, RuntimeException, ConstraintViolationException
{ {
checkRepositoryId(repositoryId); checkRepositoryId(repositoryId);
NodeRef folderNodeRef = cmisObjectsUtils.getIdentifierInstance(folderId, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier();
NodeRef folderNodeRef = this.cmisObjectsUtils.getIdentifierInstance(folderId, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier();
CMISTypeId cmisTypeId = getCmisTypeId(typeId); CMISTypeId cmisTypeId = getCmisTypeId(typeId);
assertExistType(cmisTypeId); assertTypeExists(cmisTypeId);
CMISMapping cmisMapping = cmisDictionaryService.getCMISMapping(); CMISMapping cmisMapping = cmisDictionaryService.getCMISMapping();
if (cmisMapping.isValidCmisFolder(cmisTypeId.getQName()) == false) if (cmisMapping.isValidCmisFolder(cmisTypeId.getQName()) == false)
{ {
throw new InvalidArgumentException(typeId + " isn't folder type"); throw new InvalidArgumentException(typeId + " isn't a folder type");
} }
Map<String, Serializable> propertiesMap = getPropertiesMap(properties); Map<String, Serializable> propertiesMap = getPropertiesMap(properties);
String name = (String) propertiesMap.get(CMISMapping.PROP_NAME); String name = (String) propertiesMap.get(CMISMapping.PROP_NAME);
if (name == null) if (name == null)
{ {
@@ -237,12 +242,10 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
* @throws RuntimeException * @throws RuntimeException
* @throws ConstraintViolationException * @throws ConstraintViolationException
*/ */
public String createPolicy(String repositoryId, String typeId, CmisPropertiesType properties, String folderId) throws PermissionDeniedException, UpdateConflictException, public String createPolicy(String repositoryId, String typeId, CmisPropertiesType properties, String folderId)
FolderNotValidException, OperationNotSupportedException, TypeNotFoundException, InvalidArgumentException, RuntimeException, ConstraintViolationException throws PermissionDeniedException, UpdateConflictException, FolderNotValidException, OperationNotSupportedException, TypeNotFoundException, InvalidArgumentException, RuntimeException, ConstraintViolationException
{ {
// TODO: // TODO:
return null; return null;
} }
@@ -265,8 +268,7 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
* @throws ConstraintViolationException * @throws ConstraintViolationException
*/ */
public String createRelationship(String repositoryId, String typeId, CmisPropertiesType properties, String sourceObjectId, String targetObjectId) public String createRelationship(String repositoryId, String typeId, CmisPropertiesType properties, String sourceObjectId, String targetObjectId)
throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, TypeNotFoundException, InvalidArgumentException, throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, TypeNotFoundException, InvalidArgumentException, RuntimeException, ConstraintViolationException
RuntimeException, ConstraintViolationException
{ {
checkRepositoryId(repositoryId); checkRepositoryId(repositoryId);
@@ -275,8 +277,8 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
try try
{ {
sourceNodeRef = this.cmisObjectsUtils.getIdentifierInstance(sourceObjectId, AlfrescoObjectType.ANY_OBJECT).getConvertedIdentifier(); sourceNodeRef = cmisObjectsUtils.getIdentifierInstance(sourceObjectId, AlfrescoObjectType.ANY_OBJECT).getConvertedIdentifier();
targetNodeRef = this.cmisObjectsUtils.getIdentifierInstance(targetObjectId, AlfrescoObjectType.ANY_OBJECT).getConvertedIdentifier(); targetNodeRef = cmisObjectsUtils.getIdentifierInstance(targetObjectId, AlfrescoObjectType.ANY_OBJECT).getConvertedIdentifier();
} }
catch (InvalidArgumentException e) catch (InvalidArgumentException e)
{ {
@@ -284,12 +286,10 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
{ {
throw new ObjectNotFoundException(e.getMessage()); throw new ObjectNotFoundException(e.getMessage());
} }
throw e; throw e;
} }
CMISTypeId relationshipTypeId; CMISTypeId relationshipTypeId;
try try
{ {
relationshipTypeId = cmisDictionaryService.getCMISMapping().getCmisTypeId(typeId); relationshipTypeId = cmisDictionaryService.getCMISMapping().getCmisTypeId(typeId);
@@ -300,7 +300,6 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
} }
QName relationshipTypeQName = cmisDictionaryService.getCMISMapping().getAlfrescoType(relationshipTypeId.getQName()); QName relationshipTypeQName = cmisDictionaryService.getCMISMapping().getAlfrescoType(relationshipTypeId.getQName());
AssociationDefinition associationDef = dictionaryService.getAssociation(relationshipTypeQName); AssociationDefinition associationDef = dictionaryService.getAssociation(relationshipTypeQName);
if (associationDef != null) if (associationDef != null)
{ {
@@ -339,14 +338,11 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
* @throws RuntimeException * @throws RuntimeException
* @throws ConstraintViolationException * @throws ConstraintViolationException
*/ */
public void deleteContentStream(String repositoryId, String documentId) throws PermissionDeniedException, UpdateConflictException, StorageException, public void deleteContentStream(String repositoryId, String documentId)
StreamNotSupportedException, ObjectNotFoundException, OperationNotSupportedException, VersioningException, InvalidArgumentException, RuntimeException, throws PermissionDeniedException, UpdateConflictException, StorageException, StreamNotSupportedException, ObjectNotFoundException, OperationNotSupportedException, VersioningException, InvalidArgumentException, RuntimeException, ConstraintViolationException
ConstraintViolationException
{ {
checkRepositoryId(repositoryId); checkRepositoryId(repositoryId);
safeDeleteContentStream((NodeRef) cmisObjectsUtils.getIdentifierInstance(documentId, AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier());
performContentStreamDeletion((NodeRef) this.cmisObjectsUtils.getIdentifierInstance(documentId, AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier());
} }
/** /**
@@ -362,18 +358,15 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
* @throws RuntimeException * @throws RuntimeException
* @throws ConstraintViolationException * @throws ConstraintViolationException
*/ */
public void deleteObject(String repositoryId, String objectId) throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, public void deleteObject(String repositoryId, String objectId)
OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
{ {
checkRepositoryId(repositoryId); checkRepositoryId(repositoryId);
NodeRef objectNodeReference = this.cmisObjectsUtils.getIdentifierInstance(objectId, AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT).getConvertedIdentifier(); NodeRef objectNodeReference = cmisObjectsUtils.getIdentifierInstance(objectId, AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT).getConvertedIdentifier();
checkForRootObject(repositoryId, objectId); checkForRootObject(repositoryId, objectId);
checkObjectTypeAndAppropriateStates(objectNodeReference, this.cmisDictionaryService.getCMISMapping().getCmisType(this.nodeService.getType(objectNodeReference))); checkObjectTypeAndAppropriateStates(objectNodeReference, this.cmisDictionaryService.getCMISMapping().getCmisType(this.nodeService.getType(objectNodeReference)));
if (!cmisObjectsUtils.deleteObject(objectNodeReference))
if (!this.cmisObjectsUtils.deleteObject(objectNodeReference))
{ {
throw new PermissionDeniedException("Currently authenticated User has no appropriate Permissions to delete specified Object"); throw new PermissionDeniedException("Currently authenticated User has no appropriate Permissions to delete specified Object");
} }
@@ -398,25 +391,21 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
* @throws ConstraintViolationException * @throws ConstraintViolationException
*/ */
public FailedToDelete deleteTree(String repositoryId, String folderId, EnumUnfileNonfolderObjects unfileNonfolderObjects, Boolean continueOnFailure) public FailedToDelete deleteTree(String repositoryId, String folderId, EnumUnfileNonfolderObjects unfileNonfolderObjects, Boolean continueOnFailure)
throws PermissionDeniedException, UpdateConflictException, FolderNotValidException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, throws PermissionDeniedException, UpdateConflictException, FolderNotValidException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
ConstraintViolationException
{ {
checkRepositoryId(repositoryId); checkRepositoryId(repositoryId);
checkUnfilingIsNotRequested(unfileNonfolderObjects); checkUnfilingIsNotRequested(unfileNonfolderObjects);
checkForRootObject(repositoryId, folderId); checkForRootObject(repositoryId, folderId);
NodeRef folderNodeReference = this.cmisObjectsUtils.getIdentifierInstance(folderId, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier(); NodeRef folderNodeReference = cmisObjectsUtils.getIdentifierInstance(folderId, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier();
FailedToDelete responce = new FailedToDelete(); FailedToDelete responce = new FailedToDelete();
cmisObjectsUtils.deleteFolder(folderNodeReference, continueOnFailure, (unfileNonfolderObjects == EnumUnfileNonfolderObjects.DELETE), responce.getObjectId());
this.cmisObjectsUtils.deleteFolder(folderNodeReference, continueOnFailure, (unfileNonfolderObjects == EnumUnfileNonfolderObjects.DELETE), responce.getObjectId());
return responce; return responce;
} }
/** /**
* Gets the list of allowable actions (CMIS service calls) for an object based on the current user<EFBFBD>s context, subject to any access constraints that are currently imposed by * Gets the list of allowable actions (CMIS service calls) for an object based on the current user's context, subject to any access constraints that are currently imposed by
* the repository. * the repository.
* *
* @param repositoryId repository Id * @param repositoryId repository Id
@@ -429,13 +418,11 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
* @throws InvalidArgumentException * @throws InvalidArgumentException
* @throws RuntimeException * @throws RuntimeException
*/ */
public CmisAllowableActionsType getAllowableActions(String repositoryId, String objectId) throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, public CmisAllowableActionsType getAllowableActions(String repositoryId, String objectId)
OperationNotSupportedException, InvalidArgumentException, RuntimeException throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException
{ {
checkRepositoryId(repositoryId); checkRepositoryId(repositoryId);
return determineObjectAllowableActions(cmisObjectsUtils.getIdentifierInstance(objectId, AlfrescoObjectType.ANY_OBJECT));
return determineObjectAllowableActions(this.cmisObjectsUtils.getIdentifierInstance(objectId, AlfrescoObjectType.ANY_OBJECT));
} }
/** /**
@@ -454,14 +441,13 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
* @throws RuntimeException * @throws RuntimeException
* @throws OffsetException * @throws OffsetException
*/ */
public CmisContentStreamType getContentStream(String repositoryId, String documentId) throws PermissionDeniedException, UpdateConflictException, StorageException, public CmisContentStreamType getContentStream(String repositoryId, String documentId)
StreamNotSupportedException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, OffsetException throws PermissionDeniedException, UpdateConflictException, StorageException, StreamNotSupportedException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, OffsetException
{ {
NodeRef nodeRef = this.cmisObjectsUtils.getIdentifierInstance(documentId, AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier(); NodeRef nodeRef = cmisObjectsUtils.getIdentifierInstance(documentId, AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier();
CmisContentStreamType response = new CmisContentStreamType(); CmisContentStreamType response = new CmisContentStreamType();
ContentReader reader = safeGetContentReader(nodeRef);
ContentReader reader = safelyReceiveContentReader(nodeRef);
response.setLength(BigInteger.valueOf(reader.getSize())); response.setLength(BigInteger.valueOf(reader.getSize()));
response.setMimeType(reader.getMimetype()); response.setMimeType(reader.getMimetype());
@@ -489,22 +475,20 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
* @throws RuntimeException * @throws RuntimeException
* @throws ConstraintViolationException * @throws ConstraintViolationException
*/ */
public void moveObject(String repositoryId, String objectId, String targetFolderId, String sourceFolderId) throws PermissionDeniedException, UpdateConflictException, public void moveObject(String repositoryId, String objectId, String targetFolderId, String sourceFolderId)
ObjectNotFoundException, FolderNotValidException, OperationNotSupportedException, NotInFolderException, InvalidArgumentException, RuntimeException, throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, FolderNotValidException, OperationNotSupportedException, NotInFolderException, InvalidArgumentException, RuntimeException, ConstraintViolationException
ConstraintViolationException
{ {
checkRepositoryId(repositoryId); checkRepositoryId(repositoryId);
NodeRef objectNodeRef = this.cmisObjectsUtils.getIdentifierInstance(objectId, AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT).getConvertedIdentifier(); NodeRef objectNodeRef = cmisObjectsUtils.getIdentifierInstance(objectId, AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT).getConvertedIdentifier();
NodeRef targetFolderNodeRef = this.cmisObjectsUtils.getIdentifierInstance(targetFolderId, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier(); NodeRef targetFolderNodeRef = cmisObjectsUtils.getIdentifierInstance(targetFolderId, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier();
NodeRef sourceFolderNodeRef = cmisObjectsUtils.getIdentifierInstance(sourceFolderId, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier();
// TODO: Allowed_Child_Object_Types // TODO: Allowed_Child_Object_Types
if ((this.nodeService.getParentAssocs(objectNodeRef).size() == SINGLE_PARENT_CONDITION) if (nodeService.getParentAssocs(objectNodeRef).size() == SINGLE_PARENT_CONDITION || !changeObjectParentAssociation(objectNodeRef, targetFolderNodeRef, sourceFolderNodeRef))
|| !changeObjectParentAssociation(objectNodeRef, targetFolderNodeRef, (NodeRef) this.cmisObjectsUtils.getIdentifierInstance(sourceFolderId,
AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier()))
{ {
moveObjectToFolder(objectNodeRef, targetFolderNodeRef); safeMove(objectNodeRef, targetFolderNodeRef);
} }
} }
@@ -526,13 +510,12 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
* @throws RuntimeException * @throws RuntimeException
* @throws ConstraintViolationException * @throws ConstraintViolationException
*/ */
public void setContentStream(String repositoryId, Holder<String> documentId, Boolean overwriteFlag, CmisContentStreamType contentStream) throws PermissionDeniedException, public void setContentStream(String repositoryId, Holder<String> documentId, Boolean overwriteFlag, CmisContentStreamType contentStream)
UpdateConflictException, StorageException, StreamNotSupportedException, ObjectNotFoundException, OperationNotSupportedException, ContentAlreadyExistsException, throws PermissionDeniedException, UpdateConflictException, StorageException, StreamNotSupportedException, ObjectNotFoundException, OperationNotSupportedException, ContentAlreadyExistsException, InvalidArgumentException, RuntimeException, ConstraintViolationException
InvalidArgumentException, RuntimeException, ConstraintViolationException
{ {
checkRepositoryId(repositoryId); checkRepositoryId(repositoryId);
NodeRef nodeRef = this.cmisObjectsUtils.getIdentifierInstance(documentId.value, AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier(); NodeRef nodeRef = cmisObjectsUtils.getIdentifierInstance(documentId.value, AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier();
if (contentStream.getStream() == null) if (contentStream.getStream() == null)
{ {
@@ -573,14 +556,13 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
* @throws RuntimeException * @throws RuntimeException
* @throws ConstraintViolationException * @throws ConstraintViolationException
*/ */
public void updateProperties(String repositoryId, Holder<String> objectId, String changeToken, CmisPropertiesType properties) throws PermissionDeniedException, public void updateProperties(String repositoryId, Holder<String> objectId, String changeToken, CmisPropertiesType properties)
UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
{ {
checkRepositoryId(repositoryId); checkRepositoryId(repositoryId);
checkForReadOnlyProperties(properties); checkForReadOnlyProperties(properties);
NodeRef objectNodeRef = this.cmisObjectsUtils.getIdentifierInstance(objectId.value, AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT).getConvertedIdentifier(); NodeRef objectNodeRef = cmisObjectsUtils.getIdentifierInstance(objectId.value, AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT).getConvertedIdentifier();
setProperties(objectNodeRef, properties); setProperties(objectNodeRef, properties);
// TODO: change token // TODO: change token
@@ -602,19 +584,19 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
* @throws InvalidArgumentException * @throws InvalidArgumentException
* @throws RuntimeException * @throws RuntimeException
*/ */
public GetPropertiesResponse getProperties(GetProperties parameters) throws PermissionDeniedException, UpdateConflictException, FilterNotValidException, public GetPropertiesResponse getProperties(GetProperties parameters)
ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException throws PermissionDeniedException, UpdateConflictException, FilterNotValidException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException
{ {
checkRepositoryId(parameters.getRepositoryId()); checkRepositoryId(parameters.getRepositoryId());
PropertyFilter propertyFilter = createPropertyFilter(parameters.getFilter()); PropertyFilter propertyFilter = createPropertyFilter(parameters.getFilter());
String identifier = ((NodeRef) this.cmisObjectsUtils.getIdentifierInstance(parameters.getObjectId(), AlfrescoObjectType.ANY_OBJECT).getConvertedIdentifier()).toString(); String identifier = ((NodeRef) cmisObjectsUtils.getIdentifierInstance(parameters.getObjectId(), AlfrescoObjectType.ANY_OBJECT).getConvertedIdentifier()).toString();
EnumReturnVersion returnVersion = (parameters.getReturnVersion() != null && parameters.getReturnVersion().getValue() != null) ? parameters.getReturnVersion().getValue() : null;
if ((this.cmisObjectsUtils.determineObjectType(identifier) == EnumObjectType.DOCUMENT) && (parameters.getReturnVersion() != null) if ((cmisObjectsUtils.determineObjectType(identifier) == EnumObjectType.DOCUMENT) && returnVersion != null)
&& (parameters.getReturnVersion().getValue() != null))
{ {
identifier = getLatestVersionNodeRef(new NodeRef(identifier), (parameters.getReturnVersion().getValue() != EnumReturnVersion.LATEST)).toString(); identifier = getLatestNode(new NodeRef(identifier), returnVersion != EnumReturnVersion.LATEST).toString();
} }
GetPropertiesResponse response = new GetPropertiesResponse(); GetPropertiesResponse response = new GetPropertiesResponse();
@@ -635,11 +617,6 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
return response; return response;
} }
public void setPermissionService(PermissionService permissionService)
{
this.permissionService = permissionService;
}
private Map<String, Serializable> getPropertiesMap(CmisPropertiesType cmisProperties) throws InvalidArgumentException private Map<String, Serializable> getPropertiesMap(CmisPropertiesType cmisProperties) throws InvalidArgumentException
{ {
@@ -648,7 +625,6 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
for (CmisProperty cmisProperty : cmisProperties.getProperty()) for (CmisProperty cmisProperty : cmisProperties.getProperty())
{ {
String name = PropertyUtil.getRepositoryPropertyName(cmisProperty.getName()); String name = PropertyUtil.getRepositoryPropertyName(cmisProperty.getName());
if (name == null) if (name == null)
{ {
throw new InvalidArgumentException("Unknown property with name " + name); throw new InvalidArgumentException("Unknown property with name " + name);
@@ -660,7 +636,7 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
return properties; return properties;
} }
private void assertExistType(CMISTypeId cmisTypeId) throws TypeNotFoundException private void assertTypeExists(CMISTypeId cmisTypeId) throws TypeNotFoundException
{ {
if (cmisDictionaryService.getCMISMapping().isValidCmisType(cmisTypeId.getQName()) == false) if (cmisDictionaryService.getCMISMapping().isValidCmisType(cmisTypeId.getQName()) == false)
{ {
@@ -680,9 +656,25 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
} }
} }
private void moveObjectToFolder(NodeRef objectNodeRef, NodeRef targetFolderNodeRef) throws PermissionDeniedException, UpdateConflictException private boolean changeObjectParentAssociation(NodeRef objectNodeRef, NodeRef targetFolderNodeRef, NodeRef sourceFolderNodeReference)
throws UpdateConflictException, PermissionDeniedException
{ {
if (cmisObjectsUtils.isPrimaryObjectParent(sourceFolderNodeReference, objectNodeRef))
{
return false;
}
if (!cmisObjectsUtils.removeObject(objectNodeRef, sourceFolderNodeReference) && cmisObjectsUtils.addObjectToFolder(objectNodeRef, targetFolderNodeRef))
{
determineException(cmisObjectsUtils.getLastOperationException());
}
return true;
}
private void safeMove(NodeRef objectNodeRef, NodeRef targetFolderNodeRef)
throws PermissionDeniedException, UpdateConflictException
{
try try
{ {
fileFolderService.move(objectNodeRef, targetFolderNodeRef, null); fileFolderService.move(objectNodeRef, targetFolderNodeRef, null);
@@ -693,40 +685,11 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
} }
} }
private boolean changeObjectParentAssociation(NodeRef objectNodeRef, NodeRef targetFolderNodeRef, NodeRef sourceFolderNodeReference) throws UpdateConflictException, private void safeDeleteContentStream(NodeRef documentNodeReference) throws ConstraintViolationException
PermissionDeniedException
{ {
if (this.cmisObjectsUtils.isPrimaryObjectParent(sourceFolderNodeReference, objectNodeRef))
{
return false;
}
if (!this.cmisObjectsUtils.removeObject(objectNodeRef, sourceFolderNodeReference) && this.cmisObjectsUtils.addObjectToFolder(objectNodeRef, targetFolderNodeRef))
{
determineException(this.cmisObjectsUtils.getLastOperationException());
}
return true;
}
private void determineException(Throwable lastException) throws PermissionDeniedException, UpdateConflictException
{
if (lastException instanceof AccessDeniedException)
{
throw new PermissionDeniedException(lastException.getMessage());
}
throw new UpdateConflictException("Couldn't to relocate multi-filed Object");
}
private void performContentStreamDeletion(NodeRef documentNodeReference) throws ConstraintViolationException
{
try try
{ {
this.nodeService.setProperty(documentNodeReference, ContentModel.PROP_CONTENT, null); nodeService.setProperty(documentNodeReference, ContentModel.PROP_CONTENT, null);
} }
catch (NodeLockedException e) catch (NodeLockedException e)
{ {
@@ -734,15 +697,36 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
} }
} }
private ContentReader safeGetContentReader(NodeRef objectNodeReference) throws StorageException
{
ContentReader reader = fileFolderService.getReader(objectNodeReference);
if (reader == null)
{
throw new StorageException("The specified Document has no Content Stream");
}
return reader;
}
private NodeRef safeGetFolderNodeRef(String folderId) throws FolderNotValidException
{
try
{
return this.cmisObjectsUtils.getIdentifierInstance(folderId, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier();
}
catch (InvalidArgumentException e)
{
throw new FolderNotValidException("Unfiling is not suppoerted. Each Document must have existent parent Folder");
}
}
private void checkObjectTypeAndAppropriateStates(NodeRef objectNodeReference, QName objectType) throws InvalidArgumentException, ConstraintViolationException private void checkObjectTypeAndAppropriateStates(NodeRef objectNodeReference, QName objectType) throws InvalidArgumentException, ConstraintViolationException
{ {
if (objectType == null) if (objectType == null)
{ {
throw new InvalidArgumentException("Specified Object has invalid Object Type"); throw new InvalidArgumentException("Specified Object has invalid Object Type");
} }
if (objectType.equals(CMISMapping.FOLDER_QNAME) && (this.nodeService.getChildAssocs(objectNodeReference).size() > 0)) if (objectType.equals(CMISMapping.FOLDER_QNAME) && (nodeService.getChildAssocs(objectNodeReference).size() > 0))
{ {
throw new ConstraintViolationException("Could not delete folder with at least one Child"); throw new ConstraintViolationException("Could not delete folder with at least one Child");
} }
@@ -750,7 +734,6 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
private void checkUnfilingIsNotRequested(EnumUnfileNonfolderObjects unfileNonfolderObjects) throws OperationNotSupportedException private void checkUnfilingIsNotRequested(EnumUnfileNonfolderObjects unfileNonfolderObjects) throws OperationNotSupportedException
{ {
if (unfileNonfolderObjects == EnumUnfileNonfolderObjects.UNFILE) if (unfileNonfolderObjects == EnumUnfileNonfolderObjects.UNFILE)
{ {
throw new OperationNotSupportedException("Unfiling is not supported"); throw new OperationNotSupportedException("Unfiling is not supported");
@@ -759,34 +742,14 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
private void checkForRootObject(String repositoryId, String objectId) throws OperationNotSupportedException private void checkForRootObject(String repositoryId, String objectId) throws OperationNotSupportedException
{ {
if (this.cmisService.getDefaultRootNodeRef().toString().equals(objectId) || repositoryId.equals(objectId)) if (this.cmisService.getDefaultRootNodeRef().toString().equals(objectId) || repositoryId.equals(objectId))
{ {
throw new OperationNotSupportedException("Could not delete Repository object or Root Folder object - operation is not allowed or not supported"); throw new OperationNotSupportedException("Could not delete Repository object or Root Folder object - operation is not allowed or not supported");
} }
} }
public void setDictionaryService(DictionaryService dictionaryService)
{
this.dictionaryService = dictionaryService;
}
private ContentReader safelyReceiveContentReader(NodeRef objectNodeReference) throws StorageException
{
ContentReader reader = fileFolderService.getReader(objectNodeReference);
if (reader == null)
{
throw new StorageException("The specified Document has no Content Stream");
}
return reader;
}
private void checkForReadOnlyProperties(CmisPropertiesType properties) throws ConstraintViolationException private void checkForReadOnlyProperties(CmisPropertiesType properties) throws ConstraintViolationException
{ {
for (CmisProperty property : properties.getProperty()) for (CmisProperty property : properties.getProperty())
{ {
if (PropertyUtil.isReadOnlyRepositoryProperty(property.getName())) if (PropertyUtil.isReadOnlyRepositoryProperty(property.getName()))
@@ -805,7 +768,7 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
return determineRelationshipAllowableActions((AssociationRef) objectIdentifierContainer.getConvertedIdentifier()); return determineRelationshipAllowableActions((AssociationRef) objectIdentifierContainer.getConvertedIdentifier());
} }
switch (this.cmisObjectsUtils.determineObjectType(objectNodeReference.toString())) switch (cmisObjectsUtils.determineObjectType(objectNodeReference.toString()))
{ {
case DOCUMENT: case DOCUMENT:
{ {
@@ -821,22 +784,9 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
throw new OperationNotSupportedException("It is impossible to get Allowable actions for the specified Object"); throw new OperationNotSupportedException("It is impossible to get Allowable actions for the specified Object");
} }
private CmisAllowableActionsType determineRelationshipAllowableActions(AssociationRef association)
{
CmisAllowableActionsType result = new CmisAllowableActionsType();
result.setCanDelete(this.permissionService.hasPermission(association.getSourceRef(), PermissionService.DELETE_ASSOCIATIONS) == AccessStatus.ALLOWED);
result.setCanGetRelationships(this.permissionService.hasPermission(association.getSourceRef(), PermissionService.READ_ASSOCIATIONS) == AccessStatus.ALLOWED);
return result;
}
private CmisAllowableActionsType determineBaseAllowableActions(NodeRef objectNodeReference) private CmisAllowableActionsType determineBaseAllowableActions(NodeRef objectNodeReference)
{ {
CmisAllowableActionsType result = new CmisAllowableActionsType(); CmisAllowableActionsType result = new CmisAllowableActionsType();
result.setCanGetProperties(this.permissionService.hasPermission(objectNodeReference, PermissionService.READ_PROPERTIES) == AccessStatus.ALLOWED); result.setCanGetProperties(this.permissionService.hasPermission(objectNodeReference, PermissionService.READ_PROPERTIES) == AccessStatus.ALLOWED);
result.setCanUpdateProperties(this.permissionService.hasPermission(objectNodeReference, PermissionService.WRITE_PROPERTIES) == AccessStatus.ALLOWED); result.setCanUpdateProperties(this.permissionService.hasPermission(objectNodeReference, PermissionService.WRITE_PROPERTIES) == AccessStatus.ALLOWED);
result.setCanDelete(this.permissionService.hasPermission(objectNodeReference, PermissionService.DELETE) == AccessStatus.ALLOWED); result.setCanDelete(this.permissionService.hasPermission(objectNodeReference, PermissionService.DELETE) == AccessStatus.ALLOWED);
@@ -848,22 +798,10 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
return result; return result;
} }
private void determineCommonFolderDocumentAllowableActions(NodeRef objectNodeReference, CmisAllowableActionsType allowableActions)
{
allowableActions.setCanAddToFolder(this.permissionService.hasPermission(objectNodeReference, PermissionService.CREATE_ASSOCIATIONS) == AccessStatus.ALLOWED);
allowableActions.setCanGetRelationships(this.permissionService.hasPermission(objectNodeReference, PermissionService.READ_ASSOCIATIONS) == AccessStatus.ALLOWED);
allowableActions.setCanMove(allowableActions.isCanUpdateProperties() && allowableActions.isCanAddToFolder());
allowableActions.setCanRemoveFromFolder(allowableActions.isCanUpdateProperties());
allowableActions.setCanCreateRelationship(allowableActions.isCanAddToFolder());
}
private CmisAllowableActionsType determineDocumentAllowableActions(NodeRef objectNodeReference) private CmisAllowableActionsType determineDocumentAllowableActions(NodeRef objectNodeReference)
{ {
CmisAllowableActionsType result = determineBaseAllowableActions(objectNodeReference); CmisAllowableActionsType result = determineBaseAllowableActions(objectNodeReference);
determineCommonFolderDocumentAllowableActions(objectNodeReference, result); determineCommonFolderDocumentAllowableActions(objectNodeReference, result);
result.setCanGetParents(this.permissionService.hasPermission(objectNodeReference, PermissionService.READ_ASSOCIATIONS) == AccessStatus.ALLOWED); result.setCanGetParents(this.permissionService.hasPermission(objectNodeReference, PermissionService.READ_ASSOCIATIONS) == AccessStatus.ALLOWED);
result.setCanViewContent(this.permissionService.hasPermission(objectNodeReference, PermissionService.READ_CONTENT) == AccessStatus.ALLOWED); result.setCanViewContent(this.permissionService.hasPermission(objectNodeReference, PermissionService.READ_CONTENT) == AccessStatus.ALLOWED);
result.setCanSetContent(this.permissionService.hasPermission(objectNodeReference, PermissionService.WRITE_CONTENT) == AccessStatus.ALLOWED); result.setCanSetContent(this.permissionService.hasPermission(objectNodeReference, PermissionService.WRITE_CONTENT) == AccessStatus.ALLOWED);
@@ -871,13 +809,11 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
result.setCanCheckin(this.permissionService.hasPermission(objectNodeReference, PermissionService.CHECK_IN) == AccessStatus.ALLOWED); result.setCanCheckin(this.permissionService.hasPermission(objectNodeReference, PermissionService.CHECK_IN) == AccessStatus.ALLOWED);
result.setCanCancelCheckout(this.permissionService.hasPermission(objectNodeReference, PermissionService.CANCEL_CHECK_OUT) == AccessStatus.ALLOWED); result.setCanCancelCheckout(this.permissionService.hasPermission(objectNodeReference, PermissionService.CANCEL_CHECK_OUT) == AccessStatus.ALLOWED);
result.setCanDeleteContent(result.isCanUpdateProperties() && result.isCanSetContent()); result.setCanDeleteContent(result.isCanUpdateProperties() && result.isCanSetContent());
return result; return result;
} }
private CmisAllowableActionsType determineFolderAllowableActions(NodeRef objectNodeReference) private CmisAllowableActionsType determineFolderAllowableActions(NodeRef objectNodeReference)
{ {
CmisAllowableActionsType result = determineBaseAllowableActions(objectNodeReference); CmisAllowableActionsType result = determineBaseAllowableActions(objectNodeReference);
determineCommonFolderDocumentAllowableActions(objectNodeReference, result); determineCommonFolderDocumentAllowableActions(objectNodeReference, result);
@@ -888,20 +824,34 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
result.setCanGetFolderParent(result.isCanGetRelationships()); result.setCanGetFolderParent(result.isCanGetRelationships());
result.setCanCreateFolder(result.isCanCreateDocument()); result.setCanCreateFolder(result.isCanCreateDocument());
// TODO: response.setCanCreatePolicy(value); // TODO: response.setCanCreatePolicy(value);
return result; return result;
} }
private NodeRef receiveMandatoryFolderNodeReference(String folderId) throws FolderNotValidException private void determineCommonFolderDocumentAllowableActions(NodeRef objectNodeReference, CmisAllowableActionsType allowableActions)
{ {
allowableActions.setCanAddToFolder(this.permissionService.hasPermission(objectNodeReference, PermissionService.CREATE_ASSOCIATIONS) == AccessStatus.ALLOWED);
allowableActions.setCanGetRelationships(this.permissionService.hasPermission(objectNodeReference, PermissionService.READ_ASSOCIATIONS) == AccessStatus.ALLOWED);
allowableActions.setCanMove(allowableActions.isCanUpdateProperties() && allowableActions.isCanAddToFolder());
allowableActions.setCanRemoveFromFolder(allowableActions.isCanUpdateProperties());
allowableActions.setCanCreateRelationship(allowableActions.isCanAddToFolder());
}
try private CmisAllowableActionsType determineRelationshipAllowableActions(AssociationRef association)
{ {
return this.cmisObjectsUtils.getIdentifierInstance(folderId, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier(); CmisAllowableActionsType result = new CmisAllowableActionsType();
result.setCanDelete(this.permissionService.hasPermission(association.getSourceRef(), PermissionService.DELETE_ASSOCIATIONS) == AccessStatus.ALLOWED);
result.setCanGetRelationships(this.permissionService.hasPermission(association.getSourceRef(), PermissionService.READ_ASSOCIATIONS) == AccessStatus.ALLOWED);
return result;
} }
catch (InvalidArgumentException e)
private void determineException(Throwable lastException) throws PermissionDeniedException, UpdateConflictException
{ {
throw new FolderNotValidException("Unfiling is not suppoerted. Each Document must have existent parent Folder"); if (lastException instanceof AccessDeniedException)
{
throw new PermissionDeniedException(lastException.getMessage());
} }
throw new UpdateConflictException("Couldn't to relocate multi-filed Object");
} }
} }

View File

@@ -46,7 +46,6 @@ public class DMPolicyServicePort extends DMAbstractServicePort implements Policy
OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
{ {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
/** /**
@@ -87,7 +86,6 @@ public class DMPolicyServicePort extends DMAbstractServicePort implements Policy
OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
{ {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
} }

View File

@@ -28,6 +28,7 @@ import java.math.BigInteger;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.alfresco.repo.cmis.PropertyFilter;
import org.alfresco.repo.cmis.ws.utils.AlfrescoObjectType; import org.alfresco.repo.cmis.ws.utils.AlfrescoObjectType;
import org.alfresco.repo.web.util.paging.Cursor; import org.alfresco.repo.web.util.paging.Cursor;
import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.DictionaryService;
@@ -46,6 +47,12 @@ public class DMRelationshipServicePort extends DMAbstractServicePort implements
{ {
private DictionaryService dictionaryService; private DictionaryService dictionaryService;
public void setDictionaryService(DictionaryService dictionaryService)
{
this.dictionaryService = dictionaryService;
}
/** /**
* Gets a list of relationships associated with the object, optionally of a specified relationship type, and optionally in a specified direction. * Gets a list of relationships associated with the object, optionally of a specified relationship type, and optionally in a specified direction.
* *
@@ -66,86 +73,78 @@ public class DMRelationshipServicePort extends DMAbstractServicePort implements
public GetRelationshipsResponse getRelationships(GetRelationships parameters) throws PermissionDeniedException, UpdateConflictException, FilterNotValidException, public GetRelationshipsResponse getRelationships(GetRelationships parameters) throws PermissionDeniedException, UpdateConflictException, FilterNotValidException,
ObjectNotFoundException, OperationNotSupportedException, TypeNotFoundException, InvalidArgumentException, RuntimeException, ConstraintViolationException ObjectNotFoundException, OperationNotSupportedException, TypeNotFoundException, InvalidArgumentException, RuntimeException, ConstraintViolationException
{ {
checkRepositoryId(parameters.getRepositoryId()); checkRepositoryId(parameters.getRepositoryId());
EnumRelationshipDirection direction = ((parameters.getDirection() != null) && (parameters.getDirection().getValue() != null)) ? (parameters.getDirection().getValue()) EnumRelationshipDirection direction = ((parameters.getDirection() != null) && (parameters.getDirection().getValue() != null)) ? parameters.getDirection().getValue() : EnumRelationshipDirection.SOURCE;
: (EnumRelationshipDirection.SOURCE); Boolean includingSubtypes = ((parameters.getIncludeSubRelationshipTypes() != null) && (parameters.getIncludeSubRelationshipTypes().getValue() != null)) ? parameters.getIncludeSubRelationshipTypes().getValue() : false;
Boolean includingSubtypes = ((parameters.getIncludeSubRelationshipTypes() != null) && (parameters.getIncludeSubRelationshipTypes().getValue() != null)) ? (parameters String typeId = ((parameters.getTypeId() != null) && (parameters.getTypeId().getValue() != null)) ? parameters.getTypeId().getValue() : null;
.getIncludeSubRelationshipTypes().getValue()) : (false); BigInteger skipCount = ((parameters.getSkipCount() != null) && (parameters.getSkipCount().getValue() != null)) ? parameters.getSkipCount().getValue() : BigInteger.ZERO;
String typeId = ((parameters.getTypeId() != null) && (parameters.getTypeId().getValue() != null)) ? (parameters.getTypeId().getValue()) : (null); BigInteger maxItems = ((parameters.getMaxItems() != null) && (parameters.getMaxItems().getValue() != null)) ? parameters.getMaxItems().getValue() : BigInteger.ZERO;
BigInteger skipCount = ((parameters.getSkipCount() != null) && (parameters.getSkipCount().getValue() != null)) ? (parameters.getSkipCount().getValue()) : (BigInteger.ZERO);
BigInteger maxItems = ((parameters.getMaxItems() != null) && (parameters.getMaxItems().getValue() != null)) ? (parameters.getMaxItems().getValue()) : (BigInteger.ZERO);
QName associationType = cmisDictionaryService.getCMISMapping().getAlfrescoType(cmisDictionaryService.getCMISMapping().getCmisTypeId(typeId).getQName()); QName associationType = cmisDictionaryService.getCMISMapping().getAlfrescoType(cmisDictionaryService.getCMISMapping().getCmisTypeId(typeId).getQName());
return formatResponse(createPropertyFilter(parameters.getFilter()), receiveAssociations( PropertyFilter propertyFilter = createPropertyFilter(parameters.getFilter());
(NodeRef) this.cmisObjectsUtils.getIdentifierInstance(parameters.getObjectId(), AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT).getConvertedIdentifier(), NodeRef objectNodeRef = (NodeRef) cmisObjectsUtils.getIdentifierInstance(parameters.getObjectId(), AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT).getConvertedIdentifier();
associationType, direction, includingSubtypes).toArray(), new GetRelationshipsResponse(), skipCount, maxItems); List<AssociationRef> assocs = receiveAssociations(objectNodeRef, associationType, direction, includingSubtypes);
return formatResponse(propertyFilter, assocs.toArray(), new GetRelationshipsResponse(), skipCount, maxItems);
} }
public void setDictionaryService(DictionaryService dictionaryService) private List<AssociationRef> receiveAssociations(NodeRef objectNodeReference, QName relationshipType, EnumRelationshipDirection direction, boolean includeSubtypes)
{ {
List<AssociationRef> result = new LinkedList<AssociationRef>();
QNamePattern matcher = new RelationshipTypeFilter(relationshipType, includeSubtypes);
this.dictionaryService = dictionaryService; if ((direction == EnumRelationshipDirection.BOTH) || (direction == EnumRelationshipDirection.TARGET))
{
result.addAll(nodeService.getSourceAssocs(objectNodeReference, matcher));
}
if ((direction == EnumRelationshipDirection.BOTH) || (direction == EnumRelationshipDirection.SOURCE))
{
result.addAll(nodeService.getTargetAssocs(objectNodeReference, matcher));
}
return result;
} }
private GetRelationshipsResponse formatResponse(PropertyFilter filter, Object[] sourceArray, GetRelationshipsResponse result, BigInteger skipCount, BigInteger maxItems) private GetRelationshipsResponse formatResponse(PropertyFilter filter, Object[] sourceArray, GetRelationshipsResponse result, BigInteger skipCount, BigInteger maxItems)
throws InvalidArgumentException, FilterNotValidException throws InvalidArgumentException, FilterNotValidException
{ {
Cursor cursor = createCursor(sourceArray.length, skipCount, maxItems); Cursor cursor = createCursor(sourceArray.length, skipCount, maxItems);
for (int i = cursor.getStartRow(); i < cursor.getEndRow(); i++) for (int i = cursor.getStartRow(); i < cursor.getEndRow(); i++)
{ {
result.getObject().add(convertAlfrescoObjectToCmisObject(sourceArray[i].toString(), filter)); result.getObject().add(createCmisObject(sourceArray[i].toString(), filter));
} }
return result; return result;
} }
private List<AssociationRef> receiveAssociations(NodeRef objectNodeReference, QName necessaryRelationshipType, EnumRelationshipDirection direction, boolean includingSubtypes)
private class RelationshipTypeFilter implements QNamePattern
{ {
private boolean includeSubtypes;
private QName relationshipType;
List<AssociationRef> result = new LinkedList<AssociationRef>(); public RelationshipTypeFilter(QName ralationshipType, boolean includeSubtypes)
QNamePattern matcher = new RelationshipByTypeFilter(necessaryRelationshipType, includingSubtypes);
if ((direction == EnumRelationshipDirection.BOTH) || (direction == EnumRelationshipDirection.TARGET))
{ {
result.addAll(this.nodeService.getSourceAssocs(objectNodeReference, matcher)); this.relationshipType = ralationshipType;
} this.includeSubtypes = includeSubtypes;
if ((direction == EnumRelationshipDirection.BOTH) || (direction == EnumRelationshipDirection.SOURCE))
{
result.addAll(this.nodeService.getTargetAssocs(objectNodeReference, matcher));
}
return result;
}
private class RelationshipByTypeFilter implements QNamePattern
{
private boolean includingSubtypes;
private QName necessaryGeneralType;
public RelationshipByTypeFilter(QName necessaryGeneralType, boolean includingSubtypes)
{
this.includingSubtypes = includingSubtypes;
this.necessaryGeneralType = necessaryGeneralType;
} }
public boolean isMatch(QName qname) public boolean isMatch(QName qname)
{ {
if (relationshipType == null)
if (this.necessaryGeneralType == null)
{ {
return true; return true;
} }
else if (includeSubtypes)
return ((this.includingSubtypes) ? (dictionaryService.getAssociation(qname) != null) {
: (cmisDictionaryService.getCMISMapping().isValidCmisRelationship(qname) && this.necessaryGeneralType.equals(qname))); return dictionaryService.getAssociation(qname) != null;
}
else
{
return cmisDictionaryService.getCMISMapping().isValidCmisRelationship(qname) && relationshipType.equals(qname);
}
} }
} }
} }

View File

@@ -113,8 +113,8 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
* @throws UpdateConflictException * @throws UpdateConflictException
* @throws PermissionDeniedException * @throws PermissionDeniedException
*/ */
public List<CmisRepositoryEntryType> getRepositories() throws RuntimeException, InvalidArgumentException, OperationNotSupportedException, UpdateConflictException, public List<CmisRepositoryEntryType> getRepositories()
PermissionDeniedException throws RuntimeException, InvalidArgumentException, OperationNotSupportedException, UpdateConflictException, PermissionDeniedException
{ {
CmisRepositoryEntryType repositoryEntryType = new CmisRepositoryEntryType(); CmisRepositoryEntryType repositoryEntryType = new CmisRepositoryEntryType();
Descriptor serverDescriptor = descriptorService.getServerDescriptor(); Descriptor serverDescriptor = descriptorService.getServerDescriptor();
@@ -136,11 +136,10 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
* @throws RuntimeException * @throws RuntimeException
* @throws ConstraintViolationException * @throws ConstraintViolationException
*/ */
public CmisRepositoryInfoType getRepositoryInfo(GetRepositoryInfo parameters) throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, public CmisRepositoryInfoType getRepositoryInfo(GetRepositoryInfo parameters)
OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
{ {
Descriptor serverDescriptor = descriptorService.getServerDescriptor(); Descriptor serverDescriptor = descriptorService.getServerDescriptor();
if (serverDescriptor.getId().equals(parameters.getRepositoryId()) == false) if (serverDescriptor.getId().equals(parameters.getRepositoryId()) == false)
{ {
throw new InvalidArgumentException("Invalid repository id"); throw new InvalidArgumentException("Invalid repository id");
@@ -167,7 +166,6 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
repositoryInfoType.setCapabilities(capabilities); repositoryInfoType.setCapabilities(capabilities);
repositoryInfoType.setCmisVersionsSupported(cmisService.getCMISVersion()); repositoryInfoType.setCmisVersionsSupported(cmisService.getCMISVersion());
return repositoryInfoType; return repositoryInfoType;
} }
@@ -387,7 +385,7 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
result = cmisObjectFactory.createRelationshipType(relationshipDefinitionType); result = cmisObjectFactory.createRelationshipType(relationshipDefinitionType);
break; break;
case UNKNOWN: case UNKNOWN:
throw new ObjectNotFoundException("Bab type"); throw new ObjectNotFoundException("Unknown CMIS Type");
} }
return result; return result;
@@ -407,28 +405,32 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
* @throws UpdateConflictException * @throws UpdateConflictException
* @throws PermissionDeniedException * @throws PermissionDeniedException
*/ */
public GetTypesResponse getTypes(GetTypes parameters) throws RuntimeException, InvalidArgumentException, ObjectNotFoundException, ConstraintViolationException, public GetTypesResponse getTypes(GetTypes parameters)
OperationNotSupportedException, UpdateConflictException, PermissionDeniedException throws RuntimeException, InvalidArgumentException, ObjectNotFoundException, ConstraintViolationException, OperationNotSupportedException, UpdateConflictException, PermissionDeniedException
{ {
if (descriptorService.getServerDescriptor().getId().equals(parameters.getRepositoryId()) == false) if (descriptorService.getServerDescriptor().getId().equals(parameters.getRepositoryId()) == false)
{ {
throw new InvalidArgumentException("Invalid repository id"); throw new InvalidArgumentException("Invalid repository id");
} }
Collection<CMISTypeId> typeIds;
if (parameters.getTypeId() == null)
{
typeIds = cmisDictionaryService.getAllObjectTypeIds();
}
else
{
typeIds = cmisDictionaryService.getChildTypeIds(cmisDictionaryService.getCMISMapping().getCmisTypeId(parameters.getTypeId().getValue()), true);
}
GetTypesResponse response = new GetTypesResponse(); GetTypesResponse response = new GetTypesResponse();
Collection<CMISTypeId> typeIds = parameters.getTypeId() == null ? cmisDictionaryService.getAllObjectTypeIds() : cmisDictionaryService.getChildTypeIds(cmisDictionaryService
.getCMISMapping().getCmisTypeId(parameters.getTypeId().getValue()), true);
if (parameters.getMaxItems() != null) if (parameters.getMaxItems() != null)
{ {
response.setHasMoreItems(parameters.getMaxItems().getValue().intValue() < typeIds.size()); response.setHasMoreItems(parameters.getMaxItems().getValue().intValue() < typeIds.size());
} }
Cursor cursor = createCursor(typeIds.size(), parameters.getSkipCount() != null ? parameters.getSkipCount().getValue() : null, parameters.getMaxItems() != null ? parameters
.getMaxItems().getValue() : null);
// skip // skip
Cursor cursor = createCursor(typeIds.size(), parameters.getSkipCount() != null ? parameters.getSkipCount().getValue() : null, parameters.getMaxItems() != null ? parameters.getMaxItems().getValue() : null);
Iterator<CMISTypeId> iterTypeIds = typeIds.iterator(); Iterator<CMISTypeId> iterTypeIds = typeIds.iterator();
for (int i = 0; i < cursor.getStartRow(); i++) for (int i = 0; i < cursor.getStartRow(); i++)
{ {
@@ -464,8 +466,8 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
* @throws RuntimeException * @throws RuntimeException
* @throws ConstraintViolationException * @throws ConstraintViolationException
*/ */
public GetTypeDefinitionResponse getTypeDefinition(GetTypeDefinition parameters) throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, public GetTypeDefinitionResponse getTypeDefinition(GetTypeDefinition parameters)
OperationNotSupportedException, TypeNotFoundException, InvalidArgumentException, RuntimeException, ConstraintViolationException throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, TypeNotFoundException, InvalidArgumentException, RuntimeException, ConstraintViolationException
{ {
if (descriptorService.getServerDescriptor().getId().equals(parameters.getRepositoryId()) == false) if (descriptorService.getServerDescriptor().getId().equals(parameters.getRepositoryId()) == false)
{ {

View File

@@ -30,6 +30,8 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.aop.ThrowsAdvice; import org.springframework.aop.ThrowsAdvice;
/** /**
* Map Alfresco Exceptions to CMIS Exceptions
*
* @author Dmitry Lazurkin * @author Dmitry Lazurkin
* @author Dmitry Velichkevich * @author Dmitry Velichkevich
*/ */
@@ -37,7 +39,8 @@ public class DMServicePortThrowsAdvice implements ThrowsAdvice
{ {
private static final Log log = LogFactory.getLog("org.alfresco.repo.cmis.ws"); private static final Log log = LogFactory.getLog("org.alfresco.repo.cmis.ws");
public void afterThrowing(AccessDeniedException e) throws PermissionDeniedException public void afterThrowing(AccessDeniedException e)
throws PermissionDeniedException
{ {
if (log.isInfoEnabled()) if (log.isInfoEnabled())
{ {
@@ -47,7 +50,8 @@ public class DMServicePortThrowsAdvice implements ThrowsAdvice
throw new PermissionDeniedException("Access denied. Message: " + e.getMessage(), e); throw new PermissionDeniedException("Access denied. Message: " + e.getMessage(), e);
} }
public void afterThrowing(java.lang.RuntimeException e) throws RuntimeException public void afterThrowing(java.lang.RuntimeException e)
throws RuntimeException
{ {
if (log.isErrorEnabled()) if (log.isErrorEnabled())
{ {

View File

@@ -30,6 +30,7 @@ import javax.xml.ws.Holder;
import org.alfresco.cmis.dictionary.CMISMapping; import org.alfresco.cmis.dictionary.CMISMapping;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.cmis.PropertyFilter;
import org.alfresco.repo.cmis.ws.utils.AlfrescoObjectType; import org.alfresco.repo.cmis.ws.utils.AlfrescoObjectType;
import org.alfresco.service.cmr.lock.LockService; import org.alfresco.service.cmr.lock.LockService;
import org.alfresco.service.cmr.lock.LockStatus; import org.alfresco.service.cmr.lock.LockStatus;
@@ -50,6 +51,12 @@ public class DMVersioningServicePort extends DMAbstractServicePort implements Ve
{ {
private LockService lockService; private LockService lockService;
public void setLockService(LockService lockService)
{
this.lockService = lockService;
}
/** /**
* Reverses the effect of a check-out. Removes the private working copy of the checked-out document object, allowing other documents in the version series to be checked out * Reverses the effect of a check-out. Removes the private working copy of the checked-out document object, allowing other documents in the version series to be checked out
* again. * again.
@@ -63,11 +70,11 @@ public class DMVersioningServicePort extends DMAbstractServicePort implements Ve
* @throws InvalidArgumentException * @throws InvalidArgumentException
* @throws RuntimeException * @throws RuntimeException
*/ */
public void cancelCheckOut(String repositoryId, String documentId) throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, public void cancelCheckOut(String repositoryId, String documentId)
OperationNotSupportedException, InvalidArgumentException, RuntimeException throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException
{ {
checkRepositoryId(repositoryId); checkRepositoryId(repositoryId);
NodeRef workingCopyNodeRef = this.cmisObjectsUtils.getIdentifierInstance(documentId, AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier(); NodeRef workingCopyNodeRef = cmisObjectsUtils.getIdentifierInstance(documentId, AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier();
assertWorkingCopy(workingCopyNodeRef); assertWorkingCopy(workingCopyNodeRef);
checkOutCheckInService.cancelCheckout(workingCopyNodeRef); checkOutCheckInService.cancelCheckout(workingCopyNodeRef);
} }
@@ -92,11 +99,10 @@ public class DMVersioningServicePort extends DMAbstractServicePort implements Ve
* @throws ConstraintViolationException * @throws ConstraintViolationException
*/ */
public void checkIn(String repositoryId, Holder<String> documentId, Boolean major, CmisPropertiesType properties, CmisContentStreamType contentStream, String checkinComment) public void checkIn(String repositoryId, Holder<String> documentId, Boolean major, CmisPropertiesType properties, CmisContentStreamType contentStream, String checkinComment)
throws PermissionDeniedException, UpdateConflictException, StorageException, StreamNotSupportedException, ObjectNotFoundException, OperationNotSupportedException, throws PermissionDeniedException, UpdateConflictException, StorageException, StreamNotSupportedException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
InvalidArgumentException, RuntimeException, ConstraintViolationException
{ {
checkRepositoryId(repositoryId); checkRepositoryId(repositoryId);
NodeRef workingCopyNodeRef = this.cmisObjectsUtils.getIdentifierInstance(documentId.value, AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier(); NodeRef workingCopyNodeRef = cmisObjectsUtils.getIdentifierInstance(documentId.value, AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier();
assertWorkingCopy(workingCopyNodeRef); assertWorkingCopy(workingCopyNodeRef);
if (contentStream != null) if (contentStream != null)
@@ -118,9 +124,7 @@ public class DMVersioningServicePort extends DMAbstractServicePort implements Ve
setProperties(workingCopyNodeRef, properties); setProperties(workingCopyNodeRef, properties);
} }
NodeRef nodeRef = checkOutCheckInService.checkin(workingCopyNodeRef, createVersionProperties(checkinComment, ((major != null) && (major)) ? (VersionType.MAJOR) NodeRef nodeRef = checkOutCheckInService.checkin(workingCopyNodeRef, createVersionProperties(checkinComment, major != null && major ? VersionType.MAJOR : VersionType.MINOR));
: (VersionType.MINOR)));
documentId.value = (String) cmisPropertyService.getProperty(nodeRef, CMISMapping.PROP_OBJECT_ID); documentId.value = (String) cmisPropertyService.getProperty(nodeRef, CMISMapping.PROP_OBJECT_ID);
} }
@@ -139,13 +143,12 @@ public class DMVersioningServicePort extends DMAbstractServicePort implements Ve
* @throws RuntimeException * @throws RuntimeException
* @throws ConstraintViolationException * @throws ConstraintViolationException
*/ */
public void checkOut(String repositoryId, Holder<String> documentId, Holder<Boolean> contentCopied) throws PermissionDeniedException, UpdateConflictException, public void checkOut(String repositoryId, Holder<String> documentId, Holder<Boolean> contentCopied)
ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
{ {
checkRepositoryId(repositoryId); checkRepositoryId(repositoryId);
NodeRef documentNodeRef = this.cmisObjectsUtils.getIdentifierInstance(documentId.value, AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier(); NodeRef documentNodeRef = cmisObjectsUtils.getIdentifierInstance(documentId.value, AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier();
LockStatus lockStatus = lockService.getLockStatus(documentNodeRef); LockStatus lockStatus = lockService.getLockStatus(documentNodeRef);
if (lockStatus.equals(LockStatus.LOCKED) || lockStatus.equals(LockStatus.LOCK_OWNER) || nodeService.hasAspect(documentNodeRef, ContentModel.ASPECT_WORKING_COPY)) if (lockStatus.equals(LockStatus.LOCKED) || lockStatus.equals(LockStatus.LOCK_OWNER) || nodeService.hasAspect(documentNodeRef, ContentModel.ASPECT_WORKING_COPY))
@@ -153,8 +156,7 @@ public class DMVersioningServicePort extends DMAbstractServicePort implements Ve
throw new OperationNotSupportedException("Object is already checked out"); throw new OperationNotSupportedException("Object is already checked out");
} }
NodeRef pwcNodeRef = performCheckouting(documentNodeRef); NodeRef pwcNodeRef = checkoutNode(documentNodeRef);
documentId.value = (String) cmisPropertyService.getProperty(pwcNodeRef, CMISMapping.PROP_OBJECT_ID); documentId.value = (String) cmisPropertyService.getProperty(pwcNodeRef, CMISMapping.PROP_OBJECT_ID);
contentCopied.value = true; contentCopied.value = true;
} }
@@ -172,12 +174,11 @@ public class DMVersioningServicePort extends DMAbstractServicePort implements Ve
* @throws RuntimeException * @throws RuntimeException
* @throws ConstraintViolationException * @throws ConstraintViolationException
*/ */
public void deleteAllVersions(String repositoryId, String versionSeriesId) throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, public void deleteAllVersions(String repositoryId, String versionSeriesId)
OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
{ {
checkRepositoryId(repositoryId); checkRepositoryId(repositoryId);
NodeRef documentNodeRef = this.cmisObjectsUtils.getIdentifierInstance(versionSeriesId, AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier(); NodeRef documentNodeRef = cmisObjectsUtils.getIdentifierInstance(versionSeriesId, AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier();
versionService.deleteVersionHistory(documentNodeRef); versionService.deleteVersionHistory(documentNodeRef);
} }
@@ -195,21 +196,20 @@ public class DMVersioningServicePort extends DMAbstractServicePort implements Ve
* @throws RuntimeException * @throws RuntimeException
* @throws ConstraintViolationException * @throws ConstraintViolationException
*/ */
public GetAllVersionsResponse getAllVersions(GetAllVersions parameters) throws PermissionDeniedException, UpdateConflictException, FilterNotValidException, public GetAllVersionsResponse getAllVersions(GetAllVersions parameters)
ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException throws PermissionDeniedException, UpdateConflictException, FilterNotValidException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
{ {
checkRepositoryId(parameters.getRepositoryId()); checkRepositoryId(parameters.getRepositoryId());
NodeRef documentNodeRef = this.cmisObjectsUtils.getIdentifierInstance(parameters.getVersionSeriesId(), AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier(); NodeRef documentNodeRef = cmisObjectsUtils.getIdentifierInstance(parameters.getVersionSeriesId(), AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier();
documentNodeRef = getLatestVersionNodeRef(documentNodeRef, false); documentNodeRef = getLatestNode(documentNodeRef, false);
PropertyFilter propertyFilter = createPropertyFilter(parameters.getFilter()); PropertyFilter propertyFilter = createPropertyFilter(parameters.getFilter());
GetAllVersionsResponse response = new GetAllVersionsResponse(); GetAllVersionsResponse response = new GetAllVersionsResponse();
List<CmisObjectType> objects = response.getObject(); List<CmisObjectType> objects = response.getObject();
searchWorkingCopy(documentNodeRef, propertyFilter, objects); searchWorkingCopy(documentNodeRef, propertyFilter, objects);
objects.add(convertAlfrescoObjectToCmisObject(documentNodeRef, propertyFilter)); objects.add(createCmisObject(documentNodeRef, propertyFilter));
VersionHistory versionHistory = versionService.getVersionHistory(documentNodeRef); VersionHistory versionHistory = versionService.getVersionHistory(documentNodeRef);
@@ -218,12 +218,10 @@ public class DMVersioningServicePort extends DMAbstractServicePort implements Ve
return response; return response;
} }
Version version = this.versionService.getCurrentVersion(documentNodeRef); Version version = versionService.getCurrentVersion(documentNodeRef);
while (version != null) while (version != null)
{ {
objects.add(convertAlfrescoObjectToCmisObject(version.getFrozenStateNodeRef(), propertyFilter)); objects.add(createCmisObject(version.getFrozenStateNodeRef(), propertyFilter));
version = versionHistory.getPredecessor(version); version = versionHistory.getPredecessor(version);
} }
@@ -237,15 +235,14 @@ public class DMVersioningServicePort extends DMAbstractServicePort implements Ve
* property filter * property filter
* @return CmisObjectType with properties * @return CmisObjectType with properties
*/ */
public GetPropertiesOfLatestVersionResponse getPropertiesOfLatestVersion(GetPropertiesOfLatestVersion parameters) throws PermissionDeniedException, UpdateConflictException, public GetPropertiesOfLatestVersionResponse getPropertiesOfLatestVersion(GetPropertiesOfLatestVersion parameters)
FilterNotValidException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException throws PermissionDeniedException, UpdateConflictException, FilterNotValidException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException
{ {
checkRepositoryId(parameters.getRepositoryId()); checkRepositoryId(parameters.getRepositoryId());
PropertyFilter propertyFilter = createPropertyFilter(parameters.getFilter()); PropertyFilter propertyFilter = createPropertyFilter(parameters.getFilter());
NodeRef documentNodeRef = this.cmisObjectsUtils.getIdentifierInstance(parameters.getVersionSeriesId(), AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier(); NodeRef documentNodeRef = cmisObjectsUtils.getIdentifierInstance(parameters.getVersionSeriesId(), AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier();
NodeRef latestVersionNodeRef = getLatestNode(documentNodeRef, parameters.isMajorVersion());
NodeRef latestVersionNodeRef = getLatestVersionNodeRef(documentNodeRef, parameters.isMajorVersion());
GetPropertiesOfLatestVersionResponse response = new GetPropertiesOfLatestVersionResponse(); GetPropertiesOfLatestVersionResponse response = new GetPropertiesOfLatestVersionResponse();
response.setObject(new CmisObjectType()); response.setObject(new CmisObjectType());
@@ -255,25 +252,18 @@ public class DMVersioningServicePort extends DMAbstractServicePort implements Ve
return response; return response;
} }
public void setLockService(LockService lockService)
{
this.lockService = lockService;
}
private void searchWorkingCopy(NodeRef documentNodeRef, PropertyFilter propertyFilter, List<CmisObjectType> resultList) private void searchWorkingCopy(NodeRef documentNodeRef, PropertyFilter propertyFilter, List<CmisObjectType> resultList)
{ {
NodeRef workingCopyNodeReference = cmisObjectsUtils.isWorkingCopy(documentNodeRef) ? documentNodeRef : checkOutCheckInService.getWorkingCopy(documentNodeRef);
NodeRef workingCopyNodeReference = (this.cmisObjectsUtils.isWorkingCopy(documentNodeRef)) ? (documentNodeRef) : (checkOutCheckInService.getWorkingCopy(documentNodeRef)); if (workingCopyNodeReference != null)
if (workingCopyNodeReference instanceof NodeRef)
{ {
resultList.add(convertAlfrescoObjectToCmisObject(workingCopyNodeReference, propertyFilter)); resultList.add(createCmisObject(workingCopyNodeReference, propertyFilter));
} }
} }
private void assertWorkingCopy(NodeRef nodeRef) throws OperationNotSupportedException private void assertWorkingCopy(NodeRef nodeRef) throws OperationNotSupportedException
{ {
if (!this.cmisObjectsUtils.isWorkingCopy(nodeRef)) if (!cmisObjectsUtils.isWorkingCopy(nodeRef))
{ {
throw new OperationNotSupportedException("Object isn't checked out"); throw new OperationNotSupportedException("Object isn't checked out");
} }

View File

@@ -98,13 +98,11 @@ public class PropertyUtil
public static boolean isReadOnlyCmisProperty(String internalPropertyName) public static boolean isReadOnlyCmisProperty(String internalPropertyName)
{ {
return repoToCmisPropertiesNamesMapping.get(internalPropertyName).getSecond(); return repoToCmisPropertiesNamesMapping.get(internalPropertyName).getSecond();
} }
public static boolean isReadOnlyRepositoryProperty(String cmisPropertyName) public static boolean isReadOnlyRepositoryProperty(String cmisPropertyName)
{ {
return repoToCmisPropertiesNamesMapping.get(cmisPropertyName).getSecond(); return repoToCmisPropertiesNamesMapping.get(cmisPropertyName).getSecond();
} }

View File

@@ -35,8 +35,11 @@ import org.alfresco.model.ContentModel;
*/ */
public enum AlfrescoObjectType public enum AlfrescoObjectType
{ {
DOCUMENT_OBJECT(ContentModel.TYPE_CONTENT.toString()), FOLDER_OBJECT(ContentModel.TYPE_FOLDER.toString()), DOCUMENT_OR_FOLDER_OBJECT("DOCUMENT_OR_FOLDER"), RELATIONSHIP_OBJECT( DOCUMENT_OBJECT(ContentModel.TYPE_CONTENT.toString()),
CMISMapping.RELATIONSHIP_QNAME.toString()), ANY_OBJECT("ANY"); FOLDER_OBJECT(ContentModel.TYPE_FOLDER.toString()),
DOCUMENT_OR_FOLDER_OBJECT("DOCUMENT_OR_FOLDER"),
RELATIONSHIP_OBJECT(CMISMapping.RELATIONSHIP_QNAME.toString()),
ANY_OBJECT("ANY");
String value; String value;
@@ -50,26 +53,21 @@ public enum AlfrescoObjectType
AlfrescoObjectType(String value) AlfrescoObjectType(String value)
{ {
this.value = value; this.value = value;
} }
public String getValue() public String getValue()
{ {
return this.value; return this.value;
} }
public static AlfrescoObjectType fromValue(String valueName) public static AlfrescoObjectType fromValue(String valueName)
{ {
AlfrescoObjectType result = VALUES.get(valueName); AlfrescoObjectType result = VALUES.get(valueName);
if (result == null) if (result == null)
{ {
result = ANY_OBJECT; result = ANY_OBJECT;
} }
return result; return result;
} }
} }

View File

@@ -53,10 +53,8 @@ import org.alfresco.service.namespace.QName;
*/ */
public class CmisObjectsUtils public class CmisObjectsUtils
{ {
private static final int NODE_REFERENCE_WITH_SUFFIX_DELIMETERS_COUNT = 5;
public static final String NODE_REFERENCE_ID_DELIMETER = "/"; public static final String NODE_REFERENCE_ID_DELIMETER = "/";
private static final int NODE_REFERENCE_WITH_SUFFIX_DELIMETERS_COUNT = 5;
private static final String DOUBLE_NODE_REFERENCE_ID_DELIMETER = NODE_REFERENCE_ID_DELIMETER + NODE_REFERENCE_ID_DELIMETER; private static final String DOUBLE_NODE_REFERENCE_ID_DELIMETER = NODE_REFERENCE_ID_DELIMETER + NODE_REFERENCE_ID_DELIMETER;
private static final List<QName> DOCUMENT_AND_FOLDER_TYPES; private static final List<QName> DOCUMENT_AND_FOLDER_TYPES;
@@ -77,9 +75,41 @@ public class CmisObjectsUtils
private Throwable lastOperationException; private Throwable lastOperationException;
public void setCmisDictionaryService(CMISDictionaryService cmisDictionaryService)
{
this.cmisDictionaryService = cmisDictionaryService;
this.cmisMapping = this.cmisDictionaryService.getCMISMapping();
}
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
public void setFileFolderService(FileFolderService fileFolderService)
{
this.fileFolderService = fileFolderService;
}
public void setLockService(LockService lockService)
{
this.lockService = lockService;
}
public void setCheckOutCheckInService(CheckOutCheckInService checkOutCheckInService)
{
this.checkOutCheckInService = checkOutCheckInService;
}
public void setAuthorityService(AuthorityService authorityService)
{
this.authorityService = authorityService;
}
public IdentifierConversionResults getIdentifierInstance(String identifier, AlfrescoObjectType expectedType) throws InvalidArgumentException public IdentifierConversionResults getIdentifierInstance(String identifier, AlfrescoObjectType expectedType) throws InvalidArgumentException
{ {
if (!(identifier instanceof String)) if (!(identifier instanceof String))
{ {
throw new InvalidArgumentException("Invalid Object Identifier was specified"); throw new InvalidArgumentException("Invalid Object Identifier was specified");
@@ -91,15 +121,12 @@ public class CmisObjectsUtils
if (isRelationship(identifier)) if (isRelationship(identifier))
{ {
result = createAssociationIdentifierResult(identifier); result = createAssociationIdentifierResult(identifier);
actualObjectType = AlfrescoObjectType.RELATIONSHIP_OBJECT; actualObjectType = AlfrescoObjectType.RELATIONSHIP_OBJECT;
} }
else else
{ {
NodeRef nodeReference = receiveNodeReferenceOfExistenceObject(cutNodeVersionIfNecessary(identifier, identifier.split(NODE_REFERENCE_ID_DELIMETER), 1)); NodeRef nodeReference = safeGetNodeRef(cutNodeVersionIfNecessary(identifier, identifier.split(NODE_REFERENCE_ID_DELIMETER), 1));
result = createNodeReferenceIdentifierResult(nodeReference); result = createNodeReferenceIdentifierResult(nodeReference);
actualObjectType = determineActualObjectType(expectedType, this.nodeService.getType(nodeReference)); actualObjectType = determineActualObjectType(expectedType, this.nodeService.getType(nodeReference));
} }
@@ -111,39 +138,50 @@ public class CmisObjectsUtils
throw new InvalidArgumentException("Unexpected object type of the specified Object Identifier"); throw new InvalidArgumentException("Unexpected object type of the specified Object Identifier");
} }
public void deleteFolder(NodeRef folderNodeReference, boolean continueOnFailure, boolean totalDeletion, List<String> resultList) throws OperationNotSupportedException public void deleteFolder(NodeRef folderNodeReference, boolean continueOnFailure, boolean totalDeletion, List<String> resultList)
throws OperationNotSupportedException
{ {
DescendantsQueueManager queueManager = new DescendantsQueueManager(new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, null, null, folderNodeReference)); DescendantsQueueManager queueManager = new DescendantsQueueManager(new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, null, null, folderNodeReference));
do do
{ {
DescendantElement currentElement = queueManager.receiveNextElement(); DescendantElement currentElement = queueManager.getNextElement();
if (!nodeService.exists(currentElement.getChildAssoc().getChildRef()))
if (!this.nodeService.exists(currentElement.getNodesAssociation().getChildRef()))
{ {
continue; continue;
} }
UnlinkOperationStatus unlinkingStatus = unlinkObject(currentElement.getNodesAssociation().getChildRef(), currentElement.getNodesAssociation().getParentRef(), UnlinkOperationStatus unlinkStatus = unlinkObject(currentElement.getChildAssoc().getChildRef(), currentElement.getChildAssoc().getParentRef(), totalDeletion);
totalDeletion); if (!unlinkStatus.isObjectUnlinked())
if (!unlinkingStatus.isObjectUnlinked())
{ {
processNotUnlinkedObjectResults(currentElement, unlinkingStatus, queueManager, resultList, continueOnFailure); processUnlinkStatus(currentElement, unlinkStatus, queueManager, resultList, continueOnFailure);
}
} while (!queueManager.isEmpty() && (continueOnFailure || resultList.isEmpty()));
}
private void processUnlinkStatus(DescendantElement currentElement, UnlinkOperationStatus unlinkStatus, DescendantsQueueManager queueManager, List<String> resultList, boolean addAllFailedToDelete)
{
if (!unlinkStatus.getChildren().isEmpty())
{
queueManager.addLast(currentElement);
queueManager.addFirst(currentElement, unlinkStatus.getChildren());
return;
}
resultList.add(currentElement.getChildAssoc().getChildRef().toString());
if (addAllFailedToDelete)
{
queueManager.removeParents(currentElement, resultList);
} }
} while (!queueManager.isDepleted() && (continueOnFailure || resultList.isEmpty()));
} }
public boolean deleteObject(NodeRef objectNodeReference) public boolean deleteObject(NodeRef objectNodeReference)
{ {
return canLock(objectNodeReference) && performNodeDeletion(objectNodeReference);
return isObjectLockIsNotATrouble(objectNodeReference) && performNodeDeletion(objectNodeReference);
} }
public boolean removeObject(NodeRef objectNodeReference, NodeRef folderNodeReference) public boolean removeObject(NodeRef objectNodeReference, NodeRef folderNodeReference)
{ {
if (isChildOfThisFolder(objectNodeReference, folderNodeReference)) if (isChildOfThisFolder(objectNodeReference, folderNodeReference))
{ {
try try
@@ -153,53 +191,43 @@ public class CmisObjectsUtils
catch (Throwable e) catch (Throwable e)
{ {
this.lastOperationException = e; this.lastOperationException = e;
return false; return false;
} }
return true; return true;
} }
return false; return false;
} }
public boolean addObjectToFolder(NodeRef objectNodeRef, NodeRef parentFolderNodeRef) public boolean addObjectToFolder(NodeRef objectNodeRef, NodeRef parentFolderNodeRef)
{ {
try try
{ {
this.nodeService.addChild(parentFolderNodeRef, objectNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName QName name = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName((String)nodeService.getProperty(objectNodeRef, ContentModel.PROP_NAME)));
.createValidLocalName((String) this.nodeService.getProperty(objectNodeRef, ContentModel.PROP_NAME)))); nodeService.addChild(parentFolderNodeRef, objectNodeRef, ContentModel.ASSOC_CONTAINS, name);
return true; return true;
} }
catch (Throwable e) catch (Throwable e)
{ {
this.lastOperationException = e; this.lastOperationException = e;
return false; return false;
} }
} }
public boolean isFolder(NodeRef folderNodeRef) public boolean isFolder(NodeRef folderNodeRef)
{ {
return (folderNodeRef != null) && cmisMapping.isValidCmisFolder(cmisMapping.getCmisType(nodeService.getType(folderNodeRef)));
return (folderNodeRef != null) && this.cmisMapping.isValidCmisFolder(this.cmisMapping.getCmisType(this.nodeService.getType(folderNodeRef)));
} }
public boolean isDocument(NodeRef documentNodeRef) public boolean isDocument(NodeRef documentNodeRef)
{ {
return (documentNodeRef != null) && cmisMapping.isValidCmisDocument(cmisMapping.getCmisType(nodeService.getType(documentNodeRef)));
return (documentNodeRef != null) && this.cmisMapping.isValidCmisDocument(this.cmisMapping.getCmisType(this.nodeService.getType(documentNodeRef)));
} }
public boolean isRelationship(String identifier) public boolean isRelationship(String identifier)
{ {
try try
{ {
new AssociationRef(identifier); new AssociationRef(identifier);
return true; return true;
} }
catch (Throwable e) catch (Throwable e)
@@ -210,22 +238,18 @@ public class CmisObjectsUtils
public boolean isPolicy(NodeRef policyNodeRef) public boolean isPolicy(NodeRef policyNodeRef)
{ {
// TODO: Policy // TODO: Policy
return false; return false;
} }
public EnumObjectType determineObjectType(String identifier) public EnumObjectType determineObjectType(String identifier)
{ {
if (isRelationship(identifier)) if (isRelationship(identifier))
{ {
return EnumObjectType.RELATIONSHIP; return EnumObjectType.RELATIONSHIP;
} }
NodeRef objectNodeReference = new NodeRef(identifier); NodeRef objectNodeReference = new NodeRef(identifier);
if (isFolder(objectNodeReference)) if (isFolder(objectNodeReference))
{ {
return EnumObjectType.FOLDER; return EnumObjectType.FOLDER;
@@ -241,184 +265,110 @@ public class CmisObjectsUtils
public boolean isChildOfThisFolder(NodeRef objectNodeReference, NodeRef folderNodeReference) public boolean isChildOfThisFolder(NodeRef objectNodeReference, NodeRef folderNodeReference)
{ {
NodeRef searchedObjectNodeReference = fileFolderService.searchSimple(folderNodeReference, (String)nodeService.getProperty(objectNodeReference, ContentModel.PROP_NAME));
NodeRef searchedObjectNodeReference = this.fileFolderService.searchSimple(folderNodeReference, (String) this.nodeService.getProperty(objectNodeReference,
ContentModel.PROP_NAME));
return (searchedObjectNodeReference != null) && searchedObjectNodeReference.equals(objectNodeReference); return (searchedObjectNodeReference != null) && searchedObjectNodeReference.equals(objectNodeReference);
} }
public boolean isPrimaryObjectParent(NodeRef folderNodeReference, NodeRef objectNodeReference) public boolean isPrimaryObjectParent(NodeRef folderNodeReference, NodeRef objectNodeReference)
{ {
NodeRef searchedParentObject = nodeService.getPrimaryParent(objectNodeReference).getParentRef();
NodeRef searchedParentObject = this.nodeService.getPrimaryParent(objectNodeReference).getParentRef();
return (searchedParentObject != null) && searchedParentObject.equals(folderNodeReference); return (searchedParentObject != null) && searchedParentObject.equals(folderNodeReference);
} }
public boolean isWorkingCopy(NodeRef objectIdentifier) public boolean isWorkingCopy(NodeRef objectIdentifier)
{ {
return nodeService.hasAspect(objectIdentifier, ContentModel.ASPECT_WORKING_COPY); return nodeService.hasAspect(objectIdentifier, ContentModel.ASPECT_WORKING_COPY);
} }
public void setCmisDictionaryService(CMISDictionaryService cmisDictionaryService)
{
this.cmisDictionaryService = cmisDictionaryService;
this.cmisMapping = this.cmisDictionaryService.getCMISMapping();
}
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
public void setFileFolderService(FileFolderService fileFolderService)
{
this.fileFolderService = fileFolderService;
}
public void setLockService(LockService lockService)
{
this.lockService = lockService;
}
public void setCheckOutCheckInService(CheckOutCheckInService checkOutCheckInService)
{
this.checkOutCheckInService = checkOutCheckInService;
}
public void setAuthorityService(AuthorityService authorityService)
{
this.authorityService = authorityService;
}
public Throwable getLastOperationException()
{
return lastOperationException;
}
private boolean performNodeDeletion(NodeRef objectNodeReference) private boolean performNodeDeletion(NodeRef objectNodeReference)
{ {
if (nodeService.hasAspect(objectNodeReference, ContentModel.ASPECT_WORKING_COPY))
if (this.nodeService.hasAspect(objectNodeReference, ContentModel.ASPECT_WORKING_COPY))
{ {
this.checkOutCheckInService.cancelCheckout(objectNodeReference); checkOutCheckInService.cancelCheckout(objectNodeReference);
return true; return true;
} }
try try
{ {
this.nodeService.deleteNode(objectNodeReference); nodeService.deleteNode(objectNodeReference);
} }
catch (Throwable e) catch (Throwable e)
{ {
return false; return false;
} }
return true; return true;
} }
private boolean isObjectLockIsNotATrouble(NodeRef objectNodeReference) private boolean canLock(NodeRef objectNodeReference)
{ {
String currentUserName = AuthenticationUtil.getFullyAuthenticatedUser(); String currentUserName = AuthenticationUtil.getFullyAuthenticatedUser();
return (this.lockService.getLockStatus(objectNodeReference, currentUserName) != LockStatus.LOCKED) || authorityService.isAdminAuthority(currentUserName);
return (this.lockService.getLockStatus(objectNodeReference, currentUserName) != LockStatus.LOCKED) || this.authorityService.isAdminAuthority(currentUserName);
} }
private UnlinkOperationStatus unlinkObject(NodeRef objectNodeReference, NodeRef parentFolderNodeReference, boolean totalDeletion) private UnlinkOperationStatus unlinkObject(NodeRef objectNodeReference, NodeRef parentFolderNodeReference, boolean totalDeletion)
{ {
if (isFolder(objectNodeReference)) if (isFolder(objectNodeReference))
{ {
List<ChildAssociationRef> children = this.nodeService.getChildAssocs(objectNodeReference); List<ChildAssociationRef> children = nodeService.getChildAssocs(objectNodeReference);
boolean objectUnlinked = (children == null || children.isEmpty()) && deleteObject(objectNodeReference);
return new UnlinkOperationStatus(((children == null) || children.isEmpty()) && deleteObject(objectNodeReference), (children != null) ? (children) return new UnlinkOperationStatus(objectUnlinked, children != null ? children : new LinkedList<ChildAssociationRef>());
: (new LinkedList<ChildAssociationRef>()));
} }
return new UnlinkOperationStatus((totalDeletion) ? (deleteObject(objectNodeReference)) boolean objectUnlinked = false;
: (!isPrimaryObjectParent(parentFolderNodeReference, objectNodeReference) && removeObject(objectNodeReference, parentFolderNodeReference)), if (totalDeletion)
new LinkedList<ChildAssociationRef>()); {
objectUnlinked = deleteObject(objectNodeReference);
}
else
{
objectUnlinked = !isPrimaryObjectParent(parentFolderNodeReference, objectNodeReference) && removeObject(objectNodeReference, parentFolderNodeReference);
}
return new UnlinkOperationStatus(objectUnlinked, new LinkedList<ChildAssociationRef>());
} }
private void processNotUnlinkedObjectResults(DescendantElement currentElement, UnlinkOperationStatus unlinkingStatus, DescendantsQueueManager queueManager, private NodeRef safeGetNodeRef(String nodeIdentifier) throws InvalidArgumentException
List<String> resultList, boolean addAllFailedToDelete)
{ {
if (NodeRef.isNodeRef(nodeIdentifier))
if (!unlinkingStatus.getChildren().isEmpty())
{ {
queueManager.addElementToQueueEnd(currentElement); NodeRef result = new NodeRef(nodeIdentifier);
if (nodeService.exists(result))
queueManager.addChildren(unlinkingStatus.getChildren(), currentElement);
return;
}
resultList.add(currentElement.getNodesAssociation().getChildRef().toString());
if (addAllFailedToDelete)
{
queueManager.removeParents(currentElement, resultList);
}
}
private NodeRef receiveNodeReferenceOfExistenceObject(String clearNodeIdentifier) throws InvalidArgumentException
{
if (NodeRef.isNodeRef(clearNodeIdentifier))
{
NodeRef result = new NodeRef(clearNodeIdentifier);
if (this.nodeService.exists(result))
{ {
return result; return result;
} }
} }
throw new InvalidArgumentException("Invalid Object Identifier was specified: Identifier is incorrect or Object with the specified Identifier is not exists", throw new InvalidArgumentException("Invalid Object Identifier was specified: Identifier is incorrect or Object with the specified Identifier does not exist", new ObjectNotFoundException());
new ObjectNotFoundException());
} }
private String cutNodeVersionIfNecessary(String identifier, String[] splitedNodeIdentifier, int startIndex) private String cutNodeVersionIfNecessary(String identifier, String[] splitNodeIdentifier, int startIndex)
{ {
String withoutVersionSuffix = identifier; String withoutVersionSuffix = identifier;
if (splitNodeIdentifier.length == NODE_REFERENCE_WITH_SUFFIX_DELIMETERS_COUNT)
if (splitedNodeIdentifier.length == NODE_REFERENCE_WITH_SUFFIX_DELIMETERS_COUNT)
{ {
withoutVersionSuffix = splitedNodeIdentifier[startIndex++ - 1] + DOUBLE_NODE_REFERENCE_ID_DELIMETER + splitedNodeIdentifier[startIndex++] + NODE_REFERENCE_ID_DELIMETER withoutVersionSuffix = splitNodeIdentifier[startIndex++ - 1] + DOUBLE_NODE_REFERENCE_ID_DELIMETER + splitNodeIdentifier[startIndex++] + NODE_REFERENCE_ID_DELIMETER + splitNodeIdentifier[startIndex];
+ splitedNodeIdentifier[startIndex];
} }
return withoutVersionSuffix; return withoutVersionSuffix;
} }
private AlfrescoObjectType determineActualObjectType(AlfrescoObjectType expectedType, QName objectType) private AlfrescoObjectType determineActualObjectType(AlfrescoObjectType expectedType, QName objectType)
{ {
if (expectedType != AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT)
return (expectedType != AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT) ? (AlfrescoObjectType.fromValue(objectType.toString())) : ((DOCUMENT_AND_FOLDER_TYPES {
.contains(objectType)) ? (AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT) : (AlfrescoObjectType.ANY_OBJECT)); return AlfrescoObjectType.fromValue(objectType.toString());
}
else if (DOCUMENT_AND_FOLDER_TYPES.contains(objectType))
{
return AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT;
}
return AlfrescoObjectType.ANY_OBJECT;
} }
private IdentifierConversionResults createAssociationIdentifierResult(final String identifier) private IdentifierConversionResults createAssociationIdentifierResult(final String identifier)
{ {
return new IdentifierConversionResults() return new IdentifierConversionResults()
{ {
public AssociationRef getConvertedIdentifier() public AssociationRef getConvertedIdentifier()
{ {
return new AssociationRef(identifier); return new AssociationRef(identifier);
} }
}; };
@@ -426,12 +376,10 @@ public class CmisObjectsUtils
private IdentifierConversionResults createNodeReferenceIdentifierResult(final NodeRef identifier) private IdentifierConversionResults createNodeReferenceIdentifierResult(final NodeRef identifier)
{ {
return new IdentifierConversionResults() return new IdentifierConversionResults()
{ {
public NodeRef getConvertedIdentifier() public NodeRef getConvertedIdentifier()
{ {
return identifier; return identifier;
} }
}; };
@@ -449,25 +397,28 @@ public class CmisObjectsUtils
public UnlinkOperationStatus(boolean objectUnlinked, List<ChildAssociationRef> children) public UnlinkOperationStatus(boolean objectUnlinked, List<ChildAssociationRef> children)
{ {
this.objectUnlinked = objectUnlinked; this.objectUnlinked = objectUnlinked;
this.children = children; this.children = children;
} }
public boolean isObjectUnlinked()
{
return this.objectUnlinked;
}
public List<ChildAssociationRef> getChildren()
{
return this.children;
}
protected UnlinkOperationStatus() protected UnlinkOperationStatus()
{ {
} }
public boolean isObjectUnlinked()
{
return objectUnlinked;
}
public List<ChildAssociationRef> getChildren()
{
return this.children;
} }
} }
public Throwable getLastOperationException()
{
return lastOperationException;
}
}

View File

@@ -38,119 +38,101 @@ public class DescendantsQueueManager
public DescendantsQueueManager(ChildAssociationRef headAssociation) public DescendantsQueueManager(ChildAssociationRef headAssociation)
{ {
this.queue = new LinkedList<DescendantElement>(); this.queue = new LinkedList<DescendantElement>();
this.queue.addFirst(createElement(headAssociation, null)); this.queue.addFirst(createElement(null, headAssociation));
}
public DescendantElement createElement(ChildAssociationRef data, DescendantElement parent)
{
return new DescendantElement(parent, data);
}
public void removeParents(DescendantElement source, List<String> undeletedNodes)
{
while (source.getParentElement() != null)
{
source = source.getParentElement();
determineUndeletedObjectToPut(source.getNodesAssociation().getChildRef().toString(), undeletedNodes);
this.queue.remove(source);
}
}
public void addChildren(List<ChildAssociationRef> children, DescendantElement parent)
{
for (ChildAssociationRef child : children)
{
this.queue.addFirst(createElement(child, parent));
}
}
/**
* This method receives and immediately removes next element from the queue
*
* @return next <b>DescendantElement</b> (in this case - first element) in the queue if queue still contain any element or <b>null</b> if queue is empty
*/
public DescendantElement receiveNextElement()
{
DescendantElement result = (this.queue.isEmpty()) ? (null) : (this.queue.getFirst());
this.queue.remove(result);
return result;
}
public void addElementToQueueEnd(DescendantElement element)
{
this.queue.addLast(element);
}
public boolean isDepleted()
{
return this.queue.isEmpty();
} }
protected DescendantsQueueManager() protected DescendantsQueueManager()
{ {
} }
private void determineUndeletedObjectToPut(String undeletedObjectIdentifier, List<String> undeletedNodes) public boolean isEmpty()
{
return this.queue.isEmpty();
}
/**
* This method gets and immediately removes next element from the queue
*
* @return next <b>DescendantElement</b> (in this case - first element) in the queue if queue still contain any element or <b>null</b> if queue is empty
*/
public DescendantElement getNextElement()
{
DescendantElement result = queue.isEmpty() ? null : queue.getFirst();
queue.remove(result);
return result;
}
public void addFirst(DescendantElement parent, List<ChildAssociationRef> children)
{
for (ChildAssociationRef child : children)
{
queue.addFirst(createElement(parent, child));
}
}
private DescendantElement createElement(DescendantElement parent, ChildAssociationRef child)
{
return new DescendantElement(parent, child);
}
public void addLast(DescendantElement element)
{
queue.addLast(element);
}
public void removeParents(DescendantElement element, List<String> undeletedNodes)
{ {
if (!undeletedNodes.contains(undeletedObjectIdentifier)) while (element.getParent() != null)
{ {
undeletedNodes.add(undeletedObjectIdentifier); element = element.getParent();
String child = element.getChildAssoc().getChildRef().toString();
if (!undeletedNodes.contains(child))
{
undeletedNodes.add(child);
}
queue.remove(element);
} }
} }
public class DescendantElement public class DescendantElement
{ {
private DescendantElement parentElement; private DescendantElement parent;
private ChildAssociationRef nodesAssociation; private ChildAssociationRef childAssoc;
public DescendantElement(DescendantElement parentElement, ChildAssociationRef nodesAssociation) public DescendantElement(DescendantElement parent, ChildAssociationRef childAssoc)
{ {
this.parent = parent;
this.parentElement = parentElement; this.childAssoc = childAssoc;
this.nodesAssociation = nodesAssociation;
} }
public DescendantElement getParentElement() protected DescendantElement()
{ {
return parentElement;
} }
public ChildAssociationRef getNodesAssociation() public DescendantElement getParent()
{ {
return parent;
}
return nodesAssociation; public ChildAssociationRef getChildAssoc()
{
return childAssoc;
} }
@Override @Override
public boolean equals(Object obj) public boolean equals(Object obj)
{ {
if (!(obj instanceof DescendantElement)) if (!(obj instanceof DescendantElement))
{ {
return false; return false;
} }
DescendantElement currentElement = (DescendantElement) obj; DescendantElement currentElement = (DescendantElement) obj;
return (childAssoc != null) ? (childAssoc.equals(currentElement.getChildAssoc())) : (currentElement.getChildAssoc() == null);
return (this.nodesAssociation != null) ? (this.nodesAssociation.equals(currentElement.getNodesAssociation())) : (currentElement.getNodesAssociation() == null); }
} }
protected DescendantElement()
{
}
}
} }