Merge from SEAMIST3

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@10722 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2008-09-04 10:44:42 +00:00
parent 617f8e0b2c
commit f51be032bc
170 changed files with 18520 additions and 203 deletions

View File

@@ -0,0 +1,74 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.repo.cmis;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.web.scripts.DeclarativeWebScript;
import org.alfresco.web.scripts.Description;
import org.alfresco.web.scripts.Status;
import org.alfresco.web.scripts.WebScript;
import org.alfresco.web.scripts.WebScriptRequest;
/**
* Index of CMIS Scripts
*
* @author davidc
*/
public class Index extends DeclarativeWebScript
{
/* (non-Javadoc)
* @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.WebScriptResponse)
*/
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status)
{
List<WebScript> cmisScripts = new ArrayList<WebScript>();
// scan through all web scripts looking for CMIS specific ones
Collection<WebScript> webscripts = getContainer().getRegistry().getWebScripts();
for (WebScript webscript : webscripts)
{
Description desc = webscript.getDescription();
Map<String, Serializable> extensions = desc.getExtensions();
if (extensions != null && extensions.get("cmis_version") != null)
{
cmisScripts.add(webscript);
}
}
Map<String, Object> model = new HashMap<String, Object>(7, 1.0f);
model.put("services", cmisScripts);
return model;
}
}

View File

@@ -0,0 +1,58 @@
/*
* 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.ws;
import java.util.List;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.apache.cxf.binding.soap.SoapMessage;
import org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.phase.Phase;
import org.apache.ws.security.WSSecurityEngineResult;
import org.apache.ws.security.WSUsernameTokenPrincipal;
import org.apache.ws.security.handler.WSHandlerConstants;
import org.apache.ws.security.handler.WSHandlerResult;
public class AuthenticationInterceptor extends AbstractSoapInterceptor
{
public AuthenticationInterceptor()
{
super(Phase.PRE_INVOKE);
}
public void handleMessage(SoapMessage message) throws Fault
{
@SuppressWarnings("unchecked")
WSHandlerResult handlerResult = ((List<WSHandlerResult>) message.getContextualProperty(WSHandlerConstants.RECV_RESULTS)).get(0);
WSSecurityEngineResult secRes = (WSSecurityEngineResult) handlerResult.getResults().get(0);
WSUsernameTokenPrincipal principal = (WSUsernameTokenPrincipal) secRes.get(WSSecurityEngineResult.TAG_PRINCIPAL);
// Authenticate
AuthenticationUtil.setCurrentUser(principal.getName());
}
}

View File

@@ -0,0 +1,84 @@
/*
* 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.ws;
import java.io.IOException;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.UnsupportedCallbackException;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ws.security.WSPasswordCallback;
/**
* @author Michael Shavnev
*/
public class AuthenticationTokenCallbackHandler implements CallbackHandler
{
private final Log LOG = LogFactory.getLog(AuthenticationTokenCallbackHandler.class);
private AuthenticationService authenticationService;
public void setAuthenticationService(AuthenticationService authenticationService)
{
this.authenticationService = authenticationService;
}
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
WSPasswordCallback wssPasswordCallback = (WSPasswordCallback) callbacks[0];
String userName = wssPasswordCallback.getIdentifer();
String password = getPassword(userName);
// Check the UsernameToken element.
// Depending on the password type contained in the element the processing differs.
if (wssPasswordCallback.getUsage() == WSPasswordCallback.USERNAME_TOKEN)
{
// If the password type is password digest provide stored password perform
// hash algorithm and compare the result with the transmitted password
wssPasswordCallback.setPassword(password);
}
else
{
// If the password is of type password text or any other yet unknown password type
// the delegate the password validation to the callback class.
if (!password.equals(wssPasswordCallback.getPassword()))
{
throw new SecurityException("Incorrect password");
}
}
}
private String getPassword(String userName)
{
// TODO Auto-generated method stub
return userName;
}
}

View File

@@ -0,0 +1,66 @@
/*
* 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.ws;
/**
* Cmis properties enumeration
*
* @author Dmitry Lazurkin
*
*/
public enum CmisProperty
{
// Base properties
OBJECT_ID,
URI,
OBJECT_TYPE_ID,
CREATED_BY,
CREATION_DATE,
LAST_MODIFIED_BY,
LAST_MODIFICATION_DATE,
CHANGE_TOKEN,
// Folder Object Type properties
PARENT,
ALLOWED_CHILD_OBJECT_TYPES,
// Document Object Type properties
IS_IMMUTABLE,
IS_LATEST_VERSION,
IS_MAJOR_VERSION,
IS_LATEST_MAJOR_VERSION,
VERSION_SERIES_IS_CHECKED_OUT,
VERSION_SERIES_CHECKED_OUT_BY,
VERSION_SERIES_CHECKED_OUT_OID,
CHECKIN_COMMENT,
CONTENT_STREAM_ALLOWED,
CONTENT_STREAM_LENGTH,
CONTENT_STREAM_MIME_TYPE,
CONTENT_STREAM_FILENAME,
CONTENT_STREAM_URI,
// Document Object Type and Folder Object Type properties
NAME;
}

View File

@@ -0,0 +1,509 @@
/*
* 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.ws;
import java.io.Serializable;
import java.math.BigInteger;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Map;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
import org.alfresco.service.cmr.repository.datatype.TypeConverter;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.service.cmr.version.Version;
import org.alfresco.service.cmr.version.VersionHistory;
import org.alfresco.service.cmr.version.VersionService;
import org.alfresco.service.cmr.version.VersionType;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
/**
* @author Michael Shavnev
* @author Dmitry Lazurkin
*/
public class DMAbstractServicePort
{
private static final TypeConverter TYPE_CONVERTER = DefaultTypeConverter.INSTANCE;
private DatatypeFactory _datatypeFactory;
protected NodeService nodeService;
protected PersonService personService;
protected SearchService searchService;
protected NamespaceService namespaceService;
protected DictionaryService dictionaryService;
protected VersionService versionService;
protected CheckOutCheckInService checkOutCheckInService;
protected FileFolderService fileFolderService;
protected AuthenticationService authenticationService;
private DatatypeFactory getDatatypeFactory() throws RuntimeException
{
if (_datatypeFactory == null)
{
try
{
_datatypeFactory = DatatypeFactory.newInstance();
}
catch (DatatypeConfigurationException e)
{
// TODO: error code
throw new RuntimeException(e.getMessage());
}
}
return _datatypeFactory;
}
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
public void setPersonService(PersonService personService)
{
this.personService = personService;
}
public void setSearchService(SearchService searchService)
{
this.searchService = searchService;
}
public void setNamespaceService(NamespaceService namespaceService)
{
this.namespaceService = namespaceService;
}
public void setDictionaryService(DictionaryService dictionaryService)
{
this.dictionaryService = dictionaryService;
}
public void setVersionService(VersionService versionService)
{
this.versionService = versionService;
}
public void setCheckOutCheckInService(CheckOutCheckInService checkOutCheckInService)
{
this.checkOutCheckInService = checkOutCheckInService;
}
public void setFileFolderService(FileFolderService fileFolderService)
{
this.fileFolderService = fileFolderService;
}
public void setAuthenticationService(AuthenticationService authenticationService)
{
this.authenticationService = authenticationService;
}
/**
* Sets properties for ObjectTypeBase object
*
* @param nodeRef Node reference
* @param target ObjectTypeBase object for setting
* @param propertyFilter filter for properties
* @return ObjectTypeBase object
*/
public ObjectTypeBase setObjectTypeBaseProperties(NodeRef nodeRef, ObjectTypeBase target, PropertyFilter propertyFilter) throws RuntimeException
{
Map<QName, Serializable> properties = nodeService.getProperties(nodeRef);
target.setObjectID(OIDUtils.toOID(nodeRef));
QName typeQName = nodeService.getType(nodeRef);
target.setObjectTypeID(typeQName.toString());
if (dictionaryService.isSubClass(typeQName, ContentModel.TYPE_FOLDER))
{
target.setBaseObjectType(ContentModel.TYPE_FOLDER.toString());
}
else
{
target.setBaseObjectType(ContentModel.TYPE_CONTENT.toString());
}
if (propertyFilter.allow(CmisProperty.CREATED_BY))
{
target.setCreatedBy(TYPE_CONVERTER.convert(String.class, properties.get(ContentModel.PROP_AUTHOR)));
}
if (propertyFilter.allow(CmisProperty.CREATION_DATE))
{
target.setCreationDate(convert(TYPE_CONVERTER.convert(Date.class, properties.get(ContentModel.PROP_CREATED))));
}
if (propertyFilter.allow(CmisProperty.LAST_MODIFIED_BY))
{
target.setLastModifiedBy(TYPE_CONVERTER.convert(String.class, properties.get(ContentModel.PROP_MODIFIER)));
}
Date modificationDate = TYPE_CONVERTER.convert(Date.class, properties.get(ContentModel.PROP_MODIFIED));
if (propertyFilter.allow(CmisProperty.LAST_MODIFICATION_DATE))
{
target.setLastModificationDate(convert(modificationDate));
}
if (propertyFilter.allow(CmisProperty.CHANGE_TOKEN))
{
target.setChangeToken(String.valueOf(modificationDate.getTime()));
}
return target;
}
/**
* Sets properties for FolderObjectType object
*
* @param nodeRef Node reference
* @param target FolderObjectType object for setting
* @param propertyFilter filter for properties
* @return FolderObjectType object
*/
public FolderObjectType setFolderObjectTypeProperties(NodeRef folderNodeRef, FolderObjectType target, PropertyFilter propertyFilter) throws RuntimeException
{
setObjectTypeBaseProperties(folderNodeRef, target, propertyFilter);
if (propertyFilter.allow(CmisProperty.NAME))
{
target.setName((String) nodeService.getProperty(folderNodeRef, ContentModel.PROP_NAME));
}
if (propertyFilter.allow(CmisProperty.PARENT))
{
target.setParent(OIDUtils.toOID(nodeService.getPrimaryParent(folderNodeRef).getParentRef()));
}
if (propertyFilter.allow(CmisProperty.ALLOWED_CHILD_OBJECT_TYPES))
{
// TODO: not set this property
}
return target;
}
/**
* Sets properties for DocumentOrFolderObjectType object
*
* @param nodeRef Node reference
* @param target DocumentOrFolderObjectType object for setting
* @param propertyFilter filter for properties
* @return DocumentOrFolderObjectType object
*/
public DocumentOrFolderObjectType setFolderObjectTypeProperties(NodeRef folderNodeRef, DocumentOrFolderObjectType target, PropertyFilter propertyFilter) throws RuntimeException
{
setObjectTypeBaseProperties(folderNodeRef, target, propertyFilter);
if (propertyFilter.allow(CmisProperty.NAME))
{
target.setName((String) nodeService.getProperty(folderNodeRef, ContentModel.PROP_NAME));
}
if (propertyFilter.allow(CmisProperty.PARENT))
{
target.setParent(OIDUtils.toOID(nodeService.getPrimaryParent(folderNodeRef).getParentRef()));
}
if (propertyFilter.allow(CmisProperty.ALLOWED_CHILD_OBJECT_TYPES))
{
// TODO: not set this property
}
return target;
}
/**
* Sets properties for DocumentObjectType object
*
* @param nodeRef Node reference
* @param target DocumentObjectType object for setting
* @param propertyFilter filter for properties
* @return DocumentObjectType object
*/
public DocumentObjectType setDocumentObjectTypeProperties(NodeRef documentNodeRef, DocumentObjectType target, PropertyFilter propertyFilter) throws RuntimeException
{
setObjectTypeBaseProperties(documentNodeRef, target, propertyFilter);
NodeRef workingCopy = null;
if (nodeService.hasAspect(documentNodeRef, ContentModel.ASPECT_WORKING_COPY))
{
workingCopy = documentNodeRef;
if (propertyFilter.allow(CmisProperty.IS_LATEST_VERSION))
{
target.setIsLatestVersion(false);
}
if (propertyFilter.allow(CmisProperty.IS_MAJOR_VERSION))
{
target.setIsMajorVersion(false);
}
if (propertyFilter.allow(CmisProperty.IS_LATEST_MAJOR_VERSION))
{
target.setIsLatestMajorVersion(false);
}
}
else
{
target.setName((String) nodeService.getProperty(documentNodeRef, ContentModel.PROP_NAME));
workingCopy = checkOutCheckInService.getWorkingCopy(documentNodeRef);
Version version = versionService.getCurrentVersion(documentNodeRef);
if (nodeService.hasAspect(documentNodeRef, ContentModel.ASPECT_VERSIONABLE) && version != null)
{
if (propertyFilter.allow(CmisProperty.IS_LATEST_VERSION))
{
target.setIsLatestVersion(version.getVersionedNodeRef().equals(documentNodeRef));
}
if (propertyFilter.allow(CmisProperty.IS_MAJOR_VERSION))
{
target.setIsMajorVersion(version.getVersionType().equals(VersionType.MAJOR));
}
if (propertyFilter.allow(CmisProperty.IS_LATEST_MAJOR_VERSION))
{
NodeRef latestMajorNodeRef = getLatestVersionNodeRef(documentNodeRef, true);
target.setIsLatestMajorVersion(latestMajorNodeRef.equals(documentNodeRef));
}
if (propertyFilter.allow(CmisProperty.CHECKIN_COMMENT) && workingCopy == null)
{
target.setCheckinComment(version.getDescription());
}
}
else
{
if (propertyFilter.allow(CmisProperty.IS_LATEST_VERSION))
{
target.setIsLatestVersion(true);
}
if (propertyFilter.allow(CmisProperty.IS_MAJOR_VERSION))
{
target.setIsMajorVersion(true);
}
if (propertyFilter.allow(CmisProperty.IS_LATEST_MAJOR_VERSION))
{
target.setIsLatestMajorVersion(true);
}
}
}
if (propertyFilter.allow(CmisProperty.VERSION_SERIES_IS_CHECKED_OUT))
{
target.setVersionSeriesIsCheckedOut(workingCopy != null);
}
if (propertyFilter.allow(CmisProperty.VERSION_SERIES_CHECKED_OUT_BY) && workingCopy != null)
{
target.setVersionSeriesCheckedOutBy((String) nodeService.getProperty(workingCopy, ContentModel.PROP_WORKING_COPY_OWNER));
}
if (propertyFilter.allow(CmisProperty.VERSION_SERIES_CHECKED_OUT_OID) && workingCopy != null)
{
if (AuthenticationUtil.getCurrentUserName().equals((String) nodeService.getProperty(workingCopy, ContentModel.PROP_WORKING_COPY_OWNER)))
{
target.setVersionSeriesCheckedOutOID(OIDUtils.toOID(workingCopy));
}
}
ContentReader contentReader = null;
if (nodeService.getType(documentNodeRef).equals(ContentModel.TYPE_LINK))
{
NodeRef destRef = (NodeRef) nodeService.getProperty(documentNodeRef, ContentModel.PROP_LINK_DESTINATION);
if (nodeService.exists(destRef))
{
contentReader = fileFolderService.getReader(destRef);
}
}
else
{
contentReader = fileFolderService.getReader(documentNodeRef);
}
if (contentReader != null)
{
if (propertyFilter.allow(CmisProperty.CONTENT_STREAM_LENGTH))
{
target.setContentStreamLength(BigInteger.valueOf(contentReader.getSize()));
}
if (propertyFilter.allow(CmisProperty.CONTENT_STREAM_MIME_TYPE))
{
target.setContentStreamMimeType(contentReader.getMimetype());
}
if (propertyFilter.allow(CmisProperty.CONTENT_STREAM_FILENAME))
{
target.setContentStreamFilename(target.getName()); // TODO: right on not?
}
}
return target;
}
/**
* Sets properties for RelationshipObjectType object
*
* @param associationRef Association reference
* @param target RelationshipObjectType object for setting
* @param propertyFilter filter for properties
* @return RelationshipObjectType object
*/
public RelationshipObjectType setRelationshipObjectTypeProperties(AssociationRef associationRef, RelationshipObjectType target, PropertyFilter propertyFilter)
{
target.setSourceOID(OIDUtils.toOID(associationRef.getSourceRef()));
target.setTargetOID(OIDUtils.toOID(associationRef.getTargetRef()));
// TODO: other properties
return target;
}
/**
* Sets properties for DocumentFolderOrRelationshipObjectType object
*
* @param associationRef Association reference
* @param target DocumentFolderOrRelationshipObjectType object for setting
* @param propertyFilter filter for properties
* @return DocumentFolderOrRelationshipObjectType object
*/
public DocumentFolderOrRelationshipObjectType setRelationshipObjectTypeProperties(AssociationRef associationRef, DocumentFolderOrRelationshipObjectType target, PropertyFilter propertyFilter)
{
target.setSourceOID(OIDUtils.toOID(associationRef.getSourceRef()));
target.setTargetOID(OIDUtils.toOID(associationRef.getTargetRef()));
// TODO: other properties
return target;
}
/**
* @param associationRef a reference to the association to look for
* @return Returns true if the association exists, otherwise false
*/
public boolean exists(AssociationRef associationRef)
{
if (nodeService.exists(associationRef.getSourceRef()))
{
return nodeService.getTargetAssocs(associationRef.getSourceRef(), associationRef.getTypeQName()).contains(associationRef);
}
return false;
}
/**
* @param nodeRef
* @return
*/
public boolean isFolderType(NodeRef nodeRef)
{
QName typeQName = nodeService.getType(nodeRef);
return dictionaryService.isSubClass(typeQName, ContentModel.TYPE_FOLDER);
}
/**
* @param nodeRef
* @return
*/
public boolean isDocumentType(NodeRef nodeRef)
{
QName typeQName = nodeService.getType(nodeRef);
return dictionaryService.isSubClass(typeQName, ContentModel.TYPE_CONTENT);
}
/**
* Returns latest minor or major version of document
*
* @param documentNodeRef document node reference
* @param major need latest major version
* @return latest version node reference
*/
public NodeRef getLatestVersionNodeRef(NodeRef documentNodeRef, boolean major)
{
Version currentVersion = versionService.getCurrentVersion(documentNodeRef);
NodeRef latestVersionNodeRef = documentNodeRef;
if (currentVersion != null)
{
latestVersionNodeRef = currentVersion.getVersionedNodeRef();
if (major)
{
Version latestVersion = versionService.getCurrentVersion(latestVersionNodeRef);
if (latestVersion.getVersionType().equals(VersionType.MAJOR) == false)
{
VersionHistory versionHistory = versionService.getVersionHistory(currentVersion.getVersionedNodeRef());
do
{
latestVersion = versionHistory.getPredecessor(latestVersion);
} while (latestVersion.getVersionType().equals(VersionType.MAJOR) == false);
latestVersionNodeRef = latestVersion.getFrozenStateNodeRef();
}
}
}
return latestVersionNodeRef;
}
/**
* Converts Date object to XMLGregorianCalendar object
*
* @param date Date object
* @return XMLGregorianCalendar object
* @throws RuntimeException
*/
private XMLGregorianCalendar convert(Date date) throws RuntimeException
{
GregorianCalendar calendar = new GregorianCalendar();
calendar.setTime(date);
return getDatatypeFactory().newXMLGregorianCalendar(calendar);
}
}

View File

@@ -0,0 +1,245 @@
/*
* 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.ws;
import java.math.BigInteger;
import java.util.List;
import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.repository.NodeRef;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* @author Dmitry Lazurkin
*/
@javax.jws.WebService(name = "NavigationServicePort", serviceName = "NavigationService", portName = "NavigationServicePort", targetNamespace = "http://www.cmis.org/ns/1.0", endpointInterface = "org.alfresco.repo.cmis.ws.NavigationServicePort")
public class DMNavigationServicePort extends DMAbstractServicePort implements NavigationServicePort
{
private static final Log log = LogFactory.getLog("org.alfresco.repo.cmis.ws");
public org.alfresco.repo.cmis.ws.GetDescendantsResponse getDescendants(GetDescendants parameters) throws RuntimeException, ConcurrencyException, InvalidArgumentException,
FilterNotValidException, OperationNotSupportedException, FolderNotValidException, PermissionDeniedException
{
System.out.println(parameters);
try
{
org.alfresco.repo.cmis.ws.GetDescendantsResponse _return = null;
return _return;
}
catch (Exception ex)
{
ex.printStackTrace();
throw new java.lang.RuntimeException(ex);
}
// throw new RuntimeException("RuntimeException...");
// throw new ConcurrencyException("ConcurrencyException...");
// throw new InvalidArgumentException("InvalidArgumentException...");
// throw new FilterNotValidException("FilterNotValidException...");
// throw new OperationNotSupportedException("OperationNotSupportedException...");
// throw new FolderNotValidException("FolderNotValidException...");
// throw new PermissionDeniedException("PermissionDeniedException...");
}
public org.alfresco.repo.cmis.ws.GetCheckedoutDocsResponse getCheckedoutDocs(GetCheckedoutDocs parameters) throws RuntimeException, ConcurrencyException, InvalidArgumentException,
FilterNotValidException, OperationNotSupportedException, FolderNotValidException, PermissionDeniedException
{
System.out.println(parameters);
try
{
org.alfresco.repo.cmis.ws.GetCheckedoutDocsResponse _return = null;
return _return;
}
catch (Exception ex)
{
ex.printStackTrace();
throw new java.lang.RuntimeException(ex);
}
// throw new RuntimeException("RuntimeException...");
// throw new ConcurrencyException("ConcurrencyException...");
// throw new InvalidArgumentException("InvalidArgumentException...");
// throw new FilterNotValidException("FilterNotValidException...");
// throw new OperationNotSupportedException("OperationNotSupportedException...");
// throw new FolderNotValidException("FolderNotValidException...");
// throw new PermissionDeniedException("PermissionDeniedException...");
}
public org.alfresco.repo.cmis.ws.GetDocumentParentsResponse getDocumentParents(GetDocumentParents parameters) throws RuntimeException, ConcurrencyException,
InvalidArgumentException, ObjectNotFoundException, FilterNotValidException, OperationNotSupportedException, PermissionDeniedException
{
System.out.println(parameters);
try
{
org.alfresco.repo.cmis.ws.GetDocumentParentsResponse _return = null;
return _return;
}
catch (Exception ex)
{
ex.printStackTrace();
throw new java.lang.RuntimeException(ex);
}
// throw new RuntimeException("RuntimeException...");
// throw new ConcurrencyException("ConcurrencyException...");
// throw new InvalidArgumentException("InvalidArgumentException...");
// throw new ObjectNotFoundException("ObjectNotFoundException...");
// throw new FilterNotValidException("FilterNotValidException...");
// throw new OperationNotSupportedException("OperationNotSupportedException...");
// throw new PermissionDeniedException("PermissionDeniedException...");
}
public org.alfresco.repo.cmis.ws.GetChildrenResponse getChildren(GetChildren parameters) throws RuntimeException, ConcurrencyException, InvalidArgumentException,
FilterNotValidException, OperationNotSupportedException, FolderNotValidException, PermissionDeniedException
{
PropertyFilter propertyFilter = new PropertyFilter(parameters.getFilter());
NodeRef folderNodeRef = OIDUtils.OIDtoNodeRef(parameters.getFolderId());
assertExistFolder(folderNodeRef);
List<FileInfo> listing;
if (parameters.getType().equals(TypesOfObjectsEnum.DOCUMENTS))
{
listing = fileFolderService.listFiles(folderNodeRef);
}
else if (parameters.getType().equals(TypesOfObjectsEnum.FOLDERS))
{
listing = fileFolderService.listFolders(folderNodeRef);
}
else
{
listing = fileFolderService.list(folderNodeRef);
}
int maxItems = listing.size();
int skipCount = 0;
GetChildrenResponse response = new GetChildrenResponse();
// TODO: getChildren, support for BigIntegers, support for ResultSet
if (parameters.getSkipCount() != null)
{
BigInteger skipCountParam = parameters.getSkipCount();
skipCount = skipCountParam.max(BigInteger.valueOf(skipCount)).intValue();
}
if (parameters.getMaxItems() != null)
{
BigInteger maxItemsParam = parameters.getMaxItems();
maxItems = maxItemsParam.min(BigInteger.valueOf(maxItems)).intValue();
if (maxItems == 0)
{
maxItems = listing.size();
}
response.setHasMoreItems(maxItems < listing.size());
}
response.setDocumentAndFolderCollection(new DocumentAndFolderCollection());
List<DocumentOrFolderObjectType> resultListing = response.getDocumentAndFolderCollection().getObject();
for (int index = skipCount; index < listing.size() && maxItems > 0; ++index, --maxItems)
{
FileInfo currentFileInfo = listing.get(index);
DocumentOrFolderObjectType documentOrFolderObjectType = new DocumentOrFolderObjectType();
if (currentFileInfo.isFolder())
{
setFolderObjectTypeProperties(currentFileInfo.getNodeRef(), documentOrFolderObjectType, propertyFilter);
}
else
{
setDocumentObjectTypeProperties(currentFileInfo.getNodeRef(), documentOrFolderObjectType, propertyFilter);
}
resultListing.add(documentOrFolderObjectType);
}
return response;
}
/**
* Asserts "Folder with folderNodeRef exists"
*
* @param folderNodeRef node reference
* @throws FolderNotValidException folderNodeRef doesn't exist or folderNodeRef isn't for folder object
*/
private void assertExistFolder(NodeRef folderNodeRef) throws FolderNotValidException
{
if (folderNodeRef == null || nodeService.exists(folderNodeRef) == false || isFolderType(folderNodeRef) == false)
{
// TODO: error code
BasicFault basicFault = ExceptionUtils.createBasicFault(null, "OID for non-existent object or not folder object");
throw new FolderNotValidException("OID for non-existent object or not folder object", basicFault);
}
}
public org.alfresco.repo.cmis.ws.GetFolderParentResponse getFolderParent(GetFolderParent parameters) throws RuntimeException, ConcurrencyException, InvalidArgumentException,
FilterNotValidException, OperationNotSupportedException, FolderNotValidException, PermissionDeniedException
{
System.out.println(parameters);
try
{
org.alfresco.repo.cmis.ws.GetFolderParentResponse _return = null;
return _return;
}
catch (Exception ex)
{
ex.printStackTrace();
throw new java.lang.RuntimeException(ex);
}
// throw new RuntimeException("RuntimeException...");
// throw new ConcurrencyException("ConcurrencyException...");
// throw new InvalidArgumentException("InvalidArgumentException...");
// throw new FilterNotValidException("FilterNotValidException...");
// throw new OperationNotSupportedException("OperationNotSupportedException...");
// throw new FolderNotValidException("FolderNotValidException...");
// throw new PermissionDeniedException("PermissionDeniedException...");
}
public org.alfresco.repo.cmis.ws.GetUnfiledDocsResponse getUnfiledDocs(GetUnfiledDocs parameters) throws RuntimeException, ConcurrencyException, InvalidArgumentException,
FilterNotValidException, OperationNotSupportedException, PermissionDeniedException
{
System.out.println(parameters);
try
{
org.alfresco.repo.cmis.ws.GetUnfiledDocsResponse _return = null;
return _return;
}
catch (Exception ex)
{
ex.printStackTrace();
throw new java.lang.RuntimeException(ex);
}
// throw new RuntimeException("RuntimeException...");
// throw new ConcurrencyException("ConcurrencyException...");
// throw new InvalidArgumentException("InvalidArgumentException...");
// throw new FilterNotValidException("FilterNotValidException...");
// throw new OperationNotSupportedException("OperationNotSupportedException...");
// throw new PermissionDeniedException("PermissionDeniedException...");
}
}

View File

@@ -0,0 +1,459 @@
/*
* 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.ws;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.NodeRef;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* @author Dmitry Lazurkin
*/
@javax.jws.WebService(name = "ObjectServicePort", serviceName = "ObjectService", portName = "ObjectServicePort", targetNamespace = "http://www.cmis.org/ns/1.0", endpointInterface = "org.alfresco.repo.cmis.ws.ObjectServicePort")
public class DMObjectServicePort extends DMAbstractServicePort implements ObjectServicePort
{
private static final Log log = LogFactory.getLog("org.alfresco.repo.cmis.ws");
public org.alfresco.repo.cmis.ws.DeleteTreeResponse.FailedToDelete deleteTree(java.lang.String folderId, org.alfresco.repo.cmis.ws.DeleteWithMultiFilingEnum unfileMultiFiledDocuments,
java.lang.Boolean continueOnFailure) throws RuntimeException, ConcurrencyException, InvalidArgumentException, OperationNotSupportedException, FolderNotValidException,
PermissionDeniedException
{
System.out.println(folderId);
System.out.println(unfileMultiFiledDocuments);
System.out.println(continueOnFailure);
try
{
org.alfresco.repo.cmis.ws.DeleteTreeResponse.FailedToDelete _return = null;
return _return;
}
catch (Exception ex)
{
ex.printStackTrace();
throw new java.lang.RuntimeException(ex);
}
// throw new RuntimeException("RuntimeException...");
// throw new ConcurrencyException("ConcurrencyException...");
// throw new InvalidArgumentException("InvalidArgumentException...");
// throw new OperationNotSupportedException("OperationNotSupportedException...");
// throw new FolderNotValidException("FolderNotValidException...");
// throw new PermissionDeniedException("PermissionDeniedException...");
}
public org.alfresco.repo.cmis.ws.GetAllowableActionsResponse.AllowableActionCollection getAllowableActions(java.lang.String objectId, java.lang.String asUser)
throws RuntimeException, ConcurrencyException, InvalidArgumentException, ObjectNotFoundException, OperationNotSupportedException, PermissionDeniedException
{
System.out.println(objectId);
System.out.println(asUser);
try
{
org.alfresco.repo.cmis.ws.GetAllowableActionsResponse.AllowableActionCollection _return = null;
return _return;
}
catch (Exception ex)
{
ex.printStackTrace();
throw new java.lang.RuntimeException(ex);
}
// throw new RuntimeException("RuntimeException...");
// throw new ConcurrencyException("ConcurrencyException...");
// throw new InvalidArgumentException("InvalidArgumentException...");
// throw new ObjectNotFoundException("ObjectNotFoundException...");
// throw new OperationNotSupportedException("OperationNotSupportedException...");
// throw new PermissionDeniedException("PermissionDeniedException...");
}
public void moveObject(java.lang.String objectId, java.lang.String folderId, java.lang.String sourceFolderId) throws RuntimeException, ConcurrencyException,
InvalidArgumentException, ObjectNotFoundException, NotInFolderException, ConstraintViolationException, OperationNotSupportedException, FolderNotValidException,
PermissionDeniedException
{
System.out.println(objectId);
System.out.println(folderId);
System.out.println(sourceFolderId);
try
{
}
catch (Exception ex)
{
ex.printStackTrace();
throw new java.lang.RuntimeException(ex);
}
// throw new RuntimeException("RuntimeException...");
// throw new ConcurrencyException("ConcurrencyException...");
// throw new InvalidArgumentException("InvalidArgumentException...");
// throw new ObjectNotFoundException("ObjectNotFoundException...");
// throw new NotInFolderException("NotInFolderException...");
// throw new ConstraintViolationException("ConstraintViolationException...");
// throw new OperationNotSupportedException("OperationNotSupportedException...");
// throw new FolderNotValidException("FolderNotValidException...");
// throw new PermissionDeniedException("PermissionDeniedException...");
}
public void deleteContentStream(java.lang.String documentId) throws RuntimeException, ConcurrencyException, InvalidArgumentException, ObjectNotFoundException,
StorageException, ConstraintViolationException, OperationNotSupportedException, StreamNotSupportedException, PermissionDeniedException
{
System.out.println(documentId);
try
{
}
catch (Exception ex)
{
ex.printStackTrace();
throw new java.lang.RuntimeException(ex);
}
// throw new RuntimeException("RuntimeException...");
// throw new ConcurrencyException("ConcurrencyException...");
// throw new InvalidArgumentException("InvalidArgumentException...");
// throw new ObjectNotFoundException("ObjectNotFoundException...");
// throw new StorageException("StorageException...");
// throw new ConstraintViolationException("ConstraintViolationException...");
// throw new OperationNotSupportedException("OperationNotSupportedException...");
// throw new StreamNotSupportedException("StreamNotSupportedException...");
// throw new PermissionDeniedException("PermissionDeniedException...");
}
public java.lang.String createFolder(java.lang.String typeId, org.alfresco.repo.cmis.ws.FolderObjectType propertyCollection, java.lang.String folderId) throws RuntimeException,
ConcurrencyException, InvalidArgumentException, TypeNotFoundException, ConstraintViolationException, OperationNotSupportedException, FolderNotValidException,
PermissionDeniedException
{
System.out.println(typeId);
System.out.println(propertyCollection);
System.out.println(folderId);
try
{
java.lang.String _return = "";
return _return;
}
catch (Exception ex)
{
ex.printStackTrace();
throw new java.lang.RuntimeException(ex);
}
// throw new RuntimeException("RuntimeException...");
// throw new ConcurrencyException("ConcurrencyException...");
// throw new InvalidArgumentException("InvalidArgumentException...");
// throw new TypeNotFoundException("TypeNotFoundException...");
// throw new ConstraintViolationException("ConstraintViolationException...");
// throw new OperationNotSupportedException("OperationNotSupportedException...");
// throw new FolderNotValidException("FolderNotValidException...");
// throw new PermissionDeniedException("PermissionDeniedException...");
}
public void updateProperties(java.lang.String objectId, java.lang.String changeToken, org.alfresco.repo.cmis.ws.DocumentFolderOrRelationshipObjectType object)
throws RuntimeException, ConcurrencyException, InvalidArgumentException, ObjectNotFoundException, OperationNotSupportedException, PermissionDeniedException
{
System.out.println(objectId);
System.out.println(changeToken);
System.out.println(object);
try
{
}
catch (Exception ex)
{
ex.printStackTrace();
throw new java.lang.RuntimeException(ex);
}
// throw new RuntimeException("RuntimeException...");
// throw new ConcurrencyException("ConcurrencyException...");
// throw new InvalidArgumentException("InvalidArgumentException...");
// throw new ObjectNotFoundException("ObjectNotFoundException...");
// throw new OperationNotSupportedException("OperationNotSupportedException...");
// throw new PermissionDeniedException("PermissionDeniedException...");
}
public org.alfresco.repo.cmis.ws.CreateDocumentResponse createDocument(CreateDocument parameters) throws RuntimeException, ConcurrencyException, InvalidArgumentException,
TypeNotFoundException, StorageException, ConstraintViolationException, OperationNotSupportedException, StreamNotSupportedException, FolderNotValidException,
PermissionDeniedException
{
System.out.println(parameters);
try
{
org.alfresco.repo.cmis.ws.CreateDocumentResponse _return = null;
return _return;
}
catch (Exception ex)
{
ex.printStackTrace();
throw new java.lang.RuntimeException(ex);
}
// throw new RuntimeException("RuntimeException...");
// throw new ConcurrencyException("ConcurrencyException...");
// throw new InvalidArgumentException("InvalidArgumentException...");
// throw new TypeNotFoundException("TypeNotFoundException...");
// throw new StorageException("StorageException...");
// throw new ConstraintViolationException("ConstraintViolationException...");
// throw new OperationNotSupportedException("OperationNotSupportedException...");
// throw new StreamNotSupportedException("StreamNotSupportedException...");
// throw new FolderNotValidException("FolderNotValidException...");
// throw new PermissionDeniedException("PermissionDeniedException...");
}
public byte[] getContentStream(java.lang.String documentId, java.math.BigInteger offset, java.math.BigInteger length) throws RuntimeException, ConcurrencyException,
InvalidArgumentException, ObjectNotFoundException, StorageException, OperationNotSupportedException, StreamNotSupportedException, OffsetException,
PermissionDeniedException
{
if (offset == null)
{
offset = new BigInteger("0");
}
if (length == null)
{
length = new BigInteger("-1");
}
NodeRef nodeRef = OIDUtils.OIDtoNodeRef(documentId);
if (nodeRef == null)
{
// TODO: error code
BasicFault basicFault = ExceptionUtils.createBasicFault(null, "Invalid object ID");
throw new InvalidArgumentException("Invalid object ID", basicFault);
}
if (!nodeService.exists(nodeRef))
{
// TODO: error code
BasicFault basicFault = ExceptionUtils.createBasicFault(null, "Invalid document OID");
throw new ObjectNotFoundException("Invalid document OID", basicFault);
}
if (isFolderType(nodeRef))
{
// TODO: error code
BasicFault basicFault = ExceptionUtils.createBasicFault(null, "Stream not supported for this type of node");
throw new StreamNotSupportedException("Stream not supported for this type of node", basicFault);
}
ContentReader contentReader = null;
if (nodeService.getType(nodeRef).equals(ContentModel.TYPE_LINK))
{
NodeRef destRef = (NodeRef) nodeService.getProperty(nodeRef, ContentModel.PROP_LINK_DESTINATION);
if (nodeService.exists(destRef))
{
contentReader = fileFolderService.getReader(destRef);
}
else
{
throw new ObjectNotFoundException("Missing link destination");
}
}
else
{
contentReader = fileFolderService.getReader(nodeRef);
}
if (length.intValue() == -1)
{
length = new BigInteger(String.valueOf(contentReader.getSize()));
}
byte[] buffer = new byte[length.intValue()];
try
{
InputStream inputStream = contentReader.getContentInputStream();
inputStream.skip(offset.intValue());
int resultLength = inputStream.read(buffer, 0, length.intValue());
if (resultLength == -1)
{
return new byte[0];
}
byte[] result = new byte[resultLength];
for (int i = 0; i < resultLength; i++)
{
result[i] = buffer[i];
}
return result;
}
catch (IndexOutOfBoundsException e)
{
// TODO: error code
BasicFault basicFault = ExceptionUtils.createBasicFault(null, e.getMessage());
throw new OffsetException(e.getMessage(), basicFault, e);
}
catch (IOException e)
{
// TODO: error code
BasicFault basicFault = ExceptionUtils.createBasicFault(null, e.getMessage());
throw new RuntimeException(e.getMessage(), basicFault, e);
}
}
public java.lang.String createRelationship(java.lang.String typeId, org.alfresco.repo.cmis.ws.RelationshipObjectType propertyCollection, java.lang.String sourceObjectId,
java.lang.String targetObjectId) throws RuntimeException, ConcurrencyException, InvalidArgumentException, TypeNotFoundException, ObjectNotFoundException,
ConstraintViolationException, OperationNotSupportedException, PermissionDeniedException
{
System.out.println(typeId);
System.out.println(propertyCollection);
System.out.println(sourceObjectId);
System.out.println(targetObjectId);
try
{
java.lang.String _return = "";
return _return;
}
catch (Exception ex)
{
ex.printStackTrace();
throw new java.lang.RuntimeException(ex);
}
// throw new RuntimeException("RuntimeException...");
// throw new ConcurrencyException("ConcurrencyException...");
// throw new InvalidArgumentException("InvalidArgumentException...");
// throw new TypeNotFoundException("TypeNotFoundException...");
// throw new ObjectNotFoundException("ObjectNotFoundException...");
// throw new ConstraintViolationException("ConstraintViolationException...");
// throw new OperationNotSupportedException("OperationNotSupportedException...");
// throw new PermissionDeniedException("PermissionDeniedException...");
}
public org.alfresco.repo.cmis.ws.SetContentStreamResponse setContentStream(SetContentStream parameters) throws RuntimeException, ConcurrencyException, InvalidArgumentException,
AlreadyExistsException, ObjectNotFoundException, StorageException, ConstraintViolationException, OperationNotSupportedException, StreamNotSupportedException,
PermissionDeniedException
{
System.out.println(parameters);
try
{
org.alfresco.repo.cmis.ws.SetContentStreamResponse _return = null;
return _return;
}
catch (Exception ex)
{
ex.printStackTrace();
throw new java.lang.RuntimeException(ex);
}
// throw new RuntimeException("RuntimeException...");
// throw new ConcurrencyException("ConcurrencyException...");
// throw new InvalidArgumentException("InvalidArgumentException...");
// throw new AlreadyExistsException("AlreadyExistsException...");
// throw new ObjectNotFoundException("ObjectNotFoundException...");
// throw new StorageException("StorageException...");
// throw new ConstraintViolationException("ConstraintViolationException...");
// throw new OperationNotSupportedException("OperationNotSupportedException...");
// throw new StreamNotSupportedException("StreamNotSupportedException...");
// throw new PermissionDeniedException("PermissionDeniedException...");
}
public void deleteObject(java.lang.String objectId) throws RuntimeException, ConcurrencyException, InvalidArgumentException, ObjectNotFoundException,
ConstraintViolationException, OperationNotSupportedException, PermissionDeniedException
{
System.out.println(objectId);
try
{
}
catch (Exception ex)
{
ex.printStackTrace();
throw new java.lang.RuntimeException(ex);
}
// throw new RuntimeException("RuntimeException...");
// throw new ConcurrencyException("ConcurrencyException...");
// throw new InvalidArgumentException("InvalidArgumentException...");
// throw new ObjectNotFoundException("ObjectNotFoundException...");
// throw new ConstraintViolationException("ConstraintViolationException...");
// throw new OperationNotSupportedException("OperationNotSupportedException...");
// throw new PermissionDeniedException("PermissionDeniedException...");
}
public org.alfresco.repo.cmis.ws.GetPropertiesResponse getProperties(GetProperties parameters) throws RuntimeException, ConcurrencyException, InvalidArgumentException,
ObjectNotFoundException, FilterNotValidException, OperationNotSupportedException, PermissionDeniedException
{
GetPropertiesResponse response = new GetPropertiesResponse();
response.setObject(new DocumentFolderOrRelationshipObjectType());
PropertyFilter propertyFilter = new PropertyFilter(parameters.getFilter());
NodeRef nodeRef = OIDUtils.OIDtoNodeRef(parameters.getObjectId());
if (nodeRef != null)
{
if (nodeService.exists(nodeRef) == false)
{
// TODO: error code
BasicFault basicFault = ExceptionUtils.createBasicFault(null, "Object not found");
throw new ObjectNotFoundException("Object not found", basicFault);
}
if (isFolderType(nodeRef))
{
setFolderObjectTypeProperties(nodeRef, response.getObject(), propertyFilter);
}
else
{
VersionEnum neededVersion = parameters.getReturnVersion();
if (neededVersion != null)
{
if (neededVersion.equals(VersionEnum.LATEST))
{
nodeRef = getLatestVersionNodeRef(nodeRef, false);
}
else if (neededVersion.equals(VersionEnum.LATEST_MAJOR))
{
nodeRef = getLatestVersionNodeRef(nodeRef, true);
}
}
setDocumentObjectTypeProperties(nodeRef, response.getObject(), propertyFilter);
}
}
else
{
AssociationRef associationRef = OIDUtils.OIDtoAssocRef(parameters.getObjectId());
if (associationRef != null)
{
if (exists(associationRef) == false)
{
// TODO: error code
BasicFault basicFault = ExceptionUtils.createBasicFault(null, "Object not found");
throw new ObjectNotFoundException("Object not found", basicFault);
}
setRelationshipObjectTypeProperties(associationRef, response.getObject(), propertyFilter);
}
else
{
// TODO: error code
BasicFault basicFault = ExceptionUtils.createBasicFault(null, "Invalid object ID");
throw new InvalidArgumentException("Invalid object ID", basicFault);
}
}
return response;
}
}

View File

@@ -0,0 +1,203 @@
/*
* 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.ws;
import java.util.List;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* @author Michael Shavnev
* @author Dmitry Lazurkin
*/
@javax.jws.WebService(name = "RepositoryServicePort", serviceName = "RepositoryService", portName = "RepositoryServicePort", targetNamespace = "http://www.cmis.org/ns/1.0", endpointInterface = "org.alfresco.repo.cmis.ws.RepositoryServicePort")
public class DMRepositoryServicePort extends DMAbstractServicePort implements RepositoryServicePort
{
private static final Log log = LogFactory.getLog("org.alfresco.repo.cmis.ws");
private String rootPath;
private NodeRef rootNodeRef;
public GetRootFolderResponse getRootFolder(GetRootFolder parameters) throws RuntimeException, ConcurrencyException, InvalidArgumentException, FilterNotValidException,
OperationNotSupportedException, PermissionDeniedException
{
PropertyFilter propertyFilter = new PropertyFilter(parameters.getFilter());
FolderObjectType folderObject = new FolderObjectType();
propertyFilter.disableProperty(CmisProperty.NAME);
propertyFilter.disableProperty(CmisProperty.PARENT);
setFolderObjectTypeProperties(getRootNodeRef(), folderObject, propertyFilter);
propertyFilter.enableProperty(CmisProperty.NAME);
propertyFilter.enableProperty(CmisProperty.PARENT);
if (propertyFilter.allow(CmisProperty.NAME))
{
folderObject.setName("CMIS_Root_Folder");
}
if (propertyFilter.allow(CmisProperty.PARENT))
{
folderObject.setParent(OIDUtils.toOID(rootNodeRef));
}
GetRootFolderResponse response = new GetRootFolderResponse();
response.setRootFolder(folderObject);
return response;
}
private NodeRef getRootNodeRef()
{
if (rootNodeRef == null)
{
int indexOfStoreDelim = rootPath.indexOf(StoreRef.URI_FILLER);
if (indexOfStoreDelim == -1)
{
throw new java.lang.RuntimeException("Bad path format, " + StoreRef.URI_FILLER + " not found");
}
indexOfStoreDelim += StoreRef.URI_FILLER.length();
int indexOfPathDelim = rootPath.indexOf("/", indexOfStoreDelim);
if (indexOfPathDelim == -1)
{
throw new java.lang.RuntimeException("Bad path format, / not found");
}
String storePath = rootPath.substring(0, indexOfPathDelim);
String rootPathInStore = rootPath.substring(indexOfPathDelim);
StoreRef storeRef = new StoreRef(storePath);
if (nodeService.exists(storeRef) == false)
{
throw new java.lang.RuntimeException("No store for path: " + storeRef);
}
NodeRef storeRootNodeRef = nodeService.getRootNode(storeRef);
if (rootPath.equals("/"))
{
rootNodeRef = storeRootNodeRef;
}
else
{
List<NodeRef> nodeRefs = searchService.selectNodes(storeRootNodeRef, rootPathInStore, null, namespaceService, false);
if (nodeRefs.size() > 1)
{
throw new java.lang.RuntimeException("Multiple possible roots for : \n" + " root path: " + rootPath + "\n" + " results: " + nodeRefs);
}
else if (nodeRefs.size() == 0)
{
throw new java.lang.RuntimeException("No root found for : \n" + " root path: " + rootPath);
}
else
{
rootNodeRef = nodeRefs.get(0);
}
}
}
return rootNodeRef;
}
public GetTypesResponse getTypes(GetTypes parameters) throws RuntimeException, ConcurrencyException, InvalidArgumentException, OperationNotSupportedException,
PermissionDeniedException
{
System.out.println(parameters);
try
{
org.alfresco.repo.cmis.ws.GetTypesResponse _return = null;
return _return;
}
catch (Exception ex)
{
ex.printStackTrace();
throw new java.lang.RuntimeException(ex);
}
// throw new RuntimeException("RuntimeException...");
// throw new ConcurrencyException("ConcurrencyException...");
// throw new InvalidArgumentException("InvalidArgumentException...");
// throw new OperationNotSupportedException("OperationNotSupportedException...");
// throw new PermissionDeniedException("PermissionDeniedException...");
}
public void getTypeDefinition(java.lang.String typeId, java.lang.Boolean includeInheritedProperties, javax.xml.ws.Holder<ObjectTypeDefinitionType> type,
javax.xml.ws.Holder<java.lang.Boolean> canCreateInstances) throws RuntimeException, ConcurrencyException, InvalidArgumentException, TypeNotFoundException,
OperationNotSupportedException, PermissionDeniedException
{
System.out.println(typeId);
System.out.println(includeInheritedProperties);
try
{
org.alfresco.repo.cmis.ws.ObjectTypeDefinitionType typeValue = null;
type.value = typeValue;
java.lang.Boolean canCreateInstancesValue = null;
canCreateInstances.value = canCreateInstancesValue;
}
catch (Exception ex)
{
ex.printStackTrace();
throw new java.lang.RuntimeException(ex);
}
// throw new RuntimeException("RuntimeException...");
// throw new ConcurrencyException("ConcurrencyException...");
// throw new InvalidArgumentException("InvalidArgumentException...");
// throw new TypeNotFoundException("TypeNotFoundException...");
// throw new OperationNotSupportedException("OperationNotSupportedException...");
// throw new PermissionDeniedException("PermissionDeniedException...");
}
public RepositoryInfoType getRepositoryInfo() throws RuntimeException, ConcurrencyException, InvalidArgumentException, OperationNotSupportedException,
PermissionDeniedException
{
try
{
org.alfresco.repo.cmis.ws.RepositoryInfoType _return = null;
return _return;
}
catch (Exception ex)
{
ex.printStackTrace();
throw new java.lang.RuntimeException(ex);
}
// throw new RuntimeException("RuntimeException...");
// throw new ConcurrencyException("ConcurrencyException...");
// throw new InvalidArgumentException("InvalidArgumentException...");
// throw new OperationNotSupportedException("OperationNotSupportedException...");
// throw new PermissionDeniedException("PermissionDeniedException...");
}
public void setRootPath(String rootPath)
{
this.rootPath = rootPath;
}
}

View File

@@ -0,0 +1,64 @@
/*
* 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.ws;
import org.alfresco.repo.security.permissions.AccessDeniedException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.aop.ThrowsAdvice;
/**
* @author Dmitry Lazurkin
*
*/
public class DMServicePortThrowsAdvice implements ThrowsAdvice
{
private static final Log log = LogFactory.getLog("org.alfresco.cmis.ws");
public void afterThrowing(AccessDeniedException e) throws PermissionDeniedException
{
if (log.isInfoEnabled())
{
log.info(e);
}
// TODO: error code
BasicFault basicFault = ExceptionUtils.createBasicFault(null, "Access denied");
throw new PermissionDeniedException("Access denied", basicFault, e);
}
public void afterThrowing(java.lang.RuntimeException e) throws RuntimeException
{
if (log.isErrorEnabled())
{
log.error(e);
}
// TODO: error code
BasicFault basicFault = ExceptionUtils.createBasicFault(null, "Runtime error");
throw new RuntimeException("Runtime error", basicFault, e);
}
}

View File

@@ -0,0 +1,55 @@
/*
* 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.ws;
import java.math.BigInteger;
/**
* Utils for working with cmis exceptions
*
* @author Dmitry Lazurkin
*
*/
public class ExceptionUtils
{
/**
* Creates basic fault instance
*
* @param errorCode error code
* @param errorMessage error message
* @return basic fault instance
*/
public static BasicFault createBasicFault(BigInteger errorCode, String errorMessage)
{
BasicFault basicFault = new BasicFault();
basicFault.setErrorCode(errorCode);
basicFault.setErrorMessage(errorMessage);
return basicFault;
}
}

View File

@@ -0,0 +1,52 @@
/*
* 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.ws;
/**
* OID types enumeration
*
* @author Dmitry Lazurkin
*
*/
public enum OIDType
{
DOCUMENT_FOLDER,
RELATIONSHIP;
public static OIDType getOIDType(String oid)
{
try
{
return OIDType.values()[Integer.parseInt(oid.substring(0, 1))];
}
catch (Exception e)
{
// expected if OID string is bad
}
return null;
}
}

View File

@@ -0,0 +1,111 @@
/*
* 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.ws;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* @author Dmitry Lazurkin
*
*/
public class OIDUtils
{
/**
* Returns OID for node reference
*
* @param nodeRef node reference
* @return OID
*/
public static String toOID(NodeRef nodeRef)
{
return OIDType.DOCUMENT_FOLDER.ordinal() + nodeRef.toString();
}
/**
* Returns OID for association reference
*
* @param assocRef association reference
* @return OID
*/
public static String toOID(AssociationRef assocRef)
{
return OIDType.RELATIONSHIP.ordinal() + assocRef.toString();
}
/**
* Returns node reference for OID
*
* @param oid OID
* @return node reference
*/
public static NodeRef OIDtoNodeRef(String oid)
{
NodeRef nodeRef = null;
OIDType oidType = OIDType.getOIDType(oid);
if (oidType != null && oidType.equals(OIDType.DOCUMENT_FOLDER))
{
try
{
nodeRef = new NodeRef(oid.substring(1));
}
catch (Exception e)
{
// expected if OID string is bad
}
}
return nodeRef;
}
/**
* Returns association reference for OID
*
* @param oid OID
* @return association reference
*/
public static AssociationRef OIDtoAssocRef(String oid)
{
AssociationRef assocRef = null;
OIDType oidType = OIDType.getOIDType(oid);
if (oidType != null && oidType.equals(OIDType.RELATIONSHIP))
{
try
{
assocRef = new AssociationRef(oid.substring(1));
}
catch (Exception e)
{
// expected if oid string is bad
}
}
return assocRef;
}
}

View File

@@ -0,0 +1,97 @@
/*
* 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.ws;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;
/**
* Property filter class
*
* @author Dmitry Lazurkin
*
*/
public class PropertyFilter
{
private static final Pattern PROPERTY_FILTER_REGEX = Pattern.compile("^(\\*)|([\\p{Upper}\\p{Digit}_]+(,[\\p{Upper}\\p{Digit}_]+)*)$");
private Set<String> properties;
private EnumSet<CmisProperty> disabledProperties = EnumSet.noneOf(CmisProperty.class);
/**
* Constructor
*
* @param filter filter string
* @throws FilterNotValidException if filter string isn't valid
*/
public PropertyFilter(String filter) throws FilterNotValidException
{
if (filter != null && filter.equals("") == false)
{
if (PROPERTY_FILTER_REGEX.matcher(filter).matches() == false)
{
throw new FilterNotValidException(filter, ExceptionUtils.createBasicFault(null, "Filter isn't valid"));
}
if (filter.equals("*") == false)
{
properties = new HashSet<String>(Arrays.asList(filter.split(",")));
}
}
}
/**
* @param property property
* @return if property is allow by filter then returns true else false
*/
public boolean allow(CmisProperty property)
{
return disabledProperties.contains(property) == false && (properties == null || properties.contains(property.name()));
}
/**
* Disables property
*
* @param property property
*/
public void disableProperty(CmisProperty property)
{
disabledProperties.add(property);
}
/**
* Enables property
*
* @param property property
*/
public void enableProperty(CmisProperty property)
{
disabledProperties.remove(property);
}
}

View File

@@ -27,6 +27,7 @@ package org.alfresco.repo.web.scripts.content;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.Arrays;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
@@ -87,10 +88,12 @@ public class ContentGet extends StreamContent
// convert web script URL to node reference in Repository
String match = req.getServiceMatch().getPath();
String[] matchParts = match.split("/");
String extensionPath = req.getExtensionPath();
String[] extParts = extensionPath == null ? new String[1] : extensionPath.split("/");
String[] path = new String[extParts.length -1];
System.arraycopy(extParts, 1, path, 0, extParts.length -1);
Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
String[] id = templateVars.get("id").split("/");
String[] path = new String[id.length + 2];
path[0] = templateVars.get("store_type");
path[1] = templateVars.get("store_id");
System.arraycopy(id, 0, path, 2, id.length);
NodeRef nodeRef = repository.findNodeRef(matchParts[2], path);
if (nodeRef == null)
{
@@ -99,7 +102,7 @@ public class ContentGet extends StreamContent
// determine content property
QName propertyQName = ContentModel.PROP_CONTENT;
String contentPart = extParts[0];
String contentPart = templateVars.get("property");
if (contentPart.length() > 0 && contentPart.charAt(0) == ';')
{
if (contentPart.length() < 2)

View File

@@ -423,7 +423,6 @@ public class StreamContent extends AbstractWebScript
reader.setEncoding("UTF-8");
streamContentImpl(req, res, reader, attach, this.resouceFileModifiedDate);
}
/**
@@ -439,7 +438,6 @@ public class StreamContent extends AbstractWebScript
protected void streamContentImpl(WebScriptRequest req, WebScriptResponse res, ContentReader reader, boolean attach, Date modified)
throws IOException
{
HttpServletRequest httpReq = ((WebScriptServletRequest)req).getHttpServletRequest();
HttpServletResponse httpRes = ((WebScriptServletResponse)res).getHttpServletResponse();