ilistItem = new AuthorityRefDocList.AuthorityRefDocItem();\r
String csid = NuxeoUtils.getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString());\r
ilistItem.setDocId(csid);\r
+ String uri = "";\r
UriTemplateRegistry registry = ServiceMain.getInstance().getUriTemplateRegistry();\r
UriTemplateRegistryKey key = new UriTemplateRegistryKey(tenantId, docType);\r
StoredValuesUriTemplate template = registry.get(key);\r
+ // FIXME: Need to check here for any failure to retrieve a URI Template\r
+ // from the registry, given a tenant ID and docType\r
Map<String, String> additionalValues = new HashMap<String, String>();\r
if (template.getUriTemplateType() == UriTemplateFactory.ITEM) {\r
try {\r
String inAuthorityCsid = (String) docModel.getPropertyValue("inAuthority"); // AuthorityItemJAXBSchema.IN_AUTHORITY\r
additionalValues.put(UriTemplateFactory.IDENTIFIER_VAR, inAuthorityCsid);\r
additionalValues.put(UriTemplateFactory.ITEM_IDENTIFIER_VAR, csid);\r
+ uri = template.buildUri(additionalValues);\r
} catch (Exception e) {\r
logger.warn("Could not extract inAuthority property from authority item record: " + e.getMessage());\r
}\r
+ // FIXME: Generating contact sub-resource URIs requires additional work,\r
+ // beyond CSPACE-5271 - ADR 2012-08-16\r
+ } else if (template.getUriTemplateType() == UriTemplateFactory.CONTACT) {\r
+ // Return the default (empty string) value for URI, for now.\r
} else {\r
additionalValues.put(UriTemplateFactory.IDENTIFIER_VAR, csid);\r
+ uri = template.buildUri(additionalValues);\r
}\r
- String uriStr = template.buildUri(additionalValues);\r
- ilistItem.setUri(uriStr);\r
+ ilistItem.setUri(uri);\r
try {\r
ilistItem.setWorkflowState(docModel.getCurrentLifeCycleState());\r
ilistItem.setUpdatedAt(DocHandlerBase.getUpdatedAtAsString(docModel));\r
import javax.xml.xpath.XPathFactory;
import org.collectionspace.services.common.IFragmentHandler;
import org.collectionspace.services.common.ServiceMain;
+import org.collectionspace.services.common.StoredValuesUriTemplate;
+import org.collectionspace.services.common.UriTemplateFactory;
+import org.collectionspace.services.common.UriTemplateRegistry;
+import org.collectionspace.services.common.UriTemplateRegistryKey;
import org.collectionspace.services.common.XmlSaxFragmenter;
import org.collectionspace.services.common.XmlTools;
import org.collectionspace.services.common.api.FileTools;
// document type name
private static String getDocUri(String tenantId, String docType, String docID,
String partTmpl) throws Exception {
-
-
- TenantBindingConfigReaderImpl tReader = ServiceMain.getInstance().getTenantBindingConfigReader();
- // We may have been supplied with the tenant-qualified name
- // of an extension to a document type, and thus need to
- // get the base document type name.
- docType = ServiceBindingUtils.getUnqualifiedTenantDocType(docType);
- ServiceBindingType sb =
- tReader.getServiceBindingForDocType(tenantId, docType);
-
- String serviceCategory = sb.getType();
String uri = "";
- if (serviceCategory.equalsIgnoreCase(URIUtils.AUTHORITY_SERVICE_CATEGORY)) {
- String authoritySvcName = URIUtils.getAuthoritySvcName(docType);
- if (authoritySvcName == null) {
- return uri;
+ UriTemplateRegistry registry = ServiceMain.getInstance().getUriTemplateRegistry();
+ UriTemplateRegistryKey key = new UriTemplateRegistryKey(tenantId, docType);
+ StoredValuesUriTemplate template = registry.get(key);
+ // FIXME: Need to check here for any failure to retrieve a URI Template
+ // from the registry, given a tenant ID and docType
+ Map<String, String> additionalValues = new HashMap<String, String>();
+ if (template.getUriTemplateType() == UriTemplateFactory.ITEM) {
+ try {
+ String inAuthorityCsid = getInAuthorityValue(partTmpl);
+ additionalValues.put(UriTemplateFactory.IDENTIFIER_VAR, inAuthorityCsid);
+ additionalValues.put(UriTemplateFactory.ITEM_IDENTIFIER_VAR, docID);
+ uri = template.buildUri(additionalValues);
+
+ } catch (Exception e) {
+ logger.warn("Could not extract inAuthority property from authority item record: " + e.getMessage());
}
- String inAuthorityID = getInAuthorityValue(partTmpl);
- uri = URIUtils.getAuthorityItemUri(authoritySvcName, inAuthorityID, docID);
- } else if (serviceCategory.equalsIgnoreCase(URIUtils.OBJECT_SERVICE_CATEGORY) ||
- serviceCategory.equalsIgnoreCase(URIUtils.PROCEDURE_SERVICE_CATEGORY) ) {
- String serviceName = sb.getName();
- uri = URIUtils.getUri(serviceName, docID);
- } else {
- // Currently returns a blank URI for any other cases,
- // including sub-resources like contacts
- }
+ // FIXME: Generating contact sub-resource URIs requires additional work,
+ // beyond CSPACE-5271 - ADR 2012-08-16
+ } else if (template.getUriTemplateType() == UriTemplateFactory.CONTACT) {
+ return uri;
+ } else {
+ additionalValues.put(UriTemplateFactory.IDENTIFIER_VAR, docID);
+ uri = template.buildUri(additionalValues);
+ }
return uri;
}