]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
98aab7e38dfcacc812f84fa1b138e99f69b5a03e
[tmp/jakarta-migration.git] /
1 /**\r
2  *  This document is a part of the source code and related artifacts\r
3  *  for CollectionSpace, an open source collections management system\r
4  *  for museums and related institutions:\r
5 \r
6  *  http://www.collectionspace.org\r
7  *  http://wiki.collectionspace.org\r
8 \r
9  *  Copyright 2009 University of California at Berkeley\r
10 \r
11  *  Licensed under the Educational Community License (ECL), Version 2.0.\r
12  *  You may not use this file except in compliance with this License.\r
13 \r
14  *  You may obtain a copy of the ECL 2.0 License at\r
15 \r
16  *  https://source.collectionspace.org/collection-space/LICENSE.txt\r
17 \r
18  *  Unless required by applicable law or agreed to in writing, software\r
19  *  distributed under the License is distributed on an "AS IS" BASIS,\r
20  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
21  *  See the License for the specific language governing permissions and\r
22  *  limitations under the License.\r
23  */\r
24 package org.collectionspace.services.common.vocabulary;\r
25 \r
26 import java.util.ArrayList;\r
27 import java.util.List;\r
28 \r
29 import org.nuxeo.ecm.core.api.DocumentModelList;\r
30 import org.slf4j.Logger;\r
31 import org.slf4j.LoggerFactory;\r
32 import org.collectionspace.services.common.ServiceMain;\r
33 import org.collectionspace.services.common.authorityref.AuthorityRefDocList;\r
34 import org.collectionspace.services.common.authorityref.AuthorityRefList;\r
35 import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl;\r
36 import org.collectionspace.services.common.context.ServiceBindingUtils;\r
37 import org.collectionspace.services.common.document.DocumentException;\r
38 import org.collectionspace.services.common.document.DocumentNotFoundException;\r
39 import org.collectionspace.services.common.document.DocumentWrapper;\r
40 import org.collectionspace.services.common.repository.RepositoryClient;\r
41 import org.collectionspace.services.common.service.ServiceBindingType;\r
42 \r
43 /**\r
44  * RefNameServiceUtils is a collection of services utilities related to refName usage.\r
45  *\r
46  * $LastChangedRevision: $\r
47  * $LastChangedDate: $\r
48  */\r
49 public class RefNameServiceUtils {\r
50         \r
51         public static final String AUTH_REF_PROP = "authRef";\r
52 \r
53     private final Logger logger = LoggerFactory.getLogger(RefNameServiceUtils.class);\r
54     \r
55     public AuthorityRefDocList getAuthorityRefDocs(RepositoryClient repoClient, \r
56                 String tenantId, String serviceType, String refName,\r
57                 int pageSize, int pageNum, boolean computeTotal )\r
58                 throws DocumentException, DocumentNotFoundException {\r
59         AuthorityRefDocList wrapperList = new AuthorityRefDocList();\r
60         List<AuthorityRefDocList.AuthorityRefDocItem> list = \r
61                 wrapperList.getAuthorityRefDocItem();\r
62         TenantBindingConfigReaderImpl tReader =\r
63             ServiceMain.getInstance().getTenantBindingConfigReader();\r
64         List<ServiceBindingType> servicebindings = tReader.getServiceBindingsByType(tenantId, serviceType);\r
65         if(servicebindings==null || servicebindings.size()>0)\r
66                 return null;\r
67         String domain = tReader.getTenantBinding(tenantId).getRepositoryDomain();\r
68         ArrayList<String> docTypes = new ArrayList<String>(); \r
69         StringBuilder whereClause = new StringBuilder();\r
70         for(ServiceBindingType sb:servicebindings) {\r
71                 List<String> authRefFields = ServiceBindingUtils.getAllPartsPropertyValues(sb, AUTH_REF_PROP);\r
72                 String docType = sb.getObject().getName();\r
73                 docTypes.add(docType);\r
74                 for(String field:authRefFields) {\r
75                         // Build up the where clause for each authRef field\r
76                         throw new UnsupportedOperationException();\r
77                 }\r
78         }\r
79                 // Now we have to issue the search\r
80                 DocumentWrapper<DocumentModelList> docListWrapper = repoClient.findDocs(\r
81                         docTypes, whereClause.toString(), domain, pageSize, pageNum, computeTotal );\r
82         return null;\r
83     }\r
84 \r
85                 \r
86 }\r
87 \r