mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
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:
@@ -22,14 +22,16 @@
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.cmis.ws;
|
||||
package org.alfresco.repo.cmis;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
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 Velichkevich
|
||||
@@ -37,9 +39,7 @@ import java.util.regex.Pattern;
|
||||
public class PropertyFilter
|
||||
{
|
||||
private static final int MINIMAL_ALLOWED_STRUCTURE_SIZE = 1;
|
||||
|
||||
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 Set<String> properties;
|
||||
@@ -54,34 +54,33 @@ public class PropertyFilter
|
||||
*/
|
||||
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");
|
||||
}
|
||||
|
||||
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(","));
|
||||
}
|
||||
}
|
||||
|
||||
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))
|
||||
* @return <b>true</b> returns if property is allowed by filter. In other case returns <b>false</b>
|
||||
*/
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
155
source/java/org/alfresco/repo/cmis/PropertyFilterTest.java
Executable file
155
source/java/org/alfresco/repo/cmis/PropertyFilterTest.java
Executable file
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.cmis;
|
||||
|
||||
import org.alfresco.repo.cmis.PropertyFilter;
|
||||
import org.alfresco.repo.cmis.ws.FilterNotValidException;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* @author Dmitry Velichkevich
|
||||
*/
|
||||
public class PropertyFilterTest extends TestCase
|
||||
{
|
||||
private static final String NAME_TOKEN = "name";
|
||||
|
||||
private static final String[] FILTER_TOKENS = new String[] { "Name", NAME_TOKEN, "nAmE", "ObjectId", "ObjectID", "objectId" };
|
||||
private static final String[] TOKENS_THAT_ARE_NOT_ALLOWED = new String[] { "ParentId", "parentId", "ParEnTiD", "IsMajorVersion", "iSmAJORvERSION" };
|
||||
|
||||
private static final String VALID_MATCHE_ALL_FILTER = "*";
|
||||
private static final String VALID_MATCHE_ALL_EMPTY_FILTER = "";
|
||||
private static final String VALID_FILTER_WITH_NAME = NAME_TOKEN;
|
||||
private static final String VALID_FILTER_WITH_SEVERAL_TOKENS = "name, ObjectId";
|
||||
private static final String LONG_VALID_FILTER_WITH_SEVERAL_TOKENS = "ObjectId, name, CreationDate, CreatedBy";
|
||||
private static final String VALID_FILTER_WITH_SEVERAL_TOKENS_WITHOUT_BREAKS = "name,Objectid,CreationDate";
|
||||
private static final String VALID_FILTER_WITH_SEVERAL_TOKENS_AND_WITH_BREAKS_IN_SOME_PLACES = "name, Objectid,CreationDate,CreatedBy, ModifiedBy, LastModifiedBy";
|
||||
private static final String VALID_FILTER_WITH_SEVERAL_TOKENS_AND_WITH_SEVERAL_BREAKS_IN_SOME_PLACES = "name, Objectid, CreationDate,CreatedBy, ModifiedBy, LastModifiedBy";
|
||||
|
||||
private static final String INVALID_MATCHE_ALL_FILTER = "*,";
|
||||
private static final String INVALID_FILTER_WITH_NAME = "*name,";
|
||||
private static final String INVALID_FILTER_WITH_SEVERAL_TOKENS = "name ,ObjectId";
|
||||
private static final String LONG_INVALID_FILTER_WITH_SEVERAL_TOKENS = "ObjectId, name CreationDate, CreatedBy*";
|
||||
private static final String INVALID_FILTER_WITH_SEVERAL_TOKENS_WITHOUT_BREAKS = ",name,Objectid,CreationDate";
|
||||
private static final String INVALID_FILTER_WITH_SEVERAL_TOKENS_AND_WITH_BREAKS_IN_SOME_PLACES = " name, Objectid,CreationDate CreatedBy ModifiedBy, LastModifiedBy";
|
||||
private static final String INVALID_FILTER_WITH_FIRST_BREAK_SYMBOL = " name, Objectid,CreationDate, CreatedBy, ModifiedBy, LastModifiedBy";
|
||||
private static final String INVALID_FILTER_WITH_DENIED_SYMBOL = "ObjectId; name";
|
||||
private static final String INVALID_FILTER_WITH_LAST_INVALID_SYMBOL = "ObjectId, name*";
|
||||
|
||||
|
||||
public void testValidFilters() throws Exception
|
||||
{
|
||||
try
|
||||
{
|
||||
allTokensValidAssertion(new PropertyFilter());
|
||||
allTokensValidAssertion(new PropertyFilter(VALID_MATCHE_ALL_EMPTY_FILTER));
|
||||
allTokensValidAssertion(new PropertyFilter(VALID_MATCHE_ALL_FILTER));
|
||||
|
||||
onlyNameTokensAssertionValid(new PropertyFilter(VALID_FILTER_WITH_NAME));
|
||||
|
||||
nameAndObjectIdTokensAssertionValid(new PropertyFilter(VALID_FILTER_WITH_SEVERAL_TOKENS));
|
||||
nameAndObjectIdTokensAssertionValid(new PropertyFilter(LONG_VALID_FILTER_WITH_SEVERAL_TOKENS));
|
||||
nameAndObjectIdTokensAssertionValid(new PropertyFilter(VALID_FILTER_WITH_SEVERAL_TOKENS_WITHOUT_BREAKS));
|
||||
nameAndObjectIdTokensAssertionValid(new PropertyFilter(VALID_FILTER_WITH_SEVERAL_TOKENS_AND_WITH_BREAKS_IN_SOME_PLACES));
|
||||
nameAndObjectIdTokensAssertionValid(new PropertyFilter(VALID_FILTER_WITH_SEVERAL_TOKENS_AND_WITH_SEVERAL_BREAKS_IN_SOME_PLACES));
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void testInvalidFilters() throws Exception
|
||||
{
|
||||
invalidFilterAssertion(INVALID_MATCHE_ALL_FILTER);
|
||||
invalidFilterAssertion(INVALID_FILTER_WITH_NAME);
|
||||
invalidFilterAssertion(INVALID_FILTER_WITH_SEVERAL_TOKENS);
|
||||
invalidFilterAssertion(LONG_INVALID_FILTER_WITH_SEVERAL_TOKENS);
|
||||
invalidFilterAssertion(INVALID_FILTER_WITH_SEVERAL_TOKENS_WITHOUT_BREAKS);
|
||||
invalidFilterAssertion(INVALID_FILTER_WITH_SEVERAL_TOKENS_AND_WITH_BREAKS_IN_SOME_PLACES);
|
||||
invalidFilterAssertion(INVALID_FILTER_WITH_FIRST_BREAK_SYMBOL);
|
||||
invalidFilterAssertion(INVALID_FILTER_WITH_DENIED_SYMBOL);
|
||||
invalidFilterAssertion(INVALID_FILTER_WITH_LAST_INVALID_SYMBOL);
|
||||
}
|
||||
|
||||
private void nameAndObjectIdTokensAssertionValid(PropertyFilter propertyFilter)
|
||||
{
|
||||
for (String token : FILTER_TOKENS)
|
||||
{
|
||||
assertTrue(propertyFilter.allow(token));
|
||||
}
|
||||
|
||||
for (String token : TOKENS_THAT_ARE_NOT_ALLOWED)
|
||||
{
|
||||
assertFalse(propertyFilter.allow(token));
|
||||
}
|
||||
}
|
||||
|
||||
private void onlyNameTokensAssertionValid(PropertyFilter propertyFilter)
|
||||
{
|
||||
for (String token : FILTER_TOKENS)
|
||||
{
|
||||
if (!token.equalsIgnoreCase(NAME_TOKEN))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
assertTrue(propertyFilter.allow(token));
|
||||
}
|
||||
|
||||
for (String token : TOKENS_THAT_ARE_NOT_ALLOWED)
|
||||
{
|
||||
assertFalse(propertyFilter.allow(token));
|
||||
}
|
||||
}
|
||||
|
||||
private void allTokensValidAssertion(PropertyFilter propertyFilter)
|
||||
{
|
||||
for (String token : FILTER_TOKENS)
|
||||
{
|
||||
assertTrue(propertyFilter.allow(token));
|
||||
}
|
||||
|
||||
for (String token : TOKENS_THAT_ARE_NOT_ALLOWED)
|
||||
{
|
||||
assertTrue(propertyFilter.allow(token));
|
||||
}
|
||||
}
|
||||
|
||||
private void invalidFilterAssertion(String filterValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
new PropertyFilter(filterValue);
|
||||
|
||||
fail("Invalid filter \"" + filterValue + "\" was interpreted as valid");
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
assertTrue(("Unexpected exception type was thrown: " + e.getClass().getName()), e instanceof FilterNotValidException);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -64,7 +64,6 @@ public class AuthenticationTokenCallbackHandler implements CallbackHandler
|
||||
|
||||
private String getPassword(String userName)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return userName;
|
||||
}
|
||||
|
||||
|
@@ -33,6 +33,8 @@ import javax.activation.DataSource;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
|
||||
/**
|
||||
* DataSource facade for an Alfresco Content Reader
|
||||
*
|
||||
* @author Dmitry Lazurkin
|
||||
*/
|
||||
public class ContentReaderDataSource implements DataSource
|
||||
@@ -46,21 +48,33 @@ public class ContentReaderDataSource implements DataSource
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see javax.activation.DataSource#getContentType()
|
||||
*/
|
||||
public String getContentType()
|
||||
{
|
||||
return contentReader.getMimetype();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see javax.activation.DataSource#getInputStream()
|
||||
*/
|
||||
public InputStream getInputStream() throws IOException
|
||||
{
|
||||
return contentReader.getContentInputStream();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see javax.activation.DataSource#getName()
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see javax.activation.DataSource#getOutputStream()
|
||||
*/
|
||||
public OutputStream getOutputStream() throws IOException
|
||||
{
|
||||
return null;
|
||||
|
@@ -43,6 +43,7 @@ import org.alfresco.cmis.dictionary.CMISMapping;
|
||||
import org.alfresco.cmis.property.CMISPropertyService;
|
||||
import org.alfresco.cmis.search.CMISQueryService;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.cmis.PropertyFilter;
|
||||
import org.alfresco.repo.cmis.ws.utils.CmisObjectsUtils;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.version.VersionModel;
|
||||
@@ -72,7 +73,6 @@ import org.alfresco.service.namespace.QName;
|
||||
public class DMAbstractServicePort
|
||||
{
|
||||
private static final String BASE_TYPE_PROPERTY_NAME = "BaseType";
|
||||
|
||||
protected static final String INITIAL_VERSION_DESCRIPTION = "Initial version";
|
||||
|
||||
private DatatypeFactory _datatypeFactory;
|
||||
@@ -89,9 +89,99 @@ public class DMAbstractServicePort
|
||||
protected FileFolderService fileFolderService;
|
||||
protected CheckOutCheckInService checkOutCheckInService;
|
||||
protected SearchService searchService;
|
||||
|
||||
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()
|
||||
{
|
||||
if (_datatypeFactory == null)
|
||||
@@ -117,12 +207,11 @@ public class DMAbstractServicePort
|
||||
* @throws InvalidArgumentException
|
||||
* @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)
|
||||
{
|
||||
resultList.add(convertAlfrescoObjectToCmisObject(objectNodeRef, filter));
|
||||
resultList.add(createCmisObject(objectNodeRef, filter));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,12 +222,10 @@ public class DMAbstractServicePort
|
||||
* @param filter accepted properties filter
|
||||
* @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();
|
||||
result.setProperties(getPropertiesType(identifier.toString(), filter));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -150,7 +237,6 @@ public class DMAbstractServicePort
|
||||
*/
|
||||
protected void assertExistFolder(NodeRef folderNodeRef) throws FolderNotValidException
|
||||
{
|
||||
|
||||
if (!this.cmisObjectsUtils.isFolder(folderNodeRef))
|
||||
{
|
||||
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)
|
||||
{
|
||||
Serializable value = alfrescoProperties.get(name);
|
||||
@@ -253,82 +440,7 @@ public class DMAbstractServicePort
|
||||
properties.getProperty().add(propString);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
@@ -353,7 +465,7 @@ public class DMAbstractServicePort
|
||||
* @param major need latest major version
|
||||
* @return latest version node reference
|
||||
*/
|
||||
public NodeRef getLatestVersionNodeRef(NodeRef documentNodeRef, boolean major)
|
||||
protected NodeRef getLatestNode(NodeRef documentNodeRef, boolean major)
|
||||
{
|
||||
Version currentVersion = versionService.getCurrentVersion(documentNodeRef);
|
||||
NodeRef latestVersionNodeRef = documentNodeRef;
|
||||
@@ -382,133 +494,14 @@ public class DMAbstractServicePort
|
||||
|
||||
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))
|
||||
{
|
||||
this.versionService.createVersion(documentNodeReference, createVersionProperties(INITIAL_VERSION_DESCRIPTION, VersionType.MAJOR));
|
||||
}
|
||||
|
||||
return checkOutCheckInService.checkout(documentNodeReference);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -27,6 +27,7 @@ package org.alfresco.repo.cmis.ws;
|
||||
import org.alfresco.cmis.search.CMISQueryOptions;
|
||||
import org.alfresco.cmis.search.CMISResultSet;
|
||||
import org.alfresco.cmis.search.CMISResultSetRow;
|
||||
import org.alfresco.repo.cmis.PropertyFilter;
|
||||
|
||||
/**
|
||||
* Port for Discovery service.
|
||||
@@ -67,10 +68,8 @@ public class DMDiscoveryServicePort extends DMAbstractServicePort implements Dis
|
||||
}
|
||||
|
||||
CMISResultSet resultSet = cmisQueryService.query(options);
|
||||
|
||||
QueryResponse response = new QueryResponse();
|
||||
response.setHasMoreItems(resultSet.hasMore());
|
||||
|
||||
for (CMISResultSetRow row : resultSet)
|
||||
{
|
||||
CmisObjectType object = new CmisObjectType();
|
||||
|
@@ -51,16 +51,16 @@ public class DMMultiFilingServicePort extends DMAbstractServicePort implements M
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
*/
|
||||
public void addObjectToFolder(String repositoryId, String objectId, String folderId) throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException,
|
||||
FolderNotValidException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
public void addObjectToFolder(String repositoryId, String objectId, String folderId)
|
||||
throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, FolderNotValidException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
NodeRef objectNodeRef = this.cmisObjectsUtils.getIdentifierInstance(objectId, AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT).getConvertedIdentifier();
|
||||
NodeRef parentFolderNodeRef = this.cmisObjectsUtils.getIdentifierInstance(folderId, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier();
|
||||
NodeRef objectNodeRef = cmisObjectsUtils.getIdentifierInstance(objectId, AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT).getConvertedIdentifier();
|
||||
NodeRef parentFolderNodeRef = cmisObjectsUtils.getIdentifierInstance(folderId, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier();
|
||||
|
||||
// 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 ConstraintViolationException
|
||||
*/
|
||||
public void removeObjectFromFolder(String repositoryId, String objectId, String folderId) throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException,
|
||||
FolderNotValidException, OperationNotSupportedException, NotInFolderException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
public void removeObjectFromFolder(String repositoryId, String objectId, String folderId)
|
||||
throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, FolderNotValidException, OperationNotSupportedException, NotInFolderException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
{
|
||||
|
||||
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);
|
||||
|
||||
assertExistFolder(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");
|
||||
}
|
||||
@@ -100,23 +98,21 @@ public class DMMultiFilingServicePort extends DMAbstractServicePort implements M
|
||||
|
||||
private NodeRef checkAndReceiveFolderIdentifier(String folderIdentifier) throws OperationNotSupportedException
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
return this.cmisObjectsUtils.getIdentifierInstance(folderIdentifier, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier();
|
||||
return cmisObjectsUtils.getIdentifierInstance(folderIdentifier, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier();
|
||||
}
|
||||
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
|
||||
{
|
||||
|
||||
if (this.cmisObjectsUtils.isPrimaryObjectParent(folderNodeReference, objectNodeReference))
|
||||
if (cmisObjectsUtils.isPrimaryObjectParent(folderNodeReference, objectNodeReference))
|
||||
{
|
||||
throw new OperationNotSupportedException("Unfiling is not supported. User deleteObjectService instead");
|
||||
throw new OperationNotSupportedException("Unfiling is not supported. Use deleteObjectService instead");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -30,6 +30,7 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.cmis.CMISTypesFilterEnum;
|
||||
import org.alfresco.repo.cmis.PropertyFilter;
|
||||
import org.alfresco.repo.cmis.ws.utils.AlfrescoObjectType;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
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
|
||||
{
|
||||
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 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
|
||||
{
|
||||
checkRepositoryId(parameters.getRepositoryId());
|
||||
|
||||
PropertyFilter propertyFilter = createPropertyFilter(parameters.getFilter());
|
||||
|
||||
NodeRef folderId = (NodeRef) (((parameters.getFolderID() != null) && (parameters.getFolderID().getValue() != null)) ? (this.cmisObjectsUtils.getIdentifierInstance(
|
||||
parameters.getFolderID().getValue(), AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier()) : (null));
|
||||
|
||||
NodeRef[] nodeRefs = this.cmisService.getCheckedOut(AuthenticationUtil.getFullyAuthenticatedUser(), folderId, (folderId == null));
|
||||
|
||||
NodeRef folderId = null;
|
||||
String folderIdParam = parameters.getFolderID() == null ? null : parameters.getFolderID().getValue();
|
||||
if (folderIdParam != 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,
|
||||
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++)
|
||||
{
|
||||
resultListing.add(convertAlfrescoObjectToCmisObject(nodeRefs[index].toString(), propertyFilter));
|
||||
resultListing.add(createCmisObject(nodeRefs[index].toString(), propertyFilter));
|
||||
}
|
||||
|
||||
response.setHasMoreItems(cursor.getEndRow() < (nodeRefs.length - 1));
|
||||
@@ -120,17 +121,15 @@ public class DMNavigationServicePort extends DMAbstractServicePort implements Na
|
||||
{
|
||||
PropertyFilter propertyFilter = createPropertyFilter(parameters.getFilter());
|
||||
|
||||
NodeRef folderNodeRef = this.cmisObjectsUtils.getIdentifierInstance(parameters.getFolderId(), AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier();
|
||||
|
||||
NodeRef[] listing = null;
|
||||
NodeRef folderNodeRef = cmisObjectsUtils.getIdentifierInstance(parameters.getFolderId(), AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier();
|
||||
|
||||
EnumTypesOfFileableObjects types = EnumTypesOfFileableObjects.ANY;
|
||||
|
||||
if (parameters.getType() != null)
|
||||
{
|
||||
types = parameters.getType().getValue();
|
||||
}
|
||||
|
||||
NodeRef[] listing = null;
|
||||
switch (types)
|
||||
{
|
||||
case DOCUMENTS:
|
||||
@@ -154,7 +153,7 @@ public class DMNavigationServicePort extends DMAbstractServicePort implements Na
|
||||
|
||||
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));
|
||||
@@ -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
|
||||
* 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;
|
||||
* @return collection of CmisObjectType
|
||||
* @throws RuntimeException
|
||||
@@ -182,22 +181,28 @@ public class DMNavigationServicePort extends DMAbstractServicePort implements Na
|
||||
public GetDescendantsResponse getDescendants(GetDescendants parameters) throws RuntimeException, InvalidArgumentException, ObjectNotFoundException,
|
||||
ConstraintViolationException, FilterNotValidException, OperationNotSupportedException, UpdateConflictException, FolderNotValidException, PermissionDeniedException
|
||||
{
|
||||
|
||||
BigInteger depth = ((parameters.getDepth() != null) && (parameters.getDepth().getValue() != null)) ? (parameters.getDepth().getValue()) : (BigInteger.ONE);
|
||||
|
||||
checkRepositoryId(parameters.getRepositoryId());
|
||||
PropertyFilter propertyFilter = createPropertyFilter(parameters.getFilter());
|
||||
BigInteger depth = ((parameters.getDepth() != null) && (parameters.getDepth().getValue() != null)) ? (parameters.getDepth().getValue()) : (BigInteger.ONE);
|
||||
checkDepthParameter(depth);
|
||||
|
||||
GetDescendantsResponse response = new GetDescendantsResponse();
|
||||
|
||||
formatCommonResponse(createPropertyFilter(parameters.getFilter()), createHierarchyReceiver(
|
||||
(parameters.getType() != null) ? (parameters.getType()) : (EnumTypesOfFileableObjects.ANY), depth).receiveHierarchy(parameters.getFolderId()), response.getObject());
|
||||
HierarchyReceiverStrategy receiver = createHierarchyReceiver(parameters.getType() != null ? parameters.getType() : EnumTypesOfFileableObjects.ANY, depth);
|
||||
createCmisObjectList(propertyFilter, receiver.receiveHierarchy(parameters.getFolderId()), response.getObject());
|
||||
|
||||
// TODO: includeAllowableActions, includeRelationships
|
||||
|
||||
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.
|
||||
*
|
||||
@@ -214,16 +219,16 @@ public class DMNavigationServicePort extends DMAbstractServicePort implements Na
|
||||
* @throws FolderNotValidException
|
||||
* @throws PermissionDeniedException
|
||||
*/
|
||||
public GetFolderParentResponse getFolderParent(GetFolderParent parameters) throws RuntimeException, InvalidArgumentException, ObjectNotFoundException,
|
||||
ConstraintViolationException, FilterNotValidException, OperationNotSupportedException, UpdateConflictException, FolderNotValidException, PermissionDeniedException
|
||||
public GetFolderParentResponse getFolderParent(GetFolderParent parameters)
|
||||
throws RuntimeException, InvalidArgumentException, ObjectNotFoundException, ConstraintViolationException, FilterNotValidException, OperationNotSupportedException, UpdateConflictException, FolderNotValidException, PermissionDeniedException
|
||||
{
|
||||
|
||||
checkRepositoryId(parameters.getRepositoryId());
|
||||
|
||||
PropertyFilter propertyFilter = createPropertyFilter(parameters.getFilter());
|
||||
GetFolderParentResponse response = new GetFolderParentResponse();
|
||||
|
||||
formatCommonResponse(createPropertyFilter(parameters.getFilter()), receiveParentList(parameters.getFolderId(), (((parameters.getReturnToRoot() != null) && (parameters
|
||||
.getReturnToRoot().getValue() != null)) ? (parameters.getReturnToRoot().getValue()) : (false))), response.getObject());
|
||||
boolean returnToRoot = ((parameters.getReturnToRoot() != null) && (parameters.getReturnToRoot().getValue() != null)) ? (parameters.getReturnToRoot().getValue()) : false;
|
||||
List<NodeRef> parents = receiveParentList(parameters.getFolderId(), returnToRoot);
|
||||
createCmisObjectList(propertyFilter, parents, response.getObject());
|
||||
|
||||
// TODO: includeAllowableActions, includeRelationships
|
||||
|
||||
@@ -245,108 +250,90 @@ public class DMNavigationServicePort extends DMAbstractServicePort implements Na
|
||||
* @throws FolderNotValidException
|
||||
* @throws PermissionDeniedException
|
||||
*/
|
||||
public GetObjectParentsResponse getObjectParents(GetObjectParents parameters) throws RuntimeException, InvalidArgumentException, ObjectNotFoundException,
|
||||
ConstraintViolationException, FilterNotValidException, OperationNotSupportedException, UpdateConflictException, FolderNotValidException, PermissionDeniedException
|
||||
public GetObjectParentsResponse getObjectParents(GetObjectParents parameters)
|
||||
throws RuntimeException, InvalidArgumentException, ObjectNotFoundException, ConstraintViolationException, FilterNotValidException, OperationNotSupportedException, UpdateConflictException, FolderNotValidException, PermissionDeniedException
|
||||
{
|
||||
// TODO: Policy
|
||||
|
||||
checkRepositoryId(parameters.getRepositoryId());
|
||||
|
||||
PropertyFilter propertyFilter = createPropertyFilter(parameters.getFilter());
|
||||
GetObjectParentsResponse response = new GetObjectParentsResponse();
|
||||
|
||||
formatCommonResponse(createPropertyFilter(parameters.getFilter()), receiveObjectParents((NodeRef) this.cmisObjectsUtils.getIdentifierInstance(parameters.getObjectId(),
|
||||
AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier()), response.getObject());
|
||||
List<NodeRef> parents = receiveObjectParents((NodeRef) cmisObjectsUtils.getIdentifierInstance(parameters.getObjectId(), AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier());
|
||||
createCmisObjectList(propertyFilter, parents, response.getObject());
|
||||
|
||||
// TODO: includeAllowableActions, includeRelationships
|
||||
|
||||
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>();
|
||||
|
||||
if (targetChildIdentifier.equals(this.cmisService.getDefaultRootNodeRef().toString()))
|
||||
if (targetChildIdentifier.equals(cmisService.getDefaultRootNodeRef().toString()))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
NodeRef currentParent = receiveNextParentNodeReference((NodeRef) this.cmisObjectsUtils.getIdentifierInstance(targetChildIdentifier, AlfrescoObjectType.FOLDER_OBJECT)
|
||||
.getConvertedIdentifier(), result);
|
||||
|
||||
|
||||
NodeRef currentParent = receiveNextParentNodeReference((NodeRef) cmisObjectsUtils.getIdentifierInstance(targetChildIdentifier, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier(), result);
|
||||
return (fullParentsHierarchy) ? (receiveFullAncestorsHierachy(currentParent, result)) : (result);
|
||||
}
|
||||
|
||||
|
||||
private List<NodeRef> receiveFullAncestorsHierachy(NodeRef currentParent, List<NodeRef> parents)
|
||||
{
|
||||
|
||||
String lastAncestorIdentifier = this.cmisService.getDefaultRootNodeRef().toString();
|
||||
|
||||
String lastAncestorIdentifier = cmisService.getDefaultRootNodeRef().toString();
|
||||
while ((currentParent != null) && !currentParent.toString().equals(lastAncestorIdentifier))
|
||||
{
|
||||
currentParent = receiveNextParentNodeReference(currentParent, parents);
|
||||
}
|
||||
|
||||
return parents;
|
||||
}
|
||||
|
||||
|
||||
private NodeRef receiveNextParentNodeReference(NodeRef currentParent, List<NodeRef> parents)
|
||||
{
|
||||
|
||||
currentParent = this.nodeService.getPrimaryParent(currentParent).getParentRef();
|
||||
|
||||
currentParent = nodeService.getPrimaryParent(currentParent).getParentRef();
|
||||
if (currentParent != null)
|
||||
{
|
||||
parents.add(currentParent);
|
||||
}
|
||||
|
||||
return currentParent;
|
||||
}
|
||||
|
||||
|
||||
private List<NodeRef> receiveObjectParents(NodeRef objectId) throws InvalidArgumentException
|
||||
{
|
||||
|
||||
List<NodeRef> parents = new LinkedList<NodeRef>();
|
||||
|
||||
for (ChildAssociationRef childParentAssociation : this.nodeService.getParentAssocs(objectId))
|
||||
for (ChildAssociationRef childParentAssociation : nodeService.getParentAssocs(objectId))
|
||||
{
|
||||
parents.add(childParentAssociation.getParentRef());
|
||||
}
|
||||
|
||||
return parents;
|
||||
}
|
||||
|
||||
|
||||
private HierarchyReceiverStrategy createHierarchyReceiver(EnumTypesOfFileableObjects returnObjectsType, BigInteger finalDepth)
|
||||
{
|
||||
|
||||
return (finalDepth.equals(FULL_DESCENDANTS_HIERARCHY_CONDITION)) ? (new FullHierarchyReceiver(returnObjectsType)) : (new LayerConstrainedHierarchyReceiver(
|
||||
returnObjectsType, finalDepth));
|
||||
if (finalDepth.equals(FULL_DESCENDANTS_HIERARCHY_CONDITION))
|
||||
{
|
||||
return new FullHierarchyReceiver(returnObjectsType);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new LayerConstrainedHierarchyReceiver(returnObjectsType, finalDepth);
|
||||
}
|
||||
}
|
||||
|
||||
private void separateDescendantsObjects(EnumTypesOfFileableObjects returnObjectsType, List<NodeRef> descendantsFolders, List<NodeRef> currentLayerFolders,
|
||||
List<NodeRef> currentLayerDocuments)
|
||||
private void separateDescendantsObjects(EnumTypesOfFileableObjects returnObjectsType, List<NodeRef> descendantsFolders, List<NodeRef> currentLayerFolders, List<NodeRef> currentLayerDocuments)
|
||||
{
|
||||
|
||||
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
|
||||
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
|
||||
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,
|
||||
List<NodeRef> currentLayerFolders, List<NodeRef> currentLayerDocuments)
|
||||
{
|
||||
|
||||
separateDescendantsObjects(returnObjectsType, descendantsFolders, currentLayerFolders, currentLayerDocuments);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
private class LayerConstrainedHierarchyReceiver implements HierarchyReceiverStrategy
|
||||
{
|
||||
private List<NodeRef> descendantsFolders = new LinkedList<NodeRef>();
|
||||
|
||||
private EnumTypesOfFileableObjects returnObjectsType;
|
||||
|
||||
private BigInteger finalDepth;
|
||||
|
||||
private BigInteger currentDepth = BigInteger.ZERO;
|
||||
|
||||
private List<NodeRef> resultList = new LinkedList<NodeRef>();
|
||||
|
||||
/**
|
||||
@@ -401,7 +415,6 @@ public class DMNavigationServicePort extends DMAbstractServicePort implements Na
|
||||
*/
|
||||
public LayerConstrainedHierarchyReceiver(EnumTypesOfFileableObjects returnObjectsType, BigInteger finalDepth)
|
||||
{
|
||||
|
||||
this.returnObjectsType = returnObjectsType;
|
||||
this.finalDepth = finalDepth;
|
||||
}
|
||||
@@ -411,56 +424,16 @@ public class DMNavigationServicePort extends DMAbstractServicePort implements Na
|
||||
*/
|
||||
public List<NodeRef> receiveHierarchy(String rootFolderIdentifier) throws InvalidArgumentException
|
||||
{
|
||||
|
||||
this.descendantsFolders.add((NodeRef) cmisObjectsUtils.getIdentifierInstance(rootFolderIdentifier, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier());
|
||||
descendantsFolders.add((NodeRef) cmisObjectsUtils.getIdentifierInstance(rootFolderIdentifier, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier());
|
||||
|
||||
do
|
||||
{
|
||||
this.descendantsFolders = performDescendantsResultObjectsStoring(this.returnObjectsType, this.resultList, this.descendantsFolders, new LinkedList<NodeRef>(),
|
||||
new LinkedList<NodeRef>());
|
||||
|
||||
this.currentDepth = this.currentDepth.add(BigInteger.ONE);
|
||||
} while (!this.descendantsFolders.isEmpty() && (this.currentDepth.compareTo(this.finalDepth) < EQUALS_CONDITION_VALUE));
|
||||
|
||||
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>());
|
||||
}
|
||||
descendantsFolders = performDescendantsResultObjectsStoring(this.returnObjectsType, this.resultList, this.descendantsFolders, new LinkedList<NodeRef>(), new LinkedList<NodeRef>());
|
||||
currentDepth = currentDepth.add(BigInteger.ONE);
|
||||
} while (!descendantsFolders.isEmpty() && (currentDepth.compareTo(this.finalDepth) < EQUALS_CONDITION_VALUE));
|
||||
|
||||
return this.resultList;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -38,6 +38,7 @@ import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||
import org.alfresco.cmis.dictionary.CMISMapping;
|
||||
import org.alfresco.cmis.dictionary.CMISTypeId;
|
||||
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.utils.AlfrescoObjectType;
|
||||
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
|
||||
{
|
||||
private static final int SINGLE_PARENT_CONDITION = 1;
|
||||
|
||||
private static final String VERSION_DELIMETER = ".";
|
||||
|
||||
private PermissionService permissionService;
|
||||
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
|
||||
*
|
||||
@@ -92,9 +103,9 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
*/
|
||||
public String createDocument(String repositoryId, String typeId, CmisPropertiesType properties, String folderId, CmisContentStreamType contentStream,
|
||||
EnumVersioningState versioningState) throws PermissionDeniedException, UpdateConflictException, StorageException, StreamNotSupportedException, FolderNotValidException,
|
||||
OperationNotSupportedException, TypeNotFoundException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
public String createDocument(String repositoryId, String typeId, CmisPropertiesType properties, String folderId, CmisContentStreamType contentStream, EnumVersioningState versioningState)
|
||||
throws PermissionDeniedException, UpdateConflictException, StorageException, StreamNotSupportedException, FolderNotValidException,
|
||||
OperationNotSupportedException, TypeNotFoundException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
|
||||
@@ -107,7 +118,7 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
throw new ConstraintViolationException("Invalid document type " + typeId);
|
||||
}
|
||||
|
||||
NodeRef parentNodeRef = receiveMandatoryFolderNodeReference(folderId);
|
||||
NodeRef parentNodeRef = safeGetFolderNodeRef(folderId);
|
||||
|
||||
String documentName = (String) propertiesMap.get(CMISMapping.PROP_NAME);
|
||||
if (documentName == null)
|
||||
@@ -143,24 +154,21 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
|
||||
switch (versioningState)
|
||||
{
|
||||
case CHECKEDOUT:
|
||||
newDocumentNodeRef = performCheckouting(newDocumentNodeRef);
|
||||
|
||||
break;
|
||||
case MAJOR:
|
||||
this.versionService.createVersion(newDocumentNodeRef, createVersionProperties(INITIAL_VERSION_DESCRIPTION, VersionType.MAJOR));
|
||||
|
||||
break;
|
||||
case MINOR:
|
||||
this.versionService.createVersion(newDocumentNodeRef, createVersionProperties(INITIAL_VERSION_DESCRIPTION, VersionType.MINOR));
|
||||
|
||||
break;
|
||||
case CHECKEDOUT:
|
||||
newDocumentNodeRef = checkoutNode(newDocumentNodeRef);
|
||||
break;
|
||||
case MAJOR:
|
||||
this.versionService.createVersion(newDocumentNodeRef, createVersionProperties(INITIAL_VERSION_DESCRIPTION, VersionType.MAJOR));
|
||||
break;
|
||||
case MINOR:
|
||||
this.versionService.createVersion(newDocumentNodeRef, createVersionProperties(INITIAL_VERSION_DESCRIPTION, VersionType.MINOR));
|
||||
break;
|
||||
}
|
||||
|
||||
String versionLabel = (String) cmisPropertyService.getProperty(newDocumentNodeRef, CMISMapping.PROP_VERSION_LABEL);
|
||||
|
||||
return ((versionLabel instanceof String) && versionLabel.contains(VERSION_DELIMETER)) ? (newDocumentNodeRef.toString() + CmisObjectsUtils.NODE_REFERENCE_ID_DELIMETER + versionLabel)
|
||||
: (newDocumentNodeRef.toString());
|
||||
return versionLabel != null && versionLabel.contains(VERSION_DELIMETER) ?
|
||||
newDocumentNodeRef.toString() + CmisObjectsUtils.NODE_REFERENCE_ID_DELIMETER + versionLabel :
|
||||
newDocumentNodeRef.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,25 +188,22 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
*/
|
||||
public String createFolder(String repositoryId, String typeId, CmisPropertiesType properties, String folderId) throws PermissionDeniedException, UpdateConflictException,
|
||||
FolderNotValidException, OperationNotSupportedException, TypeNotFoundException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
public String createFolder(String repositoryId, String typeId, CmisPropertiesType properties, String folderId)
|
||||
throws PermissionDeniedException, UpdateConflictException, FolderNotValidException, OperationNotSupportedException, TypeNotFoundException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
|
||||
NodeRef folderNodeRef = this.cmisObjectsUtils.getIdentifierInstance(folderId, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier();
|
||||
NodeRef folderNodeRef = cmisObjectsUtils.getIdentifierInstance(folderId, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier();
|
||||
|
||||
CMISTypeId cmisTypeId = getCmisTypeId(typeId);
|
||||
assertExistType(cmisTypeId);
|
||||
assertTypeExists(cmisTypeId);
|
||||
|
||||
CMISMapping cmisMapping = cmisDictionaryService.getCMISMapping();
|
||||
|
||||
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);
|
||||
|
||||
String name = (String) propertiesMap.get(CMISMapping.PROP_NAME);
|
||||
if (name == null)
|
||||
{
|
||||
@@ -237,12 +242,10 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
*/
|
||||
public String createPolicy(String repositoryId, String typeId, CmisPropertiesType properties, String folderId) throws PermissionDeniedException, UpdateConflictException,
|
||||
FolderNotValidException, OperationNotSupportedException, TypeNotFoundException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
public String createPolicy(String repositoryId, String typeId, CmisPropertiesType properties, String folderId)
|
||||
throws PermissionDeniedException, UpdateConflictException, FolderNotValidException, OperationNotSupportedException, TypeNotFoundException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
{
|
||||
|
||||
// TODO:
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -265,8 +268,7 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
* @throws ConstraintViolationException
|
||||
*/
|
||||
public String createRelationship(String repositoryId, String typeId, CmisPropertiesType properties, String sourceObjectId, String targetObjectId)
|
||||
throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, TypeNotFoundException, InvalidArgumentException,
|
||||
RuntimeException, ConstraintViolationException
|
||||
throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, TypeNotFoundException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
|
||||
@@ -275,8 +277,8 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
|
||||
try
|
||||
{
|
||||
sourceNodeRef = this.cmisObjectsUtils.getIdentifierInstance(sourceObjectId, AlfrescoObjectType.ANY_OBJECT).getConvertedIdentifier();
|
||||
targetNodeRef = this.cmisObjectsUtils.getIdentifierInstance(targetObjectId, AlfrescoObjectType.ANY_OBJECT).getConvertedIdentifier();
|
||||
sourceNodeRef = cmisObjectsUtils.getIdentifierInstance(sourceObjectId, AlfrescoObjectType.ANY_OBJECT).getConvertedIdentifier();
|
||||
targetNodeRef = cmisObjectsUtils.getIdentifierInstance(targetObjectId, AlfrescoObjectType.ANY_OBJECT).getConvertedIdentifier();
|
||||
}
|
||||
catch (InvalidArgumentException e)
|
||||
{
|
||||
@@ -284,12 +286,10 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
{
|
||||
throw new ObjectNotFoundException(e.getMessage());
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
|
||||
CMISTypeId relationshipTypeId;
|
||||
|
||||
try
|
||||
{
|
||||
relationshipTypeId = cmisDictionaryService.getCMISMapping().getCmisTypeId(typeId);
|
||||
@@ -300,7 +300,6 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
}
|
||||
|
||||
QName relationshipTypeQName = cmisDictionaryService.getCMISMapping().getAlfrescoType(relationshipTypeId.getQName());
|
||||
|
||||
AssociationDefinition associationDef = dictionaryService.getAssociation(relationshipTypeQName);
|
||||
if (associationDef != null)
|
||||
{
|
||||
@@ -339,14 +338,11 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
*/
|
||||
public void deleteContentStream(String repositoryId, String documentId) throws PermissionDeniedException, UpdateConflictException, StorageException,
|
||||
StreamNotSupportedException, ObjectNotFoundException, OperationNotSupportedException, VersioningException, InvalidArgumentException, RuntimeException,
|
||||
ConstraintViolationException
|
||||
public void deleteContentStream(String repositoryId, String documentId)
|
||||
throws PermissionDeniedException, UpdateConflictException, StorageException, StreamNotSupportedException, ObjectNotFoundException, OperationNotSupportedException, VersioningException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
{
|
||||
|
||||
checkRepositoryId(repositoryId);
|
||||
|
||||
performContentStreamDeletion((NodeRef) this.cmisObjectsUtils.getIdentifierInstance(documentId, AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier());
|
||||
safeDeleteContentStream((NodeRef) cmisObjectsUtils.getIdentifierInstance(documentId, AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -362,18 +358,15 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
*/
|
||||
public void deleteObject(String repositoryId, String objectId) throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException,
|
||||
OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
public void deleteObject(String repositoryId, String objectId)
|
||||
throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
{
|
||||
|
||||
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);
|
||||
checkObjectTypeAndAppropriateStates(objectNodeReference, this.cmisDictionaryService.getCMISMapping().getCmisType(this.nodeService.getType(objectNodeReference)));
|
||||
|
||||
if (!this.cmisObjectsUtils.deleteObject(objectNodeReference))
|
||||
if (!cmisObjectsUtils.deleteObject(objectNodeReference))
|
||||
{
|
||||
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
|
||||
*/
|
||||
public FailedToDelete deleteTree(String repositoryId, String folderId, EnumUnfileNonfolderObjects unfileNonfolderObjects, Boolean continueOnFailure)
|
||||
throws PermissionDeniedException, UpdateConflictException, FolderNotValidException, OperationNotSupportedException, InvalidArgumentException, RuntimeException,
|
||||
ConstraintViolationException
|
||||
throws PermissionDeniedException, UpdateConflictException, FolderNotValidException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
{
|
||||
|
||||
checkRepositoryId(repositoryId);
|
||||
checkUnfilingIsNotRequested(unfileNonfolderObjects);
|
||||
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();
|
||||
|
||||
this.cmisObjectsUtils.deleteFolder(folderNodeReference, continueOnFailure, (unfileNonfolderObjects == EnumUnfileNonfolderObjects.DELETE), responce.getObjectId());
|
||||
cmisObjectsUtils.deleteFolder(folderNodeReference, continueOnFailure, (unfileNonfolderObjects == EnumUnfileNonfolderObjects.DELETE), responce.getObjectId());
|
||||
|
||||
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.
|
||||
*
|
||||
* @param repositoryId repository Id
|
||||
@@ -429,13 +418,11 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
* @throws InvalidArgumentException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public CmisAllowableActionsType getAllowableActions(String repositoryId, String objectId) throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException,
|
||||
OperationNotSupportedException, InvalidArgumentException, RuntimeException
|
||||
public CmisAllowableActionsType getAllowableActions(String repositoryId, String objectId)
|
||||
throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException
|
||||
{
|
||||
|
||||
checkRepositoryId(repositoryId);
|
||||
|
||||
return determineObjectAllowableActions(this.cmisObjectsUtils.getIdentifierInstance(objectId, AlfrescoObjectType.ANY_OBJECT));
|
||||
return determineObjectAllowableActions(cmisObjectsUtils.getIdentifierInstance(objectId, AlfrescoObjectType.ANY_OBJECT));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -454,14 +441,13 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
* @throws RuntimeException
|
||||
* @throws OffsetException
|
||||
*/
|
||||
public CmisContentStreamType getContentStream(String repositoryId, String documentId) throws PermissionDeniedException, UpdateConflictException, StorageException,
|
||||
StreamNotSupportedException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, OffsetException
|
||||
public CmisContentStreamType getContentStream(String repositoryId, String documentId)
|
||||
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();
|
||||
|
||||
ContentReader reader = safelyReceiveContentReader(nodeRef);
|
||||
ContentReader reader = safeGetContentReader(nodeRef);
|
||||
|
||||
response.setLength(BigInteger.valueOf(reader.getSize()));
|
||||
response.setMimeType(reader.getMimetype());
|
||||
@@ -489,22 +475,20 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
*/
|
||||
public void moveObject(String repositoryId, String objectId, String targetFolderId, String sourceFolderId) throws PermissionDeniedException, UpdateConflictException,
|
||||
ObjectNotFoundException, FolderNotValidException, OperationNotSupportedException, NotInFolderException, InvalidArgumentException, RuntimeException,
|
||||
ConstraintViolationException
|
||||
public void moveObject(String repositoryId, String objectId, String targetFolderId, String sourceFolderId)
|
||||
throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, FolderNotValidException, OperationNotSupportedException, NotInFolderException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
|
||||
NodeRef objectNodeRef = this.cmisObjectsUtils.getIdentifierInstance(objectId, AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT).getConvertedIdentifier();
|
||||
NodeRef targetFolderNodeRef = this.cmisObjectsUtils.getIdentifierInstance(targetFolderId, AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier();
|
||||
|
||||
NodeRef objectNodeRef = cmisObjectsUtils.getIdentifierInstance(objectId, AlfrescoObjectType.DOCUMENT_OR_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
|
||||
|
||||
if ((this.nodeService.getParentAssocs(objectNodeRef).size() == SINGLE_PARENT_CONDITION)
|
||||
|| !changeObjectParentAssociation(objectNodeRef, targetFolderNodeRef, (NodeRef) this.cmisObjectsUtils.getIdentifierInstance(sourceFolderId,
|
||||
AlfrescoObjectType.FOLDER_OBJECT).getConvertedIdentifier()))
|
||||
if (nodeService.getParentAssocs(objectNodeRef).size() == SINGLE_PARENT_CONDITION || !changeObjectParentAssociation(objectNodeRef, targetFolderNodeRef, sourceFolderNodeRef))
|
||||
{
|
||||
moveObjectToFolder(objectNodeRef, targetFolderNodeRef);
|
||||
safeMove(objectNodeRef, targetFolderNodeRef);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -526,13 +510,12 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
*/
|
||||
public void setContentStream(String repositoryId, Holder<String> documentId, Boolean overwriteFlag, CmisContentStreamType contentStream) throws PermissionDeniedException,
|
||||
UpdateConflictException, StorageException, StreamNotSupportedException, ObjectNotFoundException, OperationNotSupportedException, ContentAlreadyExistsException,
|
||||
InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
public void setContentStream(String repositoryId, Holder<String> documentId, Boolean overwriteFlag, CmisContentStreamType contentStream)
|
||||
throws PermissionDeniedException, UpdateConflictException, StorageException, StreamNotSupportedException, ObjectNotFoundException, OperationNotSupportedException, ContentAlreadyExistsException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
{
|
||||
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)
|
||||
{
|
||||
@@ -573,14 +556,13 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
*/
|
||||
public void updateProperties(String repositoryId, Holder<String> objectId, String changeToken, CmisPropertiesType properties) throws PermissionDeniedException,
|
||||
UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
public void updateProperties(String repositoryId, Holder<String> objectId, String changeToken, CmisPropertiesType properties)
|
||||
throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
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);
|
||||
|
||||
// TODO: change token
|
||||
@@ -602,19 +584,19 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
* @throws InvalidArgumentException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public GetPropertiesResponse getProperties(GetProperties parameters) throws PermissionDeniedException, UpdateConflictException, FilterNotValidException,
|
||||
ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException
|
||||
public GetPropertiesResponse getProperties(GetProperties parameters)
|
||||
throws PermissionDeniedException, UpdateConflictException, FilterNotValidException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException
|
||||
{
|
||||
checkRepositoryId(parameters.getRepositoryId());
|
||||
|
||||
PropertyFilter propertyFilter = createPropertyFilter(parameters.getFilter());
|
||||
|
||||
String identifier = ((NodeRef) this.cmisObjectsUtils.getIdentifierInstance(parameters.getObjectId(), AlfrescoObjectType.ANY_OBJECT).getConvertedIdentifier()).toString();
|
||||
|
||||
if ((this.cmisObjectsUtils.determineObjectType(identifier) == EnumObjectType.DOCUMENT) && (parameters.getReturnVersion() != null)
|
||||
&& (parameters.getReturnVersion().getValue() != null))
|
||||
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 ((cmisObjectsUtils.determineObjectType(identifier) == EnumObjectType.DOCUMENT) && returnVersion != 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();
|
||||
@@ -635,12 +617,7 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
return response;
|
||||
}
|
||||
|
||||
public void setPermissionService(PermissionService permissionService)
|
||||
{
|
||||
|
||||
this.permissionService = permissionService;
|
||||
}
|
||||
|
||||
|
||||
private Map<String, Serializable> getPropertiesMap(CmisPropertiesType cmisProperties) throws InvalidArgumentException
|
||||
{
|
||||
Map<String, Serializable> properties = new HashMap<String, Serializable>();
|
||||
@@ -648,7 +625,6 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
for (CmisProperty cmisProperty : cmisProperties.getProperty())
|
||||
{
|
||||
String name = PropertyUtil.getRepositoryPropertyName(cmisProperty.getName());
|
||||
|
||||
if (name == null)
|
||||
{
|
||||
throw new InvalidArgumentException("Unknown property with name " + name);
|
||||
@@ -660,7 +636,7 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
return properties;
|
||||
}
|
||||
|
||||
private void assertExistType(CMISTypeId cmisTypeId) throws TypeNotFoundException
|
||||
private void assertTypeExists(CMISTypeId cmisTypeId) throws TypeNotFoundException
|
||||
{
|
||||
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
|
||||
{
|
||||
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,
|
||||
PermissionDeniedException
|
||||
private void safeDeleteContentStream(NodeRef documentNodeReference) throws ConstraintViolationException
|
||||
{
|
||||
|
||||
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
|
||||
{
|
||||
this.nodeService.setProperty(documentNodeReference, ContentModel.PROP_CONTENT, null);
|
||||
nodeService.setProperty(documentNodeReference, ContentModel.PROP_CONTENT, null);
|
||||
}
|
||||
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
|
||||
{
|
||||
|
||||
if (objectType == null)
|
||||
{
|
||||
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");
|
||||
}
|
||||
@@ -750,7 +734,6 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
|
||||
private void checkUnfilingIsNotRequested(EnumUnfileNonfolderObjects unfileNonfolderObjects) throws OperationNotSupportedException
|
||||
{
|
||||
|
||||
if (unfileNonfolderObjects == EnumUnfileNonfolderObjects.UNFILE)
|
||||
{
|
||||
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
|
||||
{
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
|
||||
for (CmisProperty property : properties.getProperty())
|
||||
{
|
||||
if (PropertyUtil.isReadOnlyRepositoryProperty(property.getName()))
|
||||
@@ -805,38 +768,25 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
return determineRelationshipAllowableActions((AssociationRef) objectIdentifierContainer.getConvertedIdentifier());
|
||||
}
|
||||
|
||||
switch (this.cmisObjectsUtils.determineObjectType(objectNodeReference.toString()))
|
||||
switch (cmisObjectsUtils.determineObjectType(objectNodeReference.toString()))
|
||||
{
|
||||
case DOCUMENT:
|
||||
{
|
||||
return determineDocumentAllowableActions((NodeRef) objectNodeReference);
|
||||
}
|
||||
case FOLDER:
|
||||
{
|
||||
return determineFolderAllowableActions((NodeRef) objectNodeReference);
|
||||
}
|
||||
case DOCUMENT:
|
||||
{
|
||||
return determineDocumentAllowableActions((NodeRef) objectNodeReference);
|
||||
}
|
||||
case FOLDER:
|
||||
{
|
||||
return determineFolderAllowableActions((NodeRef) objectNodeReference);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: determinePolicyAllowableActions() when Policy functionality is ready
|
||||
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)
|
||||
{
|
||||
|
||||
CmisAllowableActionsType result = new CmisAllowableActionsType();
|
||||
|
||||
result.setCanGetProperties(this.permissionService.hasPermission(objectNodeReference, PermissionService.READ_PROPERTIES) == AccessStatus.ALLOWED);
|
||||
result.setCanUpdateProperties(this.permissionService.hasPermission(objectNodeReference, PermissionService.WRITE_PROPERTIES) == 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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
CmisAllowableActionsType result = determineBaseAllowableActions(objectNodeReference);
|
||||
determineCommonFolderDocumentAllowableActions(objectNodeReference, result);
|
||||
|
||||
result.setCanGetParents(this.permissionService.hasPermission(objectNodeReference, PermissionService.READ_ASSOCIATIONS) == AccessStatus.ALLOWED);
|
||||
result.setCanViewContent(this.permissionService.hasPermission(objectNodeReference, PermissionService.READ_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.setCanCancelCheckout(this.permissionService.hasPermission(objectNodeReference, PermissionService.CANCEL_CHECK_OUT) == AccessStatus.ALLOWED);
|
||||
result.setCanDeleteContent(result.isCanUpdateProperties() && result.isCanSetContent());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private CmisAllowableActionsType determineFolderAllowableActions(NodeRef objectNodeReference)
|
||||
{
|
||||
|
||||
CmisAllowableActionsType result = determineBaseAllowableActions(objectNodeReference);
|
||||
determineCommonFolderDocumentAllowableActions(objectNodeReference, result);
|
||||
|
||||
@@ -888,20 +824,34 @@ public class DMObjectServicePort extends DMAbstractServicePort implements Object
|
||||
result.setCanGetFolderParent(result.isCanGetRelationships());
|
||||
result.setCanCreateFolder(result.isCanCreateDocument());
|
||||
// TODO: response.setCanCreatePolicy(value);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private NodeRef receiveMandatoryFolderNodeReference(String folderId) throws FolderNotValidException
|
||||
private void determineCommonFolderDocumentAllowableActions(NodeRef objectNodeReference, CmisAllowableActionsType allowableActions)
|
||||
{
|
||||
|
||||
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");
|
||||
}
|
||||
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 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 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");
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -46,7 +46,6 @@ public class DMPolicyServicePort extends DMAbstractServicePort implements Policy
|
||||
OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,7 +86,6 @@ public class DMPolicyServicePort extends DMAbstractServicePort implements Policy
|
||||
OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -28,6 +28,7 @@ import java.math.BigInteger;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.repo.cmis.PropertyFilter;
|
||||
import org.alfresco.repo.cmis.ws.utils.AlfrescoObjectType;
|
||||
import org.alfresco.repo.web.util.paging.Cursor;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
@@ -46,6 +47,12 @@ public class DMRelationshipServicePort extends DMAbstractServicePort implements
|
||||
{
|
||||
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.
|
||||
*
|
||||
@@ -66,86 +73,78 @@ public class DMRelationshipServicePort extends DMAbstractServicePort implements
|
||||
public GetRelationshipsResponse getRelationships(GetRelationships parameters) throws PermissionDeniedException, UpdateConflictException, FilterNotValidException,
|
||||
ObjectNotFoundException, OperationNotSupportedException, TypeNotFoundException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
{
|
||||
|
||||
checkRepositoryId(parameters.getRepositoryId());
|
||||
|
||||
EnumRelationshipDirection direction = ((parameters.getDirection() != null) && (parameters.getDirection().getValue() != null)) ? (parameters.getDirection().getValue())
|
||||
: (EnumRelationshipDirection.SOURCE);
|
||||
Boolean includingSubtypes = ((parameters.getIncludeSubRelationshipTypes() != null) && (parameters.getIncludeSubRelationshipTypes().getValue() != null)) ? (parameters
|
||||
.getIncludeSubRelationshipTypes().getValue()) : (false);
|
||||
String typeId = ((parameters.getTypeId() != null) && (parameters.getTypeId().getValue() != null)) ? (parameters.getTypeId().getValue()) : (null);
|
||||
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);
|
||||
EnumRelationshipDirection direction = ((parameters.getDirection() != null) && (parameters.getDirection().getValue() != null)) ? parameters.getDirection().getValue() : EnumRelationshipDirection.SOURCE;
|
||||
Boolean includingSubtypes = ((parameters.getIncludeSubRelationshipTypes() != null) && (parameters.getIncludeSubRelationshipTypes().getValue() != null)) ? parameters.getIncludeSubRelationshipTypes().getValue() : false;
|
||||
String typeId = ((parameters.getTypeId() != null) && (parameters.getTypeId().getValue() != null)) ? parameters.getTypeId().getValue() : null;
|
||||
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());
|
||||
|
||||
return formatResponse(createPropertyFilter(parameters.getFilter()), receiveAssociations(
|
||||
(NodeRef) this.cmisObjectsUtils.getIdentifierInstance(parameters.getObjectId(), AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT).getConvertedIdentifier(),
|
||||
associationType, direction, includingSubtypes).toArray(), new GetRelationshipsResponse(), skipCount, maxItems);
|
||||
PropertyFilter propertyFilter = createPropertyFilter(parameters.getFilter());
|
||||
NodeRef objectNodeRef = (NodeRef) cmisObjectsUtils.getIdentifierInstance(parameters.getObjectId(), AlfrescoObjectType.DOCUMENT_OR_FOLDER_OBJECT).getConvertedIdentifier();
|
||||
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)
|
||||
{
|
||||
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
private GetRelationshipsResponse formatResponse(PropertyFilter filter, Object[] sourceArray, GetRelationshipsResponse result, BigInteger skipCount, BigInteger maxItems)
|
||||
throws InvalidArgumentException, FilterNotValidException
|
||||
{
|
||||
|
||||
Cursor cursor = createCursor(sourceArray.length, skipCount, maxItems);
|
||||
|
||||
for (int i = cursor.getStartRow(); i < cursor.getEndRow(); i++)
|
||||
{
|
||||
result.getObject().add(convertAlfrescoObjectToCmisObject(sourceArray[i].toString(), filter));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<AssociationRef> receiveAssociations(NodeRef objectNodeReference, QName necessaryRelationshipType, EnumRelationshipDirection direction, boolean includingSubtypes)
|
||||
{
|
||||
|
||||
List<AssociationRef> result = new LinkedList<AssociationRef>();
|
||||
|
||||
QNamePattern matcher = new RelationshipByTypeFilter(necessaryRelationshipType, includingSubtypes);
|
||||
QNamePattern matcher = new RelationshipTypeFilter(relationshipType, includeSubtypes);
|
||||
|
||||
if ((direction == EnumRelationshipDirection.BOTH) || (direction == EnumRelationshipDirection.TARGET))
|
||||
{
|
||||
result.addAll(this.nodeService.getSourceAssocs(objectNodeReference, matcher));
|
||||
result.addAll(nodeService.getSourceAssocs(objectNodeReference, matcher));
|
||||
}
|
||||
|
||||
if ((direction == EnumRelationshipDirection.BOTH) || (direction == EnumRelationshipDirection.SOURCE))
|
||||
{
|
||||
result.addAll(this.nodeService.getTargetAssocs(objectNodeReference, matcher));
|
||||
result.addAll(nodeService.getTargetAssocs(objectNodeReference, matcher));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private class RelationshipByTypeFilter implements QNamePattern
|
||||
|
||||
private GetRelationshipsResponse formatResponse(PropertyFilter filter, Object[] sourceArray, GetRelationshipsResponse result, BigInteger skipCount, BigInteger maxItems)
|
||||
throws InvalidArgumentException, FilterNotValidException
|
||||
{
|
||||
private boolean includingSubtypes;
|
||||
private QName necessaryGeneralType;
|
||||
|
||||
public RelationshipByTypeFilter(QName necessaryGeneralType, boolean includingSubtypes)
|
||||
Cursor cursor = createCursor(sourceArray.length, skipCount, maxItems);
|
||||
for (int i = cursor.getStartRow(); i < cursor.getEndRow(); i++)
|
||||
{
|
||||
result.getObject().add(createCmisObject(sourceArray[i].toString(), filter));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
this.includingSubtypes = includingSubtypes;
|
||||
this.necessaryGeneralType = necessaryGeneralType;
|
||||
|
||||
private class RelationshipTypeFilter implements QNamePattern
|
||||
{
|
||||
private boolean includeSubtypes;
|
||||
private QName relationshipType;
|
||||
|
||||
public RelationshipTypeFilter(QName ralationshipType, boolean includeSubtypes)
|
||||
{
|
||||
this.relationshipType = ralationshipType;
|
||||
this.includeSubtypes = includeSubtypes;
|
||||
}
|
||||
|
||||
public boolean isMatch(QName qname)
|
||||
{
|
||||
|
||||
if (this.necessaryGeneralType == null)
|
||||
if (relationshipType == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return ((this.includingSubtypes) ? (dictionaryService.getAssociation(qname) != null)
|
||||
: (cmisDictionaryService.getCMISMapping().isValidCmisRelationship(qname) && this.necessaryGeneralType.equals(qname)));
|
||||
else if (includeSubtypes)
|
||||
{
|
||||
return dictionaryService.getAssociation(qname) != null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return cmisDictionaryService.getCMISMapping().isValidCmisRelationship(qname) && relationshipType.equals(qname);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -113,8 +113,8 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
|
||||
* @throws UpdateConflictException
|
||||
* @throws PermissionDeniedException
|
||||
*/
|
||||
public List<CmisRepositoryEntryType> getRepositories() throws RuntimeException, InvalidArgumentException, OperationNotSupportedException, UpdateConflictException,
|
||||
PermissionDeniedException
|
||||
public List<CmisRepositoryEntryType> getRepositories()
|
||||
throws RuntimeException, InvalidArgumentException, OperationNotSupportedException, UpdateConflictException, PermissionDeniedException
|
||||
{
|
||||
CmisRepositoryEntryType repositoryEntryType = new CmisRepositoryEntryType();
|
||||
Descriptor serverDescriptor = descriptorService.getServerDescriptor();
|
||||
@@ -136,11 +136,10 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
*/
|
||||
public CmisRepositoryInfoType getRepositoryInfo(GetRepositoryInfo parameters) throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException,
|
||||
OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
public CmisRepositoryInfoType getRepositoryInfo(GetRepositoryInfo parameters)
|
||||
throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
{
|
||||
Descriptor serverDescriptor = descriptorService.getServerDescriptor();
|
||||
|
||||
if (serverDescriptor.getId().equals(parameters.getRepositoryId()) == false)
|
||||
{
|
||||
throw new InvalidArgumentException("Invalid repository id");
|
||||
@@ -167,7 +166,6 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
|
||||
repositoryInfoType.setCapabilities(capabilities);
|
||||
|
||||
repositoryInfoType.setCmisVersionsSupported(cmisService.getCMISVersion());
|
||||
|
||||
return repositoryInfoType;
|
||||
}
|
||||
|
||||
@@ -184,54 +182,54 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
|
||||
|
||||
switch (propertyType)
|
||||
{
|
||||
case BOOLEAN:
|
||||
CmisChoiceBooleanType choiceBooleanType = new CmisChoiceBooleanType();
|
||||
choiceBooleanType.setIndex(BigInteger.valueOf(choice.getIndex()));
|
||||
choiceBooleanType.setKey(choice.getName());
|
||||
choiceBooleanType.setValue((Boolean) choice.getValue());
|
||||
result = cmisObjectFactory.createChoiceBoolean(choiceBooleanType);
|
||||
break;
|
||||
case DATETIME:
|
||||
CmisChoiceDateTimeType choiceDateTimeType = new CmisChoiceDateTimeType();
|
||||
choiceDateTimeType.setIndex(BigInteger.valueOf(choice.getIndex()));
|
||||
choiceDateTimeType.setKey(choice.getName());
|
||||
choiceDateTimeType.setValue(convert((Date) choice.getValue()));
|
||||
result = cmisObjectFactory.createChoiceDateTime(choiceDateTimeType);
|
||||
break;
|
||||
case DECIMAL:
|
||||
CmisChoiceDecimalType choiceDecimalType = new CmisChoiceDecimalType();
|
||||
choiceDecimalType.setIndex(BigInteger.valueOf(choice.getIndex()));
|
||||
choiceDecimalType.setKey(choice.getName());
|
||||
choiceDecimalType.setValue(BigDecimal.valueOf((Double) choice.getValue()));
|
||||
result = cmisObjectFactory.createChoiceDecimal(choiceDecimalType);
|
||||
break;
|
||||
case HTML:
|
||||
break;
|
||||
case ID:
|
||||
CmisChoiceIdType choiceIdType = new CmisChoiceIdType();
|
||||
choiceIdType.setIndex(BigInteger.valueOf(choice.getIndex()));
|
||||
choiceIdType.setKey(choice.getName());
|
||||
choiceIdType.setValue((String) choice.getValue());
|
||||
result = cmisObjectFactory.createChoiceId(choiceIdType);
|
||||
break;
|
||||
case INTEGER:
|
||||
CmisChoiceIntegerType choiceIntegerType = new CmisChoiceIntegerType();
|
||||
choiceIntegerType.setIndex(BigInteger.valueOf(choice.getIndex()));
|
||||
choiceIntegerType.setKey(choice.getName());
|
||||
choiceIntegerType.setValue(BigInteger.valueOf((Integer) choice.getValue()));
|
||||
result = cmisObjectFactory.createChoiceInteger(choiceIntegerType);
|
||||
break;
|
||||
case STRING:
|
||||
CmisChoiceStringType choiceStringType = new CmisChoiceStringType();
|
||||
choiceStringType.setIndex(BigInteger.valueOf(choice.getIndex()));
|
||||
choiceStringType.setKey(choice.getName());
|
||||
choiceStringType.setValue((String) choice.getValue());
|
||||
result = cmisObjectFactory.createChoiceString(choiceStringType);
|
||||
break;
|
||||
case URI:
|
||||
break;
|
||||
case XML:
|
||||
break;
|
||||
case BOOLEAN:
|
||||
CmisChoiceBooleanType choiceBooleanType = new CmisChoiceBooleanType();
|
||||
choiceBooleanType.setIndex(BigInteger.valueOf(choice.getIndex()));
|
||||
choiceBooleanType.setKey(choice.getName());
|
||||
choiceBooleanType.setValue((Boolean) choice.getValue());
|
||||
result = cmisObjectFactory.createChoiceBoolean(choiceBooleanType);
|
||||
break;
|
||||
case DATETIME:
|
||||
CmisChoiceDateTimeType choiceDateTimeType = new CmisChoiceDateTimeType();
|
||||
choiceDateTimeType.setIndex(BigInteger.valueOf(choice.getIndex()));
|
||||
choiceDateTimeType.setKey(choice.getName());
|
||||
choiceDateTimeType.setValue(convert((Date) choice.getValue()));
|
||||
result = cmisObjectFactory.createChoiceDateTime(choiceDateTimeType);
|
||||
break;
|
||||
case DECIMAL:
|
||||
CmisChoiceDecimalType choiceDecimalType = new CmisChoiceDecimalType();
|
||||
choiceDecimalType.setIndex(BigInteger.valueOf(choice.getIndex()));
|
||||
choiceDecimalType.setKey(choice.getName());
|
||||
choiceDecimalType.setValue(BigDecimal.valueOf((Double) choice.getValue()));
|
||||
result = cmisObjectFactory.createChoiceDecimal(choiceDecimalType);
|
||||
break;
|
||||
case HTML:
|
||||
break;
|
||||
case ID:
|
||||
CmisChoiceIdType choiceIdType = new CmisChoiceIdType();
|
||||
choiceIdType.setIndex(BigInteger.valueOf(choice.getIndex()));
|
||||
choiceIdType.setKey(choice.getName());
|
||||
choiceIdType.setValue((String) choice.getValue());
|
||||
result = cmisObjectFactory.createChoiceId(choiceIdType);
|
||||
break;
|
||||
case INTEGER:
|
||||
CmisChoiceIntegerType choiceIntegerType = new CmisChoiceIntegerType();
|
||||
choiceIntegerType.setIndex(BigInteger.valueOf(choice.getIndex()));
|
||||
choiceIntegerType.setKey(choice.getName());
|
||||
choiceIntegerType.setValue(BigInteger.valueOf((Integer) choice.getValue()));
|
||||
result = cmisObjectFactory.createChoiceInteger(choiceIntegerType);
|
||||
break;
|
||||
case STRING:
|
||||
CmisChoiceStringType choiceStringType = new CmisChoiceStringType();
|
||||
choiceStringType.setIndex(BigInteger.valueOf(choice.getIndex()));
|
||||
choiceStringType.setKey(choice.getName());
|
||||
choiceStringType.setValue((String) choice.getValue());
|
||||
result = cmisObjectFactory.createChoiceString(choiceStringType);
|
||||
break;
|
||||
case URI:
|
||||
break;
|
||||
case XML:
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -364,30 +362,30 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
|
||||
|
||||
switch (cmisTypeId.getScope())
|
||||
{
|
||||
case DOCUMENT:
|
||||
CmisTypeDocumentDefinitionType documentDefinitionType = new CmisTypeDocumentDefinitionType();
|
||||
setCmisTypeDefinitionProperties(documentDefinitionType, typeDefinition, includeProperties);
|
||||
documentDefinitionType.setVersionable(typeDefinition.isVersionable());
|
||||
documentDefinitionType.setContentStreamAllowed(contentStreamAllowedEnumMapping.get(typeDefinition.getContentStreamAllowed()));
|
||||
result = cmisObjectFactory.createDocumentType(documentDefinitionType);
|
||||
break;
|
||||
case FOLDER:
|
||||
CmisTypeFolderDefinitionType folderDefinitionType = new CmisTypeFolderDefinitionType();
|
||||
setCmisTypeDefinitionProperties(folderDefinitionType, typeDefinition, includeProperties);
|
||||
result = cmisObjectFactory.createFolderType(folderDefinitionType);
|
||||
break;
|
||||
case POLICY:
|
||||
CmisTypePolicyDefinitionType policyDefinitionType = new CmisTypePolicyDefinitionType();
|
||||
setCmisTypeDefinitionProperties(policyDefinitionType, typeDefinition, includeProperties);
|
||||
result = cmisObjectFactory.createPolicyType(policyDefinitionType);
|
||||
break;
|
||||
case RELATIONSHIP:
|
||||
CmisTypeRelationshipDefinitionType relationshipDefinitionType = new CmisTypeRelationshipDefinitionType();
|
||||
setCmisTypeDefinitionProperties(relationshipDefinitionType, typeDefinition, includeProperties);
|
||||
result = cmisObjectFactory.createRelationshipType(relationshipDefinitionType);
|
||||
break;
|
||||
case UNKNOWN:
|
||||
throw new ObjectNotFoundException("Bab type");
|
||||
case DOCUMENT:
|
||||
CmisTypeDocumentDefinitionType documentDefinitionType = new CmisTypeDocumentDefinitionType();
|
||||
setCmisTypeDefinitionProperties(documentDefinitionType, typeDefinition, includeProperties);
|
||||
documentDefinitionType.setVersionable(typeDefinition.isVersionable());
|
||||
documentDefinitionType.setContentStreamAllowed(contentStreamAllowedEnumMapping.get(typeDefinition.getContentStreamAllowed()));
|
||||
result = cmisObjectFactory.createDocumentType(documentDefinitionType);
|
||||
break;
|
||||
case FOLDER:
|
||||
CmisTypeFolderDefinitionType folderDefinitionType = new CmisTypeFolderDefinitionType();
|
||||
setCmisTypeDefinitionProperties(folderDefinitionType, typeDefinition, includeProperties);
|
||||
result = cmisObjectFactory.createFolderType(folderDefinitionType);
|
||||
break;
|
||||
case POLICY:
|
||||
CmisTypePolicyDefinitionType policyDefinitionType = new CmisTypePolicyDefinitionType();
|
||||
setCmisTypeDefinitionProperties(policyDefinitionType, typeDefinition, includeProperties);
|
||||
result = cmisObjectFactory.createPolicyType(policyDefinitionType);
|
||||
break;
|
||||
case RELATIONSHIP:
|
||||
CmisTypeRelationshipDefinitionType relationshipDefinitionType = new CmisTypeRelationshipDefinitionType();
|
||||
setCmisTypeDefinitionProperties(relationshipDefinitionType, typeDefinition, includeProperties);
|
||||
result = cmisObjectFactory.createRelationshipType(relationshipDefinitionType);
|
||||
break;
|
||||
case UNKNOWN:
|
||||
throw new ObjectNotFoundException("Unknown CMIS Type");
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -407,28 +405,32 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
|
||||
* @throws UpdateConflictException
|
||||
* @throws PermissionDeniedException
|
||||
*/
|
||||
public GetTypesResponse getTypes(GetTypes parameters) throws RuntimeException, InvalidArgumentException, ObjectNotFoundException, ConstraintViolationException,
|
||||
OperationNotSupportedException, UpdateConflictException, PermissionDeniedException
|
||||
public GetTypesResponse getTypes(GetTypes parameters)
|
||||
throws RuntimeException, InvalidArgumentException, ObjectNotFoundException, ConstraintViolationException, OperationNotSupportedException, UpdateConflictException, PermissionDeniedException
|
||||
{
|
||||
if (descriptorService.getServerDescriptor().getId().equals(parameters.getRepositoryId()) == false)
|
||||
{
|
||||
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();
|
||||
|
||||
Collection<CMISTypeId> typeIds = parameters.getTypeId() == null ? cmisDictionaryService.getAllObjectTypeIds() : cmisDictionaryService.getChildTypeIds(cmisDictionaryService
|
||||
.getCMISMapping().getCmisTypeId(parameters.getTypeId().getValue()), true);
|
||||
|
||||
if (parameters.getMaxItems() != null)
|
||||
{
|
||||
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
|
||||
Cursor cursor = createCursor(typeIds.size(), parameters.getSkipCount() != null ? parameters.getSkipCount().getValue() : null, parameters.getMaxItems() != null ? parameters.getMaxItems().getValue() : null);
|
||||
Iterator<CMISTypeId> iterTypeIds = typeIds.iterator();
|
||||
for (int i = 0; i < cursor.getStartRow(); i++)
|
||||
{
|
||||
@@ -464,8 +466,8 @@ public class DMRepositoryServicePort extends DMAbstractServicePort implements Re
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
*/
|
||||
public GetTypeDefinitionResponse getTypeDefinition(GetTypeDefinition parameters) throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException,
|
||||
OperationNotSupportedException, TypeNotFoundException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
public GetTypeDefinitionResponse getTypeDefinition(GetTypeDefinition parameters)
|
||||
throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, TypeNotFoundException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
{
|
||||
if (descriptorService.getServerDescriptor().getId().equals(parameters.getRepositoryId()) == false)
|
||||
{
|
||||
|
@@ -30,6 +30,8 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.aop.ThrowsAdvice;
|
||||
|
||||
/**
|
||||
* Map Alfresco Exceptions to CMIS Exceptions
|
||||
*
|
||||
* @author Dmitry Lazurkin
|
||||
* @author Dmitry Velichkevich
|
||||
*/
|
||||
@@ -37,7 +39,8 @@ public class DMServicePortThrowsAdvice implements ThrowsAdvice
|
||||
{
|
||||
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())
|
||||
{
|
||||
@@ -47,7 +50,8 @@ public class DMServicePortThrowsAdvice implements ThrowsAdvice
|
||||
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())
|
||||
{
|
||||
|
@@ -30,6 +30,7 @@ import javax.xml.ws.Holder;
|
||||
|
||||
import org.alfresco.cmis.dictionary.CMISMapping;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.cmis.PropertyFilter;
|
||||
import org.alfresco.repo.cmis.ws.utils.AlfrescoObjectType;
|
||||
import org.alfresco.service.cmr.lock.LockService;
|
||||
import org.alfresco.service.cmr.lock.LockStatus;
|
||||
@@ -50,6 +51,12 @@ public class DMVersioningServicePort extends DMAbstractServicePort implements Ve
|
||||
{
|
||||
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
|
||||
* again.
|
||||
@@ -63,11 +70,11 @@ public class DMVersioningServicePort extends DMAbstractServicePort implements Ve
|
||||
* @throws InvalidArgumentException
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public void cancelCheckOut(String repositoryId, String documentId) throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException,
|
||||
OperationNotSupportedException, InvalidArgumentException, RuntimeException
|
||||
public void cancelCheckOut(String repositoryId, String documentId)
|
||||
throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
NodeRef workingCopyNodeRef = this.cmisObjectsUtils.getIdentifierInstance(documentId, AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier();
|
||||
NodeRef workingCopyNodeRef = cmisObjectsUtils.getIdentifierInstance(documentId, AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier();
|
||||
assertWorkingCopy(workingCopyNodeRef);
|
||||
checkOutCheckInService.cancelCheckout(workingCopyNodeRef);
|
||||
}
|
||||
@@ -92,11 +99,10 @@ public class DMVersioningServicePort extends DMAbstractServicePort implements Ve
|
||||
* @throws ConstraintViolationException
|
||||
*/
|
||||
public void checkIn(String repositoryId, Holder<String> documentId, Boolean major, CmisPropertiesType properties, CmisContentStreamType contentStream, String checkinComment)
|
||||
throws PermissionDeniedException, UpdateConflictException, StorageException, StreamNotSupportedException, ObjectNotFoundException, OperationNotSupportedException,
|
||||
InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
throws PermissionDeniedException, UpdateConflictException, StorageException, StreamNotSupportedException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
{
|
||||
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);
|
||||
|
||||
if (contentStream != null)
|
||||
@@ -118,9 +124,7 @@ public class DMVersioningServicePort extends DMAbstractServicePort implements Ve
|
||||
setProperties(workingCopyNodeRef, properties);
|
||||
}
|
||||
|
||||
NodeRef nodeRef = checkOutCheckInService.checkin(workingCopyNodeRef, createVersionProperties(checkinComment, ((major != null) && (major)) ? (VersionType.MAJOR)
|
||||
: (VersionType.MINOR)));
|
||||
|
||||
NodeRef nodeRef = checkOutCheckInService.checkin(workingCopyNodeRef, createVersionProperties(checkinComment, major != null && major ? VersionType.MAJOR : VersionType.MINOR));
|
||||
documentId.value = (String) cmisPropertyService.getProperty(nodeRef, CMISMapping.PROP_OBJECT_ID);
|
||||
}
|
||||
|
||||
@@ -139,13 +143,12 @@ public class DMVersioningServicePort extends DMAbstractServicePort implements Ve
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
*/
|
||||
public void checkOut(String repositoryId, Holder<String> documentId, Holder<Boolean> contentCopied) throws PermissionDeniedException, UpdateConflictException,
|
||||
ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
public void checkOut(String repositoryId, Holder<String> documentId, Holder<Boolean> contentCopied)
|
||||
throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
{
|
||||
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);
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
NodeRef pwcNodeRef = performCheckouting(documentNodeRef);
|
||||
|
||||
NodeRef pwcNodeRef = checkoutNode(documentNodeRef);
|
||||
documentId.value = (String) cmisPropertyService.getProperty(pwcNodeRef, CMISMapping.PROP_OBJECT_ID);
|
||||
contentCopied.value = true;
|
||||
}
|
||||
@@ -172,12 +174,11 @@ public class DMVersioningServicePort extends DMAbstractServicePort implements Ve
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
*/
|
||||
public void deleteAllVersions(String repositoryId, String versionSeriesId) throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException,
|
||||
OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
public void deleteAllVersions(String repositoryId, String versionSeriesId)
|
||||
throws PermissionDeniedException, UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
NodeRef documentNodeRef = this.cmisObjectsUtils.getIdentifierInstance(versionSeriesId, AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier();
|
||||
|
||||
NodeRef documentNodeRef = cmisObjectsUtils.getIdentifierInstance(versionSeriesId, AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier();
|
||||
versionService.deleteVersionHistory(documentNodeRef);
|
||||
}
|
||||
|
||||
@@ -195,21 +196,20 @@ public class DMVersioningServicePort extends DMAbstractServicePort implements Ve
|
||||
* @throws RuntimeException
|
||||
* @throws ConstraintViolationException
|
||||
*/
|
||||
public GetAllVersionsResponse getAllVersions(GetAllVersions parameters) throws PermissionDeniedException, UpdateConflictException, FilterNotValidException,
|
||||
ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
public GetAllVersionsResponse getAllVersions(GetAllVersions parameters)
|
||||
throws PermissionDeniedException, UpdateConflictException, FilterNotValidException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException, ConstraintViolationException
|
||||
{
|
||||
checkRepositoryId(parameters.getRepositoryId());
|
||||
|
||||
NodeRef documentNodeRef = this.cmisObjectsUtils.getIdentifierInstance(parameters.getVersionSeriesId(), AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier();
|
||||
documentNodeRef = getLatestVersionNodeRef(documentNodeRef, false);
|
||||
|
||||
NodeRef documentNodeRef = cmisObjectsUtils.getIdentifierInstance(parameters.getVersionSeriesId(), AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier();
|
||||
documentNodeRef = getLatestNode(documentNodeRef, false);
|
||||
PropertyFilter propertyFilter = createPropertyFilter(parameters.getFilter());
|
||||
|
||||
GetAllVersionsResponse response = new GetAllVersionsResponse();
|
||||
List<CmisObjectType> objects = response.getObject();
|
||||
|
||||
searchWorkingCopy(documentNodeRef, propertyFilter, objects);
|
||||
objects.add(convertAlfrescoObjectToCmisObject(documentNodeRef, propertyFilter));
|
||||
objects.add(createCmisObject(documentNodeRef, propertyFilter));
|
||||
|
||||
VersionHistory versionHistory = versionService.getVersionHistory(documentNodeRef);
|
||||
|
||||
@@ -218,12 +218,10 @@ public class DMVersioningServicePort extends DMAbstractServicePort implements Ve
|
||||
return response;
|
||||
}
|
||||
|
||||
Version version = this.versionService.getCurrentVersion(documentNodeRef);
|
||||
|
||||
Version version = versionService.getCurrentVersion(documentNodeRef);
|
||||
while (version != null)
|
||||
{
|
||||
objects.add(convertAlfrescoObjectToCmisObject(version.getFrozenStateNodeRef(), propertyFilter));
|
||||
|
||||
objects.add(createCmisObject(version.getFrozenStateNodeRef(), propertyFilter));
|
||||
version = versionHistory.getPredecessor(version);
|
||||
}
|
||||
|
||||
@@ -237,15 +235,14 @@ public class DMVersioningServicePort extends DMAbstractServicePort implements Ve
|
||||
* property filter
|
||||
* @return CmisObjectType with properties
|
||||
*/
|
||||
public GetPropertiesOfLatestVersionResponse getPropertiesOfLatestVersion(GetPropertiesOfLatestVersion parameters) throws PermissionDeniedException, UpdateConflictException,
|
||||
FilterNotValidException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException
|
||||
public GetPropertiesOfLatestVersionResponse getPropertiesOfLatestVersion(GetPropertiesOfLatestVersion parameters)
|
||||
throws PermissionDeniedException, UpdateConflictException, FilterNotValidException, ObjectNotFoundException, OperationNotSupportedException, InvalidArgumentException, RuntimeException
|
||||
{
|
||||
checkRepositoryId(parameters.getRepositoryId());
|
||||
PropertyFilter propertyFilter = createPropertyFilter(parameters.getFilter());
|
||||
|
||||
NodeRef documentNodeRef = this.cmisObjectsUtils.getIdentifierInstance(parameters.getVersionSeriesId(), AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier();
|
||||
|
||||
NodeRef latestVersionNodeRef = getLatestVersionNodeRef(documentNodeRef, parameters.isMajorVersion());
|
||||
NodeRef documentNodeRef = cmisObjectsUtils.getIdentifierInstance(parameters.getVersionSeriesId(), AlfrescoObjectType.DOCUMENT_OBJECT).getConvertedIdentifier();
|
||||
NodeRef latestVersionNodeRef = getLatestNode(documentNodeRef, parameters.isMajorVersion());
|
||||
|
||||
GetPropertiesOfLatestVersionResponse response = new GetPropertiesOfLatestVersionResponse();
|
||||
response.setObject(new CmisObjectType());
|
||||
@@ -255,25 +252,18 @@ public class DMVersioningServicePort extends DMAbstractServicePort implements Ve
|
||||
return response;
|
||||
}
|
||||
|
||||
public void setLockService(LockService lockService)
|
||||
{
|
||||
this.lockService = lockService;
|
||||
}
|
||||
|
||||
private void searchWorkingCopy(NodeRef documentNodeRef, PropertyFilter propertyFilter, List<CmisObjectType> resultList)
|
||||
{
|
||||
|
||||
NodeRef workingCopyNodeReference = (this.cmisObjectsUtils.isWorkingCopy(documentNodeRef)) ? (documentNodeRef) : (checkOutCheckInService.getWorkingCopy(documentNodeRef));
|
||||
|
||||
if (workingCopyNodeReference instanceof NodeRef)
|
||||
NodeRef workingCopyNodeReference = cmisObjectsUtils.isWorkingCopy(documentNodeRef) ? documentNodeRef : checkOutCheckInService.getWorkingCopy(documentNodeRef);
|
||||
if (workingCopyNodeReference != null)
|
||||
{
|
||||
resultList.add(convertAlfrescoObjectToCmisObject(workingCopyNodeReference, propertyFilter));
|
||||
resultList.add(createCmisObject(workingCopyNodeReference, propertyFilter));
|
||||
}
|
||||
}
|
||||
|
||||
private void assertWorkingCopy(NodeRef nodeRef) throws OperationNotSupportedException
|
||||
{
|
||||
if (!this.cmisObjectsUtils.isWorkingCopy(nodeRef))
|
||||
if (!cmisObjectsUtils.isWorkingCopy(nodeRef))
|
||||
{
|
||||
throw new OperationNotSupportedException("Object isn't checked out");
|
||||
}
|
||||
|
@@ -98,13 +98,11 @@ public class PropertyUtil
|
||||
|
||||
public static boolean isReadOnlyCmisProperty(String internalPropertyName)
|
||||
{
|
||||
|
||||
return repoToCmisPropertiesNamesMapping.get(internalPropertyName).getSecond();
|
||||
}
|
||||
|
||||
public static boolean isReadOnlyRepositoryProperty(String cmisPropertyName)
|
||||
{
|
||||
|
||||
return repoToCmisPropertiesNamesMapping.get(cmisPropertyName).getSecond();
|
||||
}
|
||||
|
||||
|
@@ -35,8 +35,11 @@ import org.alfresco.model.ContentModel;
|
||||
*/
|
||||
public enum AlfrescoObjectType
|
||||
{
|
||||
DOCUMENT_OBJECT(ContentModel.TYPE_CONTENT.toString()), FOLDER_OBJECT(ContentModel.TYPE_FOLDER.toString()), DOCUMENT_OR_FOLDER_OBJECT("DOCUMENT_OR_FOLDER"), RELATIONSHIP_OBJECT(
|
||||
CMISMapping.RELATIONSHIP_QNAME.toString()), ANY_OBJECT("ANY");
|
||||
DOCUMENT_OBJECT(ContentModel.TYPE_CONTENT.toString()),
|
||||
FOLDER_OBJECT(ContentModel.TYPE_FOLDER.toString()),
|
||||
DOCUMENT_OR_FOLDER_OBJECT("DOCUMENT_OR_FOLDER"),
|
||||
RELATIONSHIP_OBJECT(CMISMapping.RELATIONSHIP_QNAME.toString()),
|
||||
ANY_OBJECT("ANY");
|
||||
|
||||
String value;
|
||||
|
||||
@@ -50,26 +53,21 @@ public enum AlfrescoObjectType
|
||||
|
||||
AlfrescoObjectType(String value)
|
||||
{
|
||||
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue()
|
||||
{
|
||||
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public static AlfrescoObjectType fromValue(String valueName)
|
||||
{
|
||||
|
||||
AlfrescoObjectType result = VALUES.get(valueName);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
result = ANY_OBJECT;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@@ -53,10 +53,8 @@ import org.alfresco.service.namespace.QName;
|
||||
*/
|
||||
public class CmisObjectsUtils
|
||||
{
|
||||
private static final int NODE_REFERENCE_WITH_SUFFIX_DELIMETERS_COUNT = 5;
|
||||
|
||||
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 List<QName> DOCUMENT_AND_FOLDER_TYPES;
|
||||
@@ -77,9 +75,41 @@ public class CmisObjectsUtils
|
||||
|
||||
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
|
||||
{
|
||||
|
||||
if (!(identifier instanceof String))
|
||||
{
|
||||
throw new InvalidArgumentException("Invalid Object Identifier was specified");
|
||||
@@ -91,15 +121,12 @@ public class CmisObjectsUtils
|
||||
if (isRelationship(identifier))
|
||||
{
|
||||
result = createAssociationIdentifierResult(identifier);
|
||||
|
||||
actualObjectType = AlfrescoObjectType.RELATIONSHIP_OBJECT;
|
||||
}
|
||||
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);
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
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));
|
||||
|
||||
do
|
||||
{
|
||||
DescendantElement currentElement = queueManager.receiveNextElement();
|
||||
|
||||
if (!this.nodeService.exists(currentElement.getNodesAssociation().getChildRef()))
|
||||
DescendantElement currentElement = queueManager.getNextElement();
|
||||
if (!nodeService.exists(currentElement.getChildAssoc().getChildRef()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
UnlinkOperationStatus unlinkingStatus = unlinkObject(currentElement.getNodesAssociation().getChildRef(), currentElement.getNodesAssociation().getParentRef(),
|
||||
totalDeletion);
|
||||
|
||||
if (!unlinkingStatus.isObjectUnlinked())
|
||||
UnlinkOperationStatus unlinkStatus = unlinkObject(currentElement.getChildAssoc().getChildRef(), currentElement.getChildAssoc().getParentRef(), totalDeletion);
|
||||
if (!unlinkStatus.isObjectUnlinked())
|
||||
{
|
||||
processNotUnlinkedObjectResults(currentElement, unlinkingStatus, queueManager, resultList, continueOnFailure);
|
||||
processUnlinkStatus(currentElement, unlinkStatus, queueManager, resultList, continueOnFailure);
|
||||
}
|
||||
} while (!queueManager.isDepleted() && (continueOnFailure || resultList.isEmpty()));
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean deleteObject(NodeRef objectNodeReference)
|
||||
{
|
||||
|
||||
return isObjectLockIsNotATrouble(objectNodeReference) && performNodeDeletion(objectNodeReference);
|
||||
return canLock(objectNodeReference) && performNodeDeletion(objectNodeReference);
|
||||
}
|
||||
|
||||
public boolean removeObject(NodeRef objectNodeReference, NodeRef folderNodeReference)
|
||||
{
|
||||
|
||||
if (isChildOfThisFolder(objectNodeReference, folderNodeReference))
|
||||
{
|
||||
try
|
||||
@@ -153,53 +191,43 @@ public class CmisObjectsUtils
|
||||
catch (Throwable e)
|
||||
{
|
||||
this.lastOperationException = e;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean addObjectToFolder(NodeRef objectNodeRef, NodeRef parentFolderNodeRef)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
this.nodeService.addChild(parentFolderNodeRef, objectNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName
|
||||
.createValidLocalName((String) this.nodeService.getProperty(objectNodeRef, ContentModel.PROP_NAME))));
|
||||
|
||||
QName name = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName((String)nodeService.getProperty(objectNodeRef, ContentModel.PROP_NAME)));
|
||||
nodeService.addChild(parentFolderNodeRef, objectNodeRef, ContentModel.ASSOC_CONTAINS, name);
|
||||
return true;
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
this.lastOperationException = e;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isFolder(NodeRef folderNodeRef)
|
||||
{
|
||||
|
||||
return (folderNodeRef != null) && this.cmisMapping.isValidCmisFolder(this.cmisMapping.getCmisType(this.nodeService.getType(folderNodeRef)));
|
||||
return (folderNodeRef != null) && cmisMapping.isValidCmisFolder(cmisMapping.getCmisType(nodeService.getType(folderNodeRef)));
|
||||
}
|
||||
|
||||
public boolean isDocument(NodeRef documentNodeRef)
|
||||
{
|
||||
|
||||
return (documentNodeRef != null) && this.cmisMapping.isValidCmisDocument(this.cmisMapping.getCmisType(this.nodeService.getType(documentNodeRef)));
|
||||
return (documentNodeRef != null) && cmisMapping.isValidCmisDocument(cmisMapping.getCmisType(nodeService.getType(documentNodeRef)));
|
||||
}
|
||||
|
||||
public boolean isRelationship(String identifier)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
new AssociationRef(identifier);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Throwable e)
|
||||
@@ -210,22 +238,18 @@ public class CmisObjectsUtils
|
||||
|
||||
public boolean isPolicy(NodeRef policyNodeRef)
|
||||
{
|
||||
|
||||
// TODO: Policy
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public EnumObjectType determineObjectType(String identifier)
|
||||
{
|
||||
|
||||
if (isRelationship(identifier))
|
||||
{
|
||||
return EnumObjectType.RELATIONSHIP;
|
||||
}
|
||||
|
||||
NodeRef objectNodeReference = new NodeRef(identifier);
|
||||
|
||||
if (isFolder(objectNodeReference))
|
||||
{
|
||||
return EnumObjectType.FOLDER;
|
||||
@@ -241,184 +265,110 @@ public class CmisObjectsUtils
|
||||
|
||||
public boolean isChildOfThisFolder(NodeRef objectNodeReference, NodeRef folderNodeReference)
|
||||
{
|
||||
|
||||
NodeRef searchedObjectNodeReference = this.fileFolderService.searchSimple(folderNodeReference, (String) this.nodeService.getProperty(objectNodeReference,
|
||||
ContentModel.PROP_NAME));
|
||||
|
||||
NodeRef searchedObjectNodeReference = fileFolderService.searchSimple(folderNodeReference, (String)nodeService.getProperty(objectNodeReference, ContentModel.PROP_NAME));
|
||||
return (searchedObjectNodeReference != null) && searchedObjectNodeReference.equals(objectNodeReference);
|
||||
}
|
||||
|
||||
public boolean isPrimaryObjectParent(NodeRef folderNodeReference, NodeRef objectNodeReference)
|
||||
{
|
||||
|
||||
NodeRef searchedParentObject = this.nodeService.getPrimaryParent(objectNodeReference).getParentRef();
|
||||
|
||||
NodeRef searchedParentObject = nodeService.getPrimaryParent(objectNodeReference).getParentRef();
|
||||
return (searchedParentObject != null) && searchedParentObject.equals(folderNodeReference);
|
||||
}
|
||||
|
||||
public boolean isWorkingCopy(NodeRef objectIdentifier)
|
||||
{
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
if (this.nodeService.hasAspect(objectNodeReference, ContentModel.ASPECT_WORKING_COPY))
|
||||
if (nodeService.hasAspect(objectNodeReference, ContentModel.ASPECT_WORKING_COPY))
|
||||
{
|
||||
this.checkOutCheckInService.cancelCheckout(objectNodeReference);
|
||||
|
||||
checkOutCheckInService.cancelCheckout(objectNodeReference);
|
||||
return true;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
this.nodeService.deleteNode(objectNodeReference);
|
||||
nodeService.deleteNode(objectNodeReference);
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isObjectLockIsNotATrouble(NodeRef objectNodeReference)
|
||||
private boolean canLock(NodeRef objectNodeReference)
|
||||
{
|
||||
|
||||
String currentUserName = AuthenticationUtil.getFullyAuthenticatedUser();
|
||||
|
||||
return (this.lockService.getLockStatus(objectNodeReference, currentUserName) != LockStatus.LOCKED) || this.authorityService.isAdminAuthority(currentUserName);
|
||||
return (this.lockService.getLockStatus(objectNodeReference, currentUserName) != LockStatus.LOCKED) || authorityService.isAdminAuthority(currentUserName);
|
||||
}
|
||||
|
||||
private UnlinkOperationStatus unlinkObject(NodeRef objectNodeReference, NodeRef parentFolderNodeReference, boolean totalDeletion)
|
||||
{
|
||||
|
||||
if (isFolder(objectNodeReference))
|
||||
{
|
||||
List<ChildAssociationRef> children = this.nodeService.getChildAssocs(objectNodeReference);
|
||||
|
||||
return new UnlinkOperationStatus(((children == null) || children.isEmpty()) && deleteObject(objectNodeReference), (children != null) ? (children)
|
||||
: (new LinkedList<ChildAssociationRef>()));
|
||||
List<ChildAssociationRef> children = nodeService.getChildAssocs(objectNodeReference);
|
||||
boolean objectUnlinked = (children == null || children.isEmpty()) && deleteObject(objectNodeReference);
|
||||
return new UnlinkOperationStatus(objectUnlinked, children != null ? children : new LinkedList<ChildAssociationRef>());
|
||||
}
|
||||
|
||||
return new UnlinkOperationStatus((totalDeletion) ? (deleteObject(objectNodeReference))
|
||||
: (!isPrimaryObjectParent(parentFolderNodeReference, objectNodeReference) && removeObject(objectNodeReference, parentFolderNodeReference)),
|
||||
new LinkedList<ChildAssociationRef>());
|
||||
boolean objectUnlinked = false;
|
||||
if (totalDeletion)
|
||||
{
|
||||
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,
|
||||
List<String> resultList, boolean addAllFailedToDelete)
|
||||
private NodeRef safeGetNodeRef(String nodeIdentifier) throws InvalidArgumentException
|
||||
{
|
||||
|
||||
if (!unlinkingStatus.getChildren().isEmpty())
|
||||
if (NodeRef.isNodeRef(nodeIdentifier))
|
||||
{
|
||||
queueManager.addElementToQueueEnd(currentElement);
|
||||
|
||||
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))
|
||||
NodeRef result = new NodeRef(nodeIdentifier);
|
||||
if (nodeService.exists(result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException("Invalid Object Identifier was specified: Identifier is incorrect or Object with the specified Identifier is not exists",
|
||||
new ObjectNotFoundException());
|
||||
throw new InvalidArgumentException("Invalid Object Identifier was specified: Identifier is incorrect or Object with the specified Identifier does not exist", new ObjectNotFoundException());
|
||||
}
|
||||
|
||||
private String cutNodeVersionIfNecessary(String identifier, String[] splitedNodeIdentifier, int startIndex)
|
||||
private String cutNodeVersionIfNecessary(String identifier, String[] splitNodeIdentifier, int startIndex)
|
||||
{
|
||||
|
||||
String withoutVersionSuffix = identifier;
|
||||
|
||||
if (splitedNodeIdentifier.length == NODE_REFERENCE_WITH_SUFFIX_DELIMETERS_COUNT)
|
||||
if (splitNodeIdentifier.length == NODE_REFERENCE_WITH_SUFFIX_DELIMETERS_COUNT)
|
||||
{
|
||||
withoutVersionSuffix = splitedNodeIdentifier[startIndex++ - 1] + DOUBLE_NODE_REFERENCE_ID_DELIMETER + splitedNodeIdentifier[startIndex++] + NODE_REFERENCE_ID_DELIMETER
|
||||
+ splitedNodeIdentifier[startIndex];
|
||||
withoutVersionSuffix = splitNodeIdentifier[startIndex++ - 1] + DOUBLE_NODE_REFERENCE_ID_DELIMETER + splitNodeIdentifier[startIndex++] + NODE_REFERENCE_ID_DELIMETER + splitNodeIdentifier[startIndex];
|
||||
}
|
||||
|
||||
return withoutVersionSuffix;
|
||||
}
|
||||
|
||||
private AlfrescoObjectType determineActualObjectType(AlfrescoObjectType expectedType, QName objectType)
|
||||
{
|
||||
|
||||
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));
|
||||
if (expectedType != AlfrescoObjectType.DOCUMENT_OR_FOLDER_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)
|
||||
{
|
||||
|
||||
return new IdentifierConversionResults()
|
||||
{
|
||||
public AssociationRef getConvertedIdentifier()
|
||||
{
|
||||
|
||||
return new AssociationRef(identifier);
|
||||
}
|
||||
};
|
||||
@@ -426,12 +376,10 @@ public class CmisObjectsUtils
|
||||
|
||||
private IdentifierConversionResults createNodeReferenceIdentifierResult(final NodeRef identifier)
|
||||
{
|
||||
|
||||
return new IdentifierConversionResults()
|
||||
{
|
||||
public NodeRef getConvertedIdentifier()
|
||||
{
|
||||
|
||||
return identifier;
|
||||
}
|
||||
};
|
||||
@@ -449,25 +397,28 @@ public class CmisObjectsUtils
|
||||
|
||||
public UnlinkOperationStatus(boolean objectUnlinked, List<ChildAssociationRef> children)
|
||||
{
|
||||
|
||||
this.objectUnlinked = objectUnlinked;
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public boolean isObjectUnlinked()
|
||||
{
|
||||
|
||||
return this.objectUnlinked;
|
||||
}
|
||||
|
||||
public List<ChildAssociationRef> getChildren()
|
||||
{
|
||||
|
||||
return this.children;
|
||||
}
|
||||
|
||||
protected UnlinkOperationStatus()
|
||||
{
|
||||
}
|
||||
|
||||
public boolean isObjectUnlinked()
|
||||
{
|
||||
return objectUnlinked;
|
||||
}
|
||||
|
||||
public List<ChildAssociationRef> getChildren()
|
||||
{
|
||||
return this.children;
|
||||
}
|
||||
}
|
||||
|
||||
public Throwable getLastOperationException()
|
||||
{
|
||||
return lastOperationException;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -38,119 +38,101 @@ public class DescendantsQueueManager
|
||||
|
||||
public DescendantsQueueManager(ChildAssociationRef headAssociation)
|
||||
{
|
||||
|
||||
this.queue = new LinkedList<DescendantElement>();
|
||||
this.queue.addFirst(createElement(headAssociation, null));
|
||||
}
|
||||
|
||||
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();
|
||||
this.queue.addFirst(createElement(null, headAssociation));
|
||||
}
|
||||
|
||||
protected DescendantsQueueManager()
|
||||
{
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return this.queue.isEmpty();
|
||||
}
|
||||
|
||||
private void determineUndeletedObjectToPut(String undeletedObjectIdentifier, List<String> undeletedNodes)
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
private DescendantElement parentElement;
|
||||
private ChildAssociationRef nodesAssociation;
|
||||
private DescendantElement parent;
|
||||
private ChildAssociationRef childAssoc;
|
||||
|
||||
public DescendantElement(DescendantElement parentElement, ChildAssociationRef nodesAssociation)
|
||||
public DescendantElement(DescendantElement parent, ChildAssociationRef childAssoc)
|
||||
{
|
||||
|
||||
this.parentElement = parentElement;
|
||||
this.nodesAssociation = nodesAssociation;
|
||||
this.parent = parent;
|
||||
this.childAssoc = childAssoc;
|
||||
}
|
||||
|
||||
public DescendantElement getParentElement()
|
||||
protected DescendantElement()
|
||||
{
|
||||
|
||||
return parentElement;
|
||||
}
|
||||
|
||||
public ChildAssociationRef getNodesAssociation()
|
||||
public DescendantElement getParent()
|
||||
{
|
||||
return parent;
|
||||
}
|
||||
|
||||
return nodesAssociation;
|
||||
public ChildAssociationRef getChildAssoc()
|
||||
{
|
||||
return childAssoc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
|
||||
if (!(obj instanceof DescendantElement))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
DescendantElement currentElement = (DescendantElement) obj;
|
||||
|
||||
return (this.nodesAssociation != null) ? (this.nodesAssociation.equals(currentElement.getNodesAssociation())) : (currentElement.getNodesAssociation() == null);
|
||||
}
|
||||
|
||||
protected DescendantElement()
|
||||
{
|
||||
return (childAssoc != null) ? (childAssoc.equals(currentElement.getChildAssoc())) : (currentElement.getChildAssoc() == null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user