mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)
75551: Reverse Merge HEAD-BUG-FIX (5.0/Cloud) 74584: Reverse merged HEAD-BUG-FIX (5.0/Cloud) << Requires more work on the EOL branch >> 74416: Merged EOL to HEAD-BUG-FIX (5.0/Cloud) 74309: ACE-2010 EOL Legacy CMIS Inputs (2) in 5.0 - Start replacing references to the original CMIS code with Alfresco and chemistry Open CMIS classes 74342: ACE-2010 EOL Legacy CMIS Inputs (2) in 5.0 - Switch ServiceRegistry over to using Open CMIS classes 74406: ACE-2010 EOL Legacy CMIS Inputs (2) in 5.0 << Compiles and starts Share without error >> - Removed Original CMIS classes from the repository, remote-api and thor - Moved the CMIS.DictionaryBootstrap bean into opencmis-context.xml before removing cmis-api-context.xml - Some code was left under: root\projects\remote-api\source\java\org\alfresco\repo\cmis ...........................................................\client ...........................................................\ws ...........................................................\rest ................................test-java\org\alfresco\repo\cmis ................................................................\ws ................................................................\rest Will have to see if it should be be removed too, or if it is common with OpenCMIS 74407: ACE-2010 EOL Legally CMIS Inputs (2) in 5.0 - Removed left over code under: root\projects\remote-api\source\java\org\alfresco\repo\cmis ................................test-java\org\alfresco\repo\cmis - Removed an authentication URL test in QuickShareRestApiTest which was failing in the same way as the tests above. - Removed CXFAuthenticationSystemTest which appears to be using the original CMIS 74465: Merged EOL (5.0/Cloud) to HEAD-BUG-FIX (5.0/Cloud) 74464: ACE-2010 EOL Legacey CMIS Inputs (2) in 5.0 - New failure in QuickShareRestApiTest - CXFAuthenticationSystemTest (deleted) was still referenced in MiscSystemTestSuite git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@77489 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,77 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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 AbstractObjectReference
|
||||
{
|
||||
protected String path;
|
||||
protected String[] reference;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param cmisServices
|
||||
* @param repo
|
||||
* @param path (note: AVM store relative path)
|
||||
*/
|
||||
public AVMPathReference(CMISServices cmisServices, CMISRepositoryReference repo, String path)
|
||||
{
|
||||
super(cmisServices, repo);
|
||||
String[] splitPath = path.split("/");
|
||||
this.reference = new String[1 + splitPath.length];
|
||||
String avmStoreName = repo.getStoreRef().getIdentifier();
|
||||
reference[0] = avmStoreName;
|
||||
this.path = avmStoreName + ":/" + path;
|
||||
System.arraycopy(splitPath, 0, reference, 1, splitPath.length);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.cmis.reference.ObjectPathReference#getNodeRef()
|
||||
*/
|
||||
public NodeRef getNodeRef()
|
||||
{
|
||||
return cmisServices.getNode("avmpath", reference);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AVM path (eg. avmstorename:/my/path/to/a/file)
|
||||
*/
|
||||
public String getPath()
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "AVMPathReference[avmpath=" + path + "]";
|
||||
}
|
||||
|
||||
}
|
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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(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 + "]";
|
||||
}
|
||||
}
|
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
@@ -1,81 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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 + "]";
|
||||
}
|
||||
|
||||
}
|
@@ -1,81 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* Node Path Object Reference
|
||||
*
|
||||
* Note: This path is from the root of the store
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public class NodePathReference extends AbstractObjectReference
|
||||
{
|
||||
protected String path;
|
||||
protected String[] reference;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param cmisServices
|
||||
* @param repo
|
||||
* @param path
|
||||
*/
|
||||
public NodePathReference(CMISServices cmisServices, CMISRepositoryReference repo, String path)
|
||||
{
|
||||
super(cmisServices, repo);
|
||||
this.path = path;
|
||||
String[] splitPath = this.path.split("/");
|
||||
this.reference = new String[2 + splitPath.length];
|
||||
StoreRef storeRef = repo.getStoreRef();
|
||||
reference[0] = storeRef.getProtocol();
|
||||
reference[1] = storeRef.getIdentifier();
|
||||
System.arraycopy(splitPath, 0, reference, 2, splitPath.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 "NodePathReference[storeRef=" + repo.getStoreRef() + ",path=" + path + "]";
|
||||
}
|
||||
|
||||
}
|
@@ -1,88 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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 + "]";
|
||||
}
|
||||
|
||||
}
|
@@ -1,83 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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
|
||||
*
|
||||
* Note: This path is relative to the CMIS root path
|
||||
*
|
||||
* @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 = cmisServices.getDefaultRootPath() + 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 + "]";
|
||||
}
|
||||
|
||||
}
|
@@ -1,163 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.cmis.reference;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.cmis.CMISObjectReference;
|
||||
import org.alfresco.cmis.CMISRelationshipReference;
|
||||
import org.alfresco.cmis.CMISRepositoryReference;
|
||||
import org.alfresco.cmis.CMISServices;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
String avmPath = templateArgs.get("avmpath");
|
||||
if (avmPath != null && store_id != null)
|
||||
{
|
||||
return new StoreRepositoryReference(cmisService, StoreRef.PROTOCOL_AVM + ":" + store_id);
|
||||
}
|
||||
|
||||
// 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 nodepath = templateArgs.get("nodepath");
|
||||
if (nodepath == null)
|
||||
{
|
||||
nodepath = args.get("nodepath");
|
||||
}
|
||||
if (nodepath != null)
|
||||
{
|
||||
return new NodePathReference(cmisService, repo, nodepath);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
assocId = templateArgs.get("id");
|
||||
}
|
||||
if (assocId == null)
|
||||
{
|
||||
assocId = args.get("noderef");
|
||||
}
|
||||
if (assocId != null)
|
||||
{
|
||||
return new AssociationIdRelationshipReference(cmisService, assocId);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@@ -1,97 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.cmis.rest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.cmis.CMISAccessControlService;
|
||||
import org.alfresco.opencmis.CMISAccessControlFormatEnum;
|
||||
import org.alfresco.repo.template.TemplateNode;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
import freemarker.ext.beans.BeanModel;
|
||||
import freemarker.template.TemplateMethodModelEx;
|
||||
import freemarker.template.TemplateModelException;
|
||||
import freemarker.template.TemplateScalarModel;
|
||||
|
||||
/**
|
||||
* Custom FreeMarker Template language method.
|
||||
* <p>
|
||||
* Gets the ACL of a TemplateNode
|
||||
* <p>
|
||||
* Usage: cmisacl(TemplateNode node)
|
||||
* cmisacl(TemplateNode node, String format)
|
||||
*
|
||||
* @author dward
|
||||
*/
|
||||
public class CMISAclMethod implements TemplateMethodModelEx
|
||||
{
|
||||
private CMISAccessControlService accessControlService;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*/
|
||||
public CMISAclMethod(CMISAccessControlService accessControlService)
|
||||
{
|
||||
this.accessControlService = accessControlService;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object exec(List args) throws TemplateModelException
|
||||
{
|
||||
NodeRef nodeRef = null;
|
||||
CMISAccessControlFormatEnum format = CMISAccessControlFormatEnum.REPOSITORY_SPECIFIC_PERMISSIONS;
|
||||
try
|
||||
{
|
||||
int i = 0;
|
||||
// extract node ref
|
||||
Object arg = args.get(i++);
|
||||
if (arg instanceof BeanModel)
|
||||
{
|
||||
Object wrapped = ((BeanModel) arg).getWrappedObject();
|
||||
if (wrapped != null)
|
||||
{
|
||||
if (wrapped instanceof TemplateNode)
|
||||
{
|
||||
nodeRef = ((TemplateNode) wrapped).getNodeRef();
|
||||
}
|
||||
}
|
||||
}
|
||||
// extract format if specified
|
||||
arg = args.get(i++);
|
||||
if (arg instanceof TemplateScalarModel)
|
||||
{
|
||||
format = CMISAccessControlFormatEnum.FACTORY.toEnum(((TemplateScalarModel) arg).getAsString());
|
||||
}
|
||||
}
|
||||
catch (IndexOutOfBoundsException e)
|
||||
{
|
||||
// Ignore optional arguments
|
||||
}
|
||||
|
||||
// query renditions
|
||||
if (nodeRef != null)
|
||||
{
|
||||
return accessControlService.getAcl(nodeRef, format);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@@ -1,88 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.cmis.rest;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.cmis.CMISServices;
|
||||
import org.alfresco.cmis.CMISTypeDefinition;
|
||||
import org.alfresco.repo.template.TemplateNode;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
import freemarker.ext.beans.BeanModel;
|
||||
import freemarker.template.TemplateMethodModelEx;
|
||||
import freemarker.template.TemplateModelException;
|
||||
|
||||
/**
|
||||
* Custom FreeMarker Template language method.
|
||||
* <p>
|
||||
* Gets the type definitions of a TemplateNode's aspects
|
||||
* <p>
|
||||
* Usage: cmisaspects(TemplateNode node)
|
||||
*
|
||||
* @author dward
|
||||
*/
|
||||
public class CMISAspectsMethod implements TemplateMethodModelEx
|
||||
{
|
||||
private CMISServices cmisService;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*/
|
||||
public CMISAspectsMethod(CMISServices cmisService)
|
||||
{
|
||||
this.cmisService = cmisService;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object exec(List args) throws TemplateModelException
|
||||
{
|
||||
NodeRef nodeRef = null;
|
||||
try
|
||||
{
|
||||
int i = 0;
|
||||
// extract node ref
|
||||
Object arg = args.get(i++);
|
||||
if (arg instanceof BeanModel)
|
||||
{
|
||||
Object wrapped = ((BeanModel) arg).getWrappedObject();
|
||||
if (wrapped != null)
|
||||
{
|
||||
if (wrapped instanceof TemplateNode)
|
||||
{
|
||||
nodeRef = ((TemplateNode) wrapped).getNodeRef();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IndexOutOfBoundsException e)
|
||||
{
|
||||
// Ignore optional arguments
|
||||
}
|
||||
|
||||
// query aspects
|
||||
if (nodeRef != null)
|
||||
{
|
||||
return cmisService.getAspects(nodeRef);
|
||||
}
|
||||
|
||||
return Collections.<CMISTypeDefinition> emptySet();
|
||||
}
|
||||
}
|
@@ -1,124 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.cmis.rest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.cmis.CMISRelationshipDirectionEnum;
|
||||
import org.alfresco.cmis.CMISServiceException;
|
||||
import org.alfresco.cmis.CMISServices;
|
||||
import org.alfresco.repo.template.TemplateNode;
|
||||
import org.alfresco.repo.web.scripts.RepositoryImageResolver;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.TemplateImageResolver;
|
||||
import org.alfresco.service.cmr.repository.TemplateValueConverter;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
|
||||
import freemarker.ext.beans.BeanModel;
|
||||
import freemarker.template.TemplateMethodModelEx;
|
||||
import freemarker.template.TemplateModelException;
|
||||
import freemarker.template.TemplateScalarModel;
|
||||
|
||||
/**
|
||||
* Custom FreeMarker Template language method.
|
||||
* <p>
|
||||
* Gets the associations of a TemplateNode
|
||||
* <p>
|
||||
* Usage: cmisassocs(TemplateNode node, String direction)
|
||||
*
|
||||
* @author dward
|
||||
*/
|
||||
public class CMISAssocsMethod implements TemplateMethodModelEx
|
||||
{
|
||||
private CMISServices cmisService;
|
||||
private TemplateImageResolver imageResolver;
|
||||
private TemplateValueConverter templateValueConverter;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*/
|
||||
public CMISAssocsMethod(CMISServices cmisService, RepositoryImageResolver imageResolver,
|
||||
TemplateValueConverter templateValueConverter)
|
||||
{
|
||||
this.cmisService = cmisService;
|
||||
this.imageResolver = imageResolver.getImageResolver();
|
||||
this.templateValueConverter = templateValueConverter;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object exec(List args) throws TemplateModelException
|
||||
{
|
||||
NodeRef nodeRef = null;
|
||||
CMISRelationshipDirectionEnum direction = CMISRelationshipDirectionEnum.SOURCE;
|
||||
try
|
||||
{
|
||||
int i = 0;
|
||||
// extract node ref
|
||||
Object arg = args.get(i++);
|
||||
if (arg instanceof BeanModel)
|
||||
{
|
||||
Object wrapped = ((BeanModel) arg).getWrappedObject();
|
||||
if (wrapped != null)
|
||||
{
|
||||
if (wrapped instanceof TemplateNode)
|
||||
{
|
||||
nodeRef = ((TemplateNode) wrapped).getNodeRef();
|
||||
}
|
||||
}
|
||||
}
|
||||
// extract direction, if specified
|
||||
arg = args.get(i++);
|
||||
if (arg instanceof TemplateScalarModel)
|
||||
{
|
||||
String strDirection = ((TemplateScalarModel)arg).getAsString();
|
||||
if (strDirection.equalsIgnoreCase(("both")))
|
||||
{
|
||||
direction = CMISRelationshipDirectionEnum.EITHER;
|
||||
}
|
||||
else
|
||||
{
|
||||
direction = CMISRelationshipDirectionEnum.FACTORY.fromLabel(strDirection);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IndexOutOfBoundsException e)
|
||||
{
|
||||
// Ignore optional arguments
|
||||
}
|
||||
|
||||
// query relationships
|
||||
if (nodeRef != null)
|
||||
{
|
||||
AssociationRef[] assocs;
|
||||
try
|
||||
{
|
||||
assocs = cmisService.getRelationships(nodeRef, null, true, direction);
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw new WebScriptException(e.getStatusCode(), e.getMessage(), e);
|
||||
}
|
||||
return templateValueConverter.convertValue(assocs, imageResolver);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@@ -1,119 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.cmis.rest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.cmis.CMISInvalidArgumentException;
|
||||
import org.alfresco.cmis.CMISServices;
|
||||
import org.alfresco.cmis.CMISTypesFilterEnum;
|
||||
import org.alfresco.repo.template.TemplateNode;
|
||||
import org.alfresco.repo.web.scripts.RepositoryImageResolver;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.TemplateImageResolver;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
|
||||
import freemarker.ext.beans.BeanModel;
|
||||
import freemarker.template.TemplateMethodModelEx;
|
||||
import freemarker.template.TemplateModelException;
|
||||
import freemarker.template.TemplateScalarModel;
|
||||
|
||||
/**
|
||||
* Custom FreeMarker Template language method.
|
||||
* <p>
|
||||
* Lists the (CMIS) children of a TemplateNode
|
||||
* <p>
|
||||
* Usage: cmischildren(TemplateNode node)
|
||||
* cmischildren(TemplateNode node, String typesFilter)
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public class CMISChildrenMethod implements TemplateMethodModelEx
|
||||
{
|
||||
private CMISServices cmisService;
|
||||
private ServiceRegistry serviceRegistry;
|
||||
private TemplateImageResolver imageResolver;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*/
|
||||
public CMISChildrenMethod(CMISServices cmisService, ServiceRegistry serviceRegistry, RepositoryImageResolver imageResolver)
|
||||
{
|
||||
this.cmisService = cmisService;
|
||||
this.serviceRegistry = serviceRegistry;
|
||||
this.imageResolver = imageResolver.getImageResolver();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object exec(List args) throws TemplateModelException
|
||||
{
|
||||
TemplateNode[] children = null;
|
||||
|
||||
if (args.size() > 0)
|
||||
{
|
||||
Object arg0 = args.get(0);
|
||||
if (arg0 instanceof BeanModel)
|
||||
{
|
||||
// extract node ref
|
||||
Object wrapped = ((BeanModel)arg0).getWrappedObject();
|
||||
if (wrapped != null)
|
||||
{
|
||||
if (wrapped instanceof TemplateNode)
|
||||
{
|
||||
NodeRef nodeRef = ((TemplateNode)wrapped).getNodeRef();
|
||||
CMISTypesFilterEnum typesFilter = CMISTypesFilterEnum.ANY;
|
||||
if (args.size() > 1)
|
||||
{
|
||||
// extract types filter, if specified
|
||||
Object arg1 = args.get(1);
|
||||
if (arg1 instanceof TemplateScalarModel)
|
||||
{
|
||||
String typesFilterStr = ((TemplateScalarModel)arg1).getAsString();
|
||||
if (typesFilterStr != null && typesFilterStr.length() > 0)
|
||||
{
|
||||
typesFilter = (CMISTypesFilterEnum)CMISTypesFilterEnum.FACTORY.toEnum(typesFilterStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// query children
|
||||
NodeRef[] childNodeRefs;
|
||||
try
|
||||
{
|
||||
childNodeRefs = cmisService.getChildren(nodeRef, typesFilter, null);
|
||||
}
|
||||
catch (CMISInvalidArgumentException e)
|
||||
{
|
||||
throw new WebScriptException(e.getStatusCode(), e.getMessage(), e);
|
||||
}
|
||||
children = new TemplateNode[childNodeRefs.length];
|
||||
for (int i = 0; i < childNodeRefs.length; i++)
|
||||
{
|
||||
children[i] = new TemplateNode(childNodeRefs[i], serviceRegistry, imageResolver);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return children;
|
||||
}
|
||||
|
||||
}
|
@@ -1,139 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.cmis.rest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.cmis.CMISServiceException;
|
||||
import org.alfresco.cmis.CMISServices;
|
||||
import org.alfresco.repo.template.TemplateAssociation;
|
||||
import org.alfresco.repo.template.TemplateNode;
|
||||
import org.alfresco.repo.web.scripts.RepositoryImageResolver;
|
||||
import org.alfresco.service.cmr.repository.TemplateImageResolver;
|
||||
import org.alfresco.service.cmr.repository.TemplateValueConverter;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
|
||||
import freemarker.ext.beans.BeanModel;
|
||||
import freemarker.ext.beans.BeansWrapper;
|
||||
import freemarker.template.TemplateBooleanModel;
|
||||
import freemarker.template.TemplateMethodModelEx;
|
||||
import freemarker.template.TemplateModel;
|
||||
import freemarker.template.TemplateModelException;
|
||||
import freemarker.template.TemplateScalarModel;
|
||||
|
||||
/**
|
||||
* Custom FreeMarker Template language method.
|
||||
* <p>
|
||||
* Retrieve the CMIS property value for an Alfresco node and optionally dereferences it as an objectId.
|
||||
* <p>
|
||||
* Usage: cmisproperty(TemplateNode node, String propertyName)
|
||||
* cmisproperty(TemplateNode node, String propertyName, Boolean asObject)
|
||||
* @author davidc
|
||||
* @author dward
|
||||
*/
|
||||
public class CMISPropertyValueMethod implements TemplateMethodModelEx
|
||||
{
|
||||
/**
|
||||
* NULL value marker
|
||||
*/
|
||||
public static class NULL
|
||||
{
|
||||
};
|
||||
|
||||
public static TemplateModel IS_NULL = new BeanModel(new NULL(), BeansWrapper.getDefaultInstance());
|
||||
|
||||
private CMISServices cmisService;
|
||||
private TemplateImageResolver imageResolver;
|
||||
private TemplateValueConverter templateValueConverter;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*/
|
||||
public CMISPropertyValueMethod(CMISServices cmisService, RepositoryImageResolver imageResolver,
|
||||
TemplateValueConverter templateValueConverter)
|
||||
{
|
||||
this.cmisService = cmisService;
|
||||
this.imageResolver = imageResolver.getImageResolver();
|
||||
this.templateValueConverter = templateValueConverter;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object exec(List args) throws TemplateModelException
|
||||
{
|
||||
Object wrapped = null;
|
||||
String propertyName = null;
|
||||
boolean asObject = false;
|
||||
try
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
// extract object
|
||||
Object arg = args.get(i++);
|
||||
if (arg instanceof BeanModel)
|
||||
{
|
||||
wrapped = ((BeanModel) arg).getWrappedObject();
|
||||
}
|
||||
|
||||
// extract property name
|
||||
arg = args.get(i++);
|
||||
if (arg instanceof TemplateScalarModel)
|
||||
{
|
||||
propertyName = ((TemplateScalarModel) arg).getAsString();
|
||||
}
|
||||
|
||||
// extract asObject flag
|
||||
arg = args.get(i++);
|
||||
if (arg instanceof TemplateBooleanModel)
|
||||
{
|
||||
asObject = ((TemplateBooleanModel) arg).getAsBoolean();
|
||||
}
|
||||
}
|
||||
catch (IndexOutOfBoundsException e)
|
||||
{
|
||||
// Ignore optional arguments
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Object result = null;
|
||||
if (wrapped != null && wrapped instanceof TemplateNode)
|
||||
{
|
||||
// retrieve property value from node, allowing aspect properties
|
||||
result = cmisService.getProperty(((TemplateNode) wrapped).getNodeRef(), null, propertyName);
|
||||
}
|
||||
else if (wrapped != null && wrapped instanceof TemplateAssociation)
|
||||
{
|
||||
// retrieve property value from association
|
||||
result = cmisService.getProperty(((TemplateAssociation) wrapped).getAssociationRef(), propertyName);
|
||||
}
|
||||
if (asObject && result instanceof String)
|
||||
{
|
||||
// convert result to an object if required
|
||||
result = cmisService.getReadableObject((String) result, Object.class);
|
||||
}
|
||||
return result == null ? IS_NULL : templateValueConverter.convertValue(result, imageResolver);
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw new WebScriptException(e.getStatusCode(), e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.cmis.rest;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.cmis.CMISResultSet;
|
||||
import org.springframework.extensions.webscripts.Cache;
|
||||
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
|
||||
|
||||
/**
|
||||
* Base Web Script Implementation that ensures query result sets are closed
|
||||
*/
|
||||
public class CMISQueryWebScript extends DeclarativeWebScript
|
||||
{
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeFinallyImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
protected void executeFinallyImpl(WebScriptRequest req, Status status, Cache cache, Map<String, Object> model)
|
||||
{
|
||||
Object object = model.get("resultset");
|
||||
if (object != null && object instanceof CMISResultSet)
|
||||
{
|
||||
CMISResultSet resultSet = (CMISResultSet)object;
|
||||
resultSet.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -1,116 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.cmis.rest;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.cmis.CMISFilterNotValidException;
|
||||
import org.alfresco.cmis.CMISServices;
|
||||
import org.alfresco.repo.template.TemplateNode;
|
||||
import org.alfresco.repo.web.scripts.RepositoryImageResolver;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.TemplateImageResolver;
|
||||
import org.alfresco.service.cmr.repository.TemplateValueConverter;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
|
||||
import freemarker.ext.beans.BeanModel;
|
||||
import freemarker.template.TemplateMethodModelEx;
|
||||
import freemarker.template.TemplateModelException;
|
||||
import freemarker.template.TemplateScalarModel;
|
||||
|
||||
/**
|
||||
* Custom FreeMarker Template language method.
|
||||
* <p>
|
||||
* Gets the renditions of a TemplateNode
|
||||
* <p>
|
||||
* Usage: cmisrenditions(TemplateNode node)
|
||||
* cmisrenditions(TemplateNode node, String renditionFilter)
|
||||
*
|
||||
* @author dward
|
||||
*/
|
||||
public class CMISRenditionsMethod implements TemplateMethodModelEx
|
||||
{
|
||||
private CMISServices cmisService;
|
||||
private TemplateImageResolver imageResolver;
|
||||
private TemplateValueConverter templateValueConverter;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*/
|
||||
public CMISRenditionsMethod(CMISServices cmisService, RepositoryImageResolver imageResolver,
|
||||
TemplateValueConverter templateValueConverter)
|
||||
{
|
||||
this.cmisService = cmisService;
|
||||
this.imageResolver = imageResolver.getImageResolver();
|
||||
this.templateValueConverter = templateValueConverter;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object exec(List args) throws TemplateModelException
|
||||
{
|
||||
NodeRef nodeRef = null;
|
||||
String renditionFilter = null;
|
||||
try
|
||||
{
|
||||
int i = 0;
|
||||
// extract node ref
|
||||
Object arg = args.get(i++);
|
||||
if (arg instanceof BeanModel)
|
||||
{
|
||||
Object wrapped = ((BeanModel) arg).getWrappedObject();
|
||||
if (wrapped != null)
|
||||
{
|
||||
if (wrapped instanceof TemplateNode)
|
||||
{
|
||||
nodeRef = ((TemplateNode) wrapped).getNodeRef();
|
||||
}
|
||||
}
|
||||
}
|
||||
// extract rendition filter, if specified
|
||||
arg = args.get(i++);
|
||||
if (arg instanceof TemplateScalarModel)
|
||||
{
|
||||
renditionFilter = ((TemplateScalarModel) arg).getAsString();
|
||||
}
|
||||
}
|
||||
catch (IndexOutOfBoundsException e)
|
||||
{
|
||||
// Ignore optional arguments
|
||||
}
|
||||
|
||||
// query renditions
|
||||
if (nodeRef != null)
|
||||
{
|
||||
Map<String, Object> renditions;
|
||||
try
|
||||
{
|
||||
renditions = cmisService.getRenditions(nodeRef, renditionFilter);
|
||||
}
|
||||
catch (CMISFilterNotValidException e)
|
||||
{
|
||||
throw new WebScriptException(e.getStatusCode(), e.getMessage(), e);
|
||||
}
|
||||
return templateValueConverter.convertValue(renditions, imageResolver);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@@ -1,96 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.cmis.rest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.cmis.CMISResultSet;
|
||||
import org.alfresco.repo.web.scripts.RepositoryImageResolver;
|
||||
import org.alfresco.repo.web.util.paging.Cursor;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.TemplateImageResolver;
|
||||
|
||||
import freemarker.ext.beans.BeanModel;
|
||||
import freemarker.template.TemplateMethodModelEx;
|
||||
import freemarker.template.TemplateModelException;
|
||||
|
||||
/**
|
||||
* Custom FreeMarker Template language method.
|
||||
* <p>
|
||||
* Creates a CMIS result set that builds TemplateNode on iteration
|
||||
* <p>
|
||||
* Usage: cmisresultset(CMISResultSet resultset)
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public final class CMISResultSetMethod implements TemplateMethodModelEx
|
||||
{
|
||||
private ServiceRegistry serviceRegistry;
|
||||
private TemplateImageResolver imageResolver;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*/
|
||||
public CMISResultSetMethod(ServiceRegistry serviceRegistry, RepositoryImageResolver imageResolver)
|
||||
{
|
||||
this.serviceRegistry = serviceRegistry;
|
||||
this.imageResolver = imageResolver.getImageResolver();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see freemarker.template.TemplateMethodModel#exec(java.util.List)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object exec(List args) throws TemplateModelException
|
||||
{
|
||||
CMISTemplateResultSet resultSet = null;
|
||||
|
||||
if (args.size() > 0)
|
||||
{
|
||||
Object arg0 = args.get(0);
|
||||
if (arg0 instanceof BeanModel)
|
||||
{
|
||||
// extract cmis result set
|
||||
Object wrapped = ((BeanModel)arg0).getWrappedObject();
|
||||
if (wrapped != null)
|
||||
{
|
||||
if (wrapped instanceof CMISResultSet)
|
||||
{
|
||||
Cursor cursor = null;
|
||||
if (args.size() == 2)
|
||||
{
|
||||
Object arg1 = args.get(1);
|
||||
if (arg1 instanceof BeanModel)
|
||||
{
|
||||
Object wrapped1 = ((BeanModel)arg1).getWrappedObject();
|
||||
if (wrapped1 != null && wrapped1 instanceof Cursor)
|
||||
{
|
||||
cursor = (Cursor)wrapped1;
|
||||
}
|
||||
}
|
||||
}
|
||||
resultSet = new CMISTemplateResultSet((CMISResultSet)wrapped, cursor, serviceRegistry, imageResolver);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return resultSet;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -1,312 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.cmis.rest;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import org.alfresco.cmis.CMISPropertyDefinition;
|
||||
import org.alfresco.cmis.CMISResultSet;
|
||||
import org.alfresco.cmis.CMISResultSetColumn;
|
||||
import org.alfresco.cmis.CMISResultSetMetaData;
|
||||
import org.alfresco.cmis.CMISResultSetRow;
|
||||
import org.alfresco.repo.template.TemplateNode;
|
||||
import org.alfresco.repo.web.util.paging.Cursor;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.TemplateImageResolver;
|
||||
|
||||
import freemarker.core.Environment;
|
||||
import freemarker.template.SimpleCollection;
|
||||
import freemarker.template.TemplateCollectionModel;
|
||||
import freemarker.template.TemplateModelException;
|
||||
|
||||
|
||||
/**
|
||||
* CMIS Result Set for use in Freemarker
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public class CMISTemplateResultSet implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 2245418238171563934L;
|
||||
|
||||
private CMISResultSet resultSet;
|
||||
private Cursor cursor;
|
||||
private ServiceRegistry serviceRegistry;
|
||||
private TemplateImageResolver imageResolver;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param resultSet
|
||||
* @param serviceRegistry
|
||||
* @param imageResolver
|
||||
*/
|
||||
public CMISTemplateResultSet(CMISResultSet resultSet, Cursor cursor, ServiceRegistry serviceRegistry, TemplateImageResolver imageResolver)
|
||||
{
|
||||
this.resultSet = resultSet;
|
||||
this.cursor = cursor;
|
||||
this.serviceRegistry = serviceRegistry;
|
||||
this.imageResolver = imageResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return result set meta-data
|
||||
*/
|
||||
public CMISResultSetMetaData getMetaData()
|
||||
{
|
||||
return resultSet.getMetaData();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return result set length
|
||||
*/
|
||||
public int getLength()
|
||||
{
|
||||
return resultSet.getLength();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return start index within full result set
|
||||
*/
|
||||
public int getStart()
|
||||
{
|
||||
return resultSet.getStart();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return selectors
|
||||
*/
|
||||
public String[] getSelectors()
|
||||
{
|
||||
return resultSet.getMetaData().getSelectorNames();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return result set rows
|
||||
* @throws TemplateModelException
|
||||
*/
|
||||
public TemplateCollectionModel getRows()
|
||||
throws TemplateModelException
|
||||
{
|
||||
return new SimpleCollection(new TemplateIterator(resultSet.iterator()), Environment.getCurrentEnvironment().getObjectWrapper());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Result Set Iterator
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public class TemplateIterator implements Iterator<TemplateIterator.TemplateRow>
|
||||
{
|
||||
private Iterator<CMISResultSetRow> iter;
|
||||
private int idx = 0;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param iter
|
||||
*/
|
||||
public TemplateIterator(Iterator<CMISResultSetRow> iter)
|
||||
{
|
||||
this.iter = iter;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.util.Iterator#hasNext()
|
||||
*/
|
||||
public boolean hasNext()
|
||||
{
|
||||
return (cursor == null || idx < cursor.getRowCount()) && iter.hasNext();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.util.Iterator#next()
|
||||
*/
|
||||
public TemplateRow next()
|
||||
{
|
||||
if (!hasNext())
|
||||
{
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
try
|
||||
{
|
||||
return new TemplateRow(iter.next());
|
||||
}
|
||||
finally
|
||||
{
|
||||
idx++;
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.util.Iterator#remove()
|
||||
*/
|
||||
public void remove()
|
||||
{
|
||||
iter.remove();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Template Row
|
||||
*/
|
||||
public class TemplateRow
|
||||
{
|
||||
private CMISResultSetRow row;
|
||||
private Map<String, TemplateNode> nodes = null;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param row
|
||||
*/
|
||||
public TemplateRow(CMISResultSetRow row)
|
||||
{
|
||||
this.row = row;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a map of serializable column values with the column name as the key
|
||||
*/
|
||||
public Map<String, Serializable> getValues()
|
||||
{
|
||||
return row.getValues();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return nodes associated with row
|
||||
*/
|
||||
public Collection<TemplateNode> getNodes()
|
||||
{
|
||||
Map<String, TemplateNode> nodes = buildNodes();
|
||||
return nodes.size() == 0 ? null : nodes.values();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return node (if there is only a single node associated with the row), otherwise null
|
||||
*/
|
||||
public TemplateNode getNode()
|
||||
{
|
||||
try
|
||||
{
|
||||
NodeRef nodeRef = row.getNodeRef();
|
||||
return new TemplateNode(nodeRef, serviceRegistry, imageResolver);
|
||||
}
|
||||
catch(UnsupportedOperationException e) {}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a map of Template Nodes for the nodes associated with this row
|
||||
*
|
||||
* @return templates nodes indexed by selector
|
||||
*/
|
||||
private Map<String, TemplateNode> buildNodes()
|
||||
{
|
||||
if (nodes == null)
|
||||
{
|
||||
Map<String, NodeRef> nodeRefs = row.getNodeRefs();
|
||||
if (nodeRefs == null || nodeRefs.size() == 0)
|
||||
{
|
||||
nodes = Collections.emptyMap();
|
||||
}
|
||||
else
|
||||
{
|
||||
HashMap<String, TemplateNode> templateNodes = new HashMap<String, TemplateNode>();
|
||||
for (Map.Entry<String, NodeRef> entry : nodeRefs.entrySet())
|
||||
{
|
||||
templateNodes.put(entry.getKey(), new TemplateNode(entry.getValue(), serviceRegistry, imageResolver));
|
||||
}
|
||||
nodes = templateNodes;
|
||||
}
|
||||
}
|
||||
return nodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets column type for specified column name
|
||||
*
|
||||
* @param colName column name
|
||||
* @return column type
|
||||
*/
|
||||
public String getColumnType(String colName)
|
||||
{
|
||||
CMISResultSetColumn col = resultSet.getMetaData().getColumn(colName);
|
||||
return col == null ? null : col.getCMISDataType().getLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets property definition for specified column name
|
||||
*
|
||||
* @param colName column name
|
||||
* @return property definition (or null, if not applicable)
|
||||
*/
|
||||
public CMISPropertyDefinition getPropertyDefinition(String colName)
|
||||
{
|
||||
CMISResultSetColumn col = resultSet.getMetaData().getColumn(colName);
|
||||
return col == null ? null : col.getCMISPropertyDefinition();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets node for specified selector
|
||||
*
|
||||
* @param selector
|
||||
* @return template node
|
||||
*/
|
||||
public TemplateNode getSelectorNode(String selector)
|
||||
{
|
||||
return nodes.get(selector);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return overall score
|
||||
*/
|
||||
public float getScore()
|
||||
{
|
||||
return row.getScore();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a map of selector name to score
|
||||
*/
|
||||
public Float getSelectorScore(String selector)
|
||||
{
|
||||
return row.getScore(selector);
|
||||
}
|
||||
|
||||
/**
|
||||
* NOTE: If you want the overall position in paged results you have to add the skipCount for the result set
|
||||
*
|
||||
* @return row index
|
||||
*/
|
||||
public int getIndex()
|
||||
{
|
||||
return row.getIndex();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,106 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.cmis.rest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.cmis.CMISDictionaryService;
|
||||
import org.alfresco.cmis.CMISScope;
|
||||
import org.alfresco.cmis.CMISTypeDefinition;
|
||||
import org.alfresco.repo.template.TemplateAssociation;
|
||||
import org.alfresco.repo.template.TemplateNode;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
import freemarker.ext.beans.BeanModel;
|
||||
import freemarker.template.TemplateMethodModelEx;
|
||||
import freemarker.template.TemplateModelException;
|
||||
|
||||
/**
|
||||
* Custom FreeMarker Template language method.
|
||||
* <p>
|
||||
* Retrieve the CMIS Type Definition for an Alfresco node
|
||||
* <p>
|
||||
* Usage: cmistype(TemplateNode node)
|
||||
* cmistype(QName nodeType)
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public class CMISTypeDefinitionMethod implements TemplateMethodModelEx
|
||||
{
|
||||
private static CMISScope[] EMPTY_SCOPES = new CMISScope[] {};
|
||||
private CMISDictionaryService dictionaryService;
|
||||
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*/
|
||||
public CMISTypeDefinitionMethod(CMISDictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see freemarker.template.TemplateMethodModel#exec(java.util.List)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object exec(List args) throws TemplateModelException
|
||||
{
|
||||
CMISTypeDefinition result = null;
|
||||
|
||||
if (args.size() == 1)
|
||||
{
|
||||
Object arg0 = args.get(0);
|
||||
if (arg0 instanceof BeanModel)
|
||||
{
|
||||
// extract node type qname
|
||||
CMISScope[] matchingScopes = EMPTY_SCOPES;
|
||||
QName nodeType = null;
|
||||
Object wrapped = ((BeanModel)arg0).getWrappedObject();
|
||||
if (wrapped != null)
|
||||
{
|
||||
if (wrapped instanceof TemplateNode)
|
||||
{
|
||||
nodeType = ((TemplateNode)wrapped).getType();
|
||||
}
|
||||
else if (wrapped instanceof TemplateAssociation)
|
||||
{
|
||||
nodeType = ((TemplateAssociation)wrapped).getTypeQName();
|
||||
matchingScopes = new CMISScope[] { CMISScope.RELATIONSHIP };
|
||||
}
|
||||
else if (wrapped instanceof QName)
|
||||
{
|
||||
nodeType = (QName)wrapped;
|
||||
}
|
||||
else if (wrapped instanceof CMISTypeDefinition)
|
||||
{
|
||||
result = ((CMISTypeDefinition)wrapped).getBaseType();
|
||||
}
|
||||
}
|
||||
|
||||
// convert to CMIS type
|
||||
if (nodeType != null)
|
||||
{
|
||||
result = dictionaryService.findTypeForClass(nodeType, matchingScopes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
@@ -1,539 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.cmis.ws;
|
||||
|
||||
import java.beans.IntrospectionException;
|
||||
import java.beans.Introspector;
|
||||
import java.beans.PropertyDescriptor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.xml.bind.JAXBElement;
|
||||
|
||||
import org.alfresco.cmis.CMISAccessControlEntry;
|
||||
import org.alfresco.cmis.CMISAccessControlReport;
|
||||
import org.alfresco.cmis.CMISAccessControlService;
|
||||
import org.alfresco.cmis.CMISAclPropagationEnum;
|
||||
import org.alfresco.cmis.CMISActionEvaluator;
|
||||
import org.alfresco.cmis.CMISAllowedActionEnum;
|
||||
import org.alfresco.cmis.CMISChangeLogService;
|
||||
import org.alfresco.cmis.CMISDictionaryModel;
|
||||
import org.alfresco.cmis.CMISFilterNotValidException;
|
||||
import org.alfresco.cmis.CMISInvalidArgumentException;
|
||||
import org.alfresco.cmis.CMISQueryService;
|
||||
import org.alfresco.cmis.CMISRelationshipDirectionEnum;
|
||||
import org.alfresco.cmis.CMISRendition;
|
||||
import org.alfresco.cmis.CMISRenditionService;
|
||||
import org.alfresco.cmis.CMISServiceException;
|
||||
import org.alfresco.cmis.CMISServices;
|
||||
import org.alfresco.cmis.CMISTypeDefinition;
|
||||
import org.alfresco.cmis.PropertyFilter;
|
||||
import org.alfresco.cmis.acl.CMISAccessControlEntryImpl;
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.opencmis.CMISAccessControlFormatEnum;
|
||||
import org.alfresco.repo.cmis.ws.utils.ExceptionUtil;
|
||||
import org.alfresco.repo.cmis.ws.utils.PropertyUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.web.util.paging.Cursor;
|
||||
import org.alfresco.repo.web.util.paging.Page;
|
||||
import org.alfresco.repo.web.util.paging.Paging;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.cmr.security.AuthorityService;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.cmr.version.Version;
|
||||
import org.alfresco.service.descriptor.DescriptorService;
|
||||
|
||||
/**
|
||||
* Base class for all CMIS web services
|
||||
*
|
||||
* @author Michael Shavnev
|
||||
* @author Dmitry Lazurkin
|
||||
* @author Dmitry Velichkevich
|
||||
* @author Stanislav Sokolovsky
|
||||
*/
|
||||
public class DMAbstractServicePort
|
||||
{
|
||||
private static final String CMIS_USER = "cmis:user";
|
||||
|
||||
private static final String INVALID_REPOSITORY_ID_MESSAGE = "Invalid repository id";
|
||||
|
||||
private static final Map<EnumACLPropagation, CMISAclPropagationEnum> ACL_PROPAGATION_ENUM_MAPPGIN;
|
||||
protected static final Map<EnumIncludeRelationships, CMISRelationshipDirectionEnum> INCLUDE_RELATIONSHIPS_ENUM_MAPPING;
|
||||
private static final Map<CMISAllowedActionEnum, PropertyDescriptor> ALLOWED_ACTION_ENUM_MAPPING;
|
||||
static
|
||||
{
|
||||
ACL_PROPAGATION_ENUM_MAPPGIN = new HashMap<EnumACLPropagation, CMISAclPropagationEnum>(5);
|
||||
ACL_PROPAGATION_ENUM_MAPPGIN.put(EnumACLPropagation.OBJECTONLY, CMISAclPropagationEnum.OBJECT_ONLY);
|
||||
ACL_PROPAGATION_ENUM_MAPPGIN.put(EnumACLPropagation.PROPAGATE, CMISAclPropagationEnum.PROPAGATE);
|
||||
ACL_PROPAGATION_ENUM_MAPPGIN.put(EnumACLPropagation.REPOSITORYDETERMINED, CMISAclPropagationEnum.REPOSITORY_DETERMINED);
|
||||
|
||||
INCLUDE_RELATIONSHIPS_ENUM_MAPPING = new HashMap<EnumIncludeRelationships, CMISRelationshipDirectionEnum>(5);
|
||||
INCLUDE_RELATIONSHIPS_ENUM_MAPPING.put(EnumIncludeRelationships.SOURCE, CMISRelationshipDirectionEnum.SOURCE);
|
||||
INCLUDE_RELATIONSHIPS_ENUM_MAPPING.put(EnumIncludeRelationships.TARGET, CMISRelationshipDirectionEnum.TARGET);
|
||||
INCLUDE_RELATIONSHIPS_ENUM_MAPPING.put(EnumIncludeRelationships.BOTH, CMISRelationshipDirectionEnum.EITHER);
|
||||
|
||||
try
|
||||
{
|
||||
ALLOWED_ACTION_ENUM_MAPPING = new HashMap<CMISAllowedActionEnum, PropertyDescriptor>(97);
|
||||
for (PropertyDescriptor propertyDescriptor : Introspector.getBeanInfo(CmisAllowableActionsType.class, Object.class).getPropertyDescriptors())
|
||||
{
|
||||
String label = propertyDescriptor.getName();
|
||||
CMISAllowedActionEnum allowedActionEnum = CMISAllowedActionEnum.FACTORY.fromLabel(label);
|
||||
if (allowedActionEnum != null)
|
||||
{
|
||||
ALLOWED_ACTION_ENUM_MAPPING.put(allowedActionEnum, propertyDescriptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IntrospectionException e)
|
||||
{
|
||||
throw new ExceptionInInitializerError(e);
|
||||
}
|
||||
}
|
||||
|
||||
private Paging paging = new Paging();
|
||||
|
||||
protected ObjectFactory cmisObjectFactory = new ObjectFactory();
|
||||
protected CMISQueryService cmisQueryService;
|
||||
protected CMISServices cmisService;
|
||||
protected CMISChangeLogService cmisChangeLogService;
|
||||
protected CMISRenditionService cmisRenditionService;
|
||||
protected CMISAccessControlService cmisAclService;
|
||||
|
||||
protected DescriptorService descriptorService;
|
||||
protected NodeService nodeService;
|
||||
protected FileFolderService fileFolderService;
|
||||
protected SearchService searchService;
|
||||
protected PropertyUtil propertiesUtil;
|
||||
protected PermissionService permissionService;
|
||||
protected AuthorityService authorityService;
|
||||
|
||||
public void setCmisService(CMISServices cmisService)
|
||||
{
|
||||
this.cmisService = cmisService;
|
||||
}
|
||||
|
||||
public void setCmisQueryService(CMISQueryService cmisQueryService)
|
||||
{
|
||||
this.cmisQueryService = cmisQueryService;
|
||||
}
|
||||
|
||||
public void setCmisChangeLogService(CMISChangeLogService cmisChangeLogService)
|
||||
{
|
||||
this.cmisChangeLogService = cmisChangeLogService;
|
||||
}
|
||||
|
||||
public void setCmisAclService(CMISAccessControlService cmisAclService)
|
||||
{
|
||||
this.cmisAclService = cmisAclService;
|
||||
}
|
||||
|
||||
public void setCmisRenditionService(CMISRenditionService cmisRenditionService)
|
||||
{
|
||||
this.cmisRenditionService = cmisRenditionService;
|
||||
}
|
||||
|
||||
public void setDescriptorService(DescriptorService descriptorService)
|
||||
{
|
||||
this.descriptorService = descriptorService;
|
||||
}
|
||||
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
public void setFileFolderService(FileFolderService fileFolderService)
|
||||
{
|
||||
this.fileFolderService = fileFolderService;
|
||||
}
|
||||
|
||||
public void setPropertiesUtil(PropertyUtil propertiesUtil)
|
||||
{
|
||||
this.propertiesUtil = propertiesUtil;
|
||||
}
|
||||
|
||||
public void setSearchService(SearchService searchService)
|
||||
{
|
||||
this.searchService = searchService;
|
||||
}
|
||||
|
||||
public void setPermissionService(PermissionService permissionService)
|
||||
{
|
||||
this.permissionService = permissionService;
|
||||
}
|
||||
|
||||
public void setAuthorityService(AuthorityService authorityService)
|
||||
{
|
||||
this.authorityService = authorityService;
|
||||
}
|
||||
|
||||
protected PropertyFilter createPropertyFilter(String filter) throws CmisException
|
||||
{
|
||||
try
|
||||
{
|
||||
return new PropertyFilter(filter);
|
||||
}
|
||||
catch (CMISFilterNotValidException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected PropertyFilter createPropertyFilter(JAXBElement<String> element) throws CmisException
|
||||
{
|
||||
String filter = null;
|
||||
if (element != null)
|
||||
{
|
||||
filter = element.getValue();
|
||||
}
|
||||
return createPropertyFilter(filter);
|
||||
}
|
||||
|
||||
protected Cursor createCursor(int totalRows, BigInteger skipCount, BigInteger maxItems)
|
||||
{
|
||||
Page window = paging.createPageOrWindow(null, null, skipCount != null ? skipCount.intValue() : null, maxItems != null ? maxItems.intValue() : null);
|
||||
return paging.createCursor(totalRows, window);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if folder contains object
|
||||
*
|
||||
* @param object object NodeRef
|
||||
* @param folder folder NodeRef
|
||||
* @return returns true if folder contains object
|
||||
*/
|
||||
protected boolean isObjectInFolder(NodeRef object, NodeRef folder)
|
||||
{
|
||||
NodeRef searchedObjectNodeRef = fileFolderService.searchSimple(folder, (String) nodeService.getProperty(object, ContentModel.PROP_NAME));
|
||||
return (null != searchedObjectNodeRef) && (searchedObjectNodeRef.equals(object));
|
||||
}
|
||||
|
||||
/**
|
||||
* This method converts Alfresco's <b>NodeRef</b>'s to CMIS objects those will be stored in <b>resultList</b>-parameter. Properties for returning filtering also performs
|
||||
*
|
||||
* @param filter properties filter value for filtering objects returning properties
|
||||
* @param includeRelationships what relationships to include
|
||||
* @param sourceList the list that contains all returning Node References
|
||||
* @param resultList the list of <b>CmisObjectType</b> values for end response result collecting
|
||||
* @throws CmisException
|
||||
*/
|
||||
protected void createCmisObjectList(PropertyFilter filter, CMISRelationshipDirectionEnum includeRelationships, boolean includeAllowableActions, String renditionFilter,
|
||||
List<NodeRef> sourceList, List<CmisObjectType> resultList) throws CmisException
|
||||
{
|
||||
for (NodeRef objectNodeRef : sourceList)
|
||||
{
|
||||
resultList.add(createCmisObject(objectNodeRef, filter, includeRelationships, includeAllowableActions, renditionFilter));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method creates and configures CMIS object against appropriate Alfresco object (NodeRef or AssociationRef).
|
||||
*
|
||||
* @param object the Alfresco object
|
||||
* @param filter accepted properties filter
|
||||
* @param includeRelationships what relationships to include
|
||||
* @param includeAllowableActions should we include allowable actions?
|
||||
* @param renditionFilter the rendition filter
|
||||
* @return the converted CMIS object
|
||||
* @throws CmisException on error
|
||||
*/
|
||||
protected CmisObjectType createCmisObject(Object object, PropertyFilter filter, EnumIncludeRelationships includeRelationships, Boolean includeAllowableActions,
|
||||
String renditionFilter) throws CmisException
|
||||
{
|
||||
return createCmisObject(object, filter, includeRelationships == null ? null : INCLUDE_RELATIONSHIPS_ENUM_MAPPING.get(includeRelationships), includeAllowableActions != null
|
||||
&& includeAllowableActions, renditionFilter);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method creates and configures CMIS object against appropriate Alfresco object (NodeRef or AssociationRef).
|
||||
*
|
||||
* @param object the Alfresco object
|
||||
* @param filter accepted properties filter
|
||||
* @param includeRelationships what relationships to include
|
||||
* @param includeAllowableActions should we include allowable actions?
|
||||
* @param renditionFilter the rendition filter
|
||||
* @return the converted CMIS object
|
||||
* @throws CmisException on error
|
||||
*/
|
||||
protected CmisObjectType createCmisObject(Object object, PropertyFilter filter, CMISRelationshipDirectionEnum includeRelationships, boolean includeAllowableActions,
|
||||
String renditionFilter) throws CmisException
|
||||
{
|
||||
// Get a NodeRef if we can
|
||||
if (object instanceof Version)
|
||||
{
|
||||
object = ((Version) object).getFrozenStateNodeRef();
|
||||
}
|
||||
CmisObjectType result = new CmisObjectType();
|
||||
result.setProperties(propertiesUtil.getProperties(object, filter));
|
||||
if (object instanceof NodeRef && includeRelationships != null)
|
||||
{
|
||||
appendWithRelationships((NodeRef) object, filter, includeRelationships, includeAllowableActions, renditionFilter, result);
|
||||
}
|
||||
if (includeAllowableActions)
|
||||
{
|
||||
result.setAllowableActions(determineObjectAllowableActions(object));
|
||||
}
|
||||
if (renditionFilter != null)
|
||||
{
|
||||
List<CmisRenditionType> renditions = getRenditions(object, renditionFilter);
|
||||
if (renditions != null && !renditions.isEmpty())
|
||||
{
|
||||
result.getRendition().addAll(renditions);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
protected void appendWithRelationships(NodeRef object, PropertyFilter filter, CMISRelationshipDirectionEnum includeRelationships, boolean includeAllowableActions,
|
||||
String renditionFilter, CmisObjectType result) throws CmisException
|
||||
{
|
||||
List<CmisObjectType> relationships = result.getRelationship();
|
||||
try
|
||||
{
|
||||
for (AssociationRef assoc : cmisService.getRelationships(object, null, true, includeRelationships))
|
||||
{
|
||||
relationships.add(createCmisObject(assoc, filter, includeRelationships, includeAllowableActions, renditionFilter));
|
||||
}
|
||||
}
|
||||
catch (CMISInvalidArgumentException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks specified in CMIS request parameters repository Id.
|
||||
*
|
||||
* @param repositoryId repository id
|
||||
* @throws CmisException repository diesn't exist
|
||||
*/
|
||||
protected void checkRepositoryId(String repositoryId) throws CmisException
|
||||
{
|
||||
if (!this.descriptorService.getCurrentRepositoryDescriptor().getId().equals(repositoryId))
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(INVALID_REPOSITORY_ID_MESSAGE, EnumServiceException.INVALID_ARGUMENT);
|
||||
}
|
||||
}
|
||||
|
||||
protected List<CmisRenditionType> getRenditions(Object object, String renditionFilter) throws CmisException
|
||||
{
|
||||
List<CmisRenditionType> result = null;
|
||||
if (object instanceof Version)
|
||||
{
|
||||
object = ((Version) object).getFrozenStateNodeRef();
|
||||
}
|
||||
if (object instanceof NodeRef)
|
||||
{
|
||||
NodeRef document = (NodeRef) object;
|
||||
|
||||
List<CMISRendition> renditions = null;
|
||||
try
|
||||
{
|
||||
renditions = cmisRenditionService.getRenditions(document, renditionFilter);
|
||||
}
|
||||
catch (CMISFilterNotValidException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
if (renditions != null && !renditions.isEmpty())
|
||||
{
|
||||
result = new ArrayList<CmisRenditionType>();
|
||||
for (CMISRendition rendition : renditions)
|
||||
{
|
||||
if (rendition != null)
|
||||
{
|
||||
CmisRenditionType cmisRenditionType = convertToCmisRenditionType(rendition);
|
||||
result.add(cmisRenditionType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private CmisRenditionType convertToCmisRenditionType(CMISRendition rendition)
|
||||
{
|
||||
CmisRenditionType cmisRenditionType = new CmisRenditionType();
|
||||
cmisRenditionType.setStreamId(rendition.getStreamId());
|
||||
cmisRenditionType.setKind(rendition.getKind());
|
||||
cmisRenditionType.setMimetype(rendition.getMimeType());
|
||||
cmisRenditionType.setTitle(rendition.getTitle());
|
||||
cmisRenditionType.setWidth(rendition.getWidth() != null ? BigInteger.valueOf(rendition.getWidth()) : null);
|
||||
cmisRenditionType.setHeight(rendition.getHeight() != null ? BigInteger.valueOf(rendition.getHeight()) : null);
|
||||
cmisRenditionType.setLength(rendition.getLength() != null ? BigInteger.valueOf(rendition.getLength()) : null);
|
||||
cmisRenditionType.setRenditionDocumentId(rendition.getRenditionDocumentId());
|
||||
return cmisRenditionType;
|
||||
}
|
||||
|
||||
protected void appendWithAce(NodeRef identifierInstance, CmisObjectType object)
|
||||
{
|
||||
CMISAccessControlReport aclReport = cmisAclService.getAcl(identifierInstance, CMISAccessControlFormatEnum.REPOSITORY_SPECIFIC_PERMISSIONS);
|
||||
object.setAcl(convertAclReportToCmisAclType(aclReport).getACL());
|
||||
object.setExactACL(aclReport.isExact());
|
||||
}
|
||||
|
||||
protected void applyPolicies(String objectId, List<String> policies) throws CmisException
|
||||
{
|
||||
// Process any provided policy IDs (they will be rejected!)
|
||||
if (policies != null)
|
||||
{
|
||||
for (String policyId : policies)
|
||||
{
|
||||
try
|
||||
{
|
||||
cmisService.applyPolicy(policyId, objectId);
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected CmisACLType applyAclCarefully(NodeRef object, CmisAccessControlListType addACEs, CmisAccessControlListType removeACEs, EnumACLPropagation aclPropagation,
|
||||
List<String> policies) throws CmisException
|
||||
{
|
||||
if (addACEs == null && removeACEs == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
try
|
||||
{
|
||||
CMISAclPropagationEnum propagation = (null == aclPropagation) ? (CMISAclPropagationEnum.PROPAGATE) : (ACL_PROPAGATION_ENUM_MAPPGIN.get(aclPropagation));
|
||||
List<CMISAccessControlEntry> acesToAdd = (null == addACEs) ? (null) : (convertToAlfrescoAceEntriesList(addACEs.getPermission()));
|
||||
List<CMISAccessControlEntry> acesToRemove = (null == removeACEs) ? (null) : (convertToAlfrescoAceEntriesList(removeACEs.getPermission()));
|
||||
CMISAccessControlReport aclReport = null;
|
||||
aclReport = cmisAclService.applyAcl(object, acesToRemove, acesToAdd, propagation, CMISAccessControlFormatEnum.REPOSITORY_SPECIFIC_PERMISSIONS);
|
||||
|
||||
// Process any provided policy IDs (they will be rejected!)
|
||||
if (policies != null)
|
||||
{
|
||||
String objectId = (String) cmisService.getProperty(object, CMISDictionaryModel.PROP_OBJECT_ID);
|
||||
applyPolicies(objectId, policies);
|
||||
}
|
||||
CmisACLType result = convertAclReportToCmisAclType(aclReport);
|
||||
return result;
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private List<CMISAccessControlEntry> convertToAlfrescoAceEntriesList(List<CmisAccessControlEntryType> source) throws CmisException
|
||||
{
|
||||
List<CMISAccessControlEntry> result = new LinkedList<CMISAccessControlEntry>();
|
||||
for (CmisAccessControlEntryType cmisEntry : source)
|
||||
{
|
||||
String principalId = cmisEntry.getPrincipal().getPrincipalId();
|
||||
if (CMIS_USER.equals(principalId))
|
||||
{
|
||||
principalId = AuthenticationUtil.getFullyAuthenticatedUser();
|
||||
}
|
||||
for (String permission : cmisEntry.getPermission())
|
||||
{
|
||||
result.add(new CMISAccessControlEntryImpl(principalId, permission));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
protected CmisACLType convertAclReportToCmisAclType(CMISAccessControlReport aclReport)
|
||||
{
|
||||
CmisACLType result = new CmisACLType();
|
||||
CmisAccessControlListType aceList = new CmisAccessControlListType();
|
||||
result.setACL(aceList);
|
||||
for (CMISAccessControlEntry ace : aclReport.getAccessControlEntries())
|
||||
{
|
||||
CmisAccessControlEntryType entry = new CmisAccessControlEntryType();
|
||||
entry.setDirect(ace.getDirect());
|
||||
entry.getPermission().add(ace.getPermission()); // FIXME: [BUG] Should be List<String> getPermission() instead of String getPermission()!!!
|
||||
CmisAccessControlPrincipalType principal = new CmisAccessControlPrincipalType();
|
||||
principal.setPrincipalId(ace.getPrincipalId());
|
||||
entry.setPrincipal(principal);
|
||||
aceList.getPermission().add(entry);
|
||||
}
|
||||
result.setExact(aclReport.isExact());
|
||||
return result;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected CmisAllowableActionsType determineObjectAllowableActions(Object objectIdentifier) throws CmisException
|
||||
{
|
||||
CMISTypeDefinition typeDef;
|
||||
try
|
||||
{
|
||||
if (objectIdentifier instanceof AssociationRef)
|
||||
{
|
||||
typeDef = cmisService.getTypeDefinition((AssociationRef) objectIdentifier);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (objectIdentifier instanceof Version)
|
||||
{
|
||||
objectIdentifier = ((Version) objectIdentifier).getFrozenStateNodeRef();
|
||||
}
|
||||
typeDef = cmisService.getTypeDefinition((NodeRef) objectIdentifier);
|
||||
}
|
||||
}
|
||||
catch (CMISInvalidArgumentException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
CmisAllowableActionsType result = new CmisAllowableActionsType();
|
||||
for (Entry<CMISAllowedActionEnum, CMISActionEvaluator<? extends Object>> entry : typeDef.getActionEvaluators().entrySet())
|
||||
{
|
||||
PropertyDescriptor propertyDescriptor = ALLOWED_ACTION_ENUM_MAPPING.get(entry.getKey());
|
||||
if (propertyDescriptor != null)
|
||||
{
|
||||
// Let's assume that the evaluator will accept the object
|
||||
try
|
||||
{
|
||||
propertyDescriptor.getWriteMethod().invoke(result, new Boolean(((CMISActionEvaluator) entry.getValue()).isAllowed(objectIdentifier)));
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Exception setting allowable actions", e);
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Exception setting allowable actions", e);
|
||||
}
|
||||
catch (InvocationTargetException e)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Exception setting allowable actions", e.getTargetException());
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.cmis.ws;
|
||||
|
||||
import org.alfresco.cmis.CMISAccessControlReport;
|
||||
import org.alfresco.cmis.CMISServiceException;
|
||||
import org.alfresco.opencmis.CMISAccessControlFormatEnum;
|
||||
import org.alfresco.repo.cmis.ws.utils.ExceptionUtil;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* @author Dmitry Velichkevich
|
||||
*/
|
||||
@javax.jws.WebService(name = "ACLServicePort", serviceName = "ACLService", portName = "ACLServicePort", targetNamespace = "http://docs.oasis-open.org/ns/cmis/ws/200908/", endpointInterface = "org.alfresco.repo.cmis.ws.ACLServicePort")
|
||||
public class DMAclServicePort extends DMAbstractServicePort implements ACLServicePort
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public CmisACLType applyACL(String repositoryId, String objectId, CmisAccessControlListType addACEs, CmisAccessControlListType removeACEs, EnumACLPropagation aclPropagation,
|
||||
CmisExtensionType extension) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
NodeRef object;
|
||||
try
|
||||
{
|
||||
object = cmisService.getObject(objectId, NodeRef.class, true, false, false);
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
return applyAclCarefully(object, addACEs, removeACEs, aclPropagation, null);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public CmisACLType getACL(String repositoryId, String objectId, Boolean onlyBasicPermissions, CmisExtensionType extension) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
NodeRef nodeRef;
|
||||
try
|
||||
{
|
||||
nodeRef = cmisService.getReadableObject(objectId, NodeRef.class);
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
CMISAccessControlFormatEnum permissionsKind = ((null == onlyBasicPermissions) || onlyBasicPermissions) ? (CMISAccessControlFormatEnum.CMIS_BASIC_PERMISSIONS)
|
||||
: (CMISAccessControlFormatEnum.REPOSITORY_SPECIFIC_PERMISSIONS);
|
||||
CMISAccessControlReport aclReport = cmisAclService.getAcl(nodeRef, permissionsKind);
|
||||
return convertAclReportToCmisAclType(aclReport);
|
||||
}
|
||||
}
|
@@ -1,290 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2012 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.cmis.ws;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigInteger;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.datatype.XMLGregorianCalendar;
|
||||
import javax.xml.ws.Holder;
|
||||
|
||||
import org.alfresco.cmis.CMISChangeEvent;
|
||||
import org.alfresco.cmis.CMISChangeLog;
|
||||
import org.alfresco.cmis.CMISChangeType;
|
||||
import org.alfresco.cmis.CMISDataTypeEnum;
|
||||
import org.alfresco.cmis.CMISDictionaryModel;
|
||||
import org.alfresco.cmis.CMISObjectNotFoundException;
|
||||
import org.alfresco.cmis.CMISQueryOptions;
|
||||
import org.alfresco.cmis.CMISRelationshipDirectionEnum;
|
||||
import org.alfresco.cmis.CMISResultSet;
|
||||
import org.alfresco.cmis.CMISResultSetColumn;
|
||||
import org.alfresco.cmis.CMISResultSetRow;
|
||||
import org.alfresco.cmis.CMISServiceException;
|
||||
import org.alfresco.cmis.PropertyFilter;
|
||||
import org.alfresco.cmis.CMISQueryOptions.CMISQueryMode;
|
||||
import org.alfresco.repo.cmis.ws.utils.ExceptionUtil;
|
||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Port for Discovery service.
|
||||
*
|
||||
* @author Dmitry Lazurkin
|
||||
* @author Dmitry Velichkevich
|
||||
*/
|
||||
@javax.jws.WebService(name = "DiscoveryServicePort", serviceName = "DiscoveryService", portName = "DiscoveryServicePort", targetNamespace = "http://docs.oasis-open.org/ns/cmis/ws/200908/", endpointInterface = "org.alfresco.repo.cmis.ws.DiscoveryServicePort")
|
||||
public class DMDiscoveryServicePort extends DMAbstractServicePort implements DiscoveryServicePort
|
||||
{
|
||||
private static Map<CMISChangeType, EnumTypeOfChanges> changesTypeMapping = new HashMap<CMISChangeType, EnumTypeOfChanges>();
|
||||
static
|
||||
{
|
||||
changesTypeMapping.put(CMISChangeType.CREATED, EnumTypeOfChanges.CREATED);
|
||||
changesTypeMapping.put(CMISChangeType.UPDATED, EnumTypeOfChanges.UPDATED);
|
||||
changesTypeMapping.put(CMISChangeType.SECURITY, EnumTypeOfChanges.SECURITY);
|
||||
changesTypeMapping.put(CMISChangeType.DELETED, EnumTypeOfChanges.DELETED);
|
||||
}
|
||||
|
||||
/**
|
||||
* Queries the repository for queryable object based on properties or an optional full-text string. Relationship objects are not queryable. Content-streams are not returned as
|
||||
* part of query
|
||||
*
|
||||
* ALF-9566 : hasMoreItems was changed to be confirmed with a section (2.2.1.1 Paging) of the specification.
|
||||
*
|
||||
* @param parameters query parameters
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME)
|
||||
*/
|
||||
public QueryResponse query(Query parameters) throws CmisException
|
||||
{
|
||||
checkRepositoryId(parameters.getRepositoryId());
|
||||
|
||||
// TODO: includeRelationships, includeRenditions
|
||||
CMISQueryOptions options = new CMISQueryOptions(parameters.getStatement(), cmisService.getDefaultRootStoreRef());
|
||||
|
||||
int skipCount = 0;
|
||||
if (parameters.getSkipCount() != null && parameters.getSkipCount().getValue() != null)
|
||||
{
|
||||
skipCount = parameters.getSkipCount().getValue().intValue();
|
||||
options.setSkipCount(skipCount);
|
||||
}
|
||||
|
||||
boolean includeAllowableActions = ((null != parameters.getIncludeAllowableActions()) && (null != parameters.getIncludeAllowableActions().getValue())) ? (parameters
|
||||
.getIncludeAllowableActions().getValue()) : (false);
|
||||
String renditionFilter = (null != parameters.getRenditionFilter()) ? (parameters.getRenditionFilter().getValue()) : null;
|
||||
|
||||
// execute query
|
||||
// TODO: If the select clause includes properties from more than a single type reference, then the repository SHOULD throw an exception if includeRelationships or
|
||||
// includeAllowableActions is specified as true.
|
||||
options.setQueryMode(CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS);
|
||||
QueryResponse response = new QueryResponse();
|
||||
CMISResultSet resultSet = null;
|
||||
|
||||
try
|
||||
{
|
||||
resultSet = cmisQueryService.query(options);
|
||||
CMISResultSetColumn[] columns = resultSet.getMetaData().getColumns();
|
||||
|
||||
// build query response
|
||||
|
||||
response.setObjects(new CmisObjectListType());
|
||||
EnumIncludeRelationships cmisDirection = (null != parameters.getIncludeRelationships()) ? (parameters.getIncludeRelationships().getValue()) : (null);
|
||||
CMISRelationshipDirectionEnum includeRelationships = INCLUDE_RELATIONSHIPS_ENUM_MAPPING.get(cmisDirection);
|
||||
|
||||
int maxItems = -1;
|
||||
if (parameters.getMaxItems() != null && parameters.getMaxItems().getValue() != null)
|
||||
{
|
||||
maxItems = parameters.getMaxItems().getValue().intValue();
|
||||
}
|
||||
|
||||
// total number of items
|
||||
int numItems = resultSet.getLength();
|
||||
// for each row...
|
||||
int idx = 0;
|
||||
for (CMISResultSetRow row : resultSet)
|
||||
{
|
||||
if (maxItems != -1 && idx == maxItems)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
Object identifier;
|
||||
NodeRef nodeRef;
|
||||
try
|
||||
{
|
||||
nodeRef = row.getNodeRef();
|
||||
identifier = cmisService.getReadableObject((String) nodeRef.toString(), Object.class);
|
||||
}
|
||||
catch (CMISObjectNotFoundException e)
|
||||
{
|
||||
// ALF-15001: Handle stale nodeRefs in the index
|
||||
numItems--;
|
||||
continue;
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
|
||||
CmisPropertiesType properties = new CmisPropertiesType();
|
||||
Map<String, Serializable> values = row.getValues();
|
||||
|
||||
// for each column...
|
||||
for (CMISResultSetColumn column : columns)
|
||||
{
|
||||
CmisProperty property = propertiesUtil.createProperty(column.getName(), column.getCMISDataType(), values.get(column.getName()));
|
||||
if (property != null)
|
||||
{
|
||||
property.setQueryName(column.getName());
|
||||
properties.getProperty().add(property);
|
||||
}
|
||||
}
|
||||
|
||||
CmisObjectType object = new CmisObjectType();
|
||||
object.setProperties(properties);
|
||||
if (includeAllowableActions)
|
||||
{
|
||||
object.setAllowableActions(determineObjectAllowableActions(identifier));
|
||||
}
|
||||
if (null != includeRelationships)
|
||||
{
|
||||
appendWithRelationships(nodeRef, createPropertyFilter((String) null), includeRelationships, includeAllowableActions, renditionFilter, object);
|
||||
}
|
||||
if (renditionFilter != null)
|
||||
{
|
||||
List<CmisRenditionType> renditions = getRenditions(identifier, renditionFilter);
|
||||
if (renditions != null && !renditions.isEmpty())
|
||||
{
|
||||
object.getRendition().addAll(renditions);
|
||||
}
|
||||
}
|
||||
response.getObjects().getObjects().add(object);
|
||||
idx++;
|
||||
}
|
||||
response.getObjects().setNumItems(BigInteger.valueOf(numItems));
|
||||
boolean hasMoreItems = (maxItems != -1 ? (numItems - (skipCount + maxItems)) > 0 : false) || resultSet.hasMore();
|
||||
response.getObjects().setHasMoreItems(hasMoreItems);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (resultSet != null) {resultSet.close();}
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of content changes. Targeted for search crawlers or other applications that need to efficiently understand what has changed in the repository. Note: The content
|
||||
* stream is NOT returned for any change event.
|
||||
*
|
||||
* @param repositoryId {@link String} value that determines Id of the necessary Repository
|
||||
* @param changeLogToken generic {@link Holder} class instance with {@link String} type parameter that determines last Change Log Token
|
||||
* @param includeProperties {@link Boolean} instance value that specifies whether all allowed by filter properties should be returned for Change Type equal to 'UPDATED' or
|
||||
* Object Id property only
|
||||
* @param filter {@link String} value for filtering properties for Change Entry with Change Type equal to 'UPDATED'
|
||||
* @param includePolicyIds {@link Boolean} instance value that determines whether Policy Ids must be returned
|
||||
* @param includeACL {@link Boolean} instance value that determines whether ACLs must be returned
|
||||
* @param maxItems {@link BigInteger} instance value that determines required amount of Change Log Entries
|
||||
* @param extension {@link CmisException} instance of unknown assignment
|
||||
* @param objects generic {@link Holder} instance with {@link CmisObjectListType} type parameter for storing results of service execution
|
||||
* @throws CmisException with next allowable {@link EnumServiceException} enum attribute of exception type values: CONSTRAINT, FILTER_NOT_VALID, INVALID_ARGUMENT,
|
||||
* NOT_SUPPORTED, OBJECT_NOT_FOUND, PERMISSION_DENIED, RUNTIME
|
||||
*/
|
||||
public void getContentChanges(String repositoryId, Holder<String> changeLogToken, Boolean includeProperties, String filter, Boolean includePolicyIds, Boolean includeACL,
|
||||
BigInteger maxItems, CmisExtensionType extension, Holder<CmisObjectListType> objects) throws CmisException
|
||||
{
|
||||
if (!authorityService.hasAdminAuthority())
|
||||
{
|
||||
throw ExceptionUtil.createCmisException("Cannot retrieve content changes", new AccessDeniedException("Requires admin authority"));
|
||||
}
|
||||
|
||||
// TODO: includePolicyIds
|
||||
checkRepositoryId(repositoryId);
|
||||
String changeToken = (null != changeLogToken) ? (changeLogToken.value) : (null);
|
||||
Integer maxAmount = (null != maxItems) ? (maxItems.intValue()) : (null);
|
||||
boolean propertiesRequsted = (null != includeProperties) ? (includeProperties.booleanValue()) : (false);
|
||||
if (propertiesRequsted)
|
||||
{
|
||||
if ((null != filter) && !"".equals(filter) && !PropertyFilter.MATCH_ALL_FILTER.equals(filter) && !filter.contains(CMISDictionaryModel.PROP_OBJECT_ID))
|
||||
{
|
||||
filter = CMISDictionaryModel.PROP_OBJECT_ID + PropertyFilter.PROPERTY_NAME_TOKENS_DELIMITER + filter;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
filter = CMISDictionaryModel.PROP_OBJECT_ID;
|
||||
}
|
||||
|
||||
CMISChangeLog changeLog = null;
|
||||
try
|
||||
{
|
||||
changeLog = cmisChangeLogService.getChangeLogEvents(changeToken, maxAmount);
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
if (null == objects.value)
|
||||
{
|
||||
objects.value = new CmisObjectListType();
|
||||
}
|
||||
if ((null == changeLog) || (null == changeLog.getChangeEvents()) || changeLog.getChangeEvents().isEmpty())
|
||||
{
|
||||
objects.value.setHasMoreItems(false);
|
||||
objects.value.setNumItems(BigInteger.valueOf(0));
|
||||
}
|
||||
else
|
||||
{
|
||||
formatObjectsResponse(filter, propertiesRequsted, includeACL, changeLog, objects.value.getObjects());
|
||||
objects.value.setHasMoreItems(changeLog.hasMoreItems());
|
||||
objects.value.setNumItems(BigInteger.valueOf(changeLog.getChangeEvents().size()));
|
||||
changeLogToken.value = changeLog.getNextChangeToken();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method formats response for Get Content Changes service
|
||||
*
|
||||
* @param filter {@link String} value that determines user specified properties filter
|
||||
* @param propertiesRequsted {@link Boolean} value that determines whether properties another than Object Id should be returned (according to specified properties filter)
|
||||
* @param changeLog {@link CMISChangeLog} instance that represents descriptor for some Change Log Token
|
||||
* @param result {@link List}<{@link CmisObjectType}> collection instance for storing Change Event entries from Change Log descriptor
|
||||
* @throws CmisException
|
||||
*/
|
||||
private void formatObjectsResponse(String filter, boolean propertiesRequsted, boolean includeAce, CMISChangeLog changeLog, List<CmisObjectType> result) throws CmisException
|
||||
{
|
||||
for (CMISChangeEvent event : changeLog.getChangeEvents())
|
||||
{
|
||||
CmisObjectType object = new CmisObjectType();
|
||||
CmisPropertiesType propertiesType = new CmisPropertiesType();
|
||||
object.setProperties(propertiesType);
|
||||
propertiesType.getProperty().add(propertiesUtil.createProperty(CMISDictionaryModel.PROP_OBJECT_ID, CMISDataTypeEnum.ID, event.getObjectId()));
|
||||
if (nodeService.exists(event.getChangedNode()) && includeAce)
|
||||
{
|
||||
appendWithAce(event.getChangedNode(), object);
|
||||
}
|
||||
CmisChangeEventType changeInfo = new CmisChangeEventType();
|
||||
XMLGregorianCalendar modificationDate = propertiesUtil.convert(event.getChangeTime());
|
||||
changeInfo.setChangeType(changesTypeMapping.get(event.getChangeType()));
|
||||
changeInfo.setChangeTime(modificationDate);
|
||||
object.setChangeEventInfo(changeInfo);
|
||||
result.add(object);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,112 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.cmis.ws;
|
||||
|
||||
import javax.xml.ws.Holder;
|
||||
|
||||
import org.alfresco.cmis.CMISDictionaryModel;
|
||||
import org.alfresco.cmis.CMISServiceException;
|
||||
import org.alfresco.cmis.CMISTypeDefinition;
|
||||
import org.alfresco.repo.cmis.ws.utils.ExceptionUtil;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Port for Multi-Filing service.
|
||||
*
|
||||
* @author Dmitry Lazurkin
|
||||
* @author Dmitry Velichkevich
|
||||
*/
|
||||
@javax.jws.WebService(name = "MultiFilingServicePort", serviceName = "MultiFilingService", portName = "MultiFilingServicePort", targetNamespace = "http://docs.oasis-open.org/ns/cmis/ws/200908/", endpointInterface = "org.alfresco.repo.cmis.ws.MultiFilingServicePort")
|
||||
public class DMMultiFilingServicePort extends DMAbstractServicePort implements MultiFilingServicePort
|
||||
{
|
||||
/**
|
||||
* Adds an existing non-folder, fileable object to a folder.
|
||||
*
|
||||
* @param repositoryId Repository Id
|
||||
* @param objectId object Id to be added to a folder
|
||||
* @param folderId folder Id to which the object is added
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, CONSTRAINT)
|
||||
*/
|
||||
public void addObjectToFolder(String repositoryId, String objectId, String folderId, Boolean allVersions, Holder<CmisExtensionType> extension) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
checkConstraints(objectId, folderId, false);
|
||||
try
|
||||
{
|
||||
cmisService.addObjectToFolder(objectId, folderId);
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a non-folder child object from a folder or from all folders. This does not delete the object and does not change the ID of the object.
|
||||
*
|
||||
* @param repositoryId repository Id
|
||||
* @param objectId The object to be removed from a folder
|
||||
* @param folderId The folder to be removed from.
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME)
|
||||
*/
|
||||
public void removeObjectFromFolder(String repositoryId, String objectId, String folderId, Holder<CmisExtensionType> extension) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
checkConstraints(objectId, folderId, true);
|
||||
|
||||
try
|
||||
{
|
||||
cmisService.removeObjectFromFolder(objectId, folderId);
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void checkConstraints(String objectId, String folderId, boolean checkIsObjectInFolder) throws CmisException
|
||||
{
|
||||
NodeRef objectNodeRef = null;
|
||||
NodeRef folderNodeRef = null;
|
||||
CMISTypeDefinition objectTypeDef = null;
|
||||
|
||||
try
|
||||
{
|
||||
objectNodeRef = cmisService.getObject(objectId, NodeRef.class, true, false, false);
|
||||
folderNodeRef = cmisService.getFolder(folderId);
|
||||
objectTypeDef = cmisService.getTypeDefinition(objectNodeRef);
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e.getMessage(), EnumServiceException.INVALID_ARGUMENT);
|
||||
}
|
||||
|
||||
if (!objectTypeDef.getTypeId().getBaseTypeId().equals(CMISDictionaryModel.DOCUMENT_TYPE_ID))
|
||||
{
|
||||
throw ExceptionUtil.createCmisException("Object " + objectId + " is not a document", EnumServiceException.INVALID_ARGUMENT);
|
||||
}
|
||||
|
||||
if (checkIsObjectInFolder && !isObjectInFolder(objectNodeRef, folderNodeRef))
|
||||
{
|
||||
throw ExceptionUtil.createCmisException("Folder doesn't contain specified object", EnumServiceException.OBJECT_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,410 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.cmis.ws;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
import org.alfresco.cmis.CMISDictionaryModel;
|
||||
import org.alfresco.cmis.CMISInvalidArgumentException;
|
||||
import org.alfresco.cmis.CMISServiceException;
|
||||
import org.alfresco.cmis.CMISTypesFilterEnum;
|
||||
import org.alfresco.cmis.PropertyFilter;
|
||||
import org.alfresco.query.PagingResults;
|
||||
import org.alfresco.repo.cmis.ws.utils.ExceptionUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.web.util.paging.Cursor;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.util.Pair;
|
||||
|
||||
/**
|
||||
* Port for navigation service
|
||||
*
|
||||
* @author Dmitry Lazurkin
|
||||
* @author Dmitry Velichkevich
|
||||
*/
|
||||
@javax.jws.WebService(name = "NavigationServicePort", serviceName = "NavigationService", portName = "NavigationServicePort", targetNamespace = "http://docs.oasis-open.org/ns/cmis/ws/200908/", endpointInterface = "org.alfresco.repo.cmis.ws.NavigationServicePort")
|
||||
public class DMNavigationServicePort extends DMAbstractServicePort implements NavigationServicePort
|
||||
{
|
||||
private static final int EQUALS_CONDITION_VALUE = 0;
|
||||
private static final BigInteger FULL_DESCENDANTS_HIERARCHY_CONDITION = BigInteger.valueOf(-1l);
|
||||
|
||||
private static final String FILTER_TOKENS_DELIMETER = ", ";
|
||||
|
||||
/**
|
||||
* Gets the private working copies of checked-out objects that the user is allowed to update.
|
||||
*
|
||||
* @param parameters repositoryId: repository Id; folderID: folder Id; filter: property filter; includeAllowableActions; includeRelationships; maxItems: 0 = Unlimited;
|
||||
* skipCount: 0 = start at beginning
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, FILTER_NOT_VALID)
|
||||
*/
|
||||
public CmisObjectListType getCheckedOutDocs(String repositoryId, String folderId, String filter, String orderBy, Boolean includeAllowableActions,
|
||||
EnumIncludeRelationships includeRelationships, String renditionFilter, BigInteger maxItems, BigInteger skipCount, CmisExtensionType extension) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
PropertyFilter propertyFilter = createPropertyFilter(filter);
|
||||
|
||||
try
|
||||
{
|
||||
NodeRef folderRef = null;
|
||||
if ((folderId != null) && !folderId.equals(""))
|
||||
{
|
||||
folderRef = cmisService.getFolder(folderId);
|
||||
}
|
||||
|
||||
NodeRef[] nodeRefs = cmisService.getCheckedOut(AuthenticationUtil.getFullyAuthenticatedUser(), folderRef,
|
||||
(folderRef == null), orderBy);
|
||||
Cursor cursor = createCursor(nodeRefs.length, skipCount, maxItems);
|
||||
|
||||
CmisObjectListType result = new CmisObjectListType();
|
||||
List<CmisObjectType> resultListing = result.getObjects();
|
||||
|
||||
for (int index = cursor.getStartRow(); index <= cursor.getEndRow(); index++)
|
||||
{
|
||||
resultListing.add(createCmisObject(nodeRefs[index], propertyFilter, includeRelationships,
|
||||
includeAllowableActions, renditionFilter));
|
||||
}
|
||||
result.setHasMoreItems(new Boolean(cursor.getEndRow() < (nodeRefs.length - 1)));
|
||||
return result;
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of child objects contained in the specified folder. Only the filter-selected properties associated with each object are returned. The content-streams of
|
||||
* documents are not returned.For returning a tree of objects of a certain depth, use {@link #getDescendants(GetDescendants parameters)}.
|
||||
*
|
||||
* @param parameters repositoryId: repository Id; folderId: folder Id; type: DOCUMENTS, FOLDERS, POLICIES, ANY; filter: property filter; includeAllowableActions;
|
||||
* includeRelationships; maxItems: 0 = Unlimited; skipCount: 0 = start at beginning
|
||||
* @return collection of CmisObjectType and boolean hasMoreItems
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, FILTER_NOT_VALID)
|
||||
*/
|
||||
public CmisObjectInFolderListType getChildren(String repositoryId, String folderId, String filter, String orderBy,
|
||||
Boolean includeAllowableActions, EnumIncludeRelationships includeRelationships, String renditionFilter,
|
||||
Boolean includePathSegments, BigInteger maxItems, BigInteger skipCount, CmisExtensionType extension)
|
||||
throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
PropertyFilter propertyFilter = createPropertyFilter(filter);
|
||||
|
||||
try
|
||||
{
|
||||
NodeRef folderNodeRef = cmisService.getFolder(folderId);
|
||||
|
||||
PagingResults<FileInfo> pageOfNodeInfos = cmisService.getChildren(folderNodeRef, CMISTypesFilterEnum.ANY, maxItems, skipCount, orderBy);
|
||||
|
||||
int pageCnt = pageOfNodeInfos.getPage().size();
|
||||
NodeRef[] children = new NodeRef[pageCnt];
|
||||
|
||||
int idx = 0;
|
||||
for (FileInfo child : pageOfNodeInfos.getPage())
|
||||
{
|
||||
children[idx] = child.getNodeRef();
|
||||
idx++;
|
||||
}
|
||||
|
||||
CmisObjectInFolderListType result = new CmisObjectInFolderListType();
|
||||
|
||||
// has more ?
|
||||
result.setHasMoreItems(pageOfNodeInfos.hasMoreItems());
|
||||
|
||||
// total count ?
|
||||
Pair<Integer, Integer> totalCounts = pageOfNodeInfos.getTotalResultCount();
|
||||
if (totalCounts != null)
|
||||
{
|
||||
Integer totalCountLower = totalCounts.getFirst();
|
||||
Integer totalCountUpper = totalCounts.getSecond();
|
||||
if ((totalCountLower != null) && (totalCountLower.equals(totalCountUpper)))
|
||||
{
|
||||
result.setNumItems(BigInteger.valueOf(totalCountLower));
|
||||
}
|
||||
}
|
||||
|
||||
for (int index = 0; index < pageCnt; index++)
|
||||
{
|
||||
CmisObjectType cmisObject = createCmisObject(children[index], propertyFilter, includeRelationships,
|
||||
includeAllowableActions, renditionFilter);
|
||||
CmisObjectInFolderType cmisObjectInFolder = new CmisObjectInFolderType();
|
||||
cmisObjectInFolder.setObject(cmisObject);
|
||||
if (includePathSegments != null && includePathSegments)
|
||||
{
|
||||
cmisObjectInFolder.setPathSegment(propertiesUtil.getProperty(children[index],
|
||||
CMISDictionaryModel.PROP_NAME, ""));
|
||||
}
|
||||
result.getObjects().add(cmisObjectInFolder);
|
||||
}
|
||||
|
||||
// TODO: Process includeRelationships, includeACL
|
||||
return result;
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of descendant objects contained at one or more levels in the tree rooted at the specified folder. Only the filter-selected properties associated with each
|
||||
* object are returned. The content-stream is not returned. For paging through the children (depth of 1) only use {@link #getChildren(GetChildren parameters)}.
|
||||
*
|
||||
* @param parameters repositoryId: repository Id; folderId: folder Id; depth: 1 this folder only (Default), N folders deep, -1 for all levels; filter: property filter;
|
||||
* includeAllowableActions; includeRelationships;
|
||||
* @return collection of CmisObjectType
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, FILTER_NOT_VALID)
|
||||
*/
|
||||
public List<CmisObjectInFolderContainerType> getDescendants(String repositoryId, String folderId, BigInteger depth, String filter, Boolean includeAllowableActions,
|
||||
EnumIncludeRelationships includeRelationships, String renditionFilter, Boolean includePathSegments, CmisExtensionType extension) throws CmisException
|
||||
{
|
||||
CmisObjectInFolderContainerType objectInFolderContainerType = getDescendantsTree(repositoryId, folderId, depth, filter, includeAllowableActions, includeRelationships,
|
||||
renditionFilter, includePathSegments, CMISTypesFilterEnum.ANY);
|
||||
return objectInFolderContainerType.getChildren();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of descendant objects contained at one or more levels in the tree rooted at the specified folder. Only the filter-selected properties associated with each
|
||||
* object are returned. The content-stream is not returned. For paging through the children (depth of 1) only use {@link #getChildren(GetChildren parameters)}.
|
||||
*
|
||||
* @param parameters repositoryId: repository Id; folderId: folder Id; depth: 1 this folder only (Default), N folders deep, -1 for all levels; filter: property filter;
|
||||
* includeAllowableActions; includeRelationships;
|
||||
* @return collection of CmisObjectType
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, FILTER_NOT_VALID)
|
||||
*/
|
||||
public List<CmisObjectInFolderContainerType> getFolderTree(String repositoryId, String folderId, BigInteger depth, String filter, Boolean includeAllowableActions,
|
||||
EnumIncludeRelationships includeRelationships, String renditionFilter, Boolean includePathSegments, CmisExtensionType extension) throws CmisException
|
||||
{
|
||||
CmisObjectInFolderContainerType objectInFolderContainerType = getDescendantsTree(repositoryId, folderId, depth, filter, includeAllowableActions, includeRelationships,
|
||||
renditionFilter, includePathSegments, CMISTypesFilterEnum.FOLDERS);
|
||||
return objectInFolderContainerType.getChildren();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parent folder object, and optionally all ancestor folder objects, above a specified folder object.
|
||||
*
|
||||
* @param parameters repositoryId: repository Id; folderId: folder Id; filter: property filter; includeAllowableActions; includeRelationships; returnToRoot: If false, return
|
||||
* only the immediate parent of the folder. If true, return an ordered list of all ancestor folders from the specified folder to the root folder
|
||||
* @return collection of CmisObjectType
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, FILTER_NOT_VALID)
|
||||
*/
|
||||
public CmisObjectType getFolderParent(String repositoryId, String folderId, String filter, CmisExtensionType extension) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
if ((filter != null) && !filter.equals("") && !filter.equals("*"))
|
||||
{
|
||||
if (!filter.contains(CMISDictionaryModel.PROP_PARENT_ID))
|
||||
{
|
||||
filter = CMISDictionaryModel.PROP_PARENT_ID + FILTER_TOKENS_DELIMETER + filter;
|
||||
}
|
||||
|
||||
if (!filter.contains(CMISDictionaryModel.PROP_OBJECT_ID))
|
||||
{
|
||||
filter = CMISDictionaryModel.PROP_OBJECT_ID + FILTER_TOKENS_DELIMETER + filter;
|
||||
}
|
||||
}
|
||||
PropertyFilter propertyFilter = createPropertyFilter(filter);
|
||||
NodeRef parentRef;
|
||||
try
|
||||
{
|
||||
parentRef = cmisService.getFolderParent(folderId);
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
|
||||
CmisObjectType result = createCmisObject(parentRef, propertyFilter, null, false, null);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parent folders for the specified non-folder, fileable object.
|
||||
*
|
||||
* @param parameters repositoryId: repository Id; objectId: object Id; filter: property filter; includeAllowableActions; includeRelationships;
|
||||
* @return collection of CmisObjectType
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, CONSTRAINT,
|
||||
* FILTER_NOT_VALID)
|
||||
*/
|
||||
public List<CmisObjectParentsType> getObjectParents(String repositoryId, String objectId, String filter,
|
||||
Boolean includeAllowableActions, EnumIncludeRelationships includeRelationships, String renditionFilter,
|
||||
Boolean includeRelativePathSegment, CmisExtensionType extension) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
PropertyFilter propertyFilter = createPropertyFilter(filter);
|
||||
|
||||
try
|
||||
{
|
||||
NodeRef childNode = (NodeRef) cmisService.getReadableObject(objectId, NodeRef.class);
|
||||
List<NodeRef> parents = receiveObjectParents(childNode);
|
||||
|
||||
List<CmisObjectParentsType> result = new ArrayList<CmisObjectParentsType>();
|
||||
String relativePathSegment = propertiesUtil.getProperty(childNode, CMISDictionaryModel.PROP_NAME, "");
|
||||
for (NodeRef objectNodeRef : parents)
|
||||
{
|
||||
CmisObjectType cmisObject = createCmisObject(objectNodeRef, propertyFilter, includeRelationships,
|
||||
includeAllowableActions, renditionFilter);
|
||||
CmisObjectParentsType cmisObjectParentsType = new CmisObjectParentsType();
|
||||
cmisObjectParentsType.setObject(cmisObject);
|
||||
if (includeRelativePathSegment != null && includeRelativePathSegment)
|
||||
{
|
||||
cmisObjectParentsType.setRelativePathSegment(relativePathSegment);
|
||||
}
|
||||
result.add(cmisObjectParentsType);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private CmisObjectInFolderContainerType getDescendantsTree(String repositoryId, String folderId, BigInteger depth, String filter, Boolean includeAllowableActions,
|
||||
EnumIncludeRelationships includeRelationships, String renditionFilter, Boolean includePathSegments, CMISTypesFilterEnum types) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
PropertyFilter propertyFilter = createPropertyFilter(filter);
|
||||
depth = (depth == null) ? (BigInteger.ONE.add(BigInteger.ONE)) : depth;
|
||||
depth = depth.equals(BigInteger.valueOf(-1)) ? BigInteger.valueOf(Integer.MAX_VALUE) : depth;
|
||||
long maxDepth = depth.longValue();
|
||||
checkDepthParameter(depth);
|
||||
|
||||
try
|
||||
{
|
||||
NodeRef folderNodeRef = cmisService.getFolder(folderId);
|
||||
Stack<RecursiveElement> descedantsStack = new Stack<RecursiveElement>();
|
||||
CmisObjectInFolderContainerType objectInFolderContainer = createObjectInFolderContainer(folderNodeRef,
|
||||
propertyFilter, includeAllowableActions, includeRelationships, renditionFilter, includePathSegments);
|
||||
NodeRef[] children = cmisService.getChildren(folderNodeRef, types, null);
|
||||
for (NodeRef childRef : children)
|
||||
{
|
||||
descedantsStack.push(new RecursiveElement(objectInFolderContainer, 1, childRef));
|
||||
}
|
||||
while (!descedantsStack.isEmpty())
|
||||
{
|
||||
RecursiveElement element = descedantsStack.pop();
|
||||
CmisObjectInFolderContainerType currentContainer = createObjectInFolderContainer(element
|
||||
.getCurrentNodeRef(), propertyFilter, includeAllowableActions, includeRelationships,
|
||||
renditionFilter, includePathSegments);
|
||||
element.getParentContainerType().getChildren().add(currentContainer);
|
||||
if (element.getDepth() <= maxDepth)
|
||||
{
|
||||
children = cmisService.getChildren(element.getCurrentNodeRef(), types, null);
|
||||
if (children != null)
|
||||
{
|
||||
for (NodeRef childRef : children)
|
||||
{
|
||||
descedantsStack.push(new RecursiveElement(currentContainer, element.getDepth() + 1,
|
||||
childRef));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return objectInFolderContainer;
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private CmisObjectInFolderContainerType createObjectInFolderContainer(NodeRef nodeRef, PropertyFilter filter, Boolean includeAllowableActions,
|
||||
EnumIncludeRelationships includeRelationships, String renditionFilter, Boolean includePathSegments) throws CmisException
|
||||
{
|
||||
CmisObjectType cmisObject = createCmisObject(nodeRef, filter, includeRelationships, includeAllowableActions,
|
||||
renditionFilter);
|
||||
|
||||
CmisObjectInFolderType objectInFolderType = new CmisObjectInFolderType();
|
||||
objectInFolderType.setObject(cmisObject);
|
||||
if (includePathSegments != null && includePathSegments)
|
||||
{
|
||||
String path;
|
||||
try
|
||||
{
|
||||
path = propertiesUtil.getProperty(nodeRef, CMISDictionaryModel.PROP_NAME, "");
|
||||
}
|
||||
catch (CMISInvalidArgumentException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
objectInFolderType.setPathSegment(path);
|
||||
}
|
||||
CmisObjectInFolderContainerType result = new CmisObjectInFolderContainerType();
|
||||
result.setObjectInFolder(objectInFolderType);
|
||||
return result;
|
||||
}
|
||||
|
||||
private void checkDepthParameter(BigInteger depth) throws CmisException
|
||||
{
|
||||
if (depth.equals(BigInteger.ZERO) || (depth.compareTo(FULL_DESCENDANTS_HIERARCHY_CONDITION) < EQUALS_CONDITION_VALUE))
|
||||
{
|
||||
throw ExceptionUtil.createCmisException("The specified descendants depth is not valid. Valid depth values are: -1 (full hierarchy), N > 0",
|
||||
EnumServiceException.INVALID_ARGUMENT);
|
||||
}
|
||||
}
|
||||
|
||||
private List<NodeRef> receiveObjectParents(NodeRef objectId) throws CmisException
|
||||
{
|
||||
List<NodeRef> parents = new LinkedList<NodeRef>();
|
||||
for (ChildAssociationRef childParentAssociation : nodeService.getParentAssocs(objectId))
|
||||
{
|
||||
NodeRef parentRef = childParentAssociation.getParentRef();
|
||||
if (!parentRef.equals(nodeService.getRootNode(parentRef.getStoreRef())))
|
||||
{
|
||||
parents.add(parentRef);
|
||||
}
|
||||
}
|
||||
return parents;
|
||||
}
|
||||
|
||||
private class RecursiveElement
|
||||
{
|
||||
private CmisObjectInFolderContainerType parentContainerType;
|
||||
private int depth;
|
||||
private NodeRef currentNodeRef;
|
||||
|
||||
public RecursiveElement(CmisObjectInFolderContainerType parentContainerType, int depth, NodeRef currentNodeRef)
|
||||
{
|
||||
this.parentContainerType = parentContainerType;
|
||||
this.depth = depth;
|
||||
this.currentNodeRef = currentNodeRef;
|
||||
}
|
||||
|
||||
public CmisObjectInFolderContainerType getParentContainerType()
|
||||
{
|
||||
return parentContainerType;
|
||||
}
|
||||
|
||||
public int getDepth()
|
||||
{
|
||||
return depth;
|
||||
}
|
||||
|
||||
public NodeRef getCurrentNodeRef()
|
||||
{
|
||||
return currentNodeRef;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,872 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.cmis.ws;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.activation.DataHandler;
|
||||
import javax.xml.ws.Holder;
|
||||
|
||||
import org.alfresco.cmis.CMISConstraintException;
|
||||
import org.alfresco.cmis.CMISContentStreamAllowedEnum;
|
||||
import org.alfresco.cmis.CMISDictionaryModel;
|
||||
import org.alfresco.cmis.CMISInvalidArgumentException;
|
||||
import org.alfresco.cmis.CMISScope;
|
||||
import org.alfresco.cmis.CMISServiceException;
|
||||
import org.alfresco.cmis.CMISTypeDefinition;
|
||||
import org.alfresco.cmis.CMISVersioningStateEnum;
|
||||
import org.alfresco.cmis.PropertyFilter;
|
||||
import org.alfresco.repo.cmis.ws.DeleteTreeResponse.FailedToDelete;
|
||||
import org.alfresco.repo.cmis.ws.utils.ExceptionUtil;
|
||||
import org.alfresco.repo.web.util.paging.Cursor;
|
||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.model.FileExistsException;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.model.FileNotFoundException;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.FileTypeImageSize;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Port for object service
|
||||
*
|
||||
* @author Dmitry Lazurkin
|
||||
* @author Dmitry Velichkevich
|
||||
*/
|
||||
@javax.jws.WebService(name = "ObjectServicePort", serviceName = "ObjectService", portName = "ObjectServicePort", targetNamespace = "http://docs.oasis-open.org/ns/cmis/ws/200908/", endpointInterface = "org.alfresco.repo.cmis.ws.ObjectServicePort")
|
||||
public class DMObjectServicePort extends DMAbstractServicePort implements ObjectServicePort
|
||||
{
|
||||
private static final Map<EnumVersioningState, CMISVersioningStateEnum> VERSIONING_STATE_ENUM_MAPPING;
|
||||
|
||||
private DictionaryService dictionaryService;
|
||||
|
||||
private FileTypeIconRetriever iconRetriever;
|
||||
|
||||
static
|
||||
{
|
||||
VERSIONING_STATE_ENUM_MAPPING = new HashMap<EnumVersioningState, CMISVersioningStateEnum>(7);
|
||||
VERSIONING_STATE_ENUM_MAPPING.put(EnumVersioningState.NONE, CMISVersioningStateEnum.NONE);
|
||||
VERSIONING_STATE_ENUM_MAPPING.put(EnumVersioningState.CHECKEDOUT, CMISVersioningStateEnum.CHECKED_OUT);
|
||||
VERSIONING_STATE_ENUM_MAPPING.put(EnumVersioningState.MAJOR, CMISVersioningStateEnum.MAJOR);
|
||||
VERSIONING_STATE_ENUM_MAPPING.put(EnumVersioningState.MINOR, CMISVersioningStateEnum.MINOR);
|
||||
}
|
||||
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a document object of the specified type, and optionally adds the document to a folder
|
||||
*
|
||||
* @param repositoryId repository Id
|
||||
* @param properties CMIS properties
|
||||
* @param folderId parent folder for this new document
|
||||
* @param contentStream content stream
|
||||
* @param versioningState versioning state (checkedout, minor, major)
|
||||
* @return Id of the created document object
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, CONSTRAINT, STORAGE,
|
||||
* STREAM_NOT_SUPPORTED)
|
||||
*/
|
||||
public void createDocument(String repositoryId, CmisPropertiesType properties, String folderId, CmisContentStreamType contentStream, EnumVersioningState versioningState,
|
||||
List<String> policies, CmisAccessControlListType addACEs, CmisAccessControlListType removeACEs, Holder<CmisExtensionType> extension, Holder<String> objectId)
|
||||
throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
try
|
||||
{
|
||||
NodeRef parentNodeRef = cmisService.getFolder(folderId);
|
||||
Map<String, Serializable> propertiesMap = propertiesUtil.getPropertiesMap(properties);
|
||||
String typeId = extractAndAssertTypeId(propertiesMap);
|
||||
CMISTypeDefinition typeDef = cmisService.getTypeDefinition(typeId);
|
||||
String documentName = checkConstraintsAndGetName(typeId, typeDef, parentNodeRef, contentStream, propertiesMap, versioningState);
|
||||
NodeRef newDocumentNodeRef = fileFolderService.create(parentNodeRef, documentName, typeDef.getTypeId().getQName()).getNodeRef();
|
||||
|
||||
if (null != contentStream)
|
||||
{
|
||||
ContentWriter writer = fileFolderService.getWriter(newDocumentNodeRef);
|
||||
String mimeType = (String) propertiesMap.get(CMISDictionaryModel.PROP_CONTENT_STREAM_MIME_TYPE);
|
||||
mimeType = (null == mimeType) ? (contentStream.getMimeType()) : (mimeType);
|
||||
if (null != mimeType)
|
||||
{
|
||||
writer.setMimetype(mimeType);
|
||||
}
|
||||
InputStream inputstream = null;
|
||||
try
|
||||
{
|
||||
inputstream = contentStream.getStream().getInputStream();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e.getMessage(), EnumServiceException.RUNTIME, e);
|
||||
}
|
||||
writer.putContent(inputstream);
|
||||
}
|
||||
PropertyFilter propertyFilter = createPropertyFilter(createIgnoringFilter(new String[] { CMISDictionaryModel.PROP_NAME, CMISDictionaryModel.PROP_OBJECT_TYPE_ID }));
|
||||
appendDataToDocument(newDocumentNodeRef, properties, versioningState, policies, addACEs, removeACEs, objectId, propertyFilter);
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
if (null == properties)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException("Properties input parameter is Mandatory", EnumServiceException.INVALID_ARGUMENT);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a document object as a copy of the given source document in the specified location
|
||||
*
|
||||
* @param repositoryId repository Id
|
||||
* @param properties CMIS properties
|
||||
* @param folderId parent folder for this new document
|
||||
* @param contentStream content stream
|
||||
* @param versioningState versioning state (checkedout, minor, major)
|
||||
* @return Id of the created document object
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, CONSTRAINT, STORAGE,
|
||||
* STREAM_NOT_SUPPORTED)
|
||||
*/
|
||||
public void createDocumentFromSource(String repositoryId, String sourceId, CmisPropertiesType properties, String folderId, EnumVersioningState versioningState,
|
||||
List<String> policies, CmisAccessControlListType addACEs, CmisAccessControlListType removeACEs, Holder<CmisExtensionType> extension, Holder<String> objectId)
|
||||
throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
try
|
||||
{
|
||||
NodeRef folderNodeRef = cmisService.getFolder(folderId);
|
||||
NodeRef sourceNodeRef = cmisService.getReadableObject(sourceId, NodeRef.class);
|
||||
String name = propertiesUtil.getCmisPropertyValue(properties, CMISDictionaryModel.PROP_NAME, null);
|
||||
if (name == null)
|
||||
{
|
||||
name = propertiesUtil.getProperty(sourceNodeRef, CMISDictionaryModel.PROP_NAME, null);
|
||||
}
|
||||
NodeRef newDocumentNodeRef;
|
||||
try
|
||||
{
|
||||
newDocumentNodeRef = fileFolderService.copy(sourceNodeRef, folderNodeRef, name).getNodeRef();
|
||||
}
|
||||
catch (FileExistsException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException("Document already exists", EnumServiceException.NAME_CONSTRAINT_VIOLATION);
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException("Source document not found", EnumServiceException.INVALID_ARGUMENT);
|
||||
}
|
||||
PropertyFilter propertyFilter = createPropertyFilter(createIgnoringFilter(new String[] { CMISDictionaryModel.PROP_OBJECT_TYPE_ID }));
|
||||
appendDataToDocument(newDocumentNodeRef, properties, versioningState, policies, addACEs, removeACEs, objectId, propertyFilter);
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a folder object of the specified type.
|
||||
*
|
||||
* @param repositoryId repository Id
|
||||
* @param properties CMIS properties
|
||||
* @param folderId parent folder for this new folder
|
||||
* @return Id of the created folder object
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, CONSTRAINT, STORAGE)
|
||||
*/
|
||||
|
||||
public void createFolder(String repositoryId, CmisPropertiesType properties, String folderId, List<String> policies, CmisAccessControlListType addACEs,
|
||||
CmisAccessControlListType removeACEs, Holder<CmisExtensionType> extension, Holder<String> objectId) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
try
|
||||
{
|
||||
NodeRef folderNodeRef = cmisService.getFolder(folderId);
|
||||
Map<String, Serializable> propertiesMap = propertiesUtil.getPropertiesMap(properties);
|
||||
String typeId = extractAndAssertTypeId(propertiesMap);
|
||||
CMISTypeDefinition type = cmisService.getTypeDefinition(typeId);
|
||||
if (type == null || type.getTypeId() == null || type.getTypeId().getScope() != CMISScope.FOLDER)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException("The typeID is not an Object-Type whose baseType is 'Folder': " + typeId, EnumServiceException.CONSTRAINT);
|
||||
}
|
||||
|
||||
String name = propertiesUtil.getCmisPropertyValue(properties, CMISDictionaryModel.PROP_NAME, null);
|
||||
if (null == name)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException("Name property not found", EnumServiceException.INVALID_ARGUMENT);
|
||||
}
|
||||
|
||||
NodeRef newFolderNodeRef = fileFolderService.create(folderNodeRef, name, type.getTypeId().getQName()).getNodeRef();
|
||||
propertiesUtil.setProperties(newFolderNodeRef, properties, createPropertyFilter(createIgnoringFilter(new String[] { CMISDictionaryModel.PROP_NAME,
|
||||
CMISDictionaryModel.PROP_OBJECT_TYPE_ID })));
|
||||
applyAclCarefully(newFolderNodeRef, addACEs, removeACEs, EnumACLPropagation.PROPAGATE, policies);
|
||||
objectId.value = propertiesUtil.getProperty(newFolderNodeRef, CMISDictionaryModel.PROP_OBJECT_ID, null);
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a policy object of the specified type, and optionally adds the policy to a folder.
|
||||
*
|
||||
* @param repositoryId repository Id
|
||||
* @param properties CMIS properties
|
||||
* @param folderId parent folder for this new policy
|
||||
* @return Id of the created policy object
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, CONSTRAINT, STORAGE)
|
||||
*/
|
||||
public void createPolicy(String repositoryId, CmisPropertiesType properties, String folderId, List<String> policies, CmisAccessControlListType addACEs,
|
||||
CmisAccessControlListType removeACEs, Holder<CmisExtensionType> extension, Holder<String> objectId) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
try
|
||||
{
|
||||
objectId.value = cmisService.createPolicy(propertiesUtil.getPropertiesMap(properties), folderId, policies);
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a relationship object of the specified type.
|
||||
*
|
||||
* @param repositoryId repository Id
|
||||
* @param typeId relationship type
|
||||
* @param properties CMIS properties
|
||||
* @param sourceObjectId source object Id
|
||||
* @param targetObjectId target object Id
|
||||
* @return Id of the created relationship object
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, CONSTRAINT, STORAGE)
|
||||
*/
|
||||
public void createRelationship(String repositoryId, CmisPropertiesType properties, List<String> policies, CmisAccessControlListType addACEs,
|
||||
CmisAccessControlListType removeACEs, Holder<CmisExtensionType> extension, Holder<String> objectId) throws CmisException
|
||||
{
|
||||
// TODO: process Policies
|
||||
|
||||
Map<String, Serializable> propertiesMap = propertiesUtil.getPropertiesMap(properties);
|
||||
String sourceObjectId = (String) propertiesMap.get(CMISDictionaryModel.PROP_SOURCE_ID);
|
||||
String targetObjectId = (String) propertiesMap.get(CMISDictionaryModel.PROP_TARGET_ID);
|
||||
|
||||
checkRepositoryId(repositoryId);
|
||||
|
||||
try
|
||||
{
|
||||
NodeRef sourceNodeRef = cmisService.getObject(sourceObjectId, NodeRef.class, true, false, false);
|
||||
NodeRef targetNodeRef = cmisService.getObject(targetObjectId, NodeRef.class, true, false, false);
|
||||
|
||||
String typeId = (String) propertiesMap.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID);
|
||||
|
||||
CMISTypeDefinition relationshipType = cmisService.getTypeDefinition(typeId);
|
||||
if (relationshipType == null || relationshipType.getTypeId() == null || relationshipType.getTypeId().getScope() != CMISScope.RELATIONSHIP)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(typeId, EnumServiceException.INVALID_ARGUMENT);
|
||||
}
|
||||
|
||||
CMISTypeDefinition sourceType = cmisService.getTypeDefinition(sourceNodeRef);
|
||||
CMISTypeDefinition targetType = cmisService.getTypeDefinition(targetNodeRef);
|
||||
|
||||
QName relationshipTypeQName = relationshipType.getTypeId().getQName();
|
||||
AssociationDefinition associationDef = dictionaryService.getAssociation(relationshipTypeQName);
|
||||
if (associationDef != null)
|
||||
{
|
||||
if (!dictionaryService.isSubClass(nodeService.getType(sourceNodeRef), associationDef.getSourceClass().getName()))
|
||||
{
|
||||
throw ExceptionUtil.createCmisException("Source object type isn't allowed as source type", EnumServiceException.CONSTRAINT);
|
||||
}
|
||||
if (!dictionaryService.isSubClass(nodeService.getType(targetNodeRef), associationDef.getTargetClass().getName()))
|
||||
{
|
||||
throw ExceptionUtil.createCmisException("Target object type isn't allowed as target type", EnumServiceException.CONSTRAINT);
|
||||
}
|
||||
|
||||
// Check ACL arguments
|
||||
if (addACEs != null && !addACEs.getPermission().isEmpty() || removeACEs != null && !removeACEs.getPermission().isEmpty())
|
||||
{
|
||||
throw ExceptionUtil.createCmisException("ACLs are not supported for type: " + relationshipType.getDisplayName(), EnumServiceException.CONSTRAINT);
|
||||
}
|
||||
|
||||
AssociationRef assocRef = nodeService.createAssociation(sourceNodeRef, targetNodeRef, relationshipTypeQName);
|
||||
String createdId = (String) cmisService.getProperty(assocRef, CMISDictionaryModel.PROP_OBJECT_ID);
|
||||
|
||||
// Try applying policies
|
||||
applyPolicies(createdId, policies);
|
||||
|
||||
objectId.value = createdId;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ExceptionUtil.createCmisException((relationshipType.getTypeId().getQName() + " Relationship type not found"), EnumServiceException.INVALID_ARGUMENT);
|
||||
}
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the content-stream of the specified document. This does not delete properties. If there are other versions this does not affect them, their properties or content.
|
||||
* This does not change the ID of the document.
|
||||
*
|
||||
* @param repositoryId repository Id
|
||||
* @param objectId document Id
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, CONSTRAINT, STORAGE,
|
||||
* UPDATE_CONFLICT, VERSIONING)
|
||||
*/
|
||||
public void deleteContentStream(String repositoryId, Holder<String> objectId, Holder<String> changeToken, Holder<CmisExtensionType> extension) throws CmisException
|
||||
{
|
||||
// TODO: Process changeToken
|
||||
checkRepositoryId(repositoryId);
|
||||
try
|
||||
{
|
||||
cmisService.deleteContentStream(objectId.value);
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes specified object.
|
||||
*
|
||||
* @param repositoryId repository Id
|
||||
* @param objectId object Id
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, CONSTRAINT,
|
||||
* UPDATE_CONFLICT)
|
||||
*/
|
||||
public void deleteObject(String repositoryId, String objectId, Boolean allVersions, Holder<CmisExtensionType> extension) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
try
|
||||
{
|
||||
cmisService.deleteObject(objectId, allVersions == null || allVersions);
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the tree rooted at specified folder (including that folder)
|
||||
*
|
||||
* @param repositoryId repository Id
|
||||
* @param folderId folder Id
|
||||
* @param unfileNonfolderObjects unfile : unfile all non-folder objects from folders in this tree. They may remain filed in other folders, or may become unfiled,
|
||||
* deletesinglefiled : delete non-folder objects filed only in this tree, and unfile the others so they remain filed in other folders, delete : delete all non-folder
|
||||
* objects in this tree (Default)
|
||||
* @param continueOnFailure flag
|
||||
* @return collection of object IDs that failed to delete (if continueOnFailure is FALSE, then single object ID)
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, UPDATE_CONFLICT)
|
||||
*/
|
||||
public FailedToDelete deleteTree(String repositoryId, String folderId, Boolean allVersions, EnumUnfileObject unfileObject, Boolean continueOnFailure,
|
||||
CmisExtensionType extension) throws CmisException
|
||||
{
|
||||
// TODO: Process allVersions
|
||||
checkRepositoryId(repositoryId);
|
||||
checkUnfilingIsNotRequested(unfileObject);
|
||||
|
||||
List<String> failedToDelete;
|
||||
try
|
||||
{
|
||||
failedToDelete = cmisService.deleteTree(folderId, continueOnFailure == null ? false : continueOnFailure, unfileObject != EnumUnfileObject.DELETE, allVersions == null || allVersions);
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
FailedToDelete response = new FailedToDelete();
|
||||
response.getObjectIds().addAll(failedToDelete);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the specified object
|
||||
*
|
||||
* @param repositoryId repository Id
|
||||
* @param folderPath The path to the folder
|
||||
* @param filter property filter
|
||||
* @return list of properties for the Folder
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND)
|
||||
*/
|
||||
// FIXME: createCmisObject instead of manual set-upping
|
||||
public CmisObjectType getObject(String repositoryId, String objectId, String filter, Boolean includeAllowableActions, EnumIncludeRelationships includeRelationships,
|
||||
String renditionFilter, Boolean includePolicyIds, Boolean includeACL, CmisExtensionType extension) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
|
||||
try
|
||||
{
|
||||
Object object = cmisService.getReadableObject(objectId, Object.class);
|
||||
PropertyFilter propertyFilter = createPropertyFilter(filter);
|
||||
CmisObjectType cmisObject = createCmisObject(object, propertyFilter, includeRelationships,
|
||||
includeAllowableActions, renditionFilter);
|
||||
|
||||
Object versionSeries = cmisService.getVersionSeries(objectId, Object.class, false);
|
||||
boolean includeAcl = (null != includeACL) ? (includeACL.booleanValue()) : (false);
|
||||
if (includeAcl && (versionSeries instanceof NodeRef))
|
||||
{
|
||||
appendWithAce((NodeRef) versionSeries, cmisObject);
|
||||
}
|
||||
|
||||
return cmisObject;
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the specified object by path
|
||||
*
|
||||
* @param repositoryId repository Id
|
||||
* @param folderPath The path to the folder
|
||||
* @param filter property filter
|
||||
* @return list of properties for the Folder
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND)
|
||||
*/
|
||||
public CmisObjectType getObjectByPath(String repositoryId, String path, String filter, Boolean includeAllowableActions, EnumIncludeRelationships includeRelationships,
|
||||
String renditionFilter, Boolean includePolicyIds, Boolean includeACL, CmisExtensionType extension) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
NodeRef objectNodeRef = resolvePathInfo(path);
|
||||
if (null == objectNodeRef)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException("Path to Folder was not specified or Folder Path is invalid", EnumServiceException.OBJECT_NOT_FOUND);
|
||||
}
|
||||
PropertyFilter propertyFilter = createPropertyFilter(filter);
|
||||
CmisObjectType object = createCmisObject(objectNodeRef, propertyFilter, includeRelationships,
|
||||
includeAllowableActions, renditionFilter);
|
||||
boolean includeAcl = (null != includeACL) ? (includeACL.booleanValue()) : (false);
|
||||
if (includeAcl)
|
||||
{
|
||||
appendWithAce(objectNodeRef, object);
|
||||
}
|
||||
// TODO: process relationships
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of allowable actions (CMIS service calls) for an object based on the current user's context, subject to any access constraints that are currently imposed by
|
||||
* the repository.
|
||||
*
|
||||
* @param repositoryId repository Id
|
||||
* @param objectId object Id
|
||||
* @return list of allowable actions
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME)
|
||||
*/
|
||||
public CmisAllowableActionsType getAllowableActions(String repositoryId, String objectId, CmisExtensionType extension) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
Object object;
|
||||
try
|
||||
{
|
||||
object = cmisService.getReadableObject(objectId, Object.class);
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
return determineObjectAllowableActions(object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the content-stream for a document.
|
||||
*
|
||||
* @param repositoryId repository Id
|
||||
* @param documentId document to return the content-stream
|
||||
* @return content stream
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, STREAM_NOT_SUPPORTED)
|
||||
*/
|
||||
public CmisContentStreamType getContentStream(String repositoryId, String objectId, String streamId, BigInteger offset, BigInteger length, CmisExtensionType extension)
|
||||
throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
try
|
||||
{
|
||||
NodeRef nodeRef = cmisService.getReadableObject(objectId, NodeRef.class);
|
||||
CMISTypeDefinition typeDefinition = cmisService.getTypeDefinition(nodeRef);
|
||||
if (CMISContentStreamAllowedEnum.NOT_ALLOWED == typeDefinition.getContentStreamAllowed())
|
||||
{
|
||||
throw ExceptionUtil.createCmisException("Content stream not allowed", EnumServiceException.STREAM_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
String filename = propertiesUtil.getProperty(nodeRef, CMISDictionaryModel.PROP_NAME, null);
|
||||
|
||||
ContentReaderDataSource dataSource = null;
|
||||
if (streamId != null && streamId.length() > 0)
|
||||
{
|
||||
FileTypeImageSize streamIcon = null;
|
||||
if (streamId.equals("alf:icon16"))
|
||||
{
|
||||
streamIcon = FileTypeImageSize.Small;
|
||||
}
|
||||
else if (streamId.equals("alf:icon32"))
|
||||
{
|
||||
streamIcon = FileTypeImageSize.Medium;
|
||||
}
|
||||
if (streamIcon != null)
|
||||
{
|
||||
InputStream iconInputStream = iconRetriever.getIconContent(filename, streamIcon);
|
||||
String iconMimetype = iconRetriever.getIconMimetype(filename, streamIcon);
|
||||
if (iconInputStream != null && iconMimetype != null)
|
||||
{
|
||||
dataSource = new ContentReaderDataSource(iconInputStream, iconMimetype, filename, offset, length);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NodeRef renditionNodeRef = new NodeRef(streamId);
|
||||
ContentReader reader = safeGetContentReader(renditionNodeRef);
|
||||
dataSource = new ContentReaderDataSource(reader, filename, offset, length, reader.getSize());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ContentReader reader = safeGetContentReader(nodeRef);
|
||||
dataSource = new ContentReaderDataSource(reader, filename, offset, length, reader.getSize());
|
||||
}
|
||||
|
||||
CmisContentStreamType response = new CmisContentStreamType();
|
||||
|
||||
response.setFilename(filename);
|
||||
|
||||
if (dataSource != null)
|
||||
{
|
||||
response.setMimeType(dataSource.getContentType());
|
||||
response.setStream(new DataHandler(dataSource));
|
||||
response.setLength(BigInteger.valueOf(dataSource.getSizeToRead()));
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the specified filed object from one folder to another
|
||||
*
|
||||
* @param repositoryId repository Id
|
||||
* @param objectId object Id
|
||||
* @param targetFolderId the target folder to be moved into
|
||||
* @param sourceFolderId the source folder to be moved out of
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, CONSTRAINT, STORAGE,
|
||||
* UPDATE_CONFLICT, VERSIONING)
|
||||
*/
|
||||
public void moveObject(String repositoryId, Holder<String> objectId, String targetFolderId, String sourceFolderId, Holder<CmisExtensionType> extension) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
try
|
||||
{
|
||||
cmisService.moveObject(objectId.value, targetFolderId, sourceFolderId);
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets (creates or replaces) the content-stream for the specified document object.
|
||||
*
|
||||
* @param repositoryId repository Id
|
||||
* @param objectId document Id
|
||||
* @param overwriteFlag flag
|
||||
* @param contentStream content stream
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, CONSTRAINT,
|
||||
* CONTENT_ALREADY_EXISTS, STORAGE, STREAM_NOT_SUPPORTED, UPDATE_CONFLICT, VERSIONING)
|
||||
*/
|
||||
|
||||
public void setContentStream(String repositoryId, Holder<String> objectId, Boolean overwriteFlag, Holder<String> changeToken, CmisContentStreamType contentStream,
|
||||
Holder<CmisExtensionType> extension) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
try
|
||||
{
|
||||
cmisService.setContentStream(objectId.value, null, overwriteFlag == null || overwriteFlag, contentStream.getStream().getInputStream(), contentStream.getMimeType());
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e.getMessage(), EnumServiceException.RUNTIME, e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates properties of the specified object. As per the data model, content-streams are not properties.
|
||||
*
|
||||
* @param repositoryId repository Id
|
||||
* @param objectId object Id
|
||||
* @param changeToken change token
|
||||
* @param properties list of properties to update
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, CONSTRAINT,
|
||||
* UPDATE_CONFLICT, VERSIONING)
|
||||
*/
|
||||
public void updateProperties(String repositoryId, Holder<String> objectId, Holder<String> changeToken, CmisPropertiesType properties, Holder<CmisExtensionType> extension)
|
||||
throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
|
||||
NodeRef objectNodeRef;
|
||||
try
|
||||
{
|
||||
objectNodeRef = cmisService.getObject(objectId.value, NodeRef.class, true, false, false);
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
propertiesUtil.setProperties(objectNodeRef, properties, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the properties of an object, and optionally the operations that the user is allowed to perform on the object.
|
||||
*
|
||||
* @param parameters
|
||||
* @return collection collection of CmisObjectType
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, FOLDER_NOT_VALID)
|
||||
*/
|
||||
public CmisPropertiesType getProperties(String repositoryId, String objectId, String filter, CmisExtensionType extension) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
|
||||
PropertyFilter propertyFilter = createPropertyFilter(filter);
|
||||
|
||||
Object identifierInstance;
|
||||
try
|
||||
{
|
||||
identifierInstance = cmisService.getReadableObject(objectId, Object.class);
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
CmisPropertiesType result = propertiesUtil.getProperties(identifierInstance, propertyFilter);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the renditions of an object, and optionally the operations that the user is allowed to perform on the object.
|
||||
*
|
||||
* @param parameters
|
||||
* @return collection collection of CmisObjectType
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, FOLDER_NOT_VALID)
|
||||
*/
|
||||
public List<CmisRenditionType> getRenditions(String repositoryId, String objectId, String renditionFilter, BigInteger maxItems, BigInteger skipCount,
|
||||
CmisExtensionType extension) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
NodeRef objectNodeRef;
|
||||
try
|
||||
{
|
||||
objectNodeRef = cmisService.getReadableObject(objectId, NodeRef.class);
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
List<CmisRenditionType> result = new ArrayList<CmisRenditionType>();
|
||||
List<CmisRenditionType> renditions = getRenditions(objectNodeRef, renditionFilter);
|
||||
if (renditions != null)
|
||||
{
|
||||
Cursor cursor = createCursor(renditions.size(), skipCount, maxItems);
|
||||
for (int index = cursor.getStartRow(); index <= cursor.getEndRow(); index++)
|
||||
{
|
||||
result.add(renditions.get(index));
|
||||
}
|
||||
}
|
||||
return renditions;
|
||||
}
|
||||
|
||||
private void appendDataToDocument(NodeRef targetDocumentNodeRef, CmisPropertiesType properties, EnumVersioningState versioningState, List<String> policies,
|
||||
CmisAccessControlListType addACEs, CmisAccessControlListType removeACEs, Holder<String> objectId, PropertyFilter propertyFilter) throws CMISConstraintException,
|
||||
CmisException, CMISInvalidArgumentException
|
||||
{
|
||||
propertiesUtil.setProperties(targetDocumentNodeRef, properties, propertyFilter);
|
||||
|
||||
// Apply the ACL before potentially creating a PWC
|
||||
applyAclCarefully(targetDocumentNodeRef, addACEs, removeACEs, EnumACLPropagation.PROPAGATE, policies);
|
||||
|
||||
if (versioningState == null)
|
||||
{
|
||||
versioningState = EnumVersioningState.MAJOR;
|
||||
}
|
||||
|
||||
targetDocumentNodeRef = cmisService.applyVersioningState(targetDocumentNodeRef, VERSIONING_STATE_ENUM_MAPPING.get(versioningState));
|
||||
objectId.value = targetDocumentNodeRef.toString();
|
||||
}
|
||||
|
||||
private String createIgnoringFilter(String[] propertyNames)
|
||||
{
|
||||
StringBuilder filter = new StringBuilder("");
|
||||
|
||||
for (String propertyName : propertyNames)
|
||||
{
|
||||
if ((null != propertyName) && !propertyName.equals(""))
|
||||
{
|
||||
filter.append(propertyName);
|
||||
filter.append(PropertyFilter.PROPERTY_NAME_TOKENS_DELIMITER);
|
||||
}
|
||||
}
|
||||
|
||||
if (filter.length() > 0)
|
||||
{
|
||||
filter.deleteCharAt(filter.length() - 1);
|
||||
}
|
||||
|
||||
return filter.toString();
|
||||
}
|
||||
|
||||
private String extractAndAssertTypeId(Map<String, Serializable> propertiesMap) throws CmisException
|
||||
{
|
||||
String typeId = (String) propertiesMap.get(CMISDictionaryModel.PROP_OBJECT_TYPE_ID);
|
||||
if ((null == typeId) || "".equals(typeId))
|
||||
{
|
||||
throw ExceptionUtil.createCmisException("Type Id property required", EnumServiceException.INVALID_ARGUMENT);
|
||||
}
|
||||
return typeId;
|
||||
}
|
||||
|
||||
private String checkConstraintsAndGetName(String documentTypeId, CMISTypeDefinition typeDef, NodeRef parentNodeRef, CmisContentStreamType contentStream,
|
||||
Map<String, Serializable> propertiesMap, EnumVersioningState versioningState) throws CmisException
|
||||
{
|
||||
if ((null == typeDef) || (null == typeDef.getTypeId()))
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(("Type with " + documentTypeId + "typeId was not found"), EnumServiceException.RUNTIME);
|
||||
}
|
||||
|
||||
if ((CMISScope.DOCUMENT != typeDef.getTypeId().getScope()) || !typeDef.isCreatable())
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(("Invalid document type \"" + documentTypeId + "\". This type is not a Creatable Document type"),
|
||||
EnumServiceException.CONSTRAINT);
|
||||
}
|
||||
|
||||
if ((null != contentStream) && CMISContentStreamAllowedEnum.NOT_ALLOWED == typeDef.getContentStreamAllowed())
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(("Content stream not allowed for \"" + documentTypeId + "\" document object type"), EnumServiceException.STREAM_NOT_SUPPORTED);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((CMISContentStreamAllowedEnum.REQUIRED == typeDef.getContentStreamAllowed()) && (null == contentStream))
|
||||
{
|
||||
throw ExceptionUtil.createCmisException("Content stream for document object of " + documentTypeId + " type is required", EnumServiceException.CONSTRAINT);
|
||||
}
|
||||
}
|
||||
|
||||
if (!typeDef.isVersionable() && (null != versioningState))
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(("Verioning for \"" + documentTypeId + "\" document type is not allowed"), EnumServiceException.CONSTRAINT);
|
||||
}
|
||||
|
||||
CMISTypeDefinition folderTypeDefinition;
|
||||
try
|
||||
{
|
||||
folderTypeDefinition = cmisService.getTypeDefinition(parentNodeRef);
|
||||
}
|
||||
catch (CMISInvalidArgumentException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e.getMessage(), EnumServiceException.INVALID_ARGUMENT, e);
|
||||
}
|
||||
if ((null != folderTypeDefinition.getAllowedTargetTypes()) && !folderTypeDefinition.getAllowedTargetTypes().isEmpty()
|
||||
&& !folderTypeDefinition.getAllowedTargetTypes().contains(typeDef))
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(("Children of \"" + documentTypeId + "\" type are not allowed for specified folder"), EnumServiceException.CONSTRAINT);
|
||||
}
|
||||
|
||||
String result = (String) propertiesMap.get(CMISDictionaryModel.PROP_NAME);
|
||||
if (null == result)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException("Name property not found", EnumServiceException.INVALID_ARGUMENT);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private NodeRef resolvePathInfo(String folderPath) throws CmisException
|
||||
{
|
||||
NodeRef result = null;
|
||||
if (null != folderPath)
|
||||
{
|
||||
folderPath = folderPath.substring(1);
|
||||
if ("".equals(folderPath))
|
||||
{
|
||||
result = cmisService.getDefaultRootNodeRef();
|
||||
}
|
||||
else
|
||||
{
|
||||
FileInfo fileInfo = null;
|
||||
try
|
||||
{
|
||||
List<String> splitedPath = Arrays.asList(folderPath.split("/"));
|
||||
fileInfo = fileFolderService.resolveNamePath(cmisService.getDefaultRootNodeRef(), splitedPath);
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
}
|
||||
result = (null != fileInfo) ? (fileInfo.getNodeRef()) : (null);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private ContentReader safeGetContentReader(NodeRef objectNodeReference) throws CmisException
|
||||
{
|
||||
ContentReader reader = fileFolderService.getReader(objectNodeReference);
|
||||
if (reader == null)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException("The specified Document has no Content Stream", EnumServiceException.CONSTRAINT);
|
||||
}
|
||||
return reader;
|
||||
}
|
||||
|
||||
private void checkUnfilingIsNotRequested(EnumUnfileObject unfileNonfolderObjects) throws CmisException
|
||||
{
|
||||
if (unfileNonfolderObjects == EnumUnfileObject.UNFILE)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException("Unfiling is not supported", EnumServiceException.NOT_SUPPORTED);
|
||||
}
|
||||
}
|
||||
|
||||
public void setFileTypeIconRetriever(FileTypeIconRetriever iconRetriever)
|
||||
{
|
||||
this.iconRetriever = iconRetriever;
|
||||
}
|
||||
}
|
@@ -1,93 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.cmis.ws;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.ws.Holder;
|
||||
|
||||
import org.alfresco.cmis.CMISServiceException;
|
||||
import org.alfresco.repo.cmis.ws.utils.ExceptionUtil;
|
||||
|
||||
@javax.jws.WebService(name = "PolicyServicePort", serviceName = "PolicyService", portName = "PolicyServicePort", targetNamespace = "http://docs.oasis-open.org/ns/cmis/ws/200908/", endpointInterface = "org.alfresco.repo.cmis.ws.PolicyServicePort")
|
||||
public class DMPolicyServicePort extends DMAbstractServicePort implements PolicyServicePort
|
||||
{
|
||||
/**
|
||||
* Applies a policy object to a target object.
|
||||
*
|
||||
* @param repositoryId repository Id
|
||||
* @param policyId policy Id
|
||||
* @param objectId target object Id
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, CONSTRAINT)
|
||||
*/
|
||||
public void applyPolicy(String repositoryId, String policyId, String objectId, Holder<CmisExtensionType> extension) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
try
|
||||
{
|
||||
cmisService.applyPolicy(policyId, objectId);
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of policy objects currently applied to a target object.
|
||||
*
|
||||
* @param parameters repositoryId: repository Id; objectId: target object Id; filter: filter specifying which properties to return
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, FILTER_NOT_VALID)
|
||||
*/
|
||||
public List<CmisObjectType> getAppliedPolicies(String repositoryId, String objectId, String filter, CmisExtensionType extension) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
try
|
||||
{
|
||||
cmisService.getAppliedPolicies(objectId, filter);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a previously applied policy from a target object. The policy object is not deleted, and may still be applied to other objects.
|
||||
*
|
||||
* @param repositoryId repository Id
|
||||
* @param policyId policy Id
|
||||
* @param objectId target object Id.
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, CONSTRAINT)
|
||||
*/
|
||||
public void removePolicy(String repositoryId, String policyId, String objectId, Holder<CmisExtensionType> extension) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
try
|
||||
{
|
||||
cmisService.removePolicy(policyId, objectId);
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.cmis.ws;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.cmis.CMISRelationshipDirectionEnum;
|
||||
import org.alfresco.cmis.CMISServiceException;
|
||||
import org.alfresco.cmis.CMISTypeDefinition;
|
||||
import org.alfresco.cmis.PropertyFilter;
|
||||
import org.alfresco.repo.cmis.ws.utils.ExceptionUtil;
|
||||
import org.alfresco.repo.web.util.paging.Cursor;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Port for relationship service
|
||||
*
|
||||
* @author Dmitry Velichkevich
|
||||
*/
|
||||
@javax.jws.WebService(name = "RelationshipServicePort", serviceName = "RelationshipService", portName = "RelationshipServicePort", targetNamespace = "http://docs.oasis-open.org/ns/cmis/ws/200908/", endpointInterface = "org.alfresco.repo.cmis.ws.RelationshipServicePort")
|
||||
public class DMRelationshipServicePort extends DMAbstractServicePort implements RelationshipServicePort
|
||||
{
|
||||
private static final Map<EnumRelationshipDirection, CMISRelationshipDirectionEnum> RELATIONSHIP_DIRECTION_MAPPING;
|
||||
static
|
||||
{
|
||||
RELATIONSHIP_DIRECTION_MAPPING = new HashMap<EnumRelationshipDirection, CMISRelationshipDirectionEnum>(5);
|
||||
RELATIONSHIP_DIRECTION_MAPPING.put(EnumRelationshipDirection.SOURCE, CMISRelationshipDirectionEnum.SOURCE);
|
||||
RELATIONSHIP_DIRECTION_MAPPING.put(EnumRelationshipDirection.TARGET, CMISRelationshipDirectionEnum.TARGET);
|
||||
RELATIONSHIP_DIRECTION_MAPPING.put(EnumRelationshipDirection.EITHER, CMISRelationshipDirectionEnum.EITHER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of relationships associated with the object, optionally of a specified relationship type, and optionally in a specified direction.
|
||||
*
|
||||
* @param parameters repositoryId: Repository Id, objectId: The object with which relationships are associated with; direction: source (Default), target, both; typeId:
|
||||
* Relationship Type; includeSubRelationshipTypes: false (Default); filter: property filter; includeAllowableActions: false (default); maxItems: 0 = Unlimited;
|
||||
* skipCount: 0 = start at beginning
|
||||
* @return collection of CmisObjectType and boolean hasMoreItems
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, FILTER_NOT_VALID)
|
||||
*/
|
||||
public CmisObjectListType getObjectRelationships(String repositoryId, String objectId, Boolean includeSubRelationshipTypes, EnumRelationshipDirection relationshipDirection,
|
||||
String typeId, String filter, Boolean includeAllowableActions, BigInteger maxItems, BigInteger skipCount, CmisExtensionType extension) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
if ((null == objectId) || "".equals(objectId) || !NodeRef.isNodeRef(objectId))
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(("Object with Id='" + objectId + "' is not exist!"), EnumServiceException.OBJECT_NOT_FOUND);
|
||||
}
|
||||
try
|
||||
{
|
||||
CMISTypeDefinition relDef = (null != typeId) ? (cmisService.getTypeDefinition(typeId)):(null);
|
||||
NodeRef nodeRef = cmisService.getReadableObject(objectId, NodeRef.class);
|
||||
AssociationRef[] assocs = cmisService.getRelationships(nodeRef, relDef, includeSubRelationshipTypes != null && includeSubRelationshipTypes,
|
||||
relationshipDirection == null ? CMISRelationshipDirectionEnum.SOURCE : RELATIONSHIP_DIRECTION_MAPPING.get(relationshipDirection));
|
||||
skipCount = (null != skipCount) ? skipCount : BigInteger.ZERO;
|
||||
maxItems = (null != maxItems) ? maxItems : BigInteger.ZERO;
|
||||
PropertyFilter propertyFilter = createPropertyFilter(filter);
|
||||
return createResult(propertyFilter, includeAllowableActions, assocs, skipCount, maxItems);
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private CmisObjectListType createResult(PropertyFilter filter, Boolean includeAllowableActions, Object[] sourceArray, BigInteger skipCount, BigInteger maxItems)
|
||||
throws CmisException
|
||||
{
|
||||
Cursor cursor = createCursor(sourceArray.length, skipCount, maxItems);
|
||||
CmisObjectListType result = new CmisObjectListType();
|
||||
for (int i = cursor.getStartRow(); i <= cursor.getEndRow(); i++)
|
||||
{
|
||||
result.getObjects().add(createCmisObject(sourceArray[i], filter, null, includeAllowableActions, null));
|
||||
}
|
||||
result.setHasMoreItems(cursor.getEndRow() < sourceArray.length);
|
||||
result.setNumItems(BigInteger.valueOf(cursor.getPageSize()));
|
||||
return result;
|
||||
}
|
||||
}
|
@@ -1,672 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.cmis.ws;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.cmis.CMISAclCapabilityEnum;
|
||||
import org.alfresco.cmis.CMISAclPropagationEnum;
|
||||
import org.alfresco.cmis.CMISAclSupportedPermissionEnum;
|
||||
import org.alfresco.cmis.CMISBaseObjectTypeIds;
|
||||
import org.alfresco.cmis.CMISCapabilityChanges;
|
||||
import org.alfresco.cmis.CMISCardinalityEnum;
|
||||
import org.alfresco.cmis.CMISChoice;
|
||||
import org.alfresco.cmis.CMISContentStreamAllowedEnum;
|
||||
import org.alfresco.cmis.CMISDataTypeEnum;
|
||||
import org.alfresco.cmis.CMISDictionaryModel;
|
||||
import org.alfresco.cmis.CMISInvalidArgumentException;
|
||||
import org.alfresco.cmis.CMISJoinEnum;
|
||||
import org.alfresco.cmis.CMISPermissionDefinition;
|
||||
import org.alfresco.cmis.CMISPermissionMapping;
|
||||
import org.alfresco.cmis.CMISPropertyDefinition;
|
||||
import org.alfresco.cmis.CMISQueryEnum;
|
||||
import org.alfresco.cmis.CMISServiceException;
|
||||
import org.alfresco.cmis.CMISTypeDefinition;
|
||||
import org.alfresco.cmis.CMISUpdatabilityEnum;
|
||||
import org.alfresco.repo.cmis.ws.utils.ExceptionUtil;
|
||||
import org.alfresco.repo.web.util.paging.Cursor;
|
||||
import org.alfresco.service.descriptor.Descriptor;
|
||||
|
||||
/**
|
||||
* Port for repository service.
|
||||
*
|
||||
* @author Dmitry Lazurkin
|
||||
*/
|
||||
@javax.jws.WebService(name = "RepositoryServicePort", serviceName = "RepositoryService", portName = "RepositoryServicePort", targetNamespace = "http://docs.oasis-open.org/ns/cmis/ws/200908/", endpointInterface = "org.alfresco.repo.cmis.ws.RepositoryServicePort")
|
||||
public class DMRepositoryServicePort extends DMAbstractServicePort implements RepositoryServicePort
|
||||
{
|
||||
private static final Map<CMISJoinEnum, EnumCapabilityJoin> JOIN_ENUM_MAPPING;
|
||||
private static final Map<CMISContentStreamAllowedEnum, EnumContentStreamAllowed> CONTENT_STREAM_ALLOWED_ENUM_MAPPING;
|
||||
private static final Map<CMISUpdatabilityEnum, EnumUpdatability> UPDATABILITY_ENUM_MAPPING;
|
||||
private static final Map<CMISCardinalityEnum, EnumCardinality> CARDINALITY_ENUM_MAPPING;
|
||||
private static final Map<CMISDataTypeEnum, EnumPropertyType> PROPERTY_TYPE_ENUM_MAPPING;
|
||||
private static final Map<CMISQueryEnum, EnumCapabilityQuery> QUERY_TYPE_ENUM_MAPPING;
|
||||
private static final Map<CMISCapabilityChanges, EnumCapabilityChanges> CHANGES_TYPE_ENUM_MAPPING;
|
||||
private static final Map<CMISBaseObjectTypeIds, EnumBaseObjectTypeIds> BASE_IDS_TYPE_ENUM_MAPPING;
|
||||
private static final Map<CMISAclCapabilityEnum, EnumCapabilityACL> ACL_CAPABILITY_ENUM_MAPPING;
|
||||
private static final Map<CMISAclSupportedPermissionEnum, EnumSupportedPermissions> ACL_SUPPORTED_PERMISSION_ENUM_MAPPING;
|
||||
private static final Map<CMISAclPropagationEnum, EnumACLPropagation> ACL_PROPAGATION_ENUM_MAPPGIN;
|
||||
|
||||
static
|
||||
{
|
||||
JOIN_ENUM_MAPPING = new HashMap<CMISJoinEnum, EnumCapabilityJoin>();
|
||||
JOIN_ENUM_MAPPING.put(CMISJoinEnum.INNER_AND_OUTER_JOIN_SUPPORT, EnumCapabilityJoin.INNERANDOUTER);
|
||||
JOIN_ENUM_MAPPING.put(CMISJoinEnum.INNER_JOIN_SUPPORT, EnumCapabilityJoin.INNERONLY);
|
||||
JOIN_ENUM_MAPPING.put(CMISJoinEnum.NO_JOIN_SUPPORT, EnumCapabilityJoin.NONE);
|
||||
|
||||
CONTENT_STREAM_ALLOWED_ENUM_MAPPING = new HashMap<CMISContentStreamAllowedEnum, EnumContentStreamAllowed>();
|
||||
CONTENT_STREAM_ALLOWED_ENUM_MAPPING.put(CMISContentStreamAllowedEnum.ALLOWED, EnumContentStreamAllowed.ALLOWED);
|
||||
CONTENT_STREAM_ALLOWED_ENUM_MAPPING.put(CMISContentStreamAllowedEnum.NOT_ALLOWED, EnumContentStreamAllowed.NOTALLOWED);
|
||||
CONTENT_STREAM_ALLOWED_ENUM_MAPPING.put(CMISContentStreamAllowedEnum.REQUIRED, EnumContentStreamAllowed.REQUIRED);
|
||||
|
||||
UPDATABILITY_ENUM_MAPPING = new HashMap<CMISUpdatabilityEnum, EnumUpdatability>();
|
||||
UPDATABILITY_ENUM_MAPPING.put(CMISUpdatabilityEnum.READ_AND_WRITE, EnumUpdatability.READWRITE);
|
||||
UPDATABILITY_ENUM_MAPPING.put(CMISUpdatabilityEnum.READ_AND_WRITE_WHEN_CHECKED_OUT, EnumUpdatability.WHENCHECKEDOUT);
|
||||
UPDATABILITY_ENUM_MAPPING.put(CMISUpdatabilityEnum.READ_ONLY, EnumUpdatability.READONLY);
|
||||
UPDATABILITY_ENUM_MAPPING.put(CMISUpdatabilityEnum.ON_CREATE, EnumUpdatability.ONCREATE);
|
||||
|
||||
CARDINALITY_ENUM_MAPPING = new HashMap<CMISCardinalityEnum, EnumCardinality>();
|
||||
CARDINALITY_ENUM_MAPPING.put(CMISCardinalityEnum.MULTI_VALUED, EnumCardinality.MULTI);
|
||||
CARDINALITY_ENUM_MAPPING.put(CMISCardinalityEnum.SINGLE_VALUED, EnumCardinality.SINGLE);
|
||||
|
||||
PROPERTY_TYPE_ENUM_MAPPING = new HashMap<CMISDataTypeEnum, EnumPropertyType>();
|
||||
PROPERTY_TYPE_ENUM_MAPPING.put(CMISDataTypeEnum.BOOLEAN, EnumPropertyType.BOOLEAN);
|
||||
PROPERTY_TYPE_ENUM_MAPPING.put(CMISDataTypeEnum.DATETIME, EnumPropertyType.DATETIME);
|
||||
PROPERTY_TYPE_ENUM_MAPPING.put(CMISDataTypeEnum.DECIMAL, EnumPropertyType.DECIMAL);
|
||||
PROPERTY_TYPE_ENUM_MAPPING.put(CMISDataTypeEnum.HTML, EnumPropertyType.HTML);
|
||||
PROPERTY_TYPE_ENUM_MAPPING.put(CMISDataTypeEnum.ID, EnumPropertyType.ID);
|
||||
PROPERTY_TYPE_ENUM_MAPPING.put(CMISDataTypeEnum.INTEGER, EnumPropertyType.INTEGER);
|
||||
PROPERTY_TYPE_ENUM_MAPPING.put(CMISDataTypeEnum.STRING, EnumPropertyType.STRING);
|
||||
PROPERTY_TYPE_ENUM_MAPPING.put(CMISDataTypeEnum.URI, EnumPropertyType.URI);
|
||||
|
||||
QUERY_TYPE_ENUM_MAPPING = new HashMap<CMISQueryEnum, EnumCapabilityQuery>();
|
||||
QUERY_TYPE_ENUM_MAPPING.put(CMISQueryEnum.BOTH_COMBINED, EnumCapabilityQuery.BOTHCOMBINED);
|
||||
QUERY_TYPE_ENUM_MAPPING.put(CMISQueryEnum.BOTH_SEPERATE, EnumCapabilityQuery.BOTHSEPARATE);
|
||||
QUERY_TYPE_ENUM_MAPPING.put(CMISQueryEnum.FULLTEXT_ONLY, EnumCapabilityQuery.FULLTEXTONLY);
|
||||
QUERY_TYPE_ENUM_MAPPING.put(CMISQueryEnum.METADATA_ONLY, EnumCapabilityQuery.METADATAONLY);
|
||||
QUERY_TYPE_ENUM_MAPPING.put(CMISQueryEnum.NONE, EnumCapabilityQuery.NONE);
|
||||
|
||||
CHANGES_TYPE_ENUM_MAPPING = new HashMap<CMISCapabilityChanges, EnumCapabilityChanges>();
|
||||
CHANGES_TYPE_ENUM_MAPPING.put(CMISCapabilityChanges.NONE, EnumCapabilityChanges.NONE);
|
||||
CHANGES_TYPE_ENUM_MAPPING.put(CMISCapabilityChanges.OBJECTIDSONLY, EnumCapabilityChanges.OBJECTIDSONLY);
|
||||
|
||||
BASE_IDS_TYPE_ENUM_MAPPING = new HashMap<CMISBaseObjectTypeIds, EnumBaseObjectTypeIds>();
|
||||
BASE_IDS_TYPE_ENUM_MAPPING.put(CMISBaseObjectTypeIds.DOCUMENT, EnumBaseObjectTypeIds.CMIS_DOCUMENT);
|
||||
BASE_IDS_TYPE_ENUM_MAPPING.put(CMISBaseObjectTypeIds.FOLDER, EnumBaseObjectTypeIds.CMIS_FOLDER);
|
||||
BASE_IDS_TYPE_ENUM_MAPPING.put(CMISBaseObjectTypeIds.RELATIONSHIP, EnumBaseObjectTypeIds.CMIS_RELATIONSHIP);
|
||||
BASE_IDS_TYPE_ENUM_MAPPING.put(CMISBaseObjectTypeIds.POLICY, EnumBaseObjectTypeIds.CMIS_POLICY);
|
||||
|
||||
ACL_CAPABILITY_ENUM_MAPPING = new HashMap<CMISAclCapabilityEnum, EnumCapabilityACL>();
|
||||
ACL_CAPABILITY_ENUM_MAPPING.put(CMISAclCapabilityEnum.DISCOVER, EnumCapabilityACL.DISCOVER);
|
||||
ACL_CAPABILITY_ENUM_MAPPING.put(CMISAclCapabilityEnum.MANAGE, EnumCapabilityACL.MANAGE);
|
||||
ACL_CAPABILITY_ENUM_MAPPING.put(CMISAclCapabilityEnum.NONE, EnumCapabilityACL.NONE);
|
||||
|
||||
ACL_PROPAGATION_ENUM_MAPPGIN = new HashMap<CMISAclPropagationEnum, EnumACLPropagation>();
|
||||
ACL_PROPAGATION_ENUM_MAPPGIN.put(CMISAclPropagationEnum.OBJECT_ONLY, EnumACLPropagation.OBJECTONLY);
|
||||
ACL_PROPAGATION_ENUM_MAPPGIN.put(CMISAclPropagationEnum.PROPAGATE, EnumACLPropagation.PROPAGATE);
|
||||
ACL_PROPAGATION_ENUM_MAPPGIN.put(CMISAclPropagationEnum.REPOSITORY_DETERMINED, EnumACLPropagation.REPOSITORYDETERMINED);
|
||||
|
||||
ACL_SUPPORTED_PERMISSION_ENUM_MAPPING = new HashMap<CMISAclSupportedPermissionEnum, EnumSupportedPermissions>();
|
||||
ACL_SUPPORTED_PERMISSION_ENUM_MAPPING.put(CMISAclSupportedPermissionEnum.BASIC, EnumSupportedPermissions.BASIC);
|
||||
ACL_SUPPORTED_PERMISSION_ENUM_MAPPING.put(CMISAclSupportedPermissionEnum.REPOSITORY, EnumSupportedPermissions.REPOSITORY);
|
||||
ACL_SUPPORTED_PERMISSION_ENUM_MAPPING.put(CMISAclSupportedPermissionEnum.BOTH, EnumSupportedPermissions.BOTH);
|
||||
}
|
||||
|
||||
private List<CmisPermissionDefinition> permissionDefinitions;
|
||||
private List<CmisPermissionMapping> permissionMapping;
|
||||
|
||||
/**
|
||||
* Add property definitions to list of definitions
|
||||
*
|
||||
* @param propertyDefinition repository property definition
|
||||
* @param wsPropertyDefs web service property definition
|
||||
*/
|
||||
private void addPropertyDefs(CMISTypeDefinition typeDefinition, CMISPropertyDefinition propertyDefinition, List<CmisPropertyDefinitionType> wsPropertyDefs)
|
||||
throws CmisException
|
||||
{
|
||||
CmisPropertyDefinitionType wsPropertyDef = createPropertyDefinitionType(propertyDefinition.getDataType());
|
||||
wsPropertyDef.setLocalName(propertyDefinition.getPropertyId().getLocalName());
|
||||
wsPropertyDef.setLocalNamespace(propertyDefinition.getPropertyId().getLocalNamespace());
|
||||
wsPropertyDef.setId(propertyDefinition.getPropertyId().getId());
|
||||
wsPropertyDef.setQueryName(propertyDefinition.getQueryName());
|
||||
wsPropertyDef.setDisplayName(propertyDefinition.getDisplayName());
|
||||
wsPropertyDef.setDescription(propertyDefinition.getDescription());
|
||||
wsPropertyDef.setPropertyType(PROPERTY_TYPE_ENUM_MAPPING.get(propertyDefinition.getDataType()));
|
||||
wsPropertyDef.setCardinality(CARDINALITY_ENUM_MAPPING.get(propertyDefinition.getCardinality()));
|
||||
wsPropertyDef.setUpdatability(UPDATABILITY_ENUM_MAPPING.get(propertyDefinition.getUpdatability()));
|
||||
wsPropertyDef.setInherited(!typeDefinition.getOwnedPropertyDefinitions().containsKey(propertyDefinition.getPropertyId().getId()));
|
||||
wsPropertyDef.setRequired(propertyDefinition.isRequired());
|
||||
wsPropertyDef.setQueryable(propertyDefinition.isQueryable());
|
||||
wsPropertyDef.setOrderable(propertyDefinition.isOrderable());
|
||||
addChoices(propertyDefinition.getDataType(), propertyDefinition.getChoices(), getChoices(wsPropertyDef));
|
||||
wsPropertyDef.setOpenChoice(propertyDefinition.isOpenChoice());
|
||||
wsPropertyDefs.add(wsPropertyDef);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add root choices to list of choices
|
||||
*
|
||||
* @param propertyType type of property
|
||||
* @param choices repository choice object
|
||||
* @param cmisChoices web service choice object
|
||||
*/
|
||||
private void addChoices(CMISDataTypeEnum propertyType, Collection<CMISChoice> choices, List<CmisChoice> cmisChoices)
|
||||
{
|
||||
for (CMISChoice choice : choices)
|
||||
{
|
||||
CmisChoice cmisChoiceType = getCmisChoiceType(choice, propertyType);
|
||||
cmisChoices.add(cmisChoiceType);
|
||||
if (choice.getChildren().isEmpty() == false)
|
||||
{
|
||||
addChoiceChildrens(propertyType, choice.getChildren(), cmisChoices);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<CmisChoice> getChoices(CmisPropertyDefinitionType propertyDef)
|
||||
{
|
||||
List<CmisChoice> result = null;
|
||||
if (propertyDef != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
result = (List<CmisChoice>) propertyDef.getClass().getMethod("getChoice").invoke(propertyDef);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create web service choice object from repository choice object
|
||||
*
|
||||
* @param choice repository choice
|
||||
* @param propertyType type of property
|
||||
* @return web service choice
|
||||
*/
|
||||
private CmisChoice getCmisChoiceType(CMISChoice choice, CMISDataTypeEnum propertyType)
|
||||
{
|
||||
CmisChoice result = null;
|
||||
|
||||
switch (propertyType)
|
||||
{
|
||||
case BOOLEAN:
|
||||
CmisChoiceBoolean choiceBooleanType = new CmisChoiceBoolean();
|
||||
choiceBooleanType.setDisplayName(choice.getName());
|
||||
choiceBooleanType.getValue().add(Boolean.parseBoolean(choice.getValue().toString()));
|
||||
result = choiceBooleanType;
|
||||
break;
|
||||
case DATETIME:
|
||||
CmisChoiceDateTime choiceDateTimeType = new CmisChoiceDateTime();
|
||||
choiceDateTimeType.setDisplayName(choice.getName());
|
||||
choiceDateTimeType.getValue().add(propertiesUtil.convert((Date) choice.getValue()));
|
||||
result = choiceDateTimeType;
|
||||
break;
|
||||
case DECIMAL:
|
||||
CmisChoiceDecimal choiceDecimalType = new CmisChoiceDecimal();
|
||||
choiceDecimalType.setDisplayName(choice.getName());
|
||||
choiceDecimalType.getValue().add(BigDecimal.valueOf(Double.parseDouble(choice.getValue().toString())));
|
||||
result = choiceDecimalType;
|
||||
break;
|
||||
case HTML:
|
||||
break;
|
||||
case ID:
|
||||
CmisChoiceId choiceIdType = new CmisChoiceId();
|
||||
choiceIdType.setDisplayName(choice.getName());
|
||||
choiceIdType.getValue().add(choice.getValue().toString());
|
||||
result = choiceIdType;
|
||||
break;
|
||||
case INTEGER:
|
||||
CmisChoiceInteger choiceIntegerType = new CmisChoiceInteger();
|
||||
choiceIntegerType.setDisplayName(choice.getName());
|
||||
choiceIntegerType.getValue().add(BigInteger.valueOf(Integer.parseInt(choice.getValue().toString())));
|
||||
result = choiceIntegerType;
|
||||
break;
|
||||
case STRING:
|
||||
CmisChoiceString choiceStringType = new CmisChoiceString();
|
||||
choiceStringType.setDisplayName(choice.getName());
|
||||
choiceStringType.getValue().add(choice.getValue().toString());
|
||||
result = choiceStringType;
|
||||
break;
|
||||
case URI:
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add choices children to list of JAXBElements
|
||||
*
|
||||
* @param propertyType type of property
|
||||
* @param choices repository choice object
|
||||
* @param cmisChoices web service choice object
|
||||
*/
|
||||
private void addChoiceChildrens(CMISDataTypeEnum propertyType, Collection<CMISChoice> choices, List<CmisChoice> cmisChoices)
|
||||
{
|
||||
for (CMISChoice choice : choices)
|
||||
{
|
||||
CmisChoice cmisChoiceType = getCmisChoiceType(choice, propertyType);
|
||||
cmisChoices.add(cmisChoiceType);
|
||||
|
||||
if (choice.getChildren().isEmpty() == false)
|
||||
{
|
||||
addChoiceChildrens(propertyType, choice.getChildren(), cmisChoices);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private CmisPropertyDefinitionType createPropertyDefinitionType(CMISDataTypeEnum type) throws CmisException
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case BOOLEAN:
|
||||
{
|
||||
return new CmisPropertyBooleanDefinitionType();
|
||||
}
|
||||
case DATETIME:
|
||||
{
|
||||
return new CmisPropertyDateTimeDefinitionType();
|
||||
}
|
||||
case DECIMAL:
|
||||
{
|
||||
return new CmisPropertyDecimalDefinitionType();
|
||||
}
|
||||
case HTML:
|
||||
{
|
||||
return new CmisPropertyHtmlDefinitionType();
|
||||
}
|
||||
case ID:
|
||||
{
|
||||
return new CmisPropertyIdDefinitionType();
|
||||
}
|
||||
case INTEGER:
|
||||
{
|
||||
return new CmisPropertyIntegerDefinitionType();
|
||||
}
|
||||
case STRING:
|
||||
{
|
||||
return new CmisPropertyStringDefinitionType();
|
||||
}
|
||||
case URI:
|
||||
{
|
||||
return new CmisPropertyUriDefinitionType();
|
||||
}
|
||||
default:
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(type.getLabel(), EnumServiceException.OBJECT_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set properties for web service type definition
|
||||
*
|
||||
* @param cmisTypeDefinition web service type definition
|
||||
* @param typeDefinition repository type definition
|
||||
* @param includeProperties true if need property definitions for type definition
|
||||
*/
|
||||
private void setCmisTypeDefinitionProperties(CmisTypeDefinitionType cmisTypeDefinition, CMISTypeDefinition typeDefinition, boolean includeProperties) throws CmisException
|
||||
{
|
||||
cmisTypeDefinition.setId(typeDefinition.getTypeId().getId());
|
||||
cmisTypeDefinition.setQueryName(typeDefinition.getQueryName());
|
||||
cmisTypeDefinition.setDisplayName(typeDefinition.getDisplayName());
|
||||
cmisTypeDefinition.setBaseId(EnumBaseObjectTypeIds.fromValue(typeDefinition.getBaseType().getTypeId().getId()));
|
||||
cmisTypeDefinition.setLocalNamespace(typeDefinition.getTypeId().getLocalNamespace());
|
||||
cmisTypeDefinition.setLocalName(typeDefinition.getTypeId().getLocalName());
|
||||
|
||||
if ((null != typeDefinition.getParentType()) && (null != typeDefinition.getParentType().getTypeId()))
|
||||
{
|
||||
cmisTypeDefinition.setParentId(typeDefinition.getParentType().getTypeId().getId());
|
||||
}
|
||||
|
||||
cmisTypeDefinition.setDescription(typeDefinition.getDescription());
|
||||
cmisTypeDefinition.setCreatable(typeDefinition.isCreatable());
|
||||
cmisTypeDefinition.setFileable(typeDefinition.isFileable());
|
||||
cmisTypeDefinition.setQueryable(typeDefinition.isQueryable());
|
||||
cmisTypeDefinition.setControllableACL(typeDefinition.isControllableACL());
|
||||
cmisTypeDefinition.setControllablePolicy(typeDefinition.isControllablePolicy());
|
||||
cmisTypeDefinition.setIncludedInSupertypeQuery(typeDefinition.isIncludedInSuperTypeQuery());
|
||||
|
||||
if (includeProperties)
|
||||
{
|
||||
List<CmisPropertyDefinitionType> propertyDefs = cmisTypeDefinition.getPropertyDefinition();
|
||||
for (CMISPropertyDefinition cmisPropDef : typeDefinition.getPropertyDefinitions().values())
|
||||
{
|
||||
addPropertyDefs(typeDefinition, cmisPropDef, propertyDefs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create web service type definition for typeId
|
||||
*
|
||||
* @param typeId type id
|
||||
* @param includeProperties true if need property definitions for type definition
|
||||
* @return web service type definition
|
||||
* @throws CmisException if type id not found
|
||||
*/
|
||||
private CmisTypeDefinitionType getCmisTypeDefinition(CMISTypeDefinition typeDef, boolean includeProperties) throws CmisException
|
||||
{
|
||||
if (typeDef == null)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException("Type not found", EnumServiceException.OBJECT_NOT_FOUND);
|
||||
}
|
||||
|
||||
CmisTypeDefinitionType result = null;
|
||||
|
||||
switch (typeDef.getTypeId().getScope())
|
||||
{
|
||||
case DOCUMENT:
|
||||
CmisTypeDocumentDefinitionType documentDefinitionType = new CmisTypeDocumentDefinitionType();
|
||||
documentDefinitionType.setVersionable(typeDef.isVersionable());
|
||||
documentDefinitionType.setContentStreamAllowed(CONTENT_STREAM_ALLOWED_ENUM_MAPPING.get(typeDef.getContentStreamAllowed()));
|
||||
result = documentDefinitionType;
|
||||
break;
|
||||
case FOLDER:
|
||||
result = new CmisTypeFolderDefinitionType();
|
||||
break;
|
||||
case POLICY:
|
||||
result = new CmisTypePolicyDefinitionType();
|
||||
break;
|
||||
case RELATIONSHIP:
|
||||
CmisTypeRelationshipDefinitionType relationshipDefinitionType = new CmisTypeRelationshipDefinitionType();
|
||||
if (typeDef.getAllowedSourceTypes() != null)
|
||||
{
|
||||
for (CMISTypeDefinition definition : typeDef.getAllowedSourceTypes())
|
||||
{
|
||||
relationshipDefinitionType.getAllowedSourceTypes().add(definition.getTypeId().getId());
|
||||
}
|
||||
}
|
||||
if (typeDef.getAllowedTargetTypes() != null)
|
||||
{
|
||||
for (CMISTypeDefinition definition : typeDef.getAllowedTargetTypes())
|
||||
{
|
||||
relationshipDefinitionType.getAllowedTargetTypes().add(definition.getTypeId().getId());
|
||||
}
|
||||
}
|
||||
result = relationshipDefinitionType;
|
||||
break;
|
||||
case UNKNOWN:
|
||||
throw ExceptionUtil.createCmisException("Unknown CMIS Type", EnumServiceException.INVALID_ARGUMENT);
|
||||
}
|
||||
if ((null != typeDef.getParentType()) && (null != typeDef.getParentType().getTypeId()))
|
||||
{
|
||||
result.setParentId(typeDef.getParentType().getTypeId().getId());
|
||||
}
|
||||
setCmisTypeDefinitionProperties(result, typeDef, includeProperties);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of available repositories for this CMIS service endpoint.
|
||||
*
|
||||
* @return collection of CmisRepositoryEntryType (repositoryId - repository Id, repositoryName: repository name, repositoryURI: Repository URI)
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME)
|
||||
*/
|
||||
public List<CmisRepositoryEntryType> getRepositories(CmisExtensionType extension) throws CmisException
|
||||
{
|
||||
CmisRepositoryEntryType repositoryEntryType = new CmisRepositoryEntryType();
|
||||
Descriptor serverDescriptor = descriptorService.getCurrentRepositoryDescriptor();
|
||||
repositoryEntryType.setRepositoryId(serverDescriptor.getId());
|
||||
repositoryEntryType.setRepositoryName(serverDescriptor.getName());
|
||||
|
||||
List<CmisRepositoryEntryType> result = new LinkedList<CmisRepositoryEntryType>();
|
||||
result.add(repositoryEntryType);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets information about the CMIS repository and the capabilities it supports.
|
||||
*
|
||||
* @param parameters repositoryId: repository Id
|
||||
* @return CMIS repository Info
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME)
|
||||
*/
|
||||
public CmisRepositoryInfoType getRepositoryInfo(String repositoryId, CmisExtensionType extension) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
|
||||
Descriptor currentDescriptor = descriptorService.getCurrentRepositoryDescriptor();
|
||||
Descriptor serverDescriptor = descriptorService.getServerDescriptor();
|
||||
CmisRepositoryInfoType repositoryInfoType = new CmisRepositoryInfoType();
|
||||
repositoryInfoType.setRepositoryId(currentDescriptor.getId());
|
||||
repositoryInfoType.setRepositoryName(currentDescriptor.getName());
|
||||
repositoryInfoType.setRepositoryDescription("");
|
||||
repositoryInfoType.setVendorName("Alfresco");
|
||||
repositoryInfoType.setProductName("Alfresco Repository (" + serverDescriptor.getEdition() + ")");
|
||||
repositoryInfoType.setProductVersion(currentDescriptor.getVersion());
|
||||
try
|
||||
{
|
||||
repositoryInfoType.setRootFolderId(propertiesUtil.getProperty(cmisService.getDefaultRootNodeRef(), CMISDictionaryModel.PROP_OBJECT_ID, (String) null));
|
||||
}
|
||||
catch (CMISInvalidArgumentException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
repositoryInfoType.setLatestChangeLogToken(cmisChangeLogService.getLastChangeLogToken());
|
||||
// TODO: cmisVersionSupported is different in stubs and specification
|
||||
repositoryInfoType.setCmisVersionSupported("1.0");
|
||||
repositoryInfoType.setChangesIncomplete(cmisChangeLogService.getChangesIncomplete());
|
||||
// TODO: getFolderTree capability
|
||||
List<CMISBaseObjectTypeIds> changesOnTypeCapability = cmisChangeLogService.getChangesOnTypeCapability();
|
||||
for (CMISBaseObjectTypeIds baseId : changesOnTypeCapability)
|
||||
{
|
||||
repositoryInfoType.getChangesOnType().add(BASE_IDS_TYPE_ENUM_MAPPING.get(baseId));
|
||||
}
|
||||
repositoryInfoType.setPrincipalAnonymous(cmisAclService.getPrincipalAnonymous());
|
||||
repositoryInfoType.setPrincipalAnyone(cmisAclService.getPrincipalAnyone());
|
||||
|
||||
CmisACLCapabilityType aclCapability = new CmisACLCapabilityType();
|
||||
aclCapability.setSupportedPermissions(ACL_SUPPORTED_PERMISSION_ENUM_MAPPING.get(cmisAclService.getSupportedPermissions()));
|
||||
aclCapability.setPropagation(ACL_PROPAGATION_ENUM_MAPPGIN.get(cmisAclService.getAclPropagation()));
|
||||
aclCapability.getMapping().addAll(getPermissionMapping());
|
||||
aclCapability.getPermissions().addAll(getPermissionDefinitions());
|
||||
repositoryInfoType.setAclCapability(aclCapability);
|
||||
|
||||
CmisRepositoryCapabilitiesType capabilities = new CmisRepositoryCapabilitiesType();
|
||||
capabilities.setCapabilityGetDescendants(true);
|
||||
capabilities.setCapabilityGetFolderTree(true);
|
||||
|
||||
capabilities.setCapabilityContentStreamUpdatability(EnumCapabilityContentStreamUpdates.ANYTIME);
|
||||
capabilities.setCapabilityChanges(CHANGES_TYPE_ENUM_MAPPING.get(cmisChangeLogService.getCapability()));
|
||||
capabilities.setCapabilityRenditions(EnumCapabilityRendition.READ);
|
||||
|
||||
capabilities.setCapabilityMultifiling(true);
|
||||
capabilities.setCapabilityUnfiling(false);
|
||||
capabilities.setCapabilityVersionSpecificFiling(false);
|
||||
|
||||
capabilities.setCapabilityPWCUpdatable(true);
|
||||
capabilities.setCapabilityPWCSearchable(cmisQueryService.getPwcSearchable());
|
||||
capabilities.setCapabilityAllVersionsSearchable(cmisQueryService.getAllVersionsSearchable());
|
||||
|
||||
capabilities.setCapabilityQuery(QUERY_TYPE_ENUM_MAPPING.get(cmisQueryService.getQuerySupport()));
|
||||
capabilities.setCapabilityJoin(JOIN_ENUM_MAPPING.get(cmisQueryService.getJoinSupport()));
|
||||
|
||||
capabilities.setCapabilityACL(ACL_CAPABILITY_ENUM_MAPPING.get(cmisAclService.getAclCapability()));
|
||||
|
||||
repositoryInfoType.setCapabilities(capabilities);
|
||||
return repositoryInfoType;
|
||||
}
|
||||
|
||||
private List<CmisPermissionDefinition> getPermissionDefinitions()
|
||||
{
|
||||
if (null == permissionDefinitions)
|
||||
{
|
||||
permissionDefinitions = new LinkedList<CmisPermissionDefinition>();
|
||||
for (CMISPermissionDefinition definition : cmisAclService.getRepositoryPermissions())
|
||||
{
|
||||
CmisPermissionDefinition cmisDefinition = new CmisPermissionDefinition();
|
||||
cmisDefinition.setDescription(definition.getDescription());
|
||||
cmisDefinition.setPermission(definition.getPermission());
|
||||
permissionDefinitions.add(cmisDefinition);
|
||||
}
|
||||
}
|
||||
return permissionDefinitions;
|
||||
}
|
||||
|
||||
private List<CmisPermissionMapping> getPermissionMapping()
|
||||
{
|
||||
if (null == permissionMapping)
|
||||
{
|
||||
permissionMapping = new LinkedList<CmisPermissionMapping>();
|
||||
for (CMISPermissionMapping mapping : cmisAclService.getPermissionMappings())
|
||||
{
|
||||
CmisPermissionMapping cmisMapping = new CmisPermissionMapping();
|
||||
cmisMapping.getPermission().addAll(mapping.getPermissions());
|
||||
cmisMapping.setKey(EnumAllowableActionsKey.fromValue(mapping.getKey()));
|
||||
permissionMapping.add(cmisMapping);
|
||||
}
|
||||
}
|
||||
return permissionMapping;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of Object-Types defined for the Repository under the specified Type.
|
||||
*
|
||||
* @param parameters repositoryId: repository Id; typeId: type Id; returnPropertyDefinitions: false (default); maxItems: 0 = Repository-default number of items(Default);
|
||||
* skipCount: 0 = start;
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME)
|
||||
*/
|
||||
public CmisTypeDefinitionListType getTypeChildren(String repositoryId, String typeId, Boolean includePropertyDefinitions, BigInteger maxItems, BigInteger skipCount,
|
||||
CmisExtensionType extension) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
Collection<CMISTypeDefinition> typeDefs;
|
||||
try
|
||||
{
|
||||
typeDefs = typeId == null ? cmisService.getBaseTypes() : cmisService.getTypeDefinition(typeId).getSubTypes(false);
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
// skip
|
||||
Cursor cursor = createCursor(typeDefs.size(), skipCount, maxItems);
|
||||
Iterator<CMISTypeDefinition> iterTypeDefs = typeDefs.iterator();
|
||||
for (int i = 0; i < cursor.getStartRow(); i++)
|
||||
{
|
||||
iterTypeDefs.next();
|
||||
}
|
||||
|
||||
boolean includePropertyDefinitionsVal = includePropertyDefinitions == null ? false : includePropertyDefinitions.booleanValue();
|
||||
|
||||
CmisTypeDefinitionListType result = new CmisTypeDefinitionListType();
|
||||
for (int i = cursor.getStartRow(); i <= cursor.getEndRow(); i++)
|
||||
{
|
||||
CmisTypeDefinitionType element = getCmisTypeDefinition(iterTypeDefs.next(), includePropertyDefinitionsVal);
|
||||
if (null != element)
|
||||
{
|
||||
result.getTypes().add(element);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(("Subtypes collection is corrupted. Type id: " + typeId), EnumServiceException.STORAGE);
|
||||
}
|
||||
}
|
||||
result.setHasMoreItems(((maxItems == null) || (0 == maxItems.intValue())) ? (false) : ((cursor.getEndRow() < (typeDefs.size() - 1))));
|
||||
result.setNumItems(BigInteger.valueOf(result.getTypes().size()));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the definition for specified object type
|
||||
*
|
||||
* @param parameters repositoryId: repository Id; typeId: type Id;
|
||||
* @return CMIS type definition
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME)
|
||||
*/
|
||||
public CmisTypeDefinitionType getTypeDefinition(String repositoryId, String typeId, CmisExtensionType extension) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
CMISTypeDefinition typeDef;
|
||||
try
|
||||
{
|
||||
typeDef = cmisService.getTypeDefinition(typeId);
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
return getCmisTypeDefinition(typeDef, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the set of descendant Object-Types defined for the Repository under the specified Type.
|
||||
*
|
||||
* @param parameters srepositoryId: repository Id; typeId: type Id; includePropertyDefinitions: false (default); depth: The number of levels of depth in the type hierarchy from
|
||||
* which to return results;
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME)
|
||||
*/
|
||||
public List<CmisTypeContainer> getTypeDescendants(String repositoryId, String typeId, BigInteger depth, Boolean includePropertyDefinitions, CmisExtensionType extension)
|
||||
throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
long depthLong = (null == depth || null == typeId) ? (-1) : (depth.longValue());
|
||||
if (0 == depthLong)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException("Invalid depth '0'", EnumServiceException.INVALID_ARGUMENT);
|
||||
}
|
||||
CMISTypeDefinition typeDef;
|
||||
try
|
||||
{
|
||||
typeDef = typeId == null ? null : cmisService.getTypeDefinition(typeId);
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
List<CmisTypeContainer> result = new LinkedList<CmisTypeContainer>();
|
||||
getTypeDescendants(typeDef, result, includePropertyDefinitions != null && includePropertyDefinitions, 1, depthLong);
|
||||
return result;
|
||||
}
|
||||
|
||||
private void getTypeDescendants(CMISTypeDefinition parent, List<CmisTypeContainer> result, boolean includePropertyDefs, long depth, long maxDepth) throws CmisException
|
||||
{
|
||||
Collection<CMISTypeDefinition> subtypes = parent == null ? cmisService.getBaseTypes() : parent.getSubTypes(false);
|
||||
for (CMISTypeDefinition subtype : subtypes)
|
||||
{
|
||||
CmisTypeContainer type = createTypeContainer(subtype, includePropertyDefs);
|
||||
result.add(type);
|
||||
if (maxDepth == -1 || depth < maxDepth)
|
||||
{
|
||||
List<CmisTypeContainer> children = type.getChildren();
|
||||
getTypeDescendants(subtype, children, includePropertyDefs, depth + 1, maxDepth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private CmisTypeContainer createTypeContainer(CMISTypeDefinition parentType, boolean includeProperties) throws CmisException
|
||||
{
|
||||
CmisTypeContainer result = new CmisTypeContainer();
|
||||
result.setType(getCmisTypeDefinition(parentType, includeProperties));
|
||||
return result;
|
||||
}
|
||||
}
|
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.cmis.ws;
|
||||
|
||||
import org.alfresco.repo.cmis.ws.utils.ExceptionUtil;
|
||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.aop.ThrowsAdvice;
|
||||
|
||||
/**
|
||||
* Map Alfresco Exceptions to CMIS Exceptions
|
||||
*
|
||||
* @author Dmitry Lazurkin
|
||||
* @author Dmitry Velichkevich
|
||||
*/
|
||||
public class DMServicePortThrowsAdvice implements ThrowsAdvice
|
||||
{
|
||||
private static final Log LOGGER = LogFactory.getLog("org.alfresco.repo.cmis.ws");
|
||||
|
||||
public void afterThrowing(AccessDeniedException e) throws CmisException
|
||||
{
|
||||
if (LOGGER.isInfoEnabled())
|
||||
{
|
||||
LOGGER.error(e.toString(), e);
|
||||
}
|
||||
throw ExceptionUtil.createCmisException(("Access denied. Message: " + e.toString()), e);
|
||||
}
|
||||
|
||||
public void afterThrowing(java.lang.RuntimeException e) throws CmisException
|
||||
{
|
||||
Throwable result = e;
|
||||
if (null != e.getCause())
|
||||
{
|
||||
result = e.getCause();
|
||||
}
|
||||
if (LOGGER.isErrorEnabled())
|
||||
{
|
||||
LOGGER.error(result.toString(), result);
|
||||
}
|
||||
throw (result instanceof CmisException) ? ((CmisException) result) : (ExceptionUtil.createCmisException(("Runtime error. Message: " + result.toString()), result));
|
||||
}
|
||||
|
||||
public void afterThrowing(java.lang.Exception e) throws CmisException
|
||||
{
|
||||
if (LOGGER.isInfoEnabled())
|
||||
{
|
||||
LOGGER.error(e.toString(), e);
|
||||
}
|
||||
if (!(e instanceof CmisException))
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(("Some error occured during last service invokation. Message: " + e.toString()), e);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw (CmisException) e;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,223 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.cmis.ws;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.ws.Holder;
|
||||
|
||||
import org.alfresco.cmis.CMISContentStreamAllowedEnum;
|
||||
import org.alfresco.cmis.CMISDictionaryModel;
|
||||
import org.alfresco.cmis.CMISServiceException;
|
||||
import org.alfresco.cmis.CMISTypeDefinition;
|
||||
import org.alfresco.cmis.PropertyFilter;
|
||||
import org.alfresco.repo.cmis.ws.utils.ExceptionUtil;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Port for versioning service.
|
||||
*
|
||||
* @author Dmitry Lazurkin
|
||||
* @author Dmitry Velichkevich
|
||||
*/
|
||||
@javax.jws.WebService(name = "VersioningServicePort", serviceName = "VersioningService", portName = "VersioningServicePort", targetNamespace = "http://docs.oasis-open.org/ns/cmis/ws/200908/", endpointInterface = "org.alfresco.repo.cmis.ws.VersioningServicePort")
|
||||
public class DMVersioningServicePort extends DMAbstractServicePort implements VersioningServicePort
|
||||
{
|
||||
/**
|
||||
* Reverses the effect of a check-out. Removes the private working copy of the checked-out document object, allowing other documents in the version series to be checked out
|
||||
* again.
|
||||
*
|
||||
* @param repositoryId repository Id
|
||||
* @param objectId document Id
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, CONSTRAINT,
|
||||
* UPDATE_CONFLICT, VERSIONING)
|
||||
*/
|
||||
// FIXME [~BUG]: may it is better returning id of the unchecked out document
|
||||
public void cancelCheckOut(String repositoryId, String objectId, Holder<CmisExtensionType> extension) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
try
|
||||
{
|
||||
cmisService.cancelCheckOut(objectId);
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the private working copy the current version of the document.
|
||||
*
|
||||
* @param repositoryId repository Id
|
||||
* @param objectId document Id
|
||||
* @param major is major True (Default)
|
||||
* @param properties CMIS properties
|
||||
* @param contentStream content stream
|
||||
* @param checkinComment check in comment
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, CONSTRAINT, STORAGE,
|
||||
* STREAM_NOT_SUPPORTED, UPDATE_CONFLICT, VERSIONING)
|
||||
*/
|
||||
// FIXME [~BUG]: it is better changing 'void' to 'PWC Id' result type
|
||||
public void checkIn(String repositoryId, Holder<String> objectId, Boolean major, CmisPropertiesType properties, CmisContentStreamType contentStream, String checkinComment,
|
||||
List<String> policies, CmisAccessControlListType addACEs, CmisAccessControlListType removeACEs, Holder<CmisExtensionType> extension) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
try
|
||||
{
|
||||
NodeRef workingCopyNodeRef = cmisService.getObject(objectId.value, NodeRef.class, true, true, true);
|
||||
CMISTypeDefinition seriesObjectTypeDefinition = cmisService.getTypeDefinition(workingCopyNodeRef);
|
||||
|
||||
if ((null != contentStream) && (CMISContentStreamAllowedEnum.NOT_ALLOWED == seriesObjectTypeDefinition.getContentStreamAllowed()))
|
||||
{
|
||||
throw ExceptionUtil.createCmisException("Content stream is not allowed", EnumServiceException.STREAM_NOT_SUPPORTED);
|
||||
}
|
||||
|
||||
if (contentStream != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
ContentWriter writer = fileFolderService.getWriter(workingCopyNodeRef);
|
||||
writer.setMimetype(contentStream.getMimeType());
|
||||
writer.putContent(contentStream.getStream().getInputStream());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException("Exception while updating content stream", EnumServiceException.RUNTIME, e);
|
||||
}
|
||||
}
|
||||
|
||||
propertiesUtil.setProperties(workingCopyNodeRef, properties, null);
|
||||
NodeRef nodeRef = cmisService.checkIn(objectId.value, checkinComment, major == null || major);
|
||||
|
||||
applyAclCarefully(nodeRef, addACEs, removeACEs, EnumACLPropagation.PROPAGATE, policies);
|
||||
objectId.value = propertiesUtil.getProperty(nodeRef, CMISDictionaryModel.PROP_OBJECT_ID, objectId.value);
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a private working copy of the object, copies the metadata and optionally content.
|
||||
*
|
||||
* @param repositoryId repository Id
|
||||
* @param objectId ObjectID of document version to checkout
|
||||
* @param contentCopied
|
||||
* @return ObjectID of private working copy as documentId; True if succeed, False otherwise as contentCopied
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, CONSTRAINT, STORAGE,
|
||||
* UPDATE_CONFLICT, VERSIONING)
|
||||
*/
|
||||
public void checkOut(String repositoryId, Holder<String> objectId, Holder<CmisExtensionType> extension, Holder<Boolean> contentCopied) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
try
|
||||
{
|
||||
NodeRef pwcNodeRef = cmisService.checkOut(objectId.value);
|
||||
objectId.value = propertiesUtil.getProperty(pwcNodeRef, CMISDictionaryModel.PROP_OBJECT_ID, objectId.value);
|
||||
contentCopied.value = null != fileFolderService.getReader(pwcNodeRef);
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of all document versions for the specified version series.
|
||||
*
|
||||
* @param parameters repositoryId: repository Id; versionSeriesId: version series Id; filter: property filter; includeAllowableActions; includeRelationships;
|
||||
* @return list of CmisObjectType
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, FILTER_NOT_VALID)
|
||||
*/
|
||||
public List<CmisObjectType> getAllVersions(String repositoryId, String objectId, String filter, Boolean includeAllowableActions, CmisExtensionType extension)
|
||||
throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
PropertyFilter propertyFilter = createPropertyFilter(filter);
|
||||
List<CmisObjectType> objects = new LinkedList<CmisObjectType>();
|
||||
try
|
||||
{
|
||||
for (NodeRef nodeRef : cmisService.getAllVersions(objectId))
|
||||
{
|
||||
objects.add(createCmisObject(nodeRef, propertyFilter, null, includeAllowableActions, null));
|
||||
}
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
return objects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the properties of the latest version, or the latest major version, of the specified version series.
|
||||
*
|
||||
* @param parameters repositoryId: repository Id; versionSeriesId: version series Id; majorVersion: whether or not to return the latest major version. Default=FALSE; filter:
|
||||
* property filter
|
||||
* @return CmisObjectType with properties
|
||||
* @throws CmisException (with following {@link EnumServiceException} : INVALID_ARGUMENT, OBJECT_NOT_FOUND, NOT_SUPPORTED, PERMISSION_DENIED, RUNTIME, FILTER_NOT_VALID)
|
||||
*/
|
||||
public CmisPropertiesType getPropertiesOfLatestVersion(String repositoryId, String objectId, Boolean major, String filter, CmisExtensionType extension) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
NodeRef latestVersionNodeRef;
|
||||
try
|
||||
{
|
||||
latestVersionNodeRef = cmisService.getLatestVersion(objectId, major != null && major);
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
PropertyFilter propertyFilter = createPropertyFilter(filter);
|
||||
return propertiesUtil.getProperties(latestVersionNodeRef, propertyFilter);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
// TODO: it is necessary to add tests for this method
|
||||
public CmisObjectType getObjectOfLatestVersion(String repositoryId, String objectId, Boolean major, String filter, Boolean includeAllowableActions,
|
||||
EnumIncludeRelationships includeRelationships, String renditionFilter, Boolean includePolicyIds, Boolean includeACL, CmisExtensionType extension) throws CmisException
|
||||
{
|
||||
checkRepositoryId(repositoryId);
|
||||
try
|
||||
{
|
||||
NodeRef latestVersionNodeRef = cmisService.getLatestVersion(objectId, major != null && major);
|
||||
// TODO: includePolicyIds
|
||||
PropertyFilter propertyFilter = createPropertyFilter(filter);
|
||||
CmisObjectType result = createCmisObject(latestVersionNodeRef, propertyFilter, includeRelationships,
|
||||
includeAllowableActions, renditionFilter);
|
||||
if (includeACL)
|
||||
{
|
||||
appendWithAce(cmisService.getVersionSeries(objectId, NodeRef.class, false), result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,96 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.cmis.ws.utils;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.cmis.CMISQueryException;
|
||||
import org.alfresco.cmis.CMISServiceException;
|
||||
import org.alfresco.repo.cmis.ws.CmisException;
|
||||
import org.alfresco.repo.cmis.ws.CmisFaultType;
|
||||
import org.alfresco.repo.cmis.ws.EnumServiceException;
|
||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||
import org.alfresco.service.cmr.model.FileExistsException;
|
||||
import org.alfresco.service.cmr.repository.ContentIOException;
|
||||
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||
|
||||
/**
|
||||
* @author Dmitry Velichkevich
|
||||
*/
|
||||
public abstract class ExceptionUtil
|
||||
{
|
||||
private static final Map<String, EnumServiceException> CLASS_TO_ENUM_EXCEPTION_MAPPING;
|
||||
static
|
||||
{
|
||||
CLASS_TO_ENUM_EXCEPTION_MAPPING = new HashMap<String, EnumServiceException>();
|
||||
CLASS_TO_ENUM_EXCEPTION_MAPPING.put(AccessDeniedException.class.getName(), EnumServiceException.PERMISSION_DENIED);
|
||||
CLASS_TO_ENUM_EXCEPTION_MAPPING.put(java.lang.RuntimeException.class.getName(), EnumServiceException.RUNTIME);
|
||||
CLASS_TO_ENUM_EXCEPTION_MAPPING.put(UnsupportedOperationException.class.getName(), EnumServiceException.NOT_SUPPORTED);
|
||||
CLASS_TO_ENUM_EXCEPTION_MAPPING.put(InvalidNodeRefException.class.getName(), EnumServiceException.INVALID_ARGUMENT);
|
||||
CLASS_TO_ENUM_EXCEPTION_MAPPING.put(ContentIOException.class.getName(), EnumServiceException.NOT_SUPPORTED);
|
||||
CLASS_TO_ENUM_EXCEPTION_MAPPING.put(CMISQueryException.class.getName(), EnumServiceException.INVALID_ARGUMENT);
|
||||
CLASS_TO_ENUM_EXCEPTION_MAPPING.put(FileExistsException.class.getName(), EnumServiceException.NAME_CONSTRAINT_VIOLATION);
|
||||
}
|
||||
|
||||
public static CmisException createCmisException(String message, EnumServiceException exceptionType)
|
||||
{
|
||||
return createCmisException(message, exceptionType, null, 0);
|
||||
}
|
||||
|
||||
public static CmisException createCmisException(String message, Throwable cause)
|
||||
{
|
||||
EnumServiceException exceptionType = null;
|
||||
|
||||
if (cause instanceof CMISServiceException)
|
||||
{
|
||||
return createCmisException((CMISServiceException)cause);
|
||||
}
|
||||
|
||||
if (CLASS_TO_ENUM_EXCEPTION_MAPPING.containsKey(cause.getClass().getName()))
|
||||
{
|
||||
exceptionType = CLASS_TO_ENUM_EXCEPTION_MAPPING.get(cause.getClass().getName());
|
||||
}
|
||||
|
||||
exceptionType = (exceptionType == null) ? (EnumServiceException.RUNTIME) : (exceptionType);
|
||||
|
||||
return createCmisException(message, exceptionType, cause, 0);
|
||||
}
|
||||
|
||||
public static CmisException createCmisException(String message, EnumServiceException exceptionType, Throwable cause)
|
||||
{
|
||||
return createCmisException(message, exceptionType, cause, 0);
|
||||
}
|
||||
|
||||
public static CmisException createCmisException(CMISServiceException exception)
|
||||
{
|
||||
return createCmisException(exception.getMessage(), EnumServiceException.fromValue(exception.getFaultName()), exception, exception.getStatusCode());
|
||||
}
|
||||
|
||||
public static CmisException createCmisException(String message, EnumServiceException exceptionType, Throwable cause, int errorCode)
|
||||
{
|
||||
CmisFaultType fault = new CmisFaultType();
|
||||
fault.setMessage(message);
|
||||
fault.setType(exceptionType);
|
||||
fault.setCode(BigInteger.valueOf(errorCode));
|
||||
|
||||
return new CmisException(message, fault, cause);
|
||||
}
|
||||
}
|
@@ -1,745 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.cmis.ws.utils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.datatype.DatatypeConfigurationException;
|
||||
import javax.xml.datatype.DatatypeFactory;
|
||||
import javax.xml.datatype.XMLGregorianCalendar;
|
||||
|
||||
import org.alfresco.cmis.CMISDataTypeEnum;
|
||||
import org.alfresco.cmis.CMISDictionaryService;
|
||||
import org.alfresco.cmis.CMISInvalidArgumentException;
|
||||
import org.alfresco.cmis.CMISPropertyDefinition;
|
||||
import org.alfresco.cmis.CMISServiceException;
|
||||
import org.alfresco.cmis.CMISServices;
|
||||
import org.alfresco.cmis.CMISTypeDefinition;
|
||||
import org.alfresco.cmis.PropertyFilter;
|
||||
import org.alfresco.repo.cmis.ws.Aspects;
|
||||
import org.alfresco.repo.cmis.ws.CmisException;
|
||||
import org.alfresco.repo.cmis.ws.CmisPropertiesType;
|
||||
import org.alfresco.repo.cmis.ws.CmisProperty;
|
||||
import org.alfresco.repo.cmis.ws.CmisPropertyBoolean;
|
||||
import org.alfresco.repo.cmis.ws.CmisPropertyDateTime;
|
||||
import org.alfresco.repo.cmis.ws.CmisPropertyDecimal;
|
||||
import org.alfresco.repo.cmis.ws.CmisPropertyHtml;
|
||||
import org.alfresco.repo.cmis.ws.CmisPropertyId;
|
||||
import org.alfresco.repo.cmis.ws.CmisPropertyInteger;
|
||||
import org.alfresco.repo.cmis.ws.CmisPropertyString;
|
||||
import org.alfresco.repo.cmis.ws.CmisPropertyUri;
|
||||
import org.alfresco.repo.cmis.ws.EnumServiceException;
|
||||
import org.alfresco.repo.cmis.ws.SetAspects;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.version.Version;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Class for managing access control to CMIS properties
|
||||
*
|
||||
* @author Dmitry Lazurkin
|
||||
* @author Dmitry Velichkevich
|
||||
*/
|
||||
public class PropertyUtil
|
||||
{
|
||||
private static final DatatypeFactory DATATYPE_FACTORY;
|
||||
static
|
||||
{
|
||||
try
|
||||
{
|
||||
DATATYPE_FACTORY = DatatypeFactory.newInstance();
|
||||
}
|
||||
catch (DatatypeConfigurationException e)
|
||||
{
|
||||
throw new RuntimeException(("Data type instance creation failed! Failed message: " + e.toString()), e);
|
||||
}
|
||||
}
|
||||
|
||||
private final static String NAMESPACE_BEGIN = "" + QName.NAMESPACE_BEGIN;
|
||||
|
||||
private DictionaryService dictionaryService;
|
||||
private NamespaceService namespaceService;
|
||||
private CMISServices cmisService;
|
||||
private CMISDictionaryService cmisDictionaryService;
|
||||
|
||||
public PropertyUtil()
|
||||
{
|
||||
}
|
||||
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
public void setNamespaceService(NamespaceService namespaceService)
|
||||
{
|
||||
this.namespaceService = namespaceService;
|
||||
}
|
||||
|
||||
public void setCmisService(CMISServices cmisService)
|
||||
{
|
||||
this.cmisService = cmisService;
|
||||
}
|
||||
|
||||
public void setCmisDictionaryService(CMISDictionaryService cmisDictionaryService)
|
||||
{
|
||||
this.cmisDictionaryService = cmisDictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets property value by its name from Node Reference object
|
||||
*
|
||||
* @param objectNodeRef - <b>NodeRef</b> instance that represents Id of the source object
|
||||
* @param propertyName - <b>String</b> instance that represents property name
|
||||
* @param defaultValue - some value of the appropriate for conversion type. Also <b>null</b> may be accepted by this parameter
|
||||
* @return value instance of the appropriate type if specified object has such property and <i>defaultValue</i> if requested property value or <i>objectNodeRef</i> or
|
||||
* <i>propertyName</i> are <b>null</b> or if some exception occurred during property receiving
|
||||
* @throws CMISInvalidArgumentException
|
||||
*/
|
||||
public <ResultType> ResultType getProperty(NodeRef objectNodeRef, String propertyName, ResultType defaultValue)
|
||||
throws CMISInvalidArgumentException
|
||||
{
|
||||
if ((null == objectNodeRef) || (null == propertyName))
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
Serializable value = cmisService.getProperty(objectNodeRef, propertyName);
|
||||
try
|
||||
{
|
||||
return convertPropertyValue(value, defaultValue);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts from <b>CmisPropertiesType</b> instance property by its name and returns casted to appropriate type value of the extracted property
|
||||
*
|
||||
* @param cmisProperties - <b>CmisPropertiesType</b> properties instance
|
||||
* @param property - <b>String</b> instance that represents property name
|
||||
* @param defaultValue - some value of the appropriate for conversion type. Also <b>null</b> may be accepted by this parameter
|
||||
* @return value instance of the appropriate type if specified <i>cmisProperties</i> contains specified properties and <i>defaultValue</i> if requested property value or
|
||||
* <i>cmisProperties</i> or <i>property</i> are <b>null</b> or if some exception occurred during property searching and receiving
|
||||
*/
|
||||
public <ResultType> ResultType getCmisPropertyValue(CmisPropertiesType cmisProperties, String property, ResultType defaultValue) throws CmisException
|
||||
{
|
||||
if ((null == property) || (null == cmisProperties))
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
for (CmisProperty cmisProperty : cmisProperties.getProperty())
|
||||
{
|
||||
if ((null != cmisProperty) && property.equals(getPropertyName(cmisProperty)))
|
||||
{
|
||||
return convertPropertyValue(getValue(cmisProperty), defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private <ResultType> ResultType convertPropertyValue(Object propertyValue, ResultType defaultValue)
|
||||
{
|
||||
if (null == propertyValue)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return (ResultType) propertyValue;
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
private Serializable getValue(CmisProperty cmisProperty) throws CmisException
|
||||
{
|
||||
Serializable value = null;
|
||||
String propertyName = getPropertyName(cmisProperty);
|
||||
if ((null == cmisProperty) || (null == propertyName))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
PropertyMultiValueStateEnum multivaluedState = getPropertyMultiValuedState(null, propertyName);
|
||||
Collection<?> convertedValue = null;
|
||||
|
||||
if (cmisProperty instanceof CmisPropertyBoolean)
|
||||
{
|
||||
convertedValue = ((CmisPropertyBoolean) cmisProperty).getValue();
|
||||
}
|
||||
else if (cmisProperty instanceof CmisPropertyDateTime)
|
||||
{
|
||||
convertedValue = ((CmisPropertyDateTime) cmisProperty).getValue();
|
||||
List<GregorianCalendar> dates = new ArrayList<GregorianCalendar>(convertedValue.size());
|
||||
for (Object date : convertedValue)
|
||||
{
|
||||
dates.add(((XMLGregorianCalendar)date).toGregorianCalendar());
|
||||
}
|
||||
convertedValue = dates;
|
||||
}
|
||||
else if (cmisProperty instanceof CmisPropertyDecimal)
|
||||
{
|
||||
convertedValue = ((CmisPropertyDecimal) cmisProperty).getValue();
|
||||
}
|
||||
else if (cmisProperty instanceof CmisPropertyHtml)
|
||||
{
|
||||
convertedValue = ((CmisPropertyHtml) cmisProperty).getValue();
|
||||
}
|
||||
else if (cmisProperty instanceof CmisPropertyId)
|
||||
{
|
||||
convertedValue = ((CmisPropertyId) cmisProperty).getValue();
|
||||
}
|
||||
else if (cmisProperty instanceof CmisPropertyInteger)
|
||||
{
|
||||
convertedValue = ((CmisPropertyInteger) cmisProperty).getValue();
|
||||
}
|
||||
else if (cmisProperty instanceof CmisPropertyString)
|
||||
{
|
||||
convertedValue = ((CmisPropertyString) cmisProperty).getValue();
|
||||
}
|
||||
else if (cmisProperty instanceof CmisPropertyUri)
|
||||
{
|
||||
convertedValue = ((CmisPropertyUri) cmisProperty).getValue();
|
||||
}
|
||||
|
||||
if (null != convertedValue)
|
||||
{
|
||||
if (isMultiValued(propertyName, multivaluedState, convertedValue))
|
||||
{
|
||||
value = (convertedValue.size() > 0) ? new ArrayList<Object>((convertedValue)) : (null);
|
||||
}
|
||||
else if (!convertedValue.isEmpty())
|
||||
{
|
||||
value = (Serializable) convertedValue.iterator().next();
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
private boolean isMultiValued(String propertyName, PropertyMultiValueStateEnum state, Collection<?> values) throws CmisException
|
||||
{
|
||||
// TODO: WARNING!!! This is invalid behavior! Multi valued property state can't be identified in this way!!!
|
||||
if (PropertyMultiValueStateEnum.PROPERTY_NOT_FOUND == state)
|
||||
{
|
||||
return (values.size() > 0) ? (values.size() > 1) : (true);
|
||||
}
|
||||
|
||||
if ((PropertyMultiValueStateEnum.PROPERTY_NOT_MULTIVALUED == state) && (values.size() > 1))
|
||||
{
|
||||
throw ExceptionUtil.createCmisException("\"" + propertyName + "\" property is not Multi Valued", EnumServiceException.INVALID_ARGUMENT);
|
||||
}
|
||||
|
||||
return PropertyMultiValueStateEnum.PROPERTY_MULTIVALUED == state;
|
||||
}
|
||||
|
||||
private PropertyMultiValueStateEnum getPropertyMultiValuedState(String typeId, String cmisPropertyName)
|
||||
{
|
||||
if ((null == cmisPropertyName) || cmisPropertyName.equals(""))
|
||||
{
|
||||
return PropertyMultiValueStateEnum.PROPERTY_NOT_FOUND;
|
||||
}
|
||||
|
||||
CMISTypeDefinition typeDefinition = ((null != typeId) && !typeId.equals("")) ? (cmisDictionaryService.findType(typeId)) : (null);
|
||||
CMISPropertyDefinition propertyDefinition = null;
|
||||
if ((null != typeDefinition) && (null != typeDefinition.getOwnedPropertyDefinitions()))
|
||||
{
|
||||
propertyDefinition = typeDefinition.getOwnedPropertyDefinitions().get(cmisPropertyName);
|
||||
}
|
||||
else
|
||||
{
|
||||
propertyDefinition = cmisDictionaryService.findProperty(cmisPropertyName, null);
|
||||
}
|
||||
|
||||
if ((null == propertyDefinition) || (null == propertyDefinition.getPropertyAccessor()))
|
||||
{
|
||||
return PropertyMultiValueStateEnum.PROPERTY_NOT_FOUND;
|
||||
}
|
||||
|
||||
PropertyDefinition nativePropertyDefinition = null;
|
||||
if (null != propertyDefinition.getPropertyAccessor().getMappedProperty())
|
||||
{
|
||||
nativePropertyDefinition = dictionaryService.getProperty(propertyDefinition.getPropertyAccessor().getMappedProperty());
|
||||
}
|
||||
else
|
||||
{
|
||||
nativePropertyDefinition = dictionaryService.getProperty(createQName(cmisPropertyName));
|
||||
}
|
||||
|
||||
if (null == nativePropertyDefinition)
|
||||
{
|
||||
return PropertyMultiValueStateEnum.PROPERTY_NOT_FOUND;
|
||||
}
|
||||
|
||||
return (nativePropertyDefinition.isMultiValued()) ? (PropertyMultiValueStateEnum.PROPERTY_MULTIVALUED) : (PropertyMultiValueStateEnum.PROPERTY_NOT_MULTIVALUED);
|
||||
}
|
||||
|
||||
private enum PropertyMultiValueStateEnum
|
||||
{
|
||||
PROPERTY_MULTIVALUED, PROPERTY_NOT_MULTIVALUED, PROPERTY_NOT_FOUND;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts <b>CmisPropertiesType</b> properties representation to rapidly accessible form
|
||||
*
|
||||
* @param cmisProperties - <b>CmisPropertiesType</b> properties representation
|
||||
* @return <b>Map</b><<b>String</b>, <b>Serializable</b>> properties representation
|
||||
* @throws <b>CmisException</b>
|
||||
*/
|
||||
public Map<String, Serializable> getPropertiesMap(CmisPropertiesType cmisProperties) throws CmisException
|
||||
{
|
||||
Map<String, Serializable> properties = new HashMap<String, Serializable>();
|
||||
|
||||
if (null == cmisProperties)
|
||||
{
|
||||
return properties;
|
||||
}
|
||||
|
||||
for (CmisProperty cmisProperty : cmisProperties.getProperty())
|
||||
{
|
||||
if (null != cmisProperty)
|
||||
{
|
||||
String pdid = getPropertyName(cmisProperty);
|
||||
Serializable value = getValue(cmisProperty);
|
||||
if (value != null)
|
||||
{
|
||||
properties.put(pdid, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets and checks all properties' fields for specified node
|
||||
*
|
||||
* @param nodeRef
|
||||
* - <b>NodeRef</b> for node for those properties must be setted
|
||||
* @param properties
|
||||
* - <b>CmisPropertiesType</b> instance that contains all the necessary properties' fields
|
||||
* @param ignoringPropertiesFilter
|
||||
* - <b>PropertyFilter</b> instance. This filter determines which properties should be ignored and not
|
||||
* setted without exception. If this parameter is <b>null</b> all properties will be processed in common
|
||||
* flow
|
||||
*/
|
||||
public void setProperties(NodeRef nodeRef, CmisPropertiesType properties, PropertyFilter ignoringPropertiesFilter)
|
||||
throws CmisException
|
||||
{
|
||||
if (nodeRef == null || properties == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
for (CmisProperty property : properties.getProperty())
|
||||
{
|
||||
String propertyName = getPropertyName(property);
|
||||
if ((null == propertyName)
|
||||
|| ((null != ignoringPropertiesFilter) && ignoringPropertiesFilter.allow(propertyName)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Object value = getValue(property);
|
||||
cmisService.setProperty(nodeRef, propertyName, (Serializable) value);
|
||||
}
|
||||
|
||||
// Process Alfresco aspect-setting extension
|
||||
for (Object extensionObj : properties.getAny())
|
||||
{
|
||||
if (!(extensionObj instanceof SetAspects))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
SetAspects setAspects = (SetAspects) extensionObj;
|
||||
cmisService.setAspects(nodeRef, setAspects.getAspectsToRemove(), setAspects.getAspectsToAdd());
|
||||
CmisPropertiesType extensionProperties = setAspects.getProperties();
|
||||
if (extensionProperties == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (CmisProperty property : extensionProperties.getProperty())
|
||||
{
|
||||
String propertyName = getPropertyName(property);
|
||||
if ((null == propertyName)
|
||||
|| ((null != ignoringPropertiesFilter) && ignoringPropertiesFilter.allow(propertyName)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Object value = getValue(property);
|
||||
|
||||
// This time, call setProperty without constraining the owning type
|
||||
cmisService.setProperty(nodeRef, null, propertyName, (Serializable) value);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public String getPropertyName(CmisProperty property)
|
||||
{
|
||||
String propertyName = (null != property) ? (property.getPropertyDefinitionId()) : (null);
|
||||
if (null == propertyName)
|
||||
{
|
||||
propertyName = property.getLocalName();
|
||||
if (null == propertyName)
|
||||
{
|
||||
propertyName = property.getDisplayName();
|
||||
}
|
||||
}
|
||||
return propertyName;
|
||||
}
|
||||
|
||||
private QName createQName(String s)
|
||||
{
|
||||
QName qname;
|
||||
if (s.indexOf(NAMESPACE_BEGIN) != -1)
|
||||
{
|
||||
qname = QName.createQName(s);
|
||||
}
|
||||
else
|
||||
{
|
||||
qname = QName.createQName(s, namespaceService);
|
||||
}
|
||||
return qname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get CMIS properties for object
|
||||
*
|
||||
* @param nodeRef node reference
|
||||
* @param filter property filter
|
||||
* @return properties
|
||||
*/
|
||||
public CmisPropertiesType getProperties(Object object, PropertyFilter filter) throws CmisException
|
||||
{
|
||||
if (object instanceof Version)
|
||||
{
|
||||
object = ((Version) object).getFrozenStateNodeRef();
|
||||
}
|
||||
try
|
||||
{
|
||||
CmisPropertiesType result = new CmisPropertiesType();
|
||||
Map<String, Serializable> properties;
|
||||
if (object instanceof NodeRef)
|
||||
{
|
||||
properties = cmisService.getProperties((NodeRef) object);
|
||||
|
||||
// Handle fetching of aspects and their properties with Alfresco extension
|
||||
Aspects extension = new Aspects();
|
||||
result.getAny().add(extension);
|
||||
List<String> aspects = extension.getAppliedAspects();
|
||||
Map<String, Serializable> aspectProperties = new HashMap<String, Serializable>(97);
|
||||
for (CMISTypeDefinition typeDef : cmisService.getAspects((NodeRef)object))
|
||||
{
|
||||
aspects.add(typeDef.getTypeId().getId());
|
||||
aspectProperties.putAll(cmisService.getProperties((NodeRef)object, typeDef));
|
||||
}
|
||||
CmisPropertiesType aspectResult = new CmisPropertiesType();
|
||||
convertToCmisProperties(aspectProperties, filter, aspectResult);
|
||||
extension.setProperties(aspectResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
properties = cmisService.getProperties((AssociationRef) object);
|
||||
}
|
||||
convertToCmisProperties( properties, filter, result);
|
||||
return result;
|
||||
}
|
||||
catch (CMISInvalidArgumentException e)
|
||||
{
|
||||
throw ExceptionUtil.createCmisException(e.getMessage(), EnumServiceException.INVALID_ARGUMENT, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void convertToCmisProperties(Map<String, Serializable> properties, PropertyFilter filter, CmisPropertiesType cmisProperties) throws CmisException
|
||||
{
|
||||
for (String propertyName : properties.keySet())
|
||||
{
|
||||
CMISPropertyDefinition propertyTypeDef = cmisDictionaryService.findProperty(propertyName, null);
|
||||
if ((null != propertyTypeDef) && filter.allow(propertyName))
|
||||
{
|
||||
CmisProperty property = createProperty(propertyName, propertyTypeDef.getDataType(), properties.get(propertyName));
|
||||
|
||||
if (null != property)
|
||||
{
|
||||
cmisProperties.getProperty().add(property);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and initializes appropriate <b>CmisProperty</b> instance by name and data type
|
||||
*
|
||||
* @param pdid - <b>String</b> value that represents CMIS property name
|
||||
* @param dataType - <b>CMISDataTypeEnum</b> value that specifies real type of the property
|
||||
* @param value - some instance of appropriate type or some <b>Collection</b> that contains several values of the type
|
||||
* @return appropriate <b>CmisProperty</b> instance
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public CmisProperty createProperty(String pdid, CMISDataTypeEnum dataType, Serializable value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
switch (dataType)
|
||||
{
|
||||
case BOOLEAN:
|
||||
{
|
||||
CmisPropertyBoolean property = new CmisPropertyBoolean();
|
||||
property.setPropertyDefinitionId(pdid);
|
||||
|
||||
if (value instanceof Collection)
|
||||
{
|
||||
for (Boolean propertyValue : (Collection<Boolean>) value)
|
||||
{
|
||||
property.getValue().add(propertyValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
property.getValue().add((Boolean) value);
|
||||
}
|
||||
|
||||
return property;
|
||||
}
|
||||
case STRING:
|
||||
{
|
||||
CmisPropertyString property = new CmisPropertyString();
|
||||
property.setPropertyDefinitionId(pdid);
|
||||
|
||||
if (value instanceof Collection)
|
||||
{
|
||||
for (String propertyValue : (Collection<String>) value)
|
||||
{
|
||||
property.getValue().add(propertyValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
property.getValue().add((String) value);
|
||||
}
|
||||
|
||||
return property;
|
||||
}
|
||||
case INTEGER:
|
||||
{
|
||||
CmisPropertyInteger property = new CmisPropertyInteger();
|
||||
property.setPropertyDefinitionId(pdid);
|
||||
|
||||
if (value instanceof Collection)
|
||||
{
|
||||
for (Object propertyValue : (Collection<Object>) value)
|
||||
{
|
||||
if(propertyValue instanceof Long)
|
||||
{
|
||||
property.getValue().add(BigInteger.valueOf((Long) propertyValue));
|
||||
}
|
||||
else
|
||||
{
|
||||
property.getValue().add(BigInteger.valueOf((Integer) propertyValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(value instanceof Long)
|
||||
{
|
||||
property.getValue().add(BigInteger.valueOf((Long) value));
|
||||
}
|
||||
else
|
||||
{
|
||||
property.getValue().add(BigInteger.valueOf((Integer) value));
|
||||
}
|
||||
}
|
||||
|
||||
return property;
|
||||
}
|
||||
case DATETIME:
|
||||
{
|
||||
CmisPropertyDateTime property = new CmisPropertyDateTime();
|
||||
property.setPropertyDefinitionId(pdid);
|
||||
|
||||
if (value instanceof Collection)
|
||||
{
|
||||
for (Date propertyValue : (Collection<Date>) value)
|
||||
{
|
||||
XMLGregorianCalendar convertedValue = convert(propertyValue);
|
||||
if (null != convertedValue)
|
||||
{
|
||||
property.getValue().add(convertedValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
XMLGregorianCalendar convertedValue = convert((Date) value);
|
||||
if (null != convertedValue)
|
||||
{
|
||||
property.getValue().add(convert((Date) value));
|
||||
}
|
||||
}
|
||||
|
||||
return property;
|
||||
}
|
||||
case ID:
|
||||
{
|
||||
CmisPropertyId property = new CmisPropertyId();
|
||||
property.setPropertyDefinitionId(pdid);
|
||||
|
||||
if (value instanceof Collection)
|
||||
{
|
||||
for (Serializable propertyValue : (Collection<Serializable>) value)
|
||||
{
|
||||
// NOTE: CMIS multi-valued values cannot contain null
|
||||
if (propertyValue != null)
|
||||
{
|
||||
property.getValue().add(propertyValue.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
property.getValue().add(value != null ? value.toString() : null);
|
||||
}
|
||||
|
||||
return property;
|
||||
}
|
||||
case URI:
|
||||
{
|
||||
CmisPropertyUri property = new CmisPropertyUri();
|
||||
property.setPropertyDefinitionId(pdid);
|
||||
|
||||
if (value instanceof Collection)
|
||||
{
|
||||
for (String propertyValue : (Collection<String>) value)
|
||||
{
|
||||
property.getValue().add(propertyValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
property.getValue().add((String) value);
|
||||
}
|
||||
|
||||
return property;
|
||||
}
|
||||
case DECIMAL:
|
||||
{
|
||||
CmisPropertyDecimal property = new CmisPropertyDecimal();
|
||||
property.setPropertyDefinitionId(pdid);
|
||||
|
||||
if (value instanceof Collection)
|
||||
{
|
||||
for (Serializable propertyValue : (Collection<Serializable>) value)
|
||||
{
|
||||
property.getValue().add(decimalValue(propertyValue));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
property.getValue().add(decimalValue(value));
|
||||
}
|
||||
|
||||
return property;
|
||||
}
|
||||
case HTML:
|
||||
{
|
||||
CmisPropertyHtml property = new CmisPropertyHtml();
|
||||
property.setPropertyDefinitionId(pdid);
|
||||
|
||||
if (value instanceof Collection)
|
||||
{
|
||||
for (String propertyValue : (Collection<String>) value)
|
||||
{
|
||||
property.getValue().add(propertyValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
property.getValue().add((String) value);
|
||||
}
|
||||
|
||||
return property;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private BigDecimal decimalValue(Serializable value)
|
||||
{
|
||||
if ((value instanceof Float) || (value instanceof Double))
|
||||
{
|
||||
return BigDecimal.valueOf(((Number) value).doubleValue());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts Date object to XMLGregorianCalendar object
|
||||
*
|
||||
* @param date Date object
|
||||
* @return XMLGregorianCalendar object
|
||||
*/
|
||||
public XMLGregorianCalendar convert(Date date)
|
||||
{
|
||||
if (null != date)
|
||||
{
|
||||
GregorianCalendar calendar = new GregorianCalendar();
|
||||
calendar.setTime(date);
|
||||
return DATATYPE_FACTORY.newXMLGregorianCalendar(calendar);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -1,133 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.web.scripts.content;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.alfresco.cmis.CMISObjectReference;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.cmis.reference.ReferenceFactory;
|
||||
import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.webscripts.AbstractWebScript;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
import org.springframework.extensions.webscripts.WebScriptResponse;
|
||||
|
||||
|
||||
/**
|
||||
* Content Delete Service
|
||||
*
|
||||
* Delete content stream from the Repository.
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public class ContentDelete extends AbstractWebScript
|
||||
{
|
||||
// Component dependencies
|
||||
private ReferenceFactory referenceFactory;
|
||||
private NamespaceService namespaceService;
|
||||
private NodeService nodeService;
|
||||
|
||||
/**
|
||||
* @param reference factory
|
||||
*/
|
||||
public void setReferenceFactory(ReferenceFactory referenceFactory)
|
||||
{
|
||||
this.referenceFactory = referenceFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param namespaceService
|
||||
*/
|
||||
public void setNamespaceService(NamespaceService namespaceService)
|
||||
{
|
||||
this.namespaceService = namespaceService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nodeService
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.scripts.WebScript#execute(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.WebScriptResponse)
|
||||
*/
|
||||
public void execute(WebScriptRequest req, WebScriptResponse res)
|
||||
throws IOException
|
||||
{
|
||||
// create map of args
|
||||
String[] names = req.getParameterNames();
|
||||
Map<String, String> args = new HashMap<String, String>(names.length, 1.0f);
|
||||
for (String name : names)
|
||||
{
|
||||
args.put(name, req.getParameter(name));
|
||||
}
|
||||
|
||||
// create map of template vars
|
||||
Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
|
||||
|
||||
// create object reference from url
|
||||
CMISObjectReference reference = referenceFactory.createObjectReferenceFromUrl(args, templateVars);
|
||||
NodeRef nodeRef = reference.getNodeRef();
|
||||
if (nodeRef == null)
|
||||
{
|
||||
throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find " + reference.toString());
|
||||
}
|
||||
|
||||
// determine content property
|
||||
QName propertyQName = ContentModel.PROP_CONTENT;
|
||||
String contentPart = templateVars.get("property");
|
||||
if (contentPart.length() > 0 && contentPart.charAt(0) == ';')
|
||||
{
|
||||
if (contentPart.length() < 2)
|
||||
{
|
||||
throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "Content property malformed");
|
||||
}
|
||||
String propertyName = contentPart.substring(1);
|
||||
if (propertyName.length() > 0)
|
||||
{
|
||||
propertyQName = QName.createQName(propertyName, namespaceService);
|
||||
}
|
||||
}
|
||||
|
||||
// retrieve content property
|
||||
ContentData contentData = (ContentData)nodeService.getProperty(nodeRef, propertyQName);
|
||||
if (contentData != null)
|
||||
{
|
||||
contentData = new ContentData(null, null, 0, null);
|
||||
nodeService.setProperty(nodeRef, propertyQName, contentData);
|
||||
}
|
||||
|
||||
// no content returned
|
||||
res.setStatus(Status.STATUS_NO_CONTENT);
|
||||
}
|
||||
}
|
@@ -1,322 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2012 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.web.scripts.content;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.alfresco.cmis.CMISFilterNotValidException;
|
||||
import org.alfresco.cmis.CMISObjectReference;
|
||||
import org.alfresco.cmis.CMISRendition;
|
||||
import org.alfresco.cmis.CMISRenditionService;
|
||||
import org.alfresco.model.ApplicationModel;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.cmis.reference.ReferenceFactory;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.security.permissions.AccessDeniedException;
|
||||
import org.alfresco.repo.web.scripts.FileTypeImageUtils;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.FileTypeImageSize;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
import org.springframework.extensions.webscripts.WebScriptResponse;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
import org.springframework.web.context.ServletContextAware;
|
||||
import org.springframework.web.context.support.ServletContextResource;
|
||||
|
||||
|
||||
/**
|
||||
* Content Retrieval Service
|
||||
*
|
||||
* Stream content from the Repository.
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public class ContentGet extends StreamContent implements ServletContextAware
|
||||
{
|
||||
// Logger
|
||||
@SuppressWarnings("unused")
|
||||
private static final Log logger = LogFactory.getLog(ContentGet.class);
|
||||
|
||||
// Component dependencies
|
||||
private ServletContext servletContext;
|
||||
private ReferenceFactory referenceFactory;
|
||||
private DictionaryService dictionaryService;
|
||||
private NamespaceService namespaceService;
|
||||
private CMISRenditionService renditionService;
|
||||
private ContentService contentService;
|
||||
|
||||
/**
|
||||
* @param
|
||||
*/
|
||||
public void setServletContext(ServletContext servletContext)
|
||||
{
|
||||
this.servletContext = servletContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param reference factory
|
||||
*/
|
||||
public void setReferenceFactory(ReferenceFactory referenceFactory)
|
||||
{
|
||||
this.referenceFactory = referenceFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dictionaryService
|
||||
*/
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param namespaceService
|
||||
*/
|
||||
public void setNamespaceService(NamespaceService namespaceService)
|
||||
{
|
||||
this.namespaceService = namespaceService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param renditionService
|
||||
*/
|
||||
public void setCMISRenditionService(CMISRenditionService renditionService)
|
||||
{
|
||||
this.renditionService = renditionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param contentService
|
||||
*/
|
||||
public void setContentService(ContentService contentService)
|
||||
{
|
||||
this.contentService = contentService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.scripts.WebScript#execute(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.WebScriptResponse)
|
||||
*/
|
||||
public void execute(WebScriptRequest req, WebScriptResponse res)
|
||||
throws IOException
|
||||
{
|
||||
// create map of args
|
||||
String[] names = req.getParameterNames();
|
||||
Map<String, String> args = new HashMap<String, String>(names.length, 1.0f);
|
||||
for (String name : names)
|
||||
{
|
||||
args.put(name, req.getParameter(name));
|
||||
}
|
||||
|
||||
// create map of template vars
|
||||
Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
|
||||
|
||||
// create object reference from url
|
||||
CMISObjectReference reference = referenceFactory.createObjectReferenceFromUrl(args, templateVars);
|
||||
NodeRef nodeRef = reference.getNodeRef();
|
||||
if (nodeRef == null)
|
||||
{
|
||||
throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find " + reference.toString());
|
||||
}
|
||||
|
||||
// determine attachment
|
||||
boolean attach = Boolean.valueOf(req.getParameter("a"));
|
||||
|
||||
// stream content on node, or rendition of node
|
||||
String streamId = req.getParameter("streamId");
|
||||
if (streamId != null && streamId.length() > 0)
|
||||
{
|
||||
// render content rendition
|
||||
streamRendition(req, res, reference, streamId, attach);
|
||||
}
|
||||
else
|
||||
{
|
||||
// render content
|
||||
QName propertyQName = ContentModel.PROP_CONTENT;
|
||||
String contentPart = templateVars.get("property");
|
||||
if (contentPart.length() > 0 && contentPart.charAt(0) == ';')
|
||||
{
|
||||
if (contentPart.length() < 2)
|
||||
{
|
||||
throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "Content property malformed");
|
||||
}
|
||||
String propertyName = contentPart.substring(1);
|
||||
if (propertyName.length() > 0)
|
||||
{
|
||||
propertyQName = QName.createQName(propertyName, namespaceService);
|
||||
}
|
||||
}
|
||||
|
||||
// Stream the content
|
||||
streamContentLocal(req, res, nodeRef, attach, propertyQName);
|
||||
}
|
||||
}
|
||||
|
||||
private void streamContentLocal(WebScriptRequest req, WebScriptResponse res, NodeRef nodeRef, boolean attach, QName propertyQName) throws IOException
|
||||
{
|
||||
String userAgent = req.getHeader("User-Agent");
|
||||
|
||||
boolean rfc5987Supported = (null != userAgent) && (userAgent.contains("MSIE") || userAgent.contains(" Chrome/") || userAgent.contains(" FireFox/"));
|
||||
|
||||
try
|
||||
{
|
||||
if (attach && rfc5987Supported)
|
||||
{
|
||||
String name = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
||||
|
||||
//IE use file extension to get mimetype
|
||||
//So we set correct extension. see MNT-11246
|
||||
if(userAgent.contains("MSIE"))
|
||||
{
|
||||
String mimeType = contentService.getReader(nodeRef, propertyQName).getMimetype();
|
||||
if (!mimetypeService.getMimetypes(FilenameUtils.getExtension(name)).contains(mimeType))
|
||||
{
|
||||
name = FilenameUtils.removeExtension(name) + FilenameUtils.EXTENSION_SEPARATOR_STR + mimetypeService.getExtension(mimeType);
|
||||
}
|
||||
}
|
||||
|
||||
streamContent(req, res, nodeRef, propertyQName, attach, name, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
streamContent(req, res, nodeRef, propertyQName, attach, null, null);
|
||||
}
|
||||
}
|
||||
catch (AccessDeniedException e)
|
||||
{
|
||||
throw new WebScriptException(Status.STATUS_FORBIDDEN, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stream content rendition
|
||||
*
|
||||
* @param req
|
||||
* @param res
|
||||
* @param reference
|
||||
* @param streamId
|
||||
* @param attach
|
||||
* @throws IOException
|
||||
*/
|
||||
private void streamRendition(WebScriptRequest req, WebScriptResponse res, CMISObjectReference reference, String streamId, boolean attach)
|
||||
throws IOException
|
||||
{
|
||||
try
|
||||
{
|
||||
// find rendition
|
||||
CMISRendition rendition = null;
|
||||
List<CMISRendition> renditions = renditionService.getRenditions(reference.getNodeRef(), "*");
|
||||
for (CMISRendition candidateRendition : renditions)
|
||||
{
|
||||
if (candidateRendition.getStreamId().equals(streamId))
|
||||
{
|
||||
rendition = candidateRendition;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (rendition == null)
|
||||
{
|
||||
throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find rendition " + streamId + " for " + reference.toString());
|
||||
}
|
||||
|
||||
// determine if special case for icons
|
||||
if (streamId.startsWith("alf:icon"))
|
||||
{
|
||||
streamIcon(res, reference, streamId, attach);
|
||||
}
|
||||
else
|
||||
{
|
||||
streamContentLocal(req, res, rendition.getNodeRef(), attach, ContentModel.PROP_CONTENT);
|
||||
}
|
||||
}
|
||||
catch(CMISFilterNotValidException e)
|
||||
{
|
||||
throw new WebScriptException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Invalid Rendition Filter");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stream Icon
|
||||
*
|
||||
* @param res
|
||||
* @param reference
|
||||
* @param streamId
|
||||
* @param attach
|
||||
* @throws IOException
|
||||
*/
|
||||
private void streamIcon(WebScriptResponse res, CMISObjectReference reference, String streamId, boolean attach)
|
||||
throws IOException
|
||||
{
|
||||
// convert stream id to icon size
|
||||
FileTypeImageSize imageSize = streamId.equals("alf:icon16") ? FileTypeImageSize.Small : FileTypeImageSize.Medium;
|
||||
String iconSize = streamId.equals("alf:icon16") ? "-16" : "";
|
||||
|
||||
// calculate icon file name and path
|
||||
String iconPath = null;
|
||||
if (dictionaryService.isSubClass(nodeService.getType(reference.getNodeRef()), ContentModel.TYPE_CONTENT))
|
||||
{
|
||||
String name = (String)nodeService.getProperty(reference.getNodeRef(), ContentModel.PROP_NAME);
|
||||
iconPath = FileTypeImageUtils.getFileTypeImage(servletContext, name, imageSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
String icon = (String)nodeService.getProperty(reference.getNodeRef(), ApplicationModel.PROP_ICON);
|
||||
if (icon != null)
|
||||
{
|
||||
iconPath = "/images/icons/" + icon + iconSize + ".gif";
|
||||
}
|
||||
else
|
||||
{
|
||||
iconPath = "/images/icons/space-icon-default" + iconSize + ".gif";
|
||||
}
|
||||
}
|
||||
|
||||
// set mimetype
|
||||
String mimetype = MimetypeMap.MIMETYPE_BINARY;
|
||||
int extIndex = iconPath.lastIndexOf('.');
|
||||
if (extIndex != -1)
|
||||
{
|
||||
String ext = iconPath.substring(extIndex + 1);
|
||||
mimetype = mimetypeService.getMimetype(ext);
|
||||
}
|
||||
res.setContentType(mimetype);
|
||||
|
||||
// stream icon
|
||||
ServletContextResource resource = new ServletContextResource(servletContext, iconPath);
|
||||
if (!resource.exists())
|
||||
{
|
||||
throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find rendition " + streamId + " for " + reference.toString());
|
||||
}
|
||||
FileCopyUtils.copy(resource.getInputStream(), res.getOutputStream());
|
||||
}
|
||||
|
||||
}
|
@@ -1,113 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.web.scripts.content;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.alfresco.cmis.CMISObjectReference;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.cmis.reference.ReferenceFactory;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.webscripts.Cache;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
import org.springframework.extensions.webscripts.WebScriptResponse;
|
||||
|
||||
/**
|
||||
* Content Info Service Get info about content from the Repository.
|
||||
*
|
||||
* @author alex.malinovsky
|
||||
*/
|
||||
public class ContentInfo extends StreamContent
|
||||
{
|
||||
|
||||
private ReferenceFactory referenceFactory;
|
||||
|
||||
public void setReferenceFactory(ReferenceFactory referenceFactory)
|
||||
{
|
||||
this.referenceFactory = referenceFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException
|
||||
{
|
||||
// create empty map of args
|
||||
Map<String, String> args = new HashMap<String, String>(0, 1.0f);
|
||||
// create map of template vars
|
||||
Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
|
||||
// create object reference from url
|
||||
CMISObjectReference reference = referenceFactory.createObjectReferenceFromUrl(args, templateVars);
|
||||
NodeRef nodeRef = reference.getNodeRef();
|
||||
if (nodeRef == null)
|
||||
{
|
||||
throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find " + reference.toString());
|
||||
}
|
||||
|
||||
// render content
|
||||
QName propertyQName = ContentModel.PROP_CONTENT;
|
||||
|
||||
// Stream the content
|
||||
streamContent(req, res, nodeRef, propertyQName, false, null, null);
|
||||
}
|
||||
|
||||
protected void streamContentImpl(WebScriptRequest req, WebScriptResponse res,
|
||||
ContentReader reader, NodeRef nodeRef, QName propertyQName,
|
||||
boolean attach, Date modified, String eTag, String attachFileName)
|
||||
throws IOException
|
||||
{
|
||||
delegate.setAttachment(req, res, attach, attachFileName);
|
||||
|
||||
// establish mimetype
|
||||
String mimetype = reader.getMimetype();
|
||||
String extensionPath = req.getExtensionPath();
|
||||
if (mimetype == null || mimetype.length() == 0)
|
||||
{
|
||||
mimetype = MimetypeMap.MIMETYPE_BINARY;
|
||||
int extIndex = extensionPath.lastIndexOf('.');
|
||||
if (extIndex != -1)
|
||||
{
|
||||
String ext = extensionPath.substring(extIndex + 1);
|
||||
mimetype = mimetypeService.getMimetype(ext);
|
||||
}
|
||||
}
|
||||
|
||||
// set mimetype for the content and the character encoding + length for the stream
|
||||
res.setContentType(mimetype);
|
||||
res.setContentEncoding(reader.getEncoding());
|
||||
res.setHeader("Content-Length", Long.toString(reader.getSize()));
|
||||
|
||||
// set caching
|
||||
Cache cache = new Cache();
|
||||
cache.setNeverCache(false);
|
||||
cache.setMustRevalidate(true);
|
||||
cache.setMaxAge(0L);
|
||||
cache.setLastModified(modified);
|
||||
cache.setETag(eTag);
|
||||
res.setCache(cache);
|
||||
}
|
||||
|
||||
}
|
@@ -1,187 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.web.scripts.content;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.alfresco.cmis.CMISDictionaryModel;
|
||||
import org.alfresco.cmis.CMISObjectReference;
|
||||
import org.alfresco.cmis.CMISServiceException;
|
||||
import org.alfresco.cmis.CMISServices;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.cmis.reference.ObjectPathReference;
|
||||
import org.alfresco.repo.cmis.reference.ReferenceFactory;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.webscripts.AbstractWebScript;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
import org.springframework.extensions.webscripts.WebScriptResponse;
|
||||
|
||||
|
||||
/**
|
||||
* Content Write Service
|
||||
*
|
||||
* Stream content to the Repository.
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public class ContentSet extends AbstractWebScript
|
||||
{
|
||||
// Logger
|
||||
@SuppressWarnings("unused")
|
||||
private static final Log logger = LogFactory.getLog(ContentSet.class);
|
||||
|
||||
// Component dependencies
|
||||
private ReferenceFactory referenceFactory;
|
||||
private DictionaryService dictionaryService;
|
||||
private NamespaceService namespaceService;
|
||||
private CMISServices cmisService;
|
||||
private MimetypeService mimetypeService;
|
||||
|
||||
/**
|
||||
* @param reference factory
|
||||
*/
|
||||
public void setReferenceFactory(ReferenceFactory referenceFactory)
|
||||
{
|
||||
this.referenceFactory = referenceFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dictionaryService
|
||||
*/
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param namespaceService
|
||||
*/
|
||||
public void setNamespaceService(NamespaceService namespaceService)
|
||||
{
|
||||
this.namespaceService = namespaceService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cmisServices
|
||||
*/
|
||||
public void setCmisService(CMISServices cmisService)
|
||||
{
|
||||
this.cmisService = cmisService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mimetypeService
|
||||
*/
|
||||
public void setMimetypeService(MimetypeService mimetypeService)
|
||||
{
|
||||
this.mimetypeService = mimetypeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.scripts.WebScript#execute(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.WebScriptResponse)
|
||||
*/
|
||||
public void execute(WebScriptRequest req, WebScriptResponse res)
|
||||
throws IOException
|
||||
{
|
||||
// create map of args
|
||||
String[] names = req.getParameterNames();
|
||||
Map<String, String> args = new HashMap<String, String>(names.length, 1.0f);
|
||||
for (String name : names)
|
||||
{
|
||||
args.put(name, req.getParameter(name));
|
||||
}
|
||||
|
||||
// create map of template vars
|
||||
Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
|
||||
|
||||
// create object reference from url
|
||||
CMISObjectReference reference = referenceFactory.createObjectReferenceFromUrl(args, templateVars);
|
||||
NodeRef nodeRef = reference.getNodeRef();
|
||||
if (nodeRef == null)
|
||||
{
|
||||
throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find " + reference.toString());
|
||||
}
|
||||
|
||||
// determine content property
|
||||
QName propertyQName = ContentModel.PROP_CONTENT;
|
||||
String contentPart = templateVars.get("property");
|
||||
if (contentPart.length() > 0 && contentPart.charAt(0) == ';')
|
||||
{
|
||||
if (contentPart.length() < 2)
|
||||
{
|
||||
throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "Content property malformed");
|
||||
}
|
||||
String propertyName = contentPart.substring(1);
|
||||
if (propertyName.length() > 0)
|
||||
{
|
||||
propertyQName = QName.createQName(propertyName, namespaceService);
|
||||
}
|
||||
}
|
||||
PropertyDefinition propertyDef = dictionaryService.getProperty(propertyQName);
|
||||
if (propertyDef == null)
|
||||
{
|
||||
throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find content property " + propertyQName + " of " + reference.toString());
|
||||
}
|
||||
if (!propertyDef.getDataType().getName().equals(DataTypeDefinition.CONTENT))
|
||||
{
|
||||
throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Content stream not found");
|
||||
}
|
||||
|
||||
// ensure content can be overwritten
|
||||
String overwrite = req.getParameter("overwriteFlag");
|
||||
|
||||
// establish mimetype
|
||||
String mimetype = req.getContentType();
|
||||
if (mimetype == null)
|
||||
{
|
||||
if (reference instanceof ObjectPathReference)
|
||||
{
|
||||
mimetype = mimetypeService.guessMimetype(((ObjectPathReference)reference).getPath());
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
boolean isUpdate = cmisService.setContentStream((String) cmisService.getProperty(nodeRef,
|
||||
CMISDictionaryModel.PROP_OBJECT_ID), propertyQName, overwrite == null || overwrite.equals("true"),
|
||||
req.getContent().getInputStream(), mimetype);
|
||||
|
||||
// set status
|
||||
res.setStatus(isUpdate ? Status.STATUS_OK : Status.STATUS_CREATED);
|
||||
}
|
||||
catch (CMISServiceException e)
|
||||
{
|
||||
throw new WebScriptException(e.getStatusCode(), e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
@@ -21,13 +21,14 @@ package org.alfresco.repo.web.scripts.quickshare;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.model.QuickShareModel;
|
||||
import org.alfresco.repo.tenant.TenantUtil;
|
||||
import org.alfresco.repo.tenant.TenantUtil.TenantRunAsWork;
|
||||
import org.alfresco.repo.web.scripts.content.ContentGet;
|
||||
import org.alfresco.repo.web.scripts.content.StreamContent;
|
||||
import org.alfresco.service.cmr.quickshare.InvalidSharedIdException;
|
||||
import org.alfresco.service.cmr.quickshare.QuickShareService;
|
||||
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||
@@ -41,6 +42,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
import org.springframework.extensions.webscripts.WebScriptResponse;
|
||||
import org.springframework.web.context.ServletContextAware;
|
||||
|
||||
|
||||
/**
|
||||
@@ -53,7 +55,7 @@ import org.springframework.extensions.webscripts.WebScriptResponse;
|
||||
* @author janv
|
||||
* @since Cloud/4.2
|
||||
*/
|
||||
public class QuickShareContentGet extends ContentGet
|
||||
public class QuickShareContentGet extends StreamContent implements ServletContextAware
|
||||
{
|
||||
private static final Log logger = LogFactory.getLog(QuickShareContentGet.class);
|
||||
|
||||
@@ -64,6 +66,10 @@ public class QuickShareContentGet extends ContentGet
|
||||
private boolean enabled = true;
|
||||
|
||||
|
||||
public void setServletContext(ServletContext servletContext)
|
||||
{
|
||||
}
|
||||
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
@@ -73,7 +79,6 @@ public class QuickShareContentGet extends ContentGet
|
||||
public void setNamespaceService(NamespaceService namespaceService)
|
||||
{
|
||||
this.namespaceService = namespaceService;
|
||||
super.setNamespaceService(namespaceService);
|
||||
}
|
||||
|
||||
public void setQuickShareService(QuickShareService quickShareService)
|
||||
|
Reference in New Issue
Block a user