This project has retired. For details please refer to its
Attic page.
RelationshipService xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.chemistry.opencmis.server.impl.browser;
20
21 import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_ALLOWABLE_ACTIONS;
22 import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_MAX_ITEMS;
23 import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_RELATIONSHIP_DIRECTION;
24 import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_RENDITION_FILTER;
25 import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_SKIP_COUNT;
26 import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_SUB_RELATIONSHIP_TYPES;
27 import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_TYPE_ID;
28 import static org.apache.chemistry.opencmis.server.impl.browser.BrowserBindingUtils.CONTEXT_OBJECT_ID;
29 import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getBigIntegerParameter;
30 import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getBooleanParameter;
31 import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getEnumParameter;
32 import static org.apache.chemistry.opencmis.server.shared.HttpUtils.getStringParameter;
33
34 import java.math.BigInteger;
35
36 import javax.servlet.http.HttpServletRequest;
37 import javax.servlet.http.HttpServletResponse;
38
39 import org.apache.chemistry.opencmis.commons.data.ObjectList;
40 import org.apache.chemistry.opencmis.commons.enums.RelationshipDirection;
41 import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
42 import org.apache.chemistry.opencmis.commons.impl.JSONConverter;
43 import org.apache.chemistry.opencmis.commons.impl.TypeCache;
44 import org.apache.chemistry.opencmis.commons.impl.json.JSONObject;
45 import org.apache.chemistry.opencmis.commons.impl.server.TypeCacheImpl;
46 import org.apache.chemistry.opencmis.commons.server.CallContext;
47 import org.apache.chemistry.opencmis.commons.server.CmisService;
48
49 public class RelationshipService {
50
51
52
53
54 public static void getObjectRelationships(CallContext context, CmisService service, String repositoryId,
55 HttpServletRequest request, HttpServletResponse response) throws Exception {
56
57 String objectId = (String) context.get(CONTEXT_OBJECT_ID);
58 Boolean includeSubRelationshipTypes = getBooleanParameter(request, PARAM_SUB_RELATIONSHIP_TYPES);
59 RelationshipDirection relationshipDirection = getEnumParameter(request, PARAM_RELATIONSHIP_DIRECTION,
60 RelationshipDirection.class);
61 String typeId = getStringParameter(request, PARAM_TYPE_ID);
62 String renditionFilter = getStringParameter(request, PARAM_RENDITION_FILTER);
63 Boolean includeAllowableActions = getBooleanParameter(request, PARAM_ALLOWABLE_ACTIONS);
64 BigInteger maxItems = getBigIntegerParameter(request, PARAM_MAX_ITEMS);
65 BigInteger skipCount = getBigIntegerParameter(request, PARAM_SKIP_COUNT);
66
67
68 ObjectList relationships = service.getObjectRelationships(repositoryId, objectId, includeSubRelationshipTypes,
69 relationshipDirection, typeId, renditionFilter, includeAllowableActions, maxItems, skipCount, null);
70
71 if (relationships == null) {
72 throw new CmisRuntimeException("Relationships are null!");
73 }
74
75 TypeCache typeCache = new TypeCacheImpl(repositoryId, service);
76 JSONObject jsonChildren = JSONConverter.convert(relationships, typeCache, false);
77
78 response.setStatus(HttpServletResponse.SC_OK);
79 BrowserBindingUtils.writeJSON(jsonChildren, request, response);
80 }
81 }