]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
ca8973f6684421da1cd401f4fd4d40ddc97f1164
[tmp/jakarta-migration.git] /
1 package org.collectionspace.services.common.vocabulary.nuxeo;
2
3 import javax.ws.rs.core.Response;
4
5 import org.collectionspace.services.client.AuthorityClient;
6 import org.collectionspace.services.client.PoxPayloadIn;
7 import org.collectionspace.services.common.context.MultipartServiceContextImpl;
8 import org.collectionspace.services.common.context.ServiceContext;
9 import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.AuthorityItemSpecifier;
10 import org.slf4j.Logger;
11 import org.slf4j.LoggerFactory;
12
13 public class AuthorityServiceUtils {
14     private static final Logger logger = LoggerFactory.getLogger(AuthorityIdentifierUtils.class);
15
16     public static final String SHOULD_UPDATE_REV_PROPERTY = "SHOULD_UPDATE_REV_PROPERTY";
17     public static final boolean DONT_UPDATE_REV = false;
18     public static final boolean UPDATE_REV = true;
19
20     static public PoxPayloadIn getPayloadIn(AuthorityItemSpecifier specifier, String serviceName, Class responseType) throws Exception {
21         PoxPayloadIn result = null;
22         
23         ServiceContext parentCtx = new MultipartServiceContextImpl(serviceName);
24         AuthorityClient client = (AuthorityClient) parentCtx.getClient();
25         Response res = client.readItem(specifier.getParentSpecifier().value, specifier.getItemSpecifier().value);
26         try {
27                 int statusCode = res.getStatus();
28         
29                 // Check the status code of the response: does it match
30                 // the expected response(s)?
31                 if (logger.isDebugEnabled()) {
32                     logger.debug(client.getClass().getCanonicalName() + ": status = " + statusCode);
33                 }
34                 
35             result = new PoxPayloadIn((String)res.readEntity(responseType)); // Get the entire response!                
36         } finally {
37                 res.close();
38         }
39         
40         return result;
41     }
42 }