import java.util.Map;
import org.collectionspace.services.client.*;
import org.collectionspace.services.common.*;
+
+import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl;
+import org.collectionspace.services.config.service.ServiceBindingType;
+
import org.collectionspace.services.nuxeo.util.NuxeoUtils;
/**
public String getItemDocType() {
// FIXME: Proof of concept placeholder
- return "item-" + getServiceName();
+ // return "item-" + getServiceName();
+
+ return super.getDocType(getItemServiceName());
+
+ /*
+ // FIXME: Replace this outrageous hack; a tenant with this ID may not exist
+ String docType = "";
+ final String DEFAULT_TENANT_ID = "1";
+ TenantBindingConfigReaderImpl reader = ServiceMain.getInstance().getTenantBindingConfigReader();
+ ServiceBindingType sb = reader.getServiceBinding(DEFAULT_TENANT_ID, getItemServiceName());
+ docType = sb.getObject().getName();
+ return docType;
+
+ String docType = "";
+ String arbitraryTenantId = "";
+ ServiceBindingType sb;
+ TenantBindingConfigReaderImpl reader = ServiceMain.getInstance().getTenantBindingConfigReader();
+ // FIXME: Makes the outrageous assumption that the list of service names and associated
+ // document types is essentially identical across tenants
+ arbitraryTenantId = getArbitraryTenantId(reader);
+ if (Tools.notBlank(arbitraryTenantId)) {
+ ServiceBindingType sb = reader.getServiceBinding(arbitraryTenantId, getItemServiceName());
+ docType = sb.getObject().getName();
+ }
+ return docType;
+ *
+ */
}
@Override
*/\r
package org.collectionspace.services.common;\r
\r
+import java.util.*;\r
import org.collectionspace.services.client.IQueryManager;\r
import org.collectionspace.services.client.PoxPayloadIn;\r
import org.collectionspace.services.client.PoxPayloadOut;\r
import javax.ws.rs.*;\r
import javax.ws.rs.core.*;\r
\r
-import java.util.HashMap;\r
-import java.util.List;\r
-import java.util.Map;\r
+\r
+import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl;\r
+import org.collectionspace.services.config.service.ServiceBindingType;\r
+import org.collectionspace.services.config.tenant.TenantBindingType;\r
+\r
\r
/**\r
* $LastChangedRevision: $\r
}\r
\r
public String getDocType() {\r
- // FIXME: Proof of concept placeholder\r
- return getServiceName();\r
+ return getDocType(getServiceName());\r
+ }\r
+ \r
+ // FIXME: This may well be a dreadful hack, just to get this initially working.\r
+ //\r
+ // Question:\r
+ // At the point we're seeking to populate docTypes in the uriTemplateRegistry, during system startup,\r
+ // we're not yet logged into any tenant, but instead it appears we are acting as the user SPRING_ADMIN.\r
+ // Could this potentially suggest reasonable method(s), other than those below, by which we can obtain\r
+ // the docType(s) associated with the current resource?\r
+ \r
+ public String getDocType(String serviceName) {\r
+ String docType = "";\r
+ String arbitraryTenantId = "";\r
+ TenantBindingConfigReaderImpl reader = ServiceMain.getInstance().getTenantBindingConfigReader();\r
+ // FIXME: Makes the outrageous assumption that the list of service names and associated\r
+ // document types is essentially identical across tenants\r
+ arbitraryTenantId = getArbitraryTenantId(reader);\r
+ if (Tools.notBlank(arbitraryTenantId)) {\r
+ ServiceBindingType sb = reader.getServiceBinding(arbitraryTenantId, serviceName);\r
+ docType = sb.getObject().getName();\r
+ }\r
+ return docType;\r
}\r
\r
public Map<String,StoredValuesUriTemplate> getUriTemplateMap() {\r
return template;\r
}\r
\r
+ public String getArbitraryTenantId(TenantBindingConfigReaderImpl reader) {\r
+ String arbitraryTenantId = "";\r
+ Hashtable<String, TenantBindingType> tenantBindings = reader.getTenantBindings();\r
+ if (tenantBindings != null && !tenantBindings.isEmpty()) {\r
+ Enumeration keys = tenantBindings.keys();\r
+ while (keys.hasMoreElements()) {\r
+ arbitraryTenantId = (String) keys.nextElement();\r
+ if (Tools.notBlank(arbitraryTenantId)) {\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ return arbitraryTenantId;\r
+ }\r
\r
}\r
import org.collectionspace.services.contact.ContactResource;
import org.collectionspace.services.contact.ContactsCommon;
import org.collectionspace.services.contact.ContactJAXBSchema;
+import org.collectionspace.services.contact.nuxeo.ContactConstants;
import org.collectionspace.services.contact.nuxeo.ContactDocumentModelHandler;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.jboss.resteasy.util.HttpResponseCodes;
}
public String getContactDocType() {
- // FIXME: Proof of concept placeholder
- return "contact-" + getServiceName();
+ return ContactConstants.NUXEO_DOCTYPE;
}
@Override