]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
6e4d794e1e13eb7b99e9d35cf14d0a5f91b3793a
[tmp/jakarta-migration.git] /
1 /**     \r
2  * RelationUtilsNuxeoImpl.java\r
3  *\r
4  * {Purpose of This Class}\r
5  *\r
6  * {Other Notes Relating to This Class (Optional)}\r
7  *\r
8  * $LastChangedBy: $\r
9  * $LastChangedRevision: $\r
10  * $LastChangedDate: $\r
11  *\r
12  * This document is a part of the source code and related artifacts\r
13  * for CollectionSpace, an open source collections management system\r
14  * for museums and related institutions:\r
15  *\r
16  * http://www.collectionspace.org\r
17  * http://wiki.collectionspace.org\r
18  *\r
19  * Copyright © 2009 {Contributing Institution}\r
20  *\r
21  * Licensed under the Educational Community License (ECL), Version 2.0.\r
22  * You may not use this file except in compliance with this License.\r
23  *\r
24  * You may obtain a copy of the ECL 2.0 License at\r
25  * https://source.collectionspace.org/collection-space/LICENSE.txt\r
26  */\r
27 package org.collectionspace.services.common.relation.nuxeo;\r
28 \r
29 import java.io.IOException;\r
30 import java.io.Serializable;\r
31 import java.util.ArrayList;\r
32 import java.util.Iterator;\r
33 import java.util.List;\r
34 import java.util.Map;\r
35 \r
36 import org.collectionspace.services.common.relation.RelationJAXBSchema;\r
37 import org.collectionspace.services.common.relation.RelationListItemJAXBSchema;\r
38 import org.collectionspace.services.common.relation.RelationUtils;\r
39 \r
40 import org.collectionspace.services.relation.Relation;\r
41 import org.collectionspace.services.relation.RelationList;\r
42 import org.collectionspace.services.relation.RelationshipType;\r
43 import org.collectionspace.services.relation.RelationList.RelationListItem;\r
44 import org.collectionspace.services.nuxeo.util.NuxeoUtils;\r
45 import org.collectionspace.services.common.repository.DocumentException;\r
46 \r
47 import org.dom4j.Document;\r
48 import org.dom4j.Element;\r
49 import org.dom4j.dom.DOMElement;\r
50 import org.dom4j.dom.DOMDocument;\r
51 import org.dom4j.dom.DOMDocumentFactory;\r
52 //import org.dom4j.DocumentException;\r
53 \r
54 import org.nuxeo.common.utils.IdUtils;\r
55 import org.nuxeo.ecm.core.api.ClientException;\r
56 import org.nuxeo.ecm.core.api.DocumentModel;\r
57 import org.nuxeo.ecm.core.api.DocumentModelList;\r
58 import org.nuxeo.ecm.core.api.model.DocumentPart;\r
59 import org.nuxeo.ecm.core.api.repository.RepositoryInstance;\r
60 import org.slf4j.Logger;\r
61 import org.slf4j.LoggerFactory;\r
62 //import org.w3c.dom.DOMException;\r
63 //import org.w3c.dom.Element;\r
64 \r
65 /**\r
66  * The Class RelationUtilsNuxeoImpl.\r
67  */\r
68 public class RelationUtilsNuxeoImpl implements RelationUtils {\r
69         \r
70         /** The C s_ relatio n_ servic e_ name. */\r
71         static public String CS_RELATION_SERVICE_NAME = "relations";\r
72         \r
73         /** The C s_ empt y_ string. */\r
74         static public String CS_EMPTY_STRING = "";\r
75         \r
76         /** The Constant REL_NUXEO_DOCTYPE. */\r
77         final public static String REL_NUXEO_DOCTYPE = "Relation";\r
78         \r
79         /** The Constant REL_NUXEO_SCHEMA_NAME. */\r
80         final public static String REL_NUXEO_SCHEMA_NAME = "relation";\r
81         \r
82         /** The Constant REL_NUXEO_SCHEMA_ROOT_ELEMENT. */\r
83         final public static String REL_NUXEO_SCHEMA_ROOT_ELEMENT = "relationtype";\r
84         \r
85         /** The Constant REL_NUXEO_DC_TITLE. */\r
86         final public static String REL_NUXEO_DC_TITLE = "CollectionSpace-Relation";\r
87         \r
88         /** The logger. */\r
89         private static Logger logger = LoggerFactory\r
90         .getLogger(RelationUtilsNuxeoImpl.class);       \r
91 \r
92 \r
93         /**\r
94          * Fill relation from doc model.\r
95          * \r
96          * @param relation the relation\r
97          * @param relDocModel the rel doc model\r
98          * \r
99          * @throws ClientException the client exception\r
100          */\r
101         static public void fillRelationFromDocModel(Relation relation, DocumentModel relDocModel)\r
102                         throws ClientException {\r
103                 String xpathRoot = "/" + REL_NUXEO_SCHEMA_ROOT_ELEMENT + "/";\r
104                 Object valueObject = null;\r
105 \r
106                 relation.setCsid(relDocModel.getId());\r
107 \r
108                 valueObject = relDocModel.getProperty(REL_NUXEO_SCHEMA_NAME, xpathRoot\r
109                                 + RelationJAXBSchema.DOCUMENT_ID_1);\r
110                 relation.setDocumentId1((String) valueObject);\r
111 \r
112                 valueObject = relDocModel.getProperty(REL_NUXEO_SCHEMA_NAME, xpathRoot\r
113                                 + RelationJAXBSchema.DOCUMENT_TYPE_1);\r
114                 relation.setDocumentType1((String) valueObject);\r
115 \r
116                 valueObject = relDocModel.getProperty(REL_NUXEO_SCHEMA_NAME, xpathRoot\r
117                                 + RelationJAXBSchema.DOCUMENT_ID_2);\r
118                 relation.setDocumentId2((String) valueObject);\r
119 \r
120                 valueObject = relDocModel.getProperty(REL_NUXEO_SCHEMA_NAME, xpathRoot\r
121                                 + RelationJAXBSchema.DOCUMENT_TYPE_2);\r
122                 relation.setDocumentType2((String) valueObject);\r
123 \r
124                 valueObject = relDocModel.getProperty(REL_NUXEO_SCHEMA_NAME, xpathRoot\r
125                                 + RelationJAXBSchema.RELATIONSHIP_TYPE);\r
126                 relation.setRelationshipType(RelationshipType\r
127                                 .fromValue((String) valueObject));\r
128 \r
129                 if (logger.isDebugEnabled() == true) {\r
130                         System.out.println("vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv");\r
131                         System.out.println(relation.toString());\r
132                         System.out.println("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");\r
133                 }\r
134         }\r
135 \r
136         /**\r
137          * Fill relation list item from doc model.\r
138          * \r
139          * @param relationListItem the relation list item\r
140          * @param relDocModel the rel doc model\r
141          * \r
142          * @throws DocumentException the document exception\r
143          */\r
144         static public void fillRelationListItemFromDocModel(RelationListItem relationListItem,\r
145                         DocumentModel relDocModel)\r
146                 throws DocumentException {\r
147 \r
148                 try {\r
149                         relationListItem.setCsid(\r
150                                         relDocModel.getId());\r
151                         relationListItem.setUri(\r
152                                         getRelURL(CS_RELATION_SERVICE_NAME, relDocModel.getId()));\r
153                 } catch (Exception e) {\r
154                         if (logger.isDebugEnabled()) {\r
155                                 logger.debug("Caught exception in fillRelationListItemFromDocModel", e);\r
156                         }\r
157                         throw new DocumentException(e);\r
158                 }\r
159         }\r
160         \r
161         /**\r
162          * Fill doc model list from relation list.\r
163          * \r
164          * @param relationList the relation list\r
165          * @param relDocModelList the rel doc model list\r
166          * \r
167          * @throws Exception the exception\r
168          */\r
169         static public void fillDocModelListFromRelationList(RelationList relationList,\r
170                         DocumentModelList relDocModelList)\r
171                 throws Exception {\r
172         }       \r
173         \r
174         /**\r
175          * Fill doc model from relation.\r
176          * \r
177          * @param p the p\r
178          * @param relDocModel the rel doc model\r
179          * \r
180          * @throws Exception the exception\r
181          */\r
182         static public void fillDocModelFromRelation(Relation p, DocumentModel relDocModel)\r
183                         throws Exception {\r
184 \r
185                 // set the DublinCore title (this works)\r
186                 relDocModel.setPropertyValue("dublincore:title", "default title");\r
187 \r
188                 // // set value for <documentType1> element\r
189                 // try {\r
190                 // relDocModel.setProperty("relation", "/relationtype/documentId1",\r
191                 // "docId1");\r
192                 // } catch (Exception x) {\r
193                 // x.printStackTrace();\r
194                 // }\r
195 \r
196                 String xpathRoot = "/" + REL_NUXEO_SCHEMA_ROOT_ELEMENT + "/";\r
197                 if (p.getDocumentId1() != null) {\r
198                         String property = xpathRoot + RelationJAXBSchema.DOCUMENT_ID_1;\r
199                         relDocModel.setProperty(REL_NUXEO_SCHEMA_NAME, property, p\r
200                                         .getDocumentId1());\r
201                 }\r
202                 if (p.getDocumentType1() != null) {\r
203                         String property = xpathRoot + RelationJAXBSchema.DOCUMENT_TYPE_1;\r
204                         relDocModel.setProperty(REL_NUXEO_SCHEMA_NAME, property, p\r
205                                         .getDocumentType1());\r
206                 }\r
207                 if (p.getDocumentId2() != null) {\r
208                         String property = xpathRoot + RelationJAXBSchema.DOCUMENT_ID_2;\r
209                         relDocModel.setProperty(REL_NUXEO_SCHEMA_NAME, property, p\r
210                                         .getDocumentId2());\r
211                 }\r
212                 if (p.getDocumentType2() != null) {\r
213                         String property = xpathRoot + "/"\r
214                                         + RelationJAXBSchema.DOCUMENT_TYPE_2;\r
215                         relDocModel.setProperty(REL_NUXEO_SCHEMA_NAME, property, p\r
216                                         .getDocumentType2());\r
217                 }\r
218 \r
219                 if (p.getRelationshipType() != null) {\r
220                         String property = xpathRoot + RelationJAXBSchema.RELATIONSHIP_TYPE;\r
221                         relDocModel.setProperty(REL_NUXEO_SCHEMA_NAME, property, p\r
222                                         .getRelationshipType().value());\r
223                 }\r
224         }\r
225         \r
226         /**\r
227          * Prints the document model.\r
228          * \r
229          * @param documentModel the document model\r
230          */\r
231         static public void printDocumentModel(DocumentModel documentModel) {\r
232                 System.out.println(documentModel);\r
233         }\r
234         \r
235         /**\r
236          * Describe document model.\r
237          * \r
238          * @param docModel the doc model\r
239          * \r
240          * @throws Exception the exception\r
241          */\r
242         static private void describeDocumentModel(DocumentModel docModel) throws Exception {\r
243                 String[] schemas = docModel.getDeclaredSchemas();\r
244                 for (int i = 0; schemas != null && i < schemas.length; i++) {\r
245                         System.out.println("Schema-" + i + "=" + schemas[i]);\r
246                 }\r
247                 \r
248                 DocumentPart[] parts = docModel.getParts();\r
249                 Map<String,Serializable> propertyValues = null;\r
250                 for (int i = 0; parts != null && i < parts.length; i++) {\r
251                         System.out.println("Part-" + i + " name =" + parts[i].getName());\r
252                         System.out.println("Part-" + i + " path =" + parts[i].getPath());\r
253                         System.out.println("Part-" + i + " schema =" + parts[i].getSchema().getName());\r
254                         propertyValues = parts[i].exportValues();\r
255                 }\r
256 \r
257         }\r
258 \r
259         /**\r
260          * Creates the relationship.\r
261          * \r
262          * @param nuxeoRepoSession the nuxeo repo session\r
263          * @param newRelation the new relation\r
264          * \r
265          * @return the document model\r
266          * \r
267          * @throws DocumentException the document exception\r
268          */\r
269         static public DocumentModel createRelationship(Object nuxeoRepoSession, Relation newRelation)\r
270                         throws DocumentException {\r
271                 DocumentModel result = null;\r
272                 RepositoryInstance repoSession = (RepositoryInstance)nuxeoRepoSession;\r
273                 \r
274                 try {\r
275                         // get the Nuxeo 'Relations' workspace\r
276                         DocumentModel workspaceModel = NuxeoUtils.getWorkspaceModel(repoSession,\r
277                                         CS_RELATION_SERVICE_NAME);\r
278                         \r
279                 String docType = REL_NUXEO_DOCTYPE;\r
280                 String id = IdUtils.generateId("New " + docType);\r
281                 \r
282                 //create document model\r
283                 String workspacePath = workspaceModel.getPathAsString();            \r
284                 DocumentModel newRelDocModel = repoSession.createDocumentModel(workspacePath, id, docType);\r
285         \r
286                 newRelation.setCsid(newRelDocModel.getId());\r
287                 fillDocModelFromRelation(newRelation, newRelDocModel);\r
288                 \r
289                 //create document with the new DocumentModel\r
290                 result = repoSession.createDocument(newRelDocModel);\r
291                 repoSession.save();\r
292                 } catch (Exception e) {\r
293                         e.printStackTrace();\r
294                         throw new DocumentException(e);\r
295                 }\r
296                 \r
297                 return result;\r
298         }\r
299         \r
300         /* (non-Javadoc)\r
301          * @see org.collectionspace.services.common.RelationUtils#createRelationship(java.lang.Object, java.lang.String, java.lang.String, java.lang.String)\r
302          */\r
303         public Relation createRelationship(Object nuxeoRepoSession, String subjectCsid, String predicate,\r
304                         String objectCsid) throws DocumentException {\r
305                 Relation result = null;\r
306                 RepositoryInstance repoSession = (RepositoryInstance)nuxeoRepoSession;\r
307                 \r
308         Relation temp = new Relation();\r
309         temp.setDocumentId1(subjectCsid);\r
310         temp.setRelationshipType(null);\r
311         temp.setDocumentId2(objectCsid);\r
312         createRelationship(repoSession, temp);\r
313                 \r
314                 return result;\r
315         }\r
316         \r
317         /* (non-Javadoc)\r
318          * @see org.collectionspace.services.common.RelationUtils#getRelationships(java.lang.Object)\r
319          */\r
320         public List<Relation> getRelationships(Object nuxeoRepoSession)\r
321                         throws DocumentException {\r
322                 List<Relation> result = null;\r
323                 RepositoryInstance repoSession = (RepositoryInstance)nuxeoRepoSession;\r
324 \r
325                 try {\r
326                         DocumentModel relationWorkspace = NuxeoUtils.getWorkspaceModel(\r
327                                         repoSession, CS_RELATION_SERVICE_NAME);\r
328                         DocumentModelList children = repoSession.getChildren(relationWorkspace\r
329                                         .getRef());\r
330                         \r
331                         result = new ArrayList<Relation>();\r
332                         Relation relation = null;\r
333                         for (DocumentModel child : children) {\r
334                                 relation = new Relation();\r
335                                 fillRelationFromDocModel(relation, child);\r
336                                 result.add(relation);\r
337                         }\r
338                 } catch (Exception e) {\r
339                         e.printStackTrace();\r
340                         throw new DocumentException(e);\r
341                 }\r
342 \r
343                 return result;\r
344         }\r
345         \r
346         /* (non-Javadoc)\r
347          * @see org.collectionspace.services.common.RelationUtils#getRelationships(java.lang.Object, java.lang.String)\r
348          */\r
349         public List<Relation> getRelationships(Object nuxeoRepoSession, String csid)\r
350                         throws DocumentException {\r
351                 List<Relation> result = null;\r
352                 RepositoryInstance repoSession = (RepositoryInstance)nuxeoRepoSession;\r
353                                 \r
354                 try {\r
355                         DocumentModel relationWorkspace = NuxeoUtils.getWorkspaceModel(\r
356                                         repoSession, CS_RELATION_SERVICE_NAME);\r
357                         DocumentModelList children = repoSession.getChildren(relationWorkspace\r
358                                         .getRef());\r
359                         \r
360                         result = new ArrayList<Relation>();\r
361                         Relation relation = null;\r
362                         for (DocumentModel child : children) {\r
363                                 if ((isSubjectOfRelation(csid, child) == true) ||\r
364                                                 (isObjectOfRelation(csid, child) == true)) {\r
365                                         relation = new Relation();\r
366                                         fillRelationFromDocModel(relation, child);\r
367                                         result.add(relation);\r
368                                 }\r
369                         }\r
370                 } catch (Exception e) {\r
371                         e.printStackTrace();\r
372                         throw new DocumentException(e);\r
373                 }\r
374                 \r
375                 return result;\r
376         }\r
377         \r
378         \r
379         /* (non-Javadoc)\r
380          * @see org.collectionspace.services.common.RelationUtils#getRelationships(java.lang.Object, java.lang.String, java.lang.String, java.lang.String)\r
381          */\r
382         public List<Relation> getRelationships(Object nuxeoRepoSession,\r
383                         String subjectCsid, \r
384                         String predicate, \r
385                         String objectCsid) throws DocumentException {\r
386                 List<Relation> result = null;\r
387                 RepositoryInstance repoSession = (RepositoryInstance)nuxeoRepoSession;\r
388                 \r
389                 try {\r
390                         DocumentModel relationWorkspace = NuxeoUtils.getWorkspaceModel(\r
391                                         repoSession, CS_RELATION_SERVICE_NAME);\r
392                         DocumentModelList children = repoSession.getChildren(relationWorkspace\r
393                                         .getRef());\r
394                         \r
395                         result = new ArrayList<Relation>();\r
396                         Relation relation = null;\r
397                         for (DocumentModel child : children) {\r
398                                 if (isQueryMatch(child, subjectCsid, predicate, objectCsid) == true) {\r
399                                         relation = new Relation();\r
400                                         fillRelationFromDocModel(relation, child);\r
401                                         result.add(relation);                   }\r
402                         }\r
403                 } catch (Exception e) {\r
404                         e.printStackTrace();\r
405                         throw new DocumentException(e);\r
406                 }\r
407                 \r
408                 return result;\r
409         }\r
410                 \r
411         /* (non-Javadoc)\r
412          * @see org.collectionspace.services.common.relation.RelationUtils#getQPropertyName(java.lang.String)\r
413          */\r
414         public String getQPropertyName(String propertyName) {\r
415                 return "/" + REL_NUXEO_SCHEMA_ROOT_ELEMENT + "/" + propertyName;\r
416         }\r
417                 \r
418         /**\r
419          * Checks if is subject of relation.\r
420          * \r
421          * @param csid the csid\r
422          * @param documentModel the document model\r
423          * \r
424          * @return true, if is subject of relation\r
425          * \r
426          * @throws ClientException the client exception\r
427          */\r
428         private boolean isSubjectOfRelation(String csid, DocumentModel documentModel)\r
429                         throws ClientException {\r
430                 boolean result = false;\r
431                 String xpathRoot = "/" + REL_NUXEO_SCHEMA_ROOT_ELEMENT + "/";\r
432 \r
433                 Object valueObject = documentModel.getProperty(REL_NUXEO_SCHEMA_NAME, xpathRoot\r
434                                 + RelationJAXBSchema.DOCUMENT_ID_1);\r
435                 if (valueObject != null && csid != null) {\r
436                         String subjectID = (String) valueObject;\r
437                         result = subjectID.equals(csid);\r
438                 }\r
439                 \r
440                 return result;\r
441         }\r
442 \r
443         /**\r
444          * Checks if is object of relation.\r
445          * \r
446          * @param csid the csid\r
447          * @param documentModel the document model\r
448          * \r
449          * @return true, if is object of relation\r
450          * \r
451          * @throws ClientException the client exception\r
452          */\r
453         private boolean isObjectOfRelation(String csid, DocumentModel documentModel)\r
454                         throws ClientException {\r
455                 boolean result = false;\r
456                 String xpathRoot = "/" + REL_NUXEO_SCHEMA_ROOT_ELEMENT + "/";\r
457 \r
458                 Object valueObject = documentModel.getProperty(REL_NUXEO_SCHEMA_NAME,\r
459                                 xpathRoot + RelationJAXBSchema.DOCUMENT_ID_2);\r
460                 if (valueObject != null  && csid != null) {\r
461                         String subjectID = (String) valueObject;\r
462                         result = subjectID.equals(csid);\r
463                 }\r
464 \r
465                 return result;\r
466         }\r
467         \r
468         /**\r
469          * Checks if is predicate of relation.\r
470          * \r
471          * @param predicate the predicate\r
472          * @param documentModel the document model\r
473          * \r
474          * @return true, if is predicate of relation\r
475          * \r
476          * @throws ClientException the client exception\r
477          */\r
478         private boolean isPredicateOfRelation(String predicate,\r
479                         DocumentModel documentModel) throws ClientException {\r
480                 boolean result = false;\r
481                 String xpathRoot = "/" + REL_NUXEO_SCHEMA_ROOT_ELEMENT + "/";\r
482 \r
483                 Object valueObject = documentModel.getProperty(REL_NUXEO_SCHEMA_NAME,\r
484                                 xpathRoot + RelationJAXBSchema.RELATIONSHIP_TYPE);\r
485                 if (valueObject != null  && predicate != null) {\r
486                         String relationType = (String) valueObject;\r
487                         result = predicate.equalsIgnoreCase(relationType);\r
488                 }\r
489 \r
490                 return result;\r
491         }\r
492 \r
493         /**\r
494          * Gets the object from subject.\r
495          * \r
496          * @param csid the csid\r
497          * @param documentModel the document model\r
498          * \r
499          * @return the object from subject\r
500          * \r
501          * @throws ClientException the client exception\r
502          */\r
503         private String getObjectFromSubject(String csid, DocumentModel documentModel)\r
504                         throws ClientException {\r
505                 String result = null;\r
506                 String xpathRoot = "/" + REL_NUXEO_SCHEMA_ROOT_ELEMENT + "/";\r
507 \r
508                 Object valueObject = documentModel.getProperty(REL_NUXEO_SCHEMA_NAME,\r
509                                 xpathRoot + RelationJAXBSchema.DOCUMENT_ID_1);\r
510                 if (valueObject != null) {\r
511                         String subjectID = (String) valueObject;\r
512                         if (subjectID.equals(csid) == true) {\r
513                                 valueObject = documentModel.getProperty(REL_NUXEO_SCHEMA_NAME,\r
514                                                 xpathRoot + RelationJAXBSchema.DOCUMENT_ID_2);\r
515                                 if (valueObject != null) {\r
516                                         result = (String) valueObject;\r
517                                 }\r
518                         }\r
519                 }\r
520 \r
521                 return result;\r
522         }\r
523         \r
524         /**\r
525          * Gets the document.\r
526          * \r
527          * @param relationList the relation list\r
528          * \r
529          * @return the document\r
530          * \r
531          * @throws DocumentException the document exception\r
532          */\r
533         static public Document getDocument(List<Relation> relationList)\r
534                         throws DocumentException {\r
535                 DOMDocumentFactory domfactory = new DOMDocumentFactory();\r
536                 DOMDocument result = (DOMDocument) domfactory.createDocument();\r
537 \r
538                 try {\r
539                         // setup the root element\r
540                         DOMElement root = (DOMElement) result\r
541                                         .createElement(RelationListItemJAXBSchema.REL_ROOT_ELEM_NAME);\r
542                         result.setRootElement((org.dom4j.Element) root);\r
543 \r
544                         // populate the document with child elements\r
545                         for (Relation child : relationList) {\r
546                                 DOMElement el = (DOMElement) result.createElement(RelationJAXBSchema.REL_ROOT_ELEM_NAME);\r
547                                 el.setAttribute(RelationListItemJAXBSchema.CSID, child\r
548                                                 .getCsid());\r
549                                 el.setAttribute(RelationListItemJAXBSchema.URI, getRelURL(\r
550                                                 CS_RELATION_SERVICE_NAME, child.getCsid()));\r
551 \r
552                                 if (logger.isDebugEnabled() == true) {\r
553                                         System.out.println(el.asXML());\r
554                                 }\r
555                                 \r
556                                 root.appendChild(el);\r
557                         }\r
558                 } catch (Exception e) {\r
559                         if (logger.isDebugEnabled()) {\r
560                                 logger.debug("Caught exception ", e);\r
561                         }\r
562                         throw new DocumentException(e);\r
563                 }\r
564 \r
565                 if (logger.isDebugEnabled() == true) {\r
566                         System.out.println(result.asXML());\r
567                 }\r
568 \r
569                 return result;\r
570         }\r
571         \r
572         /**\r
573          * Checks if is query match.\r
574          * \r
575          * @param documentModel the document model\r
576          * @param subjectCsid the subject csid\r
577          * @param predicate the predicate\r
578          * @param objectCsid the object csid\r
579          * \r
580          * @return true, if is query match\r
581          * \r
582          * @throws ClientException the client exception\r
583          */\r
584         public boolean isQueryMatch(DocumentModel documentModel,\r
585                         String subjectCsid,\r
586                         String predicate,\r
587                         String objectCsid) throws DocumentException {\r
588                 boolean result = true;\r
589                 \r
590                 try {\r
591                 block: {\r
592                         if (subjectCsid != null) {\r
593                                 if (isSubjectOfRelation(subjectCsid, documentModel) == false) {\r
594                                         result = false;\r
595                                         break block;\r
596                                 }\r
597                         }\r
598                         if (predicate != null) {\r
599                                 if (isPredicateOfRelation(predicate, documentModel) == false) {\r
600                                         result = false;\r
601                                         break block;\r
602                                 }\r
603                         }\r
604                         if (objectCsid != null) {\r
605                                 if (isObjectOfRelation(objectCsid, documentModel) == false) {\r
606                                         result = false;\r
607                                         break block;\r
608                                 }\r
609                         }\r
610                 }\r
611                 } catch (ClientException e) {\r
612                         if (logger.isDebugEnabled() == true) {\r
613                                 e.printStackTrace();\r
614                         }\r
615                         throw new DocumentException(e);\r
616                 }\r
617                 \r
618                 return result;\r
619         }\r
620         \r
621     /**\r
622      * Gets the rel url.\r
623      * \r
624      * @param repo the repo\r
625      * @param uuid the uuid\r
626      * \r
627      * @return the rel url\r
628      */\r
629     private static String getRelURL(String repo, String uuid) {\r
630         return '/' + repo + '/' + uuid;\r
631     }   \r
632         \r
633 }\r