public AuthorityRefDocList getReferencingObjects(
@PathParam("csid") String parentspecifier,
@PathParam("itemcsid") String itemspecifier,
- @Context UriInfo ui) {
+ @Context UriTemplateRegistry uriTemplateRegistry,
+ @Context UriInfo uriInfo) {
AuthorityRefDocList authRefDocList = null;
try {
- MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
-
- String parentcsid = lookupParentCSID(parentspecifier, "getReferencingObjects(parent)", "GET_ITEM_REF_OBJS", queryParams);
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(getItemServiceName(), uriInfo);
+ MultivaluedMap<String, String> queryParams = ctx.getQueryParams();
- ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(getItemServiceName(), queryParams);
+ String parentcsid = lookupParentCSID(parentspecifier, "getReferencingObjects(parent)", "GET_ITEM_REF_OBJS", uriInfo);
String itemcsid = lookupItemCSID(itemspecifier, parentcsid, "getReferencingObjects(item)", "GET_ITEM_REF_OBJS", ctx);
List<String> serviceTypes = queryParams.remove(ServiceBindingUtils.SERVICE_TYPE_PROP);
package org.collectionspace.services.common.vocabulary.nuxeo;
import org.collectionspace.services.client.AuthorityClient;
+ import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.IQueryManager;
- import org.collectionspace.services.client.PayloadInputPart;
- import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
- import org.collectionspace.services.client.RelationClient;
- import org.collectionspace.services.common.ResourceBase;
+import org.collectionspace.services.common.UriTemplateRegistry;
import org.collectionspace.services.common.api.CommonAPI;
import org.collectionspace.services.common.api.RefName;
import org.collectionspace.services.common.api.Tools;
AuthorityItemJAXBSchema.IN_AUTHORITY, inAuthority);
}
-
public AuthorityRefDocList getReferencingObjects(
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
+ UriTemplateRegistry uriTemplateRegistry,
List<String> serviceTypes,
String propertyName,
String itemcsid) throws Exception {
*/\r
package org.collectionspace.services.common;\r
\r
+import java.util.*;\r
+ import org.collectionspace.services.client.IClientQueryParams;\r
import org.collectionspace.services.client.IQueryManager;\r
import org.collectionspace.services.client.PoxPayloadIn;\r
import org.collectionspace.services.client.PoxPayloadOut;\r
throws Exception, DocumentNotFoundException {\r
return getDocModelForAuthorityItem(repoSession, RefName.AuthorityItem.parse(refName));\r
}\r
+ \r
+ protected String getDocType(String tenantId) {\r
+ return getDocType(tenantId, getServiceName());\r
+ }\r
+\r
+ /**\r
+ * Returns the Nuxeo document type associated with a specified service, within a specified tenant.\r
+ * \r
+ * @param tenantId a tenant ID\r
+ * @param serviceName a service name\r
+ * @return the Nuxeo document type associated with that service and tenant.\r
+ */\r
+ // FIXME: This method may properly belong in a different services package or class.\r
+ // Also, we need to check for any existing methods that may duplicate this one.\r
+ protected String getDocType(String tenantId, String serviceName) {\r
+ String docType = "";\r
+ if (Tools.isBlank(tenantId)) {\r
+ return docType;\r
+ }\r
+ ServiceBindingType sb = getTenantBindingsReader().getServiceBinding(tenantId, serviceName);\r
+ if (sb == null) {\r
+ return docType;\r
+ }\r
+ docType = sb.getObject().getName(); // Reads the Nuxeo Document Type from tenant bindings configuration\r
+ System.out.println(tenantId + " : " + serviceName + " : " + docType); // FIXME: for debugging\r
+ return docType;\r
+ }\r
+ \r
+ /**\r
+ * Returns a UriRegistry entry: a map of tenant-qualified URI templates\r
+ * for the current resource, for all tenants\r
+ * \r
+ * @return a map of URI templates for the current resource, for all tenants\r
+ */\r
+ public Map<UriTemplateRegistryKey,StoredValuesUriTemplate> getUriRegistryEntries() {\r
+ Map<UriTemplateRegistryKey,StoredValuesUriTemplate> uriRegistryEntriesMap =\r
+ new HashMap<UriTemplateRegistryKey,StoredValuesUriTemplate>();\r
+ List<String> tenantIds = getTenantBindingsReader().getTenantIds();\r
+ for (String tenantId : tenantIds) {\r
+ uriRegistryEntriesMap.putAll(getUriRegistryEntries(tenantId, getDocType(tenantId), UriTemplateFactory.RESOURCE));\r
+ }\r
+ return uriRegistryEntriesMap;\r
+ }\r
+ \r
+ /**\r
+ * Returns a UriRegistry entry: a map of tenant-qualified URI templates\r
+ * for the current resource, for a specified tenants\r
+ * \r
+ * @return a map of URI templates for the current resource, for a specified tenant\r
+ */\r
+ protected Map<UriTemplateRegistryKey,StoredValuesUriTemplate> getUriRegistryEntries(String tenantId,\r
+ String docType, UriTemplateFactory.UriTemplateType type) {\r
+ Map<UriTemplateRegistryKey,StoredValuesUriTemplate> uriRegistryEntriesMap =\r
+ new HashMap<UriTemplateRegistryKey,StoredValuesUriTemplate>();\r
+ UriTemplateRegistryKey key;\r
+ if (Tools.isBlank(tenantId) || Tools.isBlank(docType)) {\r
+ return uriRegistryEntriesMap;\r
+ }\r
+ key = new UriTemplateRegistryKey();\r
+ key.setTenantId(tenantId);\r
+ key.setDocType(docType); \r
+ uriRegistryEntriesMap.put(key, getUriTemplate(type));\r
+ return uriRegistryEntriesMap;\r
+ }\r
+ \r
+ /**\r
+ * Returns a URI template of the appropriate type, populated with the\r
+ * current service name as one of its stored values.\r
+ * * \r
+ * @param type a URI template type\r
+ * @return a URI template of the appropriate type.\r
+ */\r
+ protected StoredValuesUriTemplate getUriTemplate(UriTemplateFactory.UriTemplateType type) {\r
+ Map<String,String> storedValuesMap = new HashMap<String,String>();\r
+ storedValuesMap.put(UriTemplateFactory.SERVICENAME_VAR, getServiceName());\r
+ StoredValuesUriTemplate template =\r
+ UriTemplateFactory.getURITemplate(type, storedValuesMap);\r
+ return template;\r
+ }\r
+\r
+ /**\r
+ * Returns a reader for reading values from tenant bindings configuration\r
+ * \r
+ * @return a tenant bindings configuration reader\r
+ */\r
+ protected TenantBindingConfigReaderImpl getTenantBindingsReader() {\r
+ return ServiceMain.getInstance().getTenantBindingConfigReader();\r
+ }\r
+\r
\r
+ \r
}\r