/**
* Build a registry of URI templates by querying each resource
- * for its own entry in the registry.
+ * for its own entries in the registry.
*
- * That entry consists of a tenant-qualified map of URI templates, each
- * associated with a specific document type
+ * These entries consist of one or more URI templates for
+ * building URIs for accessing that resource.
*/
private void buildUriTemplateRegistry() {
ResourceBase resource = null;
* Maps document types to templates for building URIs, per tenant.\r
*/\r
public class UriTemplateRegistry extends HashMap<UriTemplateRegistryKey, Map<UriTemplateType, StoredValuesUriTemplate>> {\r
+ \r
+ /**\r
+ * Get a URI template by tenant, document type, and template type.\r
+ * \r
+ */\r
+ public StoredValuesUriTemplate get(UriTemplateRegistryKey key, UriTemplateType type) {\r
+ if (get(key) != null) {\r
+ return get(key).get(type);\r
+ } else {\r
+ return null;\r
+ }\r
+ }\r
\r
/**\r
* Dump all registry settings, For debugging purposes.\r
--- /dev/null
+package org.collectionspace.services.common;
+
+/**
+ * Defines a compound key consisting of the combination of a tenant ID and a
+ * Nuxeo document type (docType), for accessing entries in the
+ * UriTemplateRegistry.
+ */
+public class UriTemplateRegistryKey {
+
+ private String tenantId;
+ private String docType;
+
+ public void UriTemplateRegistryKey() {
+ }
+
+ public void UriTemplateRegistryKey(String tenantId, String docType) {
+ this.tenantId = tenantId;
+ this.docType = docType;
+ }
+
+ /**
+ * @return the tenantId
+ */
+ public String getTenantId() {
+ return tenantId;
+ }
+
+ /**
+ * @param tenantId the tenantId to set
+ */
+ public void setTenantId(String tenantId) {
+ this.tenantId = tenantId;
+ }
+
+ /**
+ * @return the docType
+ */
+ public String getDocType() {
+ return docType;
+ }
+
+ /**
+ * @param docType the docType to set
+ */
+ public void setDocType(String docType) {
+ this.docType = docType;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+
+ if (o == null) {
+ return false;
+ }
+ if (getClass() != o.getClass()) {
+ return false;
+ }
+
+ if (o == this) {
+ return true;
+ }
+
+ // Cast the compared-to object to an object of this type
+ UriTemplateRegistryKey key = (UriTemplateRegistryKey) o;
+
+ // If either the tenant ID or docType values dont't match, whether
+ // only one is null, or via a failure of an 'equals' test of their
+ // values, return false
+ if (tenantId == null ? key.tenantId != null : !tenantId.equals(key.tenantId)) {
+ return false;
+ }
+ if (docType == null ? key.docType != null : !docType.equals(key.docType)) {
+ return false;
+ }
+
+ return true;
+
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 3;
+ hash = 89 * hash + (this.tenantId != null ? this.tenantId.hashCode() : 0);
+ hash = 89 * hash + (this.docType != null ? this.docType.hashCode() : 0);
+ return hash;
+ }
+}