From: Aron Roberts Date: Tue, 11 Sep 2012 18:36:27 +0000 (-0700) Subject: Merge remote-tracking branch 'upstream/master' into CSPACE-5271 X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=b6f493aa0e10ccd44aa76bd5a2c73f2ed3a8faa2;p=tmp%2Fjakarta-migration.git Merge remote-tracking branch 'upstream/master' into CSPACE-5271 Conflicts: services/JaxRsServiceProvider/src/main/java/org/collectionspace/services/jaxrs/CollectionSpaceJaxRsApplication.java services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java services/common/src/main/java/org/collectionspace/services/common/ResourceBase.java services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java services/imports/service/src/main/java/org/collectionspace/services/imports/TemplateExpander.java --- b6f493aa0e10ccd44aa76bd5a2c73f2ed3a8faa2 diff --cc services/JaxRsServiceProvider/src/main/java/org/collectionspace/services/jaxrs/CollectionSpaceJaxRsApplication.java index 72a7ac736,7276c2d3c..4279f1a22 --- a/services/JaxRsServiceProvider/src/main/java/org/collectionspace/services/jaxrs/CollectionSpaceJaxRsApplication.java +++ b/services/JaxRsServiceProvider/src/main/java/org/collectionspace/services/jaxrs/CollectionSpaceJaxRsApplication.java @@@ -65,7 -63,11 +64,8 @@@ import java.util.Set //import org.collectionspace.services.common.FileUtils; import org.collectionspace.services.authorization.PermissionResource; import org.collectionspace.services.authorization.RoleResource; -import org.collectionspace.services.common.ResourceBase; -import org.collectionspace.services.common.ResourceMap; -import org.collectionspace.services.common.ResourceMapHolder; -import org.collectionspace.services.common.ResourceMapImpl; +import org.collectionspace.services.common.*; + import org.collectionspace.services.common.relation.RelationResource; import org.collectionspace.services.common.security.SecurityInterceptor; import org.jboss.resteasy.core.Dispatcher; import org.jboss.resteasy.spi.ResteasyProviderFactory; diff --cc services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java index cd6c6caf1,e7a862fd6..d4681fcc0 --- a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java +++ b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java @@@ -791,15 -774,13 +781,14 @@@ public abstract class AuthorityResource public AuthorityRefDocList getReferencingObjects( @PathParam("csid") String parentspecifier, @PathParam("itemcsid") String itemspecifier, + @Context UriTemplateRegistry uriTemplateRegistry, - @Context UriInfo ui) { + @Context UriInfo uriInfo) { AuthorityRefDocList authRefDocList = null; try { - MultivaluedMap queryParams = ui.getQueryParameters(); - - String parentcsid = lookupParentCSID(parentspecifier, "getReferencingObjects(parent)", "GET_ITEM_REF_OBJS", queryParams); + ServiceContext ctx = createServiceContext(getItemServiceName(), uriInfo); + MultivaluedMap queryParams = ctx.getQueryParams(); - ServiceContext 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 serviceTypes = queryParams.remove(ServiceBindingUtils.SERVICE_TYPE_PROP); diff --cc services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java index a00b74f92,788e91b7a..2d1dee0c8 --- a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java +++ b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java @@@ -24,15 -24,11 +24,12 @@@ 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; @@@ -452,10 -436,8 +437,9 @@@ public abstract class AuthorityItemDocu AuthorityItemJAXBSchema.IN_AUTHORITY, inAuthority); } - public AuthorityRefDocList getReferencingObjects( ServiceContext ctx, + UriTemplateRegistry uriTemplateRegistry, List serviceTypes, String propertyName, String itemcsid) throws Exception { diff --cc services/common/src/main/java/org/collectionspace/services/common/ResourceBase.java index ef31879bb,e0855324c..6909eea35 --- a/services/common/src/main/java/org/collectionspace/services/common/ResourceBase.java +++ b/services/common/src/main/java/org/collectionspace/services/common/ResourceBase.java @@@ -23,7 -23,7 +23,8 @@@ */ package org.collectionspace.services.common; +import java.util.*; + import org.collectionspace.services.client.IClientQueryParams; import org.collectionspace.services.client.IQueryManager; import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; @@@ -414,94 -509,6 +516,95 @@@ public abstract class ResourceBas throws Exception, DocumentNotFoundException { return getDocModelForAuthorityItem(repoSession, RefName.AuthorityItem.parse(refName)); } + + protected String getDocType(String tenantId) { + return getDocType(tenantId, getServiceName()); + } + + /** + * Returns the Nuxeo document type associated with a specified service, within a specified tenant. + * + * @param tenantId a tenant ID + * @param serviceName a service name + * @return the Nuxeo document type associated with that service and tenant. + */ + // FIXME: This method may properly belong in a different services package or class. + // Also, we need to check for any existing methods that may duplicate this one. + protected String getDocType(String tenantId, String serviceName) { + String docType = ""; + if (Tools.isBlank(tenantId)) { + return docType; + } + ServiceBindingType sb = getTenantBindingsReader().getServiceBinding(tenantId, serviceName); + if (sb == null) { + return docType; + } + docType = sb.getObject().getName(); // Reads the Nuxeo Document Type from tenant bindings configuration + System.out.println(tenantId + " : " + serviceName + " : " + docType); // FIXME: for debugging + return docType; + } + + /** + * Returns a UriRegistry entry: a map of tenant-qualified URI templates + * for the current resource, for all tenants + * + * @return a map of URI templates for the current resource, for all tenants + */ + public Map getUriRegistryEntries() { + Map uriRegistryEntriesMap = + new HashMap(); + List tenantIds = getTenantBindingsReader().getTenantIds(); + for (String tenantId : tenantIds) { + uriRegistryEntriesMap.putAll(getUriRegistryEntries(tenantId, getDocType(tenantId), UriTemplateFactory.RESOURCE)); + } + return uriRegistryEntriesMap; + } + + /** + * Returns a UriRegistry entry: a map of tenant-qualified URI templates + * for the current resource, for a specified tenants + * + * @return a map of URI templates for the current resource, for a specified tenant + */ + protected Map getUriRegistryEntries(String tenantId, + String docType, UriTemplateFactory.UriTemplateType type) { + Map uriRegistryEntriesMap = + new HashMap(); + UriTemplateRegistryKey key; + if (Tools.isBlank(tenantId) || Tools.isBlank(docType)) { + return uriRegistryEntriesMap; + } + key = new UriTemplateRegistryKey(); + key.setTenantId(tenantId); + key.setDocType(docType); + uriRegistryEntriesMap.put(key, getUriTemplate(type)); + return uriRegistryEntriesMap; + } + + /** + * Returns a URI template of the appropriate type, populated with the + * current service name as one of its stored values. + * * + * @param type a URI template type + * @return a URI template of the appropriate type. + */ + protected StoredValuesUriTemplate getUriTemplate(UriTemplateFactory.UriTemplateType type) { + Map storedValuesMap = new HashMap(); + storedValuesMap.put(UriTemplateFactory.SERVICENAME_VAR, getServiceName()); + StoredValuesUriTemplate template = + UriTemplateFactory.getURITemplate(type, storedValuesMap); + return template; + } + + /** + * Returns a reader for reading values from tenant bindings configuration + * + * @return a tenant bindings configuration reader + */ + protected TenantBindingConfigReaderImpl getTenantBindingsReader() { + return ServiceMain.getInstance().getTenantBindingConfigReader(); + } + + } diff --cc services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java index e6691991a,9583ec9dc..fc962d795 --- a/services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java +++ b/services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java @@@ -67,9 -65,7 +67,8 @@@ import org.collectionspace.services.com import org.collectionspace.services.config.service.ServiceBindingType; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.nuxeo.util.NuxeoUtils; +import org.jboss.resteasy.spi.ResteasyProviderFactory; - /** * RefNameServiceUtils is a collection of services utilities related to refName * usage. diff --cc services/imports/service/src/main/java/org/collectionspace/services/imports/TemplateExpander.java index d4e446c43,ff40a3c48..1c8738892 --- a/services/imports/service/src/main/java/org/collectionspace/services/imports/TemplateExpander.java +++ b/services/imports/service/src/main/java/org/collectionspace/services/imports/TemplateExpander.java @@@ -41,8 -37,12 +41,8 @@@ import org.collectionspace.services.com import org.collectionspace.services.common.XmlSaxFragmenter; import org.collectionspace.services.common.XmlTools; import org.collectionspace.services.common.api.FileTools; + import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils; import org.collectionspace.services.common.api.Tools; - import org.collectionspace.services.common.datetime.GregorianCalendarDateTimeUtils; -import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl; -import org.collectionspace.services.common.config.URIUtils; -import org.collectionspace.services.common.context.ServiceBindingUtils; -import org.collectionspace.services.config.service.ServiceBindingType; import org.collectionspace.services.nuxeo.util.NuxeoUtils; import org.dom4j.Attribute; import org.dom4j.Document;