<artifactId>org.collectionspace.services.intake.service</artifactId>\r
<version>1.0</version>\r
</dependency>\r
-\r
<dependency>\r
<groupId>org.collectionspace.services</groupId>\r
<artifactId>org.collectionspace.services.relation.service</artifactId>\r
<version>1.0</version>\r
</dependency>\r
+ <dependency>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.query.service</artifactId>\r
+ <version>1.0</version>\r
+ </dependency>\r
<dependency>\r
<groupId>commons-io</groupId>\r
<artifactId>commons-io</artifactId>\r
<port>8180</port>\r
</configuration>\r
<executions>\r
+ \r
<execution>\r
<id>jboss-undeploy</id>\r
<phase>pre-integration-test</phase>\r
</fileNames>\r
</configuration>\r
</execution>\r
+ \r
</executions>\r
</plugin>\r
\r
import org.collectionspace.services.intake.IntakeResource;
//import org.collectionspace.services.relation.RelationResource;
import org.collectionspace.services.relation.NewRelationResource;
+import org.collectionspace.services.query.QueryResource;
import javax.ws.rs.core.Application;
import java.util.HashSet;
singletons.add(new IDResource());
singletons.add(new IntakeResource());
// singletons.add(new RelationResource());
- singletons.add(new NewRelationResource());
+ singletons.add(new NewRelationResource());
+ singletons.add(new QueryResource());
// singletons.add(new DomainIdentifierResource());
// singletons.add(new PingResource());
}
public Document deleteCollectionObject(String csid)\r
throws DocumentException, IOException {\r
\r
- NuxeoRESTClient nxClient = getClient();\r
- List<String> pathParams = new ArrayList<String>();\r
- Map<String, String> queryParams = new HashMap<String, String>();\r
-\r
- pathParams.add("default");\r
- pathParams.add(csid);\r
- pathParams.add("deleteDocumentRestlet");\r
- Representation res = nxClient.get(pathParams, queryParams);\r
- SAXReader reader = new SAXReader();\r
- Document document = reader.read(res.getStream());\r
+ Document result = null;\r
+ \r
+// NuxeoRESTClient nxClient = getClient();\r
+// List<String> pathParams = new ArrayList<String>();\r
+// Map<String, String> queryParams = new HashMap<String, String>();\r
+//\r
+// pathParams.add("default");\r
+// pathParams.add(csid);\r
+// pathParams.add("deleteDocumentRestlet");\r
+// Representation res = nxClient.get(pathParams, queryParams);\r
+// SAXReader reader = new SAXReader();\r
+// result = reader.read(res.getStream());\r
\r
- return document;\r
+ return result;\r
}\r
\r
public Document getCollectionObject(String csid) throws DocumentException,\r
//getCollectionObjectViaJavaAPI(csid);\r
\r
// Return to normal Nuxeo REST call\r
- List<String> pathParams = new ArrayList<String>();\r
- Map<String, String> queryParams = new HashMap<String, String>();\r
-\r
- pathParams.add("default");\r
- pathParams.add(csid);\r
- pathParams.add("export");\r
- queryParams.put("format", "XML");\r
-\r
- NuxeoRESTClient nxClient = getClient();\r
- Representation res = nxClient.get(pathParams, queryParams);\r
-\r
- SAXReader reader = new SAXReader();\r
- Document document = reader.read(res.getStream());\r
+ Document result = null;\r
+// \r
+// List<String> pathParams = new ArrayList<String>();\r
+// Map<String, String> queryParams = new HashMap<String, String>();\r
+//\r
+// pathParams.add("default");\r
+// pathParams.add(csid);\r
+// pathParams.add("export");\r
+// queryParams.put("format", "XML");\r
+//\r
+// NuxeoRESTClient nxClient = getClient();\r
+// Representation res = nxClient.get(pathParams, queryParams);\r
+//\r
+// SAXReader reader = new SAXReader();\r
+// result = reader.read(res.getStream());\r
\r
- return document;\r
+ return result;\r
}\r
\r
\r
IOException {\r
Document result = null;\r
\r
- NuxeoRESTClient nxClient = getClient();\r
- List<String> pathParams = new ArrayList<String>();\r
- Map<String, String> queryParams = new HashMap<String, String>();\r
- pathParams = Arrays.asList("default",\r
- CS_COLLECTIONOBJECT_WORKSPACE_UID, "browse");\r
- Representation res = nxClient.get(pathParams, queryParams);\r
- SAXReader reader = new SAXReader();\r
- result = reader.read(res.getStream());\r
+// NuxeoRESTClient nxClient = getClient();\r
+// List<String> pathParams = new ArrayList<String>();\r
+// Map<String, String> queryParams = new HashMap<String, String>();\r
+// pathParams = Arrays.asList("default",\r
+// CS_COLLECTIONOBJECT_WORKSPACE_UID, "browse");\r
+// Representation res = nxClient.get(pathParams, queryParams);\r
+// SAXReader reader = new SAXReader();\r
+// result = reader.read(res.getStream());\r
\r
return result;\r
}\r
\r
public Document postCollectionObject(CollectionObject co)\r
throws DocumentException, IOException {\r
- NuxeoRESTClient nxClient = getClient();\r
-\r
- List<String> pathParams = new ArrayList<String>();\r
- Map<String, String> queryParams = new HashMap<String, String>();\r
- pathParams.add("default");\r
- pathParams.add(CS_COLLECTIONOBJECT_WORKSPACE_UID);\r
- pathParams.add("createDocument");\r
- queryParams.put("docType", CO_NUXEO_DOCTYPE);\r
-\r
- // a default title for the Dublin Core schema\r
- queryParams.put("dublincore:title", CO_NUXEO_DC_TITLE);\r
-\r
- // CollectionObject core values\r
- queryParams.put(CO_NUXEO_SCHEMA_NAME + ":"\r
- + CollectionObjectJAXBSchema.OBJECT_NUMBER, co\r
- .getObjectNumber());\r
- queryParams.put(CO_NUXEO_SCHEMA_NAME + ":"\r
- + CollectionObjectJAXBSchema.OTHER_NUMBER, co.getOtherNumber());\r
- queryParams.put(CO_NUXEO_SCHEMA_NAME + ":"\r
- + CollectionObjectJAXBSchema.BRIEF_DESCRIPTION, co\r
- .getBriefDescription());\r
- queryParams.put(CO_NUXEO_SCHEMA_NAME + ":"\r
- + CollectionObjectJAXBSchema.COMMENTS, co.getComments());\r
- queryParams.put(CO_NUXEO_SCHEMA_NAME + ":"\r
- + CollectionObjectJAXBSchema.DIST_FEATURES, co\r
- .getDistFeatures());\r
- queryParams.put(CO_NUXEO_SCHEMA_NAME + ":"\r
- + CollectionObjectJAXBSchema.OBJECT_NAME, co.getObjectName());\r
- queryParams.put(CO_NUXEO_SCHEMA_NAME + ":"\r
- + CollectionObjectJAXBSchema.RESPONSIBLE_DEPT, co\r
- .getResponsibleDept());\r
- queryParams.put(CO_NUXEO_SCHEMA_NAME + ":"\r
- + CollectionObjectJAXBSchema.TITLE, co.getTitle());\r
-\r
- ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]);\r
- Representation res = nxClient.post(pathParams, queryParams, bais);\r
-\r
- SAXReader reader = new SAXReader();\r
- Document document = reader.read(res.getStream());\r
-\r
- return document;\r
+ Document result = null;\r
+ \r
+// NuxeoRESTClient nxClient = getClient();\r
+//\r
+// List<String> pathParams = new ArrayList<String>();\r
+// Map<String, String> queryParams = new HashMap<String, String>();\r
+// pathParams.add("default");\r
+// pathParams.add(CS_COLLECTIONOBJECT_WORKSPACE_UID);\r
+// pathParams.add("createDocument");\r
+// queryParams.put("docType", CO_NUXEO_DOCTYPE);\r
+//\r
+// // a default title for the Dublin Core schema\r
+// queryParams.put("dublincore:title", CO_NUXEO_DC_TITLE);\r
+//\r
+// // CollectionObject core values\r
+// queryParams.put(CO_NUXEO_SCHEMA_NAME + ":"\r
+// + CollectionObjectJAXBSchema.OBJECT_NUMBER, co\r
+// .getObjectNumber());\r
+// queryParams.put(CO_NUXEO_SCHEMA_NAME + ":"\r
+// + CollectionObjectJAXBSchema.OTHER_NUMBER, co.getOtherNumber());\r
+// queryParams.put(CO_NUXEO_SCHEMA_NAME + ":"\r
+// + CollectionObjectJAXBSchema.BRIEF_DESCRIPTION, co\r
+// .getBriefDescription());\r
+// queryParams.put(CO_NUXEO_SCHEMA_NAME + ":"\r
+// + CollectionObjectJAXBSchema.COMMENTS, co.getComments());\r
+// queryParams.put(CO_NUXEO_SCHEMA_NAME + ":"\r
+// + CollectionObjectJAXBSchema.DIST_FEATURES, co\r
+// .getDistFeatures());\r
+// queryParams.put(CO_NUXEO_SCHEMA_NAME + ":"\r
+// + CollectionObjectJAXBSchema.OBJECT_NAME, co.getObjectName());\r
+// queryParams.put(CO_NUXEO_SCHEMA_NAME + ":"\r
+// + CollectionObjectJAXBSchema.RESPONSIBLE_DEPT, co\r
+// .getResponsibleDept());\r
+// queryParams.put(CO_NUXEO_SCHEMA_NAME + ":"\r
+// + CollectionObjectJAXBSchema.TITLE, co.getTitle());\r
+//\r
+// ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]);\r
+// Representation res = nxClient.post(pathParams, queryParams, bais);\r
+//\r
+// SAXReader reader = new SAXReader();\r
+// result = reader.read(res.getStream());\r
+\r
+ return result;\r
}\r
\r
public Document putCollectionObject(String csid, CollectionObject theUpdate)\r
throws DocumentException, IOException {\r
- List<String> pathParams = new ArrayList<String>();\r
- Map<String, String> queryParams = new HashMap<String, String>();\r
- pathParams.add("default");\r
- pathParams.add(csid);\r
- pathParams.add("updateDocumentRestlet");\r
-\r
- // todo: intelligent merge needed\r
- if (theUpdate.getObjectNumber() != null) {\r
- queryParams.put(CO_NUXEO_SCHEMA_NAME + ":"\r
- + CollectionObjectJAXBSchema.OBJECT_NUMBER, theUpdate\r
- .getObjectNumber());\r
- }\r
-\r
- if (theUpdate.getOtherNumber() != null) {\r
- queryParams.put(CO_NUXEO_SCHEMA_NAME + ":"\r
- + CollectionObjectJAXBSchema.OTHER_NUMBER, theUpdate\r
- .getOtherNumber());\r
- }\r
-\r
- if (theUpdate.getBriefDescription() != null) {\r
- queryParams.put(CO_NUXEO_SCHEMA_NAME + ":"\r
- + CollectionObjectJAXBSchema.BRIEF_DESCRIPTION, theUpdate\r
- .getBriefDescription());\r
- }\r
-\r
- if (theUpdate.getComments() != null) {\r
- queryParams.put(CO_NUXEO_SCHEMA_NAME + ":"\r
- + CollectionObjectJAXBSchema.COMMENTS, theUpdate\r
- .getComments());\r
- }\r
-\r
- if (theUpdate.getDistFeatures() != null) {\r
- queryParams.put(CO_NUXEO_SCHEMA_NAME + ":"\r
- + CollectionObjectJAXBSchema.DIST_FEATURES, theUpdate\r
- .getDistFeatures());\r
- }\r
-\r
- if (theUpdate.getObjectName() != null) {\r
- queryParams.put(CO_NUXEO_SCHEMA_NAME + ":"\r
- + CollectionObjectJAXBSchema.OBJECT_NAME, theUpdate\r
- .getObjectName());\r
- }\r
-\r
- if (theUpdate.getResponsibleDept() != null) {\r
- queryParams.put(CO_NUXEO_SCHEMA_NAME + ":"\r
- + CollectionObjectJAXBSchema.RESPONSIBLE_DEPT, theUpdate\r
- .getResponsibleDept());\r
- }\r
-\r
- if (theUpdate.getTitle() != null) {\r
- queryParams.put(CO_NUXEO_SCHEMA_NAME + ":"\r
- + CollectionObjectJAXBSchema.TITLE, theUpdate.getTitle());\r
- }\r
-\r
- NuxeoRESTClient nxClient = getClient();\r
- Representation res = nxClient.get(pathParams, queryParams);\r
- SAXReader reader = new SAXReader();\r
- Document document = reader.read(res.getStream());\r
-\r
- return document;\r
+ \r
+ Document result = null;\r
+ \r
+// List<String> pathParams = new ArrayList<String>();\r
+// Map<String, String> queryParams = new HashMap<String, String>();\r
+// pathParams.add("default");\r
+// pathParams.add(csid);\r
+// pathParams.add("updateDocumentRestlet");\r
+//\r
+// // todo: intelligent merge needed\r
+// if (theUpdate.getObjectNumber() != null) {\r
+// queryParams.put(CO_NUXEO_SCHEMA_NAME + ":"\r
+// + CollectionObjectJAXBSchema.OBJECT_NUMBER, theUpdate\r
+// .getObjectNumber());\r
+// }\r
+//\r
+// if (theUpdate.getOtherNumber() != null) {\r
+// queryParams.put(CO_NUXEO_SCHEMA_NAME + ":"\r
+// + CollectionObjectJAXBSchema.OTHER_NUMBER, theUpdate\r
+// .getOtherNumber());\r
+// }\r
+//\r
+// if (theUpdate.getBriefDescription() != null) {\r
+// queryParams.put(CO_NUXEO_SCHEMA_NAME + ":"\r
+// + CollectionObjectJAXBSchema.BRIEF_DESCRIPTION, theUpdate\r
+// .getBriefDescription());\r
+// }\r
+//\r
+// if (theUpdate.getComments() != null) {\r
+// queryParams.put(CO_NUXEO_SCHEMA_NAME + ":"\r
+// + CollectionObjectJAXBSchema.COMMENTS, theUpdate\r
+// .getComments());\r
+// }\r
+//\r
+// if (theUpdate.getDistFeatures() != null) {\r
+// queryParams.put(CO_NUXEO_SCHEMA_NAME + ":"\r
+// + CollectionObjectJAXBSchema.DIST_FEATURES, theUpdate\r
+// .getDistFeatures());\r
+// }\r
+//\r
+// if (theUpdate.getObjectName() != null) {\r
+// queryParams.put(CO_NUXEO_SCHEMA_NAME + ":"\r
+// + CollectionObjectJAXBSchema.OBJECT_NAME, theUpdate\r
+// .getObjectName());\r
+// }\r
+//\r
+// if (theUpdate.getResponsibleDept() != null) {\r
+// queryParams.put(CO_NUXEO_SCHEMA_NAME + ":"\r
+// + CollectionObjectJAXBSchema.RESPONSIBLE_DEPT, theUpdate\r
+// .getResponsibleDept());\r
+// }\r
+//\r
+// if (theUpdate.getTitle() != null) {\r
+// queryParams.put(CO_NUXEO_SCHEMA_NAME + ":"\r
+// + CollectionObjectJAXBSchema.TITLE, theUpdate.getTitle());\r
+// }\r
+//\r
+// NuxeoRESTClient nxClient = getClient();\r
+// Representation res = nxClient.get(pathParams, queryParams);\r
+// SAXReader reader = new SAXReader();\r
+// result = reader.read(res.getStream());\r
+\r
+ return result;\r
}\r
\r
}\r
--- /dev/null
+package org.collectionspace.services.common.query;\r
+\r
+public interface IQueryManager {\r
+ \r
+ public void execQuery(String queryString);\r
+\r
+}\r
--- /dev/null
+package org.collectionspace.services.common.query;\r
+\r
+import org.collectionspace.services.common.query.nuxeo.QueryManagerNuxeoImpl;\r
+\r
+public class QueryManager {\r
+ static private final IQueryManager queryManager = new QueryManagerNuxeoImpl();\r
+ \r
+ static public void execQuery(String queryString) {\r
+ queryManager.execQuery(queryString);\r
+ }\r
+}\r
--- /dev/null
+package org.collectionspace.services.common.query.nuxeo;\r
+\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
+import org.nuxeo.ecm.core.api.DocumentModel;\r
+import org.nuxeo.ecm.core.api.DocumentModelList;\r
+import org.nuxeo.ecm.core.api.repository.RepositoryInstance;\r
+import org.nuxeo.ecm.core.client.NuxeoClient;\r
+\r
+import org.collectionspace.services.nuxeo.client.java.NuxeoConnector;\r
+import org.collectionspace.services.nuxeo.client.java.RepositoryJavaClient;\r
+import org.collectionspace.services.common.query.IQueryManager;\r
+\r
+public class QueryManagerNuxeoImpl implements IQueryManager {\r
+ \r
+ private final Logger logger = LoggerFactory\r
+ .getLogger(RepositoryJavaClient.class);\r
+ \r
+ public void execQuery(String queryString) {\r
+ NuxeoClient client = null;\r
+ try {\r
+ client = NuxeoConnector.getInstance().getClient();\r
+ RepositoryInstance repoSession = client.openRepository();\r
+ \r
+ DocumentModelList docModelList = repoSession.query("SELECT * FROM Relation WHERE relation:relationtype.documentId1='updated-Subject-1'");\r
+// DocumentModelList docModelList = repoSession.query("SELECT * FROM Relation");\r
+// DocumentModelList docModelList = repoSession.query("SELECT * FROM CollectionObject WHERE collectionobject:objectNumber='objectNumber-1251305545865'");\r
+ for (DocumentModel docModel : docModelList) {\r
+ System.out.println("--------------------------------------------");\r
+ System.out.println(docModel.getPathAsString());\r
+ System.out.println(docModel.getName());\r
+ System.out.println(docModel.getPropertyValue("dc:title"));\r
+// System.out.println("documentId1=" + docModel.getProperty("relation", "relationtype/documentId1").toString());\r
+ }\r
+ \r
+ } catch (Exception e) {\r
+ // TODO Auto-generated catch block\r
+ e.printStackTrace();\r
+ } \r
+ }\r
+\r
+}\r
/**\r
* The Interface RelationUtils.\r
*/\r
-public interface RelationUtils {\r
+public interface IRelationsManager {\r
\r
/**\r
* Gets the relationships.\r
import java.util.List;\r
\r
import org.collectionspace.services.common.repository.DocumentException;\r
-import org.collectionspace.services.common.relation.nuxeo.RelationUtilsNuxeoImpl;\r
+import org.collectionspace.services.common.relation.nuxeo.RelationsManagerNuxeoImpl;\r
import org.collectionspace.services.relation.Relation;\r
-import org.collectionspace.services.common.relation.RelationUtils;\r
+import org.collectionspace.services.common.relation.IRelationsManager;\r
\r
import org.dom4j.Document;\r
import org.nuxeo.ecm.core.api.DocumentModel;\r
static public final String OBJECT = "objectCsid";\r
\r
/** The relation utils. */\r
- static private RelationUtils relationUtils = new RelationUtilsNuxeoImpl();\r
+ static private IRelationsManager relationUtils = new RelationsManagerNuxeoImpl();\r
\r
/**\r
* Gets the relationships.\r
\r
import org.collectionspace.services.common.relation.RelationJAXBSchema;\r
import org.collectionspace.services.common.relation.RelationListItemJAXBSchema;\r
-import org.collectionspace.services.common.relation.RelationUtils;\r
+import org.collectionspace.services.common.relation.IRelationsManager;\r
\r
import org.collectionspace.services.relation.Relation;\r
import org.collectionspace.services.relation.RelationList;\r
/**\r
* The Class RelationUtilsNuxeoImpl.\r
*/\r
-public class RelationUtilsNuxeoImpl implements RelationUtils {\r
+public class RelationsManagerNuxeoImpl implements IRelationsManager {\r
\r
/** The C s_ relatio n_ servic e_ name. */\r
static public String CS_RELATION_SERVICE_NAME = "relations";\r
\r
/** The logger. */\r
private static Logger logger = LoggerFactory\r
- .getLogger(RelationUtilsNuxeoImpl.class); \r
+ .getLogger(RelationsManagerNuxeoImpl.class); \r
\r
\r
/**\r
*/\r
public abstract class CollectionSpaceServiceNuxeoImpl {\r
\r
- // replace host if not running on localhost\r
- // static String CS_NUXEO_HOST = "173.45.234.217";\r
- static String CS_NUXEO_HOST = "localhost";\r
- static String CS_NUXEO_URI = "http://" + CS_NUXEO_HOST + ":8080/nuxeo";\r
\r
protected Logger logger = LoggerFactory\r
.getLogger(CollectionSpaceServiceNuxeoImpl.class);\r
\r
- public NuxeoRESTClient getClient() {\r
- NuxeoRESTClient nxClient = new NuxeoRESTClient(CS_NUXEO_URI);\r
-\r
- nxClient.setAuthType(NuxeoRESTClient.AUTH_TYPE_BASIC);\r
- nxClient.setBasicAuthentication("Administrator", "Administrator");\r
-\r
- return nxClient;\r
- }\r
-\r
-// FIXME: Replace this method after integration of the relation code\r
- protected RepositoryInstance getRepositorySession() throws Exception {\r
+// public NuxeoRESTClient getClient() {\r
+// NuxeoRESTClient nxClient = new NuxeoRESTClient(CS_NUXEO_URI);\r
+//\r
+// nxClient.setAuthType(NuxeoRESTClient.AUTH_TYPE_BASIC);\r
+// nxClient.setBasicAuthentication("Administrator", "Administrator");\r
+//\r
+// return nxClient;\r
+// }\r
+\r
+ \r
+ protected RepositoryInstance getRepositorySession() throws Exception {\r
// FIXME: is it possible to reuse repository session?\r
// Authentication failures happen while trying to reuse the session\r
- NuxeoConnector nuxeoConnector = NuxeoConnector.getInstance();\r
- return nuxeoConnector.getRepositorySession();\r
- }\r
- \r
- protected Document deleteDocument(RepositoryInstance repoSession, String csid)\r
- throws DocumentException, IOException {\r
- Document result = null;\r
-\r
- try {\r
- repoSession = getRepositorySession();\r
- DocumentRef relDocumentRef = new IdRef(csid);\r
- \r
- try{\r
- repoSession.removeDocument(relDocumentRef);\r
- }catch(ClientException ce){\r
- String msg = "could not find document to delete with id=" + csid;\r
- logger.error(msg, ce);\r
- throw new DocumentNotFoundException(msg, ce);\r
- }\r
- repoSession.save(); \r
- } catch (Exception e) {\r
- e.printStackTrace();\r
+ NuxeoClient client = NuxeoConnector.getInstance().getClient();\r
+ RepositoryInstance repoSession = client.openRepository();\r
+ if (logger.isDebugEnabled()) {\r
+ logger.debug("getRepository() repository root: "\r
+ + repoSession.getRootDocument());\r
}\r
- \r
- return result;\r
+ return repoSession;\r
}\r
- \r
- protected Document listWorkspaceContent(RepositoryInstance repoSession,\r
- String workspaceName) {\r
-\r
- DOMDocumentFactory domfactory = new DOMDocumentFactory();\r
- DOMDocument result = (DOMDocument) domfactory.createDocument();\r
\r
+ protected void releaseRepositorySession(RepositoryInstance repoSession) {\r
try {\r
- repoSession = getRepositorySession();\r
- DocumentModel workspaceModel = NuxeoUtils.getWorkspaceModel(repoSession,\r
- workspaceName);\r
-\r
- Element current = result.createElement("document");\r
- try {\r
- current.setAttribute("title", workspaceModel.getTitle());\r
- } catch (Exception e) {\r
- e.printStackTrace();\r
- }\r
- current.setAttribute("type", workspaceModel.getType());\r
- current.setAttribute("id", workspaceModel.getId());\r
- current.setAttribute("name", workspaceModel.getName());\r
- current.setAttribute("url", getRelURL(workspaceName, workspaceModel.getRef().toString()));\r
- result.setRootElement((org.dom4j.Element) current);\r
-\r
- if (workspaceModel.isFolder()) {\r
- // Element childrenElem = result.createElement("children");\r
- // root.appendChild(childrenElem);\r
-\r
- DocumentModelList children = null;\r
- try {\r
- children = repoSession.getChildren(workspaceModel.getRef());\r
- } catch (ClientException e) {\r
- e.printStackTrace();\r
- }\r
-\r
- for (DocumentModel child : children) {\r
- Element el = result.createElement("document");\r
- try {\r
- el.setAttribute("title", child.getTitle());\r
- } catch (DOMException e) {\r
- e.printStackTrace();\r
- } catch (ClientException e) {\r
- e.printStackTrace();\r
- }\r
- el.setAttribute("type", child.getType());\r
- el.setAttribute("id", child.getId());\r
- el.setAttribute("name", child.getName());\r
- el.setAttribute("url", getRelURL(workspaceName, child.getRef()\r
- .toString()));\r
- current.appendChild(el);\r
- }\r
- }\r
-\r
- } catch (Exception e) {\r
- e.printStackTrace();\r
- }\r
- \r
- if (logger.isDebugEnabled() == true) {\r
- System.out.println(result.asXML());\r
- }\r
-\r
- return result;\r
- }\r
-\r
- protected void releaseRepositorySession(RepositoryInstance repoSession) {\r
- try {\r
+ NuxeoClient client = NuxeoConnector.getInstance().getClient();\r
// release session\r
- NuxeoConnector nuxeoConnector = NuxeoConnector.getInstance();\r
- nuxeoConnector.releaseRepositorySession(repoSession);\r
+ client.releaseRepository(repoSession);\r
} catch (Exception e) {\r
logger.error("Could not close the repository session", e);\r
// no need to throw this service specific exception\r
}\r
}\r
- \r
- private static String getRelURL(String repo, String uuid) {\r
- return '/' + repo + '/' + uuid;\r
- } \r
+ \r
}\r
public Document deleteIntake(String csid)\r
throws DocumentException, IOException {\r
\r
- NuxeoRESTClient nxClient = getClient();\r
- List<String> pathParams = new ArrayList<String>();\r
- Map<String, String> queryParams = new HashMap<String, String>();\r
-\r
- pathParams.add("default");\r
- pathParams.add(csid);\r
- pathParams.add("deleteDocumentRestlet");\r
- Representation res = nxClient.get(pathParams, queryParams);\r
- SAXReader reader = new SAXReader();\r
- Document document = reader.read(res.getStream());\r
+ Document result = null;\r
+ \r
+// NuxeoRESTClient nxClient = getClient();\r
+// List<String> pathParams = new ArrayList<String>();\r
+// Map<String, String> queryParams = new HashMap<String, String>();\r
+//\r
+// pathParams.add("default");\r
+// pathParams.add(csid);\r
+// pathParams.add("deleteDocumentRestlet");\r
+// Representation res = nxClient.get(pathParams, queryParams);\r
+// SAXReader reader = new SAXReader();\r
+// result = reader.read(res.getStream());\r
\r
- return document;\r
+ return result;\r
}\r
\r
public Document getIntake(String csid) throws DocumentException,\r
IOException {\r
- List<String> pathParams = new ArrayList<String>();\r
- Map<String, String> queryParams = new HashMap<String, String>();\r
-\r
- pathParams.add("default");\r
- pathParams.add(csid);\r
- pathParams.add("export");\r
- queryParams.put("format", "XML");\r
-\r
- NuxeoRESTClient nxClient = getClient();\r
- Representation res = nxClient.get(pathParams, queryParams);\r
-\r
- SAXReader reader = new SAXReader();\r
- Document document = reader.read(res.getStream());\r
+ Document result = null;\r
+ \r
+// List<String> pathParams = new ArrayList<String>();\r
+// Map<String, String> queryParams = new HashMap<String, String>();\r
+//\r
+// pathParams.add("default");\r
+// pathParams.add(csid);\r
+// pathParams.add("export");\r
+// queryParams.put("format", "XML");\r
+//\r
+// NuxeoRESTClient nxClient = getClient();\r
+// Representation res = nxClient.get(pathParams, queryParams);\r
+//\r
+// SAXReader reader = new SAXReader();\r
+// result = reader.read(res.getStream());\r
\r
- return document;\r
+ return result;\r
}\r
\r
public Document getIntakeList() throws DocumentException,\r
IOException {\r
Document result = null;\r
\r
- NuxeoRESTClient nxClient = getClient();\r
- List<String> pathParams = new ArrayList<String>();\r
- Map<String, String> queryParams = new HashMap<String, String>();\r
- pathParams = Arrays.asList("default",\r
- CS_INTAKE_WORKSPACE_UID, "browse");\r
- Representation res = nxClient.get(pathParams, queryParams);\r
- SAXReader reader = new SAXReader();\r
- result = reader.read(res.getStream());\r
+// NuxeoRESTClient nxClient = getClient();\r
+// List<String> pathParams = new ArrayList<String>();\r
+// Map<String, String> queryParams = new HashMap<String, String>();\r
+// pathParams = Arrays.asList("default",\r
+// CS_INTAKE_WORKSPACE_UID, "browse");\r
+// Representation res = nxClient.get(pathParams, queryParams);\r
+// SAXReader reader = new SAXReader();\r
+// result = reader.read(res.getStream());\r
\r
return result;\r
}\r
\r
public Document postIntake(Intake co)\r
throws DocumentException, IOException {\r
- NuxeoRESTClient nxClient = getClient();\r
-\r
- List<String> pathParams = new ArrayList<String>();\r
- Map<String, String> queryParams = new HashMap<String, String>();\r
- pathParams.add("default");\r
- pathParams.add(CS_INTAKE_WORKSPACE_UID);\r
- pathParams.add("createDocument");\r
- queryParams.put("docType", INTAKE_NUXEO_DOCTYPE);\r
-\r
- // a default title for the Dublin Core schema\r
- queryParams.put("dublincore:title", INTAKE_NUXEO_DC_TITLE);\r
-\r
- // Intake core values\r
- queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
- + IntakeJAXBSchema.CURRENT_OWNER, co\r
- .getCurrentOwner());\r
- queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
- + IntakeJAXBSchema.DEPOSITOR, co.getDepositor());\r
- queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
- + IntakeJAXBSchema.DEPOSITORS_REQUIREMENTS, co\r
- .getDepositorsRequirements());\r
- queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
- + IntakeJAXBSchema.ENTRY_DATE, co.getEntryDate());\r
- queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
- + IntakeJAXBSchema.ENTRY_METHOD, co\r
- .getEntryMethod());\r
- queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
- + IntakeJAXBSchema.ENTRY_NOTE, co.getEntryNote());\r
- queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
- + IntakeJAXBSchema.ENTRY_NUMBER, co\r
- .getEntryNumber());\r
- queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
- + IntakeJAXBSchema.ENTRY_REASON, co.getEntryReason());\r
- queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
- + IntakeJAXBSchema.PACKING_NOTE, co.getPackingNote());\r
- queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
- + IntakeJAXBSchema.RETURN_DATE, co.getReturnDate());\r
-\r
- ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]);\r
- Representation res = nxClient.post(pathParams, queryParams, bais);\r
-\r
- SAXReader reader = new SAXReader();\r
- Document document = reader.read(res.getStream());\r
-\r
- return document;\r
+ Document result = null;\r
+ \r
+// NuxeoRESTClient nxClient = getClient();\r
+//\r
+// List<String> pathParams = new ArrayList<String>();\r
+// Map<String, String> queryParams = new HashMap<String, String>();\r
+// pathParams.add("default");\r
+// pathParams.add(CS_INTAKE_WORKSPACE_UID);\r
+// pathParams.add("createDocument");\r
+// queryParams.put("docType", INTAKE_NUXEO_DOCTYPE);\r
+//\r
+// // a default title for the Dublin Core schema\r
+// queryParams.put("dublincore:title", INTAKE_NUXEO_DC_TITLE);\r
+//\r
+// // Intake core values\r
+// queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
+// + IntakeJAXBSchema.CURRENT_OWNER, co\r
+// .getCurrentOwner());\r
+// queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
+// + IntakeJAXBSchema.DEPOSITOR, co.getDepositor());\r
+// queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
+// + IntakeJAXBSchema.DEPOSITORS_REQUIREMENTS, co\r
+// .getDepositorsRequirements());\r
+// queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
+// + IntakeJAXBSchema.ENTRY_DATE, co.getEntryDate());\r
+// queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
+// + IntakeJAXBSchema.ENTRY_METHOD, co\r
+// .getEntryMethod());\r
+// queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
+// + IntakeJAXBSchema.ENTRY_NOTE, co.getEntryNote());\r
+// queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
+// + IntakeJAXBSchema.ENTRY_NUMBER, co\r
+// .getEntryNumber());\r
+// queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
+// + IntakeJAXBSchema.ENTRY_REASON, co.getEntryReason());\r
+// queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
+// + IntakeJAXBSchema.PACKING_NOTE, co.getPackingNote());\r
+// queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
+// + IntakeJAXBSchema.RETURN_DATE, co.getReturnDate());\r
+//\r
+// ByteArrayInputStream bais = new ByteArrayInputStream(new byte[0]);\r
+// Representation res = nxClient.post(pathParams, queryParams, bais);\r
+//\r
+// SAXReader reader = new SAXReader();\r
+// result = reader.read(res.getStream());\r
+\r
+ return result;\r
}\r
\r
public Document putIntake(String csid, Intake theUpdate)\r
throws DocumentException, IOException {\r
- List<String> pathParams = new ArrayList<String>();\r
- Map<String, String> queryParams = new HashMap<String, String>();\r
- pathParams.add("default");\r
- pathParams.add(csid);\r
- pathParams.add("updateDocumentRestlet");\r
-\r
- // todo: intelligent merge needed\r
- if (theUpdate.getCurrentOwner() != null) {\r
- queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
- + IntakeJAXBSchema.CURRENT_OWNER, theUpdate.getCurrentOwner());\r
- }\r
-\r
- if (theUpdate.getDepositor() != null) {\r
- queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
- + IntakeJAXBSchema.DEPOSITOR, theUpdate.getDepositor());\r
- }\r
-\r
- if (theUpdate.getDepositorsRequirements() != null) {\r
- queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
- + IntakeJAXBSchema.DEPOSITORS_REQUIREMENTS, theUpdate.getDepositorsRequirements());\r
- }\r
-\r
- if (theUpdate.getEntryDate() != null) {\r
- queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
- + IntakeJAXBSchema.ENTRY_DATE, theUpdate.getEntryDate());\r
- }\r
-\r
- if (theUpdate.getEntryMethod() != null) {\r
- queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
- + IntakeJAXBSchema.ENTRY_METHOD, theUpdate.getEntryMethod());\r
- }\r
-\r
- if (theUpdate.getEntryNote() != null) {\r
- queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
- + IntakeJAXBSchema.ENTRY_NOTE, theUpdate.getEntryNote());\r
- }\r
-\r
- if (theUpdate.getEntryNumber() != null) {\r
- queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
- + IntakeJAXBSchema.ENTRY_NUMBER, theUpdate.getEntryNumber());\r
- }\r
-\r
- if (theUpdate.getEntryReason() != null) {\r
- queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
- + IntakeJAXBSchema.ENTRY_REASON, theUpdate.getEntryReason());\r
- }\r
-\r
- if (theUpdate.getPackingNote() != null) {\r
- queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
- + IntakeJAXBSchema.PACKING_NOTE, theUpdate.getPackingNote());\r
- }\r
-\r
- if (theUpdate.getReturnDate() != null) {\r
- queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
- + IntakeJAXBSchema.RETURN_DATE, theUpdate.getReturnDate());\r
- }\r
-\r
- NuxeoRESTClient nxClient = getClient();\r
- Representation res = nxClient.get(pathParams, queryParams);\r
- SAXReader reader = new SAXReader();\r
- Document document = reader.read(res.getStream());\r
-\r
- return document;\r
+ Document result = null;\r
+ \r
+// List<String> pathParams = new ArrayList<String>();\r
+// Map<String, String> queryParams = new HashMap<String, String>();\r
+// pathParams.add("default");\r
+// pathParams.add(csid);\r
+// pathParams.add("updateDocumentRestlet");\r
+//\r
+// // todo: intelligent merge needed\r
+// if (theUpdate.getCurrentOwner() != null) {\r
+// queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
+// + IntakeJAXBSchema.CURRENT_OWNER, theUpdate.getCurrentOwner());\r
+// }\r
+//\r
+// if (theUpdate.getDepositor() != null) {\r
+// queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
+// + IntakeJAXBSchema.DEPOSITOR, theUpdate.getDepositor());\r
+// }\r
+//\r
+// if (theUpdate.getDepositorsRequirements() != null) {\r
+// queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
+// + IntakeJAXBSchema.DEPOSITORS_REQUIREMENTS, theUpdate.getDepositorsRequirements());\r
+// }\r
+//\r
+// if (theUpdate.getEntryDate() != null) {\r
+// queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
+// + IntakeJAXBSchema.ENTRY_DATE, theUpdate.getEntryDate());\r
+// }\r
+//\r
+// if (theUpdate.getEntryMethod() != null) {\r
+// queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
+// + IntakeJAXBSchema.ENTRY_METHOD, theUpdate.getEntryMethod());\r
+// }\r
+//\r
+// if (theUpdate.getEntryNote() != null) {\r
+// queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
+// + IntakeJAXBSchema.ENTRY_NOTE, theUpdate.getEntryNote());\r
+// }\r
+//\r
+// if (theUpdate.getEntryNumber() != null) {\r
+// queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
+// + IntakeJAXBSchema.ENTRY_NUMBER, theUpdate.getEntryNumber());\r
+// }\r
+//\r
+// if (theUpdate.getEntryReason() != null) {\r
+// queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
+// + IntakeJAXBSchema.ENTRY_REASON, theUpdate.getEntryReason());\r
+// }\r
+//\r
+// if (theUpdate.getPackingNote() != null) {\r
+// queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
+// + IntakeJAXBSchema.PACKING_NOTE, theUpdate.getPackingNote());\r
+// }\r
+//\r
+// if (theUpdate.getReturnDate() != null) {\r
+// queryParams.put(INTAKE_NUXEO_SCHEMA_NAME + ":"\r
+// + IntakeJAXBSchema.RETURN_DATE, theUpdate.getReturnDate());\r
+// }\r
+//\r
+// NuxeoRESTClient nxClient = getClient();\r
+// Representation res = nxClient.get(pathParams, queryParams);\r
+// SAXReader reader = new SAXReader();\r
+// result = reader.read(res.getStream());\r
+\r
+ return result;\r
}\r
\r
}\r
<module>common</module>\r
<module>authentication</module>\r
<module>relation</module>\r
+ <module>query</module>\r
<module>id</module>\r
<module>collectionobject</module>\r
<module>intake</module>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>\r
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>\r
+ <classpathentry kind="output" path="target/classes"/>\r
+</classpath>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+ <name>org.collectionspace.services.collectionobject</name>\r
+ <comment></comment>\r
+ <projects>\r
+ </projects>\r
+ <buildSpec>\r
+ <buildCommand>\r
+ <name>org.eclipse.jdt.core.javabuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ <buildCommand>\r
+ <name>org.maven.ide.eclipse.maven2Builder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ </buildSpec>\r
+ <natures>\r
+ <nature>org.eclipse.jdt.core.javanature</nature>\r
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>\r
+ </natures>\r
+</projectDescription>\r
--- /dev/null
+#Thu Apr 30 16:21:29 PDT 2009\r
+eclipse.preferences.version=1\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\r
+org.eclipse.jdt.core.compiler.compliance=1.6\r
+org.eclipse.jdt.core.compiler.source=1.6\r
--- /dev/null
+#Thu Jul 16 13:50:16 PDT 2009\r
+activeProfiles=\r
+eclipse.preferences.version=1\r
+fullBuildGoals=process-test-resources\r
+includeModules=false\r
+resolveWorkspaceProjects=true\r
+resourceFilterGoals=process-resources resources\:testResources\r
+version=1\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">\r
+ <parent>\r
+ <artifactId>org.collectionspace.services.main</artifactId>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <version>1.0</version>\r
+ </parent>\r
+ <modelVersion>4.0.0</modelVersion>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <version>1.0</version>\r
+ <artifactId>org.collectionspace.services.query</artifactId>\r
+ <packaging>pom</packaging>\r
+ <name>services.query</name>\r
+\r
+ <modules>\r
+ <module>service</module>\r
+ </modules>\r
+\r
+ <build>\r
+ <pluginManagement>\r
+ <plugins>\r
+ <plugin>\r
+ <groupId>org.apache.maven.plugins</groupId>\r
+ <artifactId>maven-compiler-plugin</artifactId>\r
+ <configuration>\r
+ <source>1.5</source>\r
+ <target>1.5</target>\r
+ </configuration>\r
+ </plugin>\r
+ <plugin>\r
+ <groupId>org.apache.maven.plugins</groupId>\r
+ <artifactId>maven-site-plugin</artifactId>\r
+ <configuration>\r
+ <unzipCommand>/usr/bin/unzip -o > err.txt</unzipCommand>\r
+ </configuration>\r
+ </plugin>\r
+ <plugin>\r
+ <groupId>org.apache.maven.plugins</groupId>\r
+ <artifactId>maven-war-plugin</artifactId>\r
+ <version>2.0.1</version>\r
+ <configuration>\r
+ <warSourceExcludes>WEB-INF/lib/*.jar</warSourceExcludes>\r
+ <archive>\r
+ <manifest>\r
+ <addClasspath>true</addClasspath>\r
+ </manifest>\r
+ </archive>\r
+ </configuration>\r
+ </plugin>\r
+ </plugins>\r
+ </pluginManagement>\r
+ <plugins>\r
+ <plugin>\r
+ <groupId>org.apache.maven.plugins</groupId>\r
+ <artifactId>maven-compiler-plugin</artifactId>\r
+ <version>2.0.2</version>\r
+ <configuration>\r
+ <source>1.6</source>\r
+ <target>1.6</target>\r
+ </configuration>\r
+ </plugin>\r
+ </plugins>\r
+ </build>\r
+</project>\r
+\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<classpath>\r
+ <classpathentry kind="src" output="target/classes" path="src/main/java"/>\r
+ <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>\r
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>\r
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>\r
+ <classpathentry kind="output" path="target/classes"/>\r
+</classpath>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<projectDescription>\r
+ <name>org.collectionspace.services.collectionobject.service</name>\r
+ <comment></comment>\r
+ <projects>\r
+ </projects>\r
+ <buildSpec>\r
+ <buildCommand>\r
+ <name>org.eclipse.jdt.core.javabuilder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ <buildCommand>\r
+ <name>org.maven.ide.eclipse.maven2Builder</name>\r
+ <arguments>\r
+ </arguments>\r
+ </buildCommand>\r
+ </buildSpec>\r
+ <natures>\r
+ <nature>org.eclipse.jdt.core.javanature</nature>\r
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>\r
+ </natures>\r
+</projectDescription>\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">\r
+\r
+ <parent>\r
+ <artifactId>org.collectionspace.services.query</artifactId>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <version>1.0</version>\r
+ </parent>\r
+ \r
+ <modelVersion>4.0.0</modelVersion>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.query.service</artifactId>\r
+ <packaging>jar</packaging>\r
+ <version>1.0</version>\r
+ <name>services.query.service</name>\r
+\r
+ <dependencies>\r
+ <dependency>\r
+ <groupId>org.collectionspace.services</groupId>\r
+ <artifactId>org.collectionspace.services.common</artifactId>\r
+ <version>1.0</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.slf4j</groupId>\r
+ <artifactId>slf4j-api</artifactId>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.slf4j</groupId>\r
+ <artifactId>slf4j-log4j12</artifactId>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>junit</groupId>\r
+ <artifactId>junit</artifactId>\r
+ <version>4.1</version>\r
+ <scope>test</scope>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.testng</groupId>\r
+ <artifactId>testng</artifactId>\r
+ <version>5.6</version>\r
+ </dependency>\r
+ \r
+ <!-- apache -->\r
+ <dependency>\r
+ <groupId>commons-beanutils</groupId>\r
+ <artifactId>commons-beanutils</artifactId>\r
+ <version>1.6.1</version>\r
+ </dependency>\r
+ <!-- use explict 1.1 version to prevent errors coming from Nuxeo client -->\r
+ <dependency>\r
+ <groupId>commons-logging</groupId>\r
+ <artifactId>commons-logging</artifactId>\r
+ <version>1.1</version>\r
+ </dependency>\r
+ <!-- javax -->\r
+\r
+\r
+ <dependency>\r
+ <groupId>javax.security</groupId>\r
+ <artifactId>jaas</artifactId>\r
+ <version>1.0.01</version>\r
+ <scope>provided</scope>\r
+ </dependency>\r
+\r
+ <dependency>\r
+ <groupId>dom4j</groupId>\r
+ <artifactId>dom4j</artifactId>\r
+ <version>1.6.1</version>\r
+ <scope>provided</scope>\r
+ </dependency>\r
+ \r
+ <!-- jboss -->\r
+\r
+ <dependency>\r
+ <groupId>org.jboss.resteasy</groupId>\r
+ <artifactId>resteasy-jaxrs</artifactId>\r
+ <version>1.0.2.GA</version>\r
+ <exclusions>\r
+ <exclusion>\r
+ <groupId>tjws</groupId>\r
+ <artifactId>webserver</artifactId>\r
+ </exclusion>\r
+ </exclusions>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.jboss.resteasy</groupId>\r
+ <artifactId>resteasy-jaxb-provider</artifactId>\r
+ <version>1.0.2.GA</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.jboss.resteasy</groupId>\r
+ <artifactId>resteasy-multipart-provider</artifactId>\r
+ <version>1.0.2.GA</version>\r
+ </dependency>\r
+ \r
+ <!-- nuxeo -->\r
+\r
+ <dependency>\r
+ <groupId>org.nuxeo.ecm.core</groupId>\r
+ <artifactId>nuxeo-core-api</artifactId>\r
+ <version>${nuxeo.version.1.5}</version>\r
+ <exclusions>\r
+ <exclusion>\r
+ <artifactId>jboss-remoting</artifactId>\r
+ <groupId>jboss</groupId>\r
+ </exclusion>\r
+ </exclusions>\r
+ </dependency>\r
+\r
+ <dependency>\r
+ <groupId>org.restlet</groupId>\r
+ <artifactId>org.restlet</artifactId>\r
+ <version>1.0.7</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>com.noelios.restlet</groupId>\r
+ <artifactId>com.noelios.restlet.ext.httpclient</artifactId>\r
+ <version>1.0.7</version>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>com.noelios.restlet</groupId>\r
+ <artifactId>com.noelios.restlet</artifactId>\r
+ <version>1.0.7</version>\r
+ </dependency>\r
+\r
+ </dependencies>\r
+ \r
+ <build>\r
+ <finalName>collectionspace-services-query</finalName>\r
+ <plugins>\r
+ <plugin>\r
+ <groupId>org.codehaus.mojo</groupId>\r
+ <artifactId>jboss-maven-plugin</artifactId>\r
+ <configuration>\r
+ <jbossHome>${jboss.dir}</jbossHome>\r
+ </configuration>\r
+ </plugin>\r
+ <plugin>\r
+ <groupId>org.apache.maven.plugins</groupId>\r
+ <artifactId>maven-compiler-plugin</artifactId>\r
+ <configuration>\r
+ <source>1.6</source>\r
+ <target>1.6</target>\r
+ </configuration>\r
+ </plugin>\r
+ </plugins>\r
+ </build>\r
+</project>\r
+\r
--- /dev/null
+/**\r
+ * This document is a part of the source code and related artifacts\r
+ * for CollectionSpace, an open source collections management system\r
+ * for museums and related institutions:\r
+\r
+ * http://www.collectionspace.org\r
+ * http://wiki.collectionspace.org\r
+\r
+ * Copyright 2009 University of California at Berkeley\r
+\r
+ * Licensed under the Educational Community License (ECL), Version 2.0.\r
+ * You may not use this file except in compliance with this License.\r
+\r
+ * You may obtain a copy of the ECL 2.0 License at\r
+\r
+ * https://source.collectionspace.org/collection-space/LICENSE.txt\r
+\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package org.collectionspace.services.query;\r
+\r
+import javax.ws.rs.Consumes;\r
+import javax.ws.rs.GET;\r
+import javax.ws.rs.Path;\r
+import javax.ws.rs.Produces;\r
+import javax.ws.rs.DELETE;\r
+import javax.ws.rs.POST;\r
+import javax.ws.rs.PUT;\r
+import javax.ws.rs.PathParam;\r
+import javax.ws.rs.WebApplicationException;\r
+import javax.ws.rs.core.Context;\r
+import javax.ws.rs.core.Response;\r
+import javax.ws.rs.core.UriBuilder;\r
+import javax.ws.rs.core.UriInfo;\r
+import javax.xml.bind.JAXBContext;\r
+import javax.xml.bind.Marshaller;\r
+\r
+import org.collectionspace.services.common.query.QueryManager;\r
+import org.collectionspace.services.common.NuxeoClientType;\r
+import org.collectionspace.services.common.ServiceMain;\r
+import org.collectionspace.services.common.repository.DocumentNotFoundException;\r
+import org.collectionspace.services.common.repository.DocumentHandler;\r
+import org.collectionspace.services.common.repository.RepositoryClient;\r
+import org.collectionspace.services.common.repository.RepositoryClientFactory;\r
+import org.jboss.resteasy.util.HttpResponseCodes;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
+@Path("/query")\r
+@Consumes("application/xml")\r
+@Produces("application/xml")\r
+public class QueryResource {\r
+\r
+ public final static String SERVICE_NAME = "query";\r
+ final Logger logger = LoggerFactory.getLogger(QueryResource.class);\r
+ //FIXME retrieve client type from configuration\r
+ final static NuxeoClientType CLIENT_TYPE = ServiceMain.getInstance().getNuxeoClientType();\r
+\r
+ public QueryResource() {\r
+ // do nothing\r
+ }\r
+\r
+ @GET\r
+ @Path("{csid}")\r
+ public void getQuery(\r
+ @PathParam("csid") String csid) {\r
+ if(logger.isDebugEnabled()){\r
+ verbose("getQuery with csid=" + csid);\r
+ }\r
+ if(csid == null || "".equals(csid)){\r
+ logger.error("getQuery: missing csid!");\r
+ Response response = Response.status(Response.Status.BAD_REQUEST).entity(\r
+ "get failed on getQuery csid=" + csid).type(\r
+ "text/plain").build();\r
+ throw new WebApplicationException(response);\r
+ }\r
+\r
+ try {\r
+ QueryManager.execQuery(csid);\r
+ } catch(Exception e){\r
+ if(logger.isDebugEnabled()){\r
+ logger.debug("getQuery", e);\r
+ }\r
+ Response response = Response.status(Response.Status.NOT_FOUND).entity(\r
+ "Get failed on query csid=" + csid).type(\r
+ "text/plain").build();\r
+ throw new WebApplicationException(response);\r
+ }\r
+\r
+ if(false){\r
+ Response response = Response.status(Response.Status.NOT_FOUND).entity(\r
+ "Get failed, the requested CSID:" + csid + ": was not found.").type(\r
+ "text/plain").build();\r
+ throw new WebApplicationException(response);\r
+ }\r
+\r
+// return intakeObject;\r
+ }\r
+\r
+// private void verbose(String msg, Intake intakeObject) {\r
+// try{\r
+// verbose(msg);\r
+// JAXBContext jc = JAXBContext.newInstance(\r
+// Intake.class);\r
+//\r
+// Marshaller m = jc.createMarshaller();\r
+// m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);\r
+// m.marshal(intakeObject, System.out);\r
+// }catch(Exception e){\r
+// e.printStackTrace();\r
+// }\r
+//\r
+// }\r
+\r
+ private void verbose(String msg) {\r
+ System.out.println("QueryResource. " + msg);\r
+ }\r
+}\r
}
}
+ /*
+ * Prototype for using NXQL -will move away from here once protyping is finished.
+ */
@GET
@Path("query/{queryValue}")
public Response getQuery(@PathParam("queryValue") String queryString) {
if (logger.isDebugEnabled() == true) {
logger.debug("Query string is: " + queryString);
}
+
+ //getDefaultClient().
result = Response.status(Response.Status.ACCEPTED).entity(
"Query performed. Look in $JBOSS_HOME/server/cspace/log/" +
import java.util.Map;
import org.collectionspace.services.common.relation.RelationJAXBSchema;
-import org.collectionspace.services.common.relation.nuxeo.RelationUtilsNuxeoImpl;
+import org.collectionspace.services.common.relation.nuxeo.RelationsManagerNuxeoImpl;
import org.collectionspace.services.common.relation.RelationsManager;
import org.collectionspace.services.relation.Relation;
DocumentModel docModel = (DocumentModel) wrapDoc.getWrappedObject();
Relation theRelation = new Relation();
- RelationUtilsNuxeoImpl.fillRelationFromDocModel(theRelation, docModel);
+ RelationsManagerNuxeoImpl.fillRelationFromDocModel(theRelation, docModel);
return theRelation;
}
public void fillCommonObject(Relation relation, DocumentWrapper wrapDoc) throws Exception {
DocumentModel docModel = (DocumentModel) wrapDoc.getWrappedObject();
- RelationUtilsNuxeoImpl.fillDocModelFromRelation(relation, docModel);
+ RelationsManagerNuxeoImpl.fillDocModelFromRelation(relation, docModel);
}
@Override
if (RelationsManager.isQueryMatch(docModel, subjectCsid,
predicate, objectCsid) == true) {
RelationListItem coListItem = new RelationListItem();
- RelationUtilsNuxeoImpl.fillRelationListItemFromDocModel(
+ RelationsManagerNuxeoImpl.fillRelationListItemFromDocModel(
coListItem, docModel);
list.add(coListItem);
}
package org.collectionspace.services.relation.nuxeo;\r
\r
-import org.collectionspace.services.common.relation.nuxeo.RelationUtilsNuxeoImpl;\r
+import org.collectionspace.services.common.relation.nuxeo.RelationsManagerNuxeoImpl;\r
\r
public class RelationNuxeoConstants {\r
- static String NUXEO_DOCTYPE = RelationUtilsNuxeoImpl.REL_NUXEO_DOCTYPE;\r
+ static String NUXEO_DOCTYPE = RelationsManagerNuxeoImpl.REL_NUXEO_DOCTYPE;\r
}
\ No newline at end of file
import org.collectionspace.services.common.repository.DocumentException;\r
//import org.collectionspace.services.nuxeo.NuxeoRESTClient;\r
import org.collectionspace.services.nuxeo.CollectionSpaceServiceNuxeoImpl;\r
-import org.collectionspace.services.common.relation.nuxeo.RelationUtilsNuxeoImpl;\r
+import org.collectionspace.services.common.relation.nuxeo.RelationsManagerNuxeoImpl;\r
import org.collectionspace.services.relation.Relation;\r
import org.collectionspace.services.relation.RelationService;\r
//import org.collectionspace.services.relation.RelationList;\r
public Document deleteRelation(String csid) throws DocumentException {\r
Document result = null;\r
\r
- RepositoryInstance repoSession = null;\r
- try {\r
- repoSession = getRepositorySession();\r
- result = deleteDocument(repoSession, csid);\r
- } catch (Exception e) {\r
- if (logger.isDebugEnabled()) {\r
- logger.debug("Caught exception ", e);\r
- }\r
- throw new DocumentException(e);\r
- } finally {\r
- if (repoSession != null) {\r
- releaseRepositorySession(repoSession);\r
- }\r
- }\r
+// RepositoryInstance repoSession = null;\r
+// try {\r
+// repoSession = getRepositorySession();\r
+// result = deleteDocument(repoSession, csid);\r
+// } catch (Exception e) {\r
+// if (logger.isDebugEnabled()) {\r
+// logger.debug("Caught exception ", e);\r
+// }\r
+// throw new DocumentException(e);\r
+// } finally {\r
+// if (repoSession != null) {\r
+// releaseRepositorySession(repoSession);\r
+// }\r
+// }\r
\r
return result;\r
}\r
repoSession = getRepositorySession();\r
List<Relation> relationList = RelationsManager.getRelationships(repoSession);\r
\r
- result = RelationUtilsNuxeoImpl.getDocument(relationList);\r
+ result = RelationsManagerNuxeoImpl.getDocument(relationList);\r
} catch (Exception e) {\r
if (logger.isDebugEnabled()) {\r
logger.debug("Caught exception ", e);\r
List<Relation> relationList = RelationsManager.getRelationships(repoSession,\r
subjectCsid, predicate, objectCsid);\r
\r
- result = RelationUtilsNuxeoImpl.getDocument(relationList);\r
+ result = RelationsManagerNuxeoImpl.getDocument(relationList);\r
} catch (Exception e) {\r
if (logger.isDebugEnabled()) {\r
logger.debug("Caught exception ", e);\r
\r
try {\r
repoSession = getRepositorySession();\r
- DocumentModel resultDocModel = RelationUtilsNuxeoImpl.createRelationship(repoSession, co);\r
+ DocumentModel resultDocModel = RelationsManagerNuxeoImpl.createRelationship(repoSession, co);\r
repoSession.save();\r
result = NuxeoUtils.getDocument(repoSession, resultDocModel);\r
} catch (Exception e) {\r
repoSession = getRepositorySession();\r
DocumentRef documentRef = new IdRef(csid);\r
DocumentModel documentModel = repoSession.getDocument(documentRef);\r
- RelationUtilsNuxeoImpl.fillDocModelFromRelation(theUpdate, documentModel);\r
+ RelationsManagerNuxeoImpl.fillDocModelFromRelation(theUpdate, documentModel);\r
repoSession.saveDocument(documentModel);\r
repoSession.save();\r
result = NuxeoUtils.getDocument(repoSession, documentModel);\r