Merging BRANCHES/DEV/CMIS_10 to HEAD (phase 2 - currently up-to-date with branch):

18717: SAIL-166: Refactor CMIS to use shared services and resolve objectIds and error codes consistently
   18731: SAIL-169: CMIS REST versioning compliance
   18732: Fix failing change log test.
   18768: Add displayName and queryName attributes to rendered properties (in CMIS AtomPub binding).
   18775: Fix exception reporting when retrieving items that do not exist (in CMIS AtomPub binding).
   18784: Fix CMIS REST change logging
   18785: SAIL-174: CMIS Relationship lookup by association ID
   18812: SAIL-183: Support orderBy argument for getChildren and getCheckedOutDocs in CMIS REST and Web Service bindings
   18823: CMIS WS Bindings were moved to 1.0 cd07 schema.
   18838: Update to latest Chemistry TCK.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@18847 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2010-02-25 15:02:44 +00:00
parent fc172da640
commit bd2f2441fd
65 changed files with 2477 additions and 2782 deletions

View File

@@ -0,0 +1,66 @@
/*
* 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.reference;
import org.alfresco.cmis.CMISRepositoryReference;
import org.alfresco.cmis.CMISServices;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* AVM Path Reference
*
* @author davidc
*/
public class AVMPathReference extends ObjectPathReference
{
/**
* Construct
*
* @param cmisServices
* @param repo
* @param path
*/
public AVMPathReference(CMISServices cmisServices, CMISRepositoryReference repo, String path)
{
super(cmisServices, repo, path);
}
/*
* (non-Javadoc)
* @see org.alfresco.cmis.reference.ObjectPathReference#getNodeRef()
*/
public NodeRef getNodeRef()
{
return cmisServices.getNode("avmpath", reference);
}
@Override
public String toString()
{
return "AVMPathReference[storeRef=" + repo.getStoreRef() + ",path=" + path + "]";
}
}

View File

@@ -0,0 +1,62 @@
/*
* Copyright (C) 2005-2010 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 received 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.reference;
import org.alfresco.cmis.CMISObjectReference;
import org.alfresco.cmis.CMISRepositoryReference;
import org.alfresco.cmis.CMISServices;
/**
* Abstract Object Reference
*
* @author davidc
*/
public abstract class AbstractObjectReference implements CMISObjectReference
{
protected CMISServices cmisServices;
protected CMISRepositoryReference repo;
/**
* Construct
*
* @param cmisServices
* @param repo
*/
public AbstractObjectReference(CMISServices cmisServices, CMISRepositoryReference repo)
{
this.cmisServices = cmisServices;
this.repo = repo;
}
/*
* (non-Javadoc)
* @see org.alfresco.cmis.CMISObjectReference#getRepositoryReference()
*/
public CMISRepositoryReference getRepositoryReference()
{
return repo;
}
}

View File

@@ -0,0 +1,56 @@
/*
* 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.reference;
import org.alfresco.cmis.CMISRepositoryReference;
import org.alfresco.cmis.CMISServices;
/**
* Abstract Repository Reference
*
* @author davidc
*/
public abstract class AbstractRepositoryReference implements CMISRepositoryReference
{
protected CMISServices cmisServices;
/**
* Construct
*
* @param cmisServices
*/
public AbstractRepositoryReference(CMISServices cmisServices)
{
this.cmisServices = cmisServices;
}
@Override
public String toString()
{
return getStoreRef().toString();
}
}

View File

@@ -0,0 +1,93 @@
/*
* Copyright (C) 2005-2010 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 received 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.reference;
import org.alfresco.cmis.CMISRelationshipReference;
import org.alfresco.cmis.CMISRepositoryReference;
import org.alfresco.cmis.CMISServiceException;
import org.alfresco.cmis.CMISServices;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.StoreRef;
import org.springframework.extensions.webscripts.WebScriptException;
/**
* Association ID relationship reference. An association ID can be resolved to an {@link AssociationRef}.
*
* @author dward
*/
public class AssociationIdRelationshipReference implements CMISRelationshipReference
{
private CMISServices cmisServices;
private String assocId;
/**
* Construct
*
* @param cmisServices
* @param assocId
*/
public AssociationIdRelationshipReference(CMISServices cmisServices, String assocId)
{
this.cmisServices = cmisServices;
this.assocId = assocId;
}
/*
* (non-Javadoc)
* @see org.alfresco.cmis.CMISRelationshipReference#getAssocRef()
*/
public AssociationRef getAssocRef()
{
try
{
return cmisServices.getReadableObject(CMISServices.ASSOC_ID_PREFIX + this.assocId, AssociationRef.class);
}
catch (CMISServiceException e)
{
throw new WebScriptException(e.getStatusCode(), e.getMessage(), e);
}
}
/*
* (non-Javadoc)
* @see org.alfresco.cmis.CMISObjectReference#getRepositoryReference()
*/
public CMISRepositoryReference getRepositoryReference()
{
return new AbstractRepositoryReference(cmisServices)
{
public StoreRef getStoreRef()
{
return getAssocRef().getSourceRef().getStoreRef();
}
};
}
@Override
public String toString()
{
return "AssociationIdRelationshipReference[assocId=" + this.assocId + "]";
}
}

View File

@@ -0,0 +1,57 @@
/*
* 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.reference;
import org.alfresco.cmis.CMISServices;
import org.alfresco.service.cmr.repository.StoreRef;
/**
* Default Repository Reference
*
* @author davidc
*/
public class DefaultRepositoryReference extends AbstractRepositoryReference
{
/**
* Construct
*
* @param cmisServices
*/
public DefaultRepositoryReference(CMISServices cmisServices)
{
super(cmisServices);
}
/*
* (non-Javadoc)
* @see org.alfresco.cmis.CMISRepositoryReference#getStoreRef()
*/
public StoreRef getStoreRef()
{
return cmisServices.getDefaultRootStoreRef();
}
}

View File

@@ -0,0 +1,87 @@
/*
* Copyright (C) 2005-2010 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 received 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.reference;
import org.alfresco.cmis.CMISRepositoryReference;
import org.alfresco.cmis.CMISServices;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef;
/**
* GUID Object Reference. This class decodes node 'paths' generated by links.lib.atom.ftl. These are not the same as
* CMIS object IDs.
*
* @author davidc
*/
public class NodeIdReference extends AbstractObjectReference
{
private String id;
private String[] reference;
/**
* Construct
*
* @param cmisServices
* @param repo
* @param id
*/
public NodeIdReference(CMISServices cmisServices, CMISRepositoryReference repo, String id)
{
super(cmisServices, repo);
this.id = id;
StoreRef storeRef = repo.getStoreRef();
String[] idParts = this.id.split("/");
reference = new String[2 + idParts.length];
reference[0] = storeRef.getProtocol();
reference[1] = storeRef.getIdentifier();
System.arraycopy(idParts, 0, reference, 2, idParts.length);
}
/*
* (non-Javadoc)
* @see org.alfresco.cmis.CMISObjectReference#getNodeRef()
*/
public NodeRef getNodeRef()
{
return cmisServices.getNode("node", reference);
}
/**
* @return id
*/
public String getId()
{
return id;
}
@Override
public String toString()
{
return "NodeIdReference[storeRef=" + repo.getStoreRef() + ",id=" + id + "]";
}
}

View File

@@ -0,0 +1,94 @@
/*
* Copyright (C) 2005-2010 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 received 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.reference;
import org.alfresco.cmis.CMISObjectReference;
import org.alfresco.cmis.CMISRepositoryReference;
import org.alfresco.cmis.CMISServiceException;
import org.alfresco.cmis.CMISServices;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef;
import org.springframework.extensions.webscripts.WebScriptException;
/**
* CMIS Object ID reference. A CMIS object ID encapsulates both a store and a node and identifies a specific version.
*
* @author dward
*/
public class ObjectIdReference implements CMISObjectReference
{
private CMISServices cmisServices;
private String objectId;
/**
* Construct
*
* @param cmisServices
* @param storeRef
*/
public ObjectIdReference(CMISServices cmisServices, String objectId)
{
this.cmisServices = cmisServices;
this.objectId = objectId;
}
/*
* (non-Javadoc)
* @see org.alfresco.cmis.CMISObjectReference#getNodeRef()
*/
public NodeRef getNodeRef()
{
try
{
return cmisServices.getReadableObject(this.objectId, NodeRef.class);
}
catch (CMISServiceException e)
{
throw new WebScriptException(e.getStatusCode(), e.getMessage(), e);
}
}
/*
* (non-Javadoc)
* @see org.alfresco.cmis.CMISObjectReference#getRepositoryReference()
*/
public CMISRepositoryReference getRepositoryReference()
{
return new AbstractRepositoryReference(cmisServices)
{
public StoreRef getStoreRef()
{
return getNodeRef().getStoreRef();
}
};
}
@Override
public String toString()
{
return "ObjectIdReference[objectId=" + this.objectId + "]";
}
}

View File

@@ -0,0 +1,88 @@
/*
* Copyright (C) 2005-2010 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 received 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.reference;
import org.alfresco.cmis.CMISRepositoryReference;
import org.alfresco.cmis.CMISServices;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef;
/**
* Path Object Reference
*
* @author davidc
*/
public class ObjectPathReference extends AbstractObjectReference
{
protected String path;
protected String[] reference;
/**
* Construct
*
* @param cmisServices
* @param repo
* @param path
*/
public ObjectPathReference(CMISServices cmisServices, CMISRepositoryReference repo, String path)
{
super(cmisServices, repo);
this.path = path.startsWith("/") ? path : "/" + path;
this.path = (!cmisServices.getDefaultRootPath().equals("/")) ? cmisServices.getDefaultRootPath() + this.path : this.path;
String[] splitPath = this.path.split("/");
String[] pathSegments = new String[splitPath.length -1];
System.arraycopy(splitPath, 1, pathSegments, 0, splitPath.length -1);
this.reference = new String[2 + pathSegments.length];
StoreRef storeRef = repo.getStoreRef();
reference[0] = storeRef.getProtocol();
reference[1] = storeRef.getIdentifier();
System.arraycopy(pathSegments, 0, reference, 2, pathSegments.length);
}
/*
* (non-Javadoc)
* @see org.alfresco.cmis.CMISObjectReference#getNodeRef()
*/
public NodeRef getNodeRef()
{
return cmisServices.getNode("path", reference);
}
/**
* @return path
*/
public String getPath()
{
return path;
}
@Override
public String toString()
{
return "ObjectPathReference[storeRef=" + repo.getStoreRef() + ",path=" + path + "]";
}
}

View File

@@ -0,0 +1,145 @@
/*
* Copyright (C) 2005-2010 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.reference;
import java.util.Map;
import org.alfresco.cmis.CMISDictionaryService;
import org.alfresco.cmis.CMISObjectReference;
import org.alfresco.cmis.CMISRelationshipReference;
import org.alfresco.cmis.CMISRepositoryReference;
import org.alfresco.cmis.CMISServices;
/**
* Reference Factory
*
* @author davidc
*/
public class ReferenceFactory
{
private CMISServices cmisService;
/**
* @param cmisService
*/
public void setCMISService(CMISServices cmisService)
{
this.cmisService = cmisService;
}
/**
* Create CMIS Repository Reference from URL segments
*
* @param args url arguments
* @param templateArgs url template arguments
* @return Repository Reference (or null, in case of bad url)
*/
public CMISRepositoryReference createRepoReferenceFromUrl(Map<String, String> args, Map<String, String> templateArgs)
{
String store_type = templateArgs.get("store_type");
String store_id = templateArgs.get("store_id");
if (store_type != null && store_id != null)
{
return new StoreRepositoryReference(cmisService, store_type + ":" + store_id);
}
String store = templateArgs.get("store");
if (store != null)
{
return new StoreRepositoryReference(cmisService, store);
}
// TODO: repository id
// String repoId = templateArgs.get("repo");
// else if (repoId != null)
// {
// }
return new DefaultRepositoryReference(cmisService);
}
/**
* Create CMIS Object Reference from URL segments
*
* @param args url arguments
* @param templateArgs url template arguments
* @return Repository Reference (or null, in case of bad url)
*/
public CMISObjectReference createObjectReferenceFromUrl(Map<String, String> args, Map<String, String> templateArgs)
{
// Despite the name of this argument, it is included in the "Object by ID" URL template and actually accepts a
// value in object ID format (including version label suffix) so should be parsed as an object ID rather than a
// NodeRef
String objectId = args.get("noderef");
if (objectId != null)
{
return new ObjectIdReference(cmisService, objectId);
}
CMISRepositoryReference repo = createRepoReferenceFromUrl(args, templateArgs);
String id = templateArgs.get("id");
if (id != null)
{
return new NodeIdReference(cmisService, repo, id);
}
String path = templateArgs.get("path");
if (path == null)
{
path = args.get("path");
}
if (path != null)
{
return new ObjectPathReference(cmisService, repo, path);
}
String avmPath = templateArgs.get("avmpath");
if (avmPath != null)
{
return new AVMPathReference(cmisService, repo, avmPath);
}
return null;
}
/**
* Create CMIS Relationship Reference from URL segments
*
* @param args url arguments
* @param templateArgs url template arguments
* @return Repository Reference (or null, in case of bad url)
*/
public CMISRelationshipReference createRelationshipReferenceFromUrl(Map<String, String> args, Map<String, String> templateArgs)
{
String assocId = templateArgs.get("assoc_id");
if (assocId != null)
{
return new AssociationIdRelationshipReference(cmisService, assocId);
}
return null;
}
}

View File

@@ -0,0 +1,93 @@
/*
* 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.reference;
import org.alfresco.cmis.CMISRelationshipReference;
import org.alfresco.cmis.CMISRepositoryReference;
import org.alfresco.cmis.CMISServices;
import org.alfresco.cmis.CMISTypeDefinition;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* Source Node / Rel Type / Target Node Relationship Reference
*
* @author davidc
*/
public class SourceTypeTargetRelationshipReference implements CMISRelationshipReference
{
protected CMISServices cmisServices;
protected StoreRepositoryReference repo;
protected CMISTypeDefinition type;
protected NodeRef source;
protected NodeRef target;
/**
* Construct
*
* @param cmisServices
* @param type
* @param srcStore
* @param srcId
* @param tgtStore
* @param tgtId
*/
public SourceTypeTargetRelationshipReference(CMISServices cmisServices, CMISTypeDefinition type, String srcStore, String srcId, String tgtStore, String tgtId)
{
this.cmisServices = cmisServices;
this.repo = new StoreRepositoryReference(cmisServices, srcStore);
this.type = type;
this.source = new NodeRef(repo.getStoreRef(), srcId);
StoreRepositoryReference tgtStoreRef = new StoreRepositoryReference(cmisServices, tgtStore);
this.target = new NodeRef(tgtStoreRef.getStoreRef(), tgtId);
}
/*
* (non-Javadoc)
* @see org.alfresco.cmis.CMISRelationshipReference#getRepositoryReference()
*/
public CMISRepositoryReference getRepositoryReference()
{
return repo;
}
/*
* (non-Javadoc)
* @see org.alfresco.cmis.CMISRelationshipReference#getAssocRef()
*/
public AssociationRef getAssocRef()
{
return cmisServices.getRelationship(type, source, target);
}
@Override
public String toString()
{
return "SourceTypeTargetRelationshipReference[type=" + type.getTypeId().getId() + ",source=" + source.toString() + ",target=" + target.toString() + "]";
}
}

View File

@@ -0,0 +1,86 @@
/*
* 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.reference;
import org.alfresco.cmis.CMISServices;
import org.alfresco.service.cmr.repository.StoreRef;
/**
* Store Ref Repository Reference
*
* @author davidc
*/
public class StoreRepositoryReference extends AbstractRepositoryReference
{
private StoreRef storeRef;
/**
* Construct
*
* @param cmisServices
* @param storeRef
*/
public StoreRepositoryReference(CMISServices cmisServices, StoreRef storeRef)
{
super(cmisServices);
this.storeRef = storeRef;
}
/**
* Construct
*
* @param cmisServices
* @param store accept storeType://storeId, storeType:storeId, storeId
*/
public StoreRepositoryReference(CMISServices cmisServices, String store)
{
super(cmisServices);
if (store.indexOf(StoreRef.URI_FILLER) != -1)
{
storeRef = new StoreRef(store);
}
else if (store.indexOf(':') != -1)
{
String[] storeParts = store.split(":");
storeRef = new StoreRef(storeParts[0], storeParts[1]);
}
else
{
storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, store);
}
}
/*
* (non-Javadoc)
* @see org.alfresco.cmis.CMISRepositoryReference#getStoreRef()
*/
public StoreRef getStoreRef()
{
return storeRef;
}
}