]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
1bdf10f3dcbedb1f476e35e1b5acb797c6d87be4
[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     static public PoxPayloadIn getPayloadIn(AuthorityItemSpecifier specifier, String serviceName, Class responseType) throws Exception {
17         PoxPayloadIn result = null;
18         
19         ServiceContext parentCtx = new MultipartServiceContextImpl(serviceName);
20         AuthorityClient client = (AuthorityClient) parentCtx.getClient();
21         Response res = client.readItem(specifier.getParentSpecifier().value, specifier.getItemSpecifier().value);
22         try {
23                 int statusCode = res.getStatus();
24         
25                 // Check the status code of the response: does it match
26                 // the expected response(s)?
27                 if (logger.isDebugEnabled()) {
28                     logger.debug(client.getClass().getCanonicalName() + ": status = " + statusCode);
29                 }
30                 
31             result = new PoxPayloadIn((String)res.readEntity(responseType)); // Get the entire response!                
32         } finally {
33                 res.close();
34         }
35         
36         return result;
37     }
38 }