<tenant:TenantBindingConfig xmlns:tenant="http://collectionspace.org/services/common/tenant" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://collectionspace.org/services/common/tenant http://collectionspace.org/services/common/tenant.xsd">
<!-- begin movingimages.us tenant meta-data -->
<tenant:tenantBinding id="1" name="collectionspace.org" displayName="CollectionSpace Demo" version="0.1">
- <tenant:repositoryDomain name="default-domain" repositoryClient="nuxeo-java" />
+ <tenant:repositoryDomain name="default-domain" storageName="default-domain" repositoryClient="nuxeo-java" />
<tenant:properties>
<types:item xmlns:types="http://collectionspace.org/services/common/types">
<types:key>datePattern</types:key>
<tenant:TenantBindingConfig xmlns:tenant="http://collectionspace.org/services/common/tenant" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://collectionspace.org/services/common/tenant http://collectionspace.org/services/common/tenant.xsd">
<!-- begin hearstmuseum.berkeley.edu tenant meta-data -->
<tenant:tenantBinding id="2" name="hearstmuseum.berkeley.edu" displayName="Phoebe A. Hearst Museum of Anthropology" version="0.1">
- <tenant:repositoryDomain name="default-domain" repositoryClient="nuxeo-java" />
+ <tenant:repositoryDomain name="default-domain" storageName="hearst-domain" repositoryClient="nuxeo-java" />
<tenant:properties>
<types:item xmlns:types="http://collectionspace.org/services/common/types">
<types:key>datePattern</types:key>
private void readDomains(TenantBindingType tenantBinding) throws Exception {
for (RepositoryDomainType domain : tenantBinding.getRepositoryDomain()) {
- domains.put(domain.getName(), domain);
+ String key = getTenantQualifiedIdentifier(tenantBinding.getId(),
+ domain.getName());
+ domains.put(key, domain);
}
}
*/
return null;
}
- return domains.get(repoDomain.trim());
+ String key = this.getTenantQualifiedIdentifier(tenantId, repoDomain.trim());
+ return domains.get(key);
}
/**
*/
public static String getTenantQualifiedServiceName(
String tenantId, String serviceName) {
- return tenantId + "." + serviceName.toLowerCase();
+// return tenantId + "." + serviceName.toLowerCase();
+ return getTenantQualifiedIdentifier(tenantId, serviceName.toLowerCase());
}
public static String getTenantQualifiedIdentifier(String tenantId, String identifier) {
return repositoryDomain.getName();
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.context.ServiceContext#getRepositoryDomainName()
+ */
+ @Override
+ public String getRepositoryDomainStorageName() {
+ if (repositoryDomain == null) {
+ return null;
+ }
+ return repositoryDomain.getStorageName();
+ }
+
/* (non-Javadoc)
* @see org.collectionspace.services.common.context.ServiceContext#getRepositoryWorkspaceId()
*/
* @return repository domain for the tenant
*/
public String getRepositoryDomainName();
+
+ /*
+ * Get's the name/label used to create the storage container (folder or directory name)
+ */
+ public String getRepositoryDomainStorageName();
/**
* getRepositoryClientName returns the repository client name as
throw new DocumentNotFoundException(\r
"Unable to find DocumentType for service " + ctx.getServiceName());\r
}\r
- domain = ctx.getRepositoryDomainName();\r
+ domain = ctx.getRepositoryDomainStorageName();\r
tenantId = ctx.getTenantId();\r
if (tenantId == null) {\r
throw new IllegalArgumentException(\r
public String getDomainId(String domainName) throws Exception {
String domainId = null;
RepositoryInstance repoSession = null;
- try {
- repoSession = getRepositorySession();
- DocumentRef docRef = new PathRef(
- "/" + domainName);
- DocumentModel domain = repoSession.getDocument(docRef);
- domainId = domain.getId();
- } catch (Exception e) {
- if (logger.isDebugEnabled()) {
- logger.debug("Caught exception ", e);
- }
- //there is no way to identify if document does not exist due to
- //lack of typed exception for getDocument method
- return null;
- } finally {
- if (repoSession != null) {
- releaseRepositorySession(repoSession);
- }
+
+ if (domainName != null && !domainName.isEmpty()) {
+ try {
+ repoSession = getRepositorySession();
+ DocumentRef docRef = new PathRef(
+ "/" + domainName);
+ DocumentModel domain = repoSession.getDocument(docRef);
+ domainId = domain.getId();
+ } catch (Exception e) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Caught exception ", e);
+ }
+ //there is no way to identify if document does not exist due to
+ //lack of typed exception for getDocument method
+ return null;
+ } finally {
+ if (repoSession != null) {
+ releaseRepositorySession(repoSession);
+ }
+ }
}
+
return domainId;
}
RepositoryDomainType repositoryDomain) throws Exception {
String domainName = repositoryDomain.getName();
RepositoryClient repositoryClient = getRepositoryClient(repositoryDomain);
- String domainId = repositoryClient.getDomainId(domainName);
+ String domainId = repositoryClient.getDomainId(repositoryDomain.getStorageName());
if (domainId == null) {
- domainId = repositoryClient.createDomain(domainName);
+ domainId = repositoryClient.createDomain(repositoryDomain.getStorageName());
if (logger.isDebugEnabled()) {
logger.debug("created repository domain for " + domainName
+ " id=" + domainId);
//retrieve all workspace ids for a domain
//domain specific table of workspace name and id
Hashtable<String, String> workspaceIds =
- repositoryClient.retrieveWorkspaceIds(repositoryDomain.getName());
+ repositoryClient.retrieveWorkspaceIds(repositoryDomain.getStorageName());
//verify if workspace exists for each service from the tenant binding
for (ServiceBindingType serviceBinding : tenantBinding.getServiceBindings()) {
String serviceName = serviceBinding.getName();
+ " in repository. Creating new workspace ...");
}
workspaceId = repositoryClient.createWorkspace(
- repositoryDomain.getName(),
+ repositoryDomain.getStorageName(),
serviceBinding.getName());
if (workspaceId == null) {
if (logger.isWarnEnabled()) {
* @return PathRef
*/
public static DocumentRef createPathRef(ServiceContext ctx, String id) {
- return new PathRef("/" + ctx.getRepositoryDomainName() +
+ return new PathRef("/" + ctx.getRepositoryDomainStorageName() +
"/" + "workspaces" +
"/" + ctx.getRepositoryWorkspaceName() +
"/" + id);
</xs:annotation>
<xs:sequence/>
<xs:attribute name="name" type="xs:string" use="required"/>
+ <xs:attribute name="storageName" type="xs:string" use="required"/>
<xs:attribute name="repositoryClient" type="xs:string" use="optional" default="nuxeo-java"/>
</xs:complexType>