-<ns3:vocabularyitems-common-list xmlns:ns3="http://collectionspace.org/services/vocabulary" xmlns:ns2="http://collectionspace.org/services/jaxb">
+<ns3:abstract-common-list xmlns:ns3="http://collectionspace.org/services/vocabulary" xmlns:ns2="http://collectionspace.org/services/jaxb">
<!-- This test result is dependent on test group vocabulary/vocabulary.xml::TestOrder
and the vars defined there.
Do not use this expected result with any other tests.
<pageNum>0</pageNum>
<itemsInPage>3</itemsInPage>
<totalItems>3</totalItems>
- <fieldsReturned>displayName|refName|shortIdentifier|order|uri|csid</fieldsReturned>
- <vocabularyitem_list_item>
+ <fieldsReturned>csid|uri|updatedAt|displayName|shortIdentifier|refName|order</fieldsReturned>
+ <list-item>
<displayName>${Item3DupeOrder.displayName}</displayName>
<shortIdentifier>${Item3DupeOrder.itemID}</shortIdentifier>
<order>${Item3DupeOrder.order}</order>
<uri>/vocabularies/${Vocabulary1.CSID}/items/${Item3DupeOrder.CSID}</uri>
<csid>${Item3DupeOrder.CSID}</csid>
- </vocabularyitem_list_item>
- <vocabularyitem_list_item>
+ </list-item>
+ <list-item>
<displayName>${Item2.displayName}</displayName>
<shortIdentifier>${Item2.itemID}</shortIdentifier>
<order>${Item2.order}</order>
<uri>/vocabularies/${Vocabulary1.CSID}/items/${Item2.CSID}</uri>
<csid>${Item2.CSID}</csid>
- </vocabularyitem_list_item>
- <vocabularyitem_list_item>
+ </list-item>
+ <list-item>
<displayName>${Item1.displayName}</displayName>
<shortIdentifier>${Item1.itemID}</shortIdentifier>
<order>${Item1.order}</order>
<uri>/vocabularies/${Vocabulary1.CSID}/items/${Item1.CSID}</uri>
<csid>${Item1.CSID}</csid>
- </vocabularyitem_list_item>
-</ns3:vocabularyitems-common-list>
+ </list-item>
+</ns3:abstract-common-list>
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.client.workflow.WorkflowClient;
-import org.collectionspace.services.common.AbstractMultiPartCollectionSpaceResourceImpl;
import org.collectionspace.services.common.ClientType;
import org.collectionspace.services.common.ResourceBase;
import org.collectionspace.services.common.ServiceMain;
import org.collectionspace.services.common.document.DocumentNotFoundException;
import org.collectionspace.services.common.document.DocumentWrapper;
import org.collectionspace.services.common.query.QueryManager;
-import org.collectionspace.services.common.relation.IRelationsManager;
import org.collectionspace.services.common.repository.RepositoryClient;
-import org.collectionspace.services.common.security.UnauthorizedException;
import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityDocumentModelHandler;
import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityItemDocumentModelHandler;
import org.collectionspace.services.common.workflow.service.nuxeo.WorkflowDocumentModelHandler;
+import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
import org.collectionspace.services.relation.RelationResource;
import org.collectionspace.services.relation.RelationsCommonList;
*/
@Consumes("application/xml")
@Produces("application/xml")
-public abstract class AuthorityResource<AuthCommon, AuthCommonList, AuthItemCommonList, AuthItemHandler>
+public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
extends ResourceBase {
- //extends AbstractMultiPartCollectionSpaceResourceImpl {
protected Class<AuthCommon> authCommonClass;
protected Class<?> resourceClass;
String inAuthority, String parentShortIdentifier)
throws Exception {
String authorityRefNameBase;
- AuthorityItemDocumentModelHandler<?,?> docHandler;
+ AuthorityItemDocumentModelHandler<?> docHandler;
if(parentShortIdentifier==null) {
authorityRefNameBase = null;
authorityRefNameBase = buildAuthorityRefNameBase(parentCtx, parentShortIdentifier);
}
- docHandler = (AuthorityItemDocumentModelHandler<?,?>)createDocumentHandler(ctx,
+ docHandler = (AuthorityItemDocumentModelHandler<?>)createDocumentHandler(ctx,
ctx.getCommonPartLabel(getItemServiceName()),
authCommonClass);
docHandler.setInAuthority(inAuthority);
String shortIdentifier = null;
try {
DocumentWrapper<DocumentModel> wrapDoc = getRepositoryClient(ctx).getDocFromCsid(ctx, authCSID);
- AuthorityDocumentModelHandler<?,?> handler =
- (AuthorityDocumentModelHandler<?,?>)createDocumentHandler(ctx);
+ AuthorityDocumentModelHandler<?> handler =
+ (AuthorityDocumentModelHandler<?>)createDocumentHandler(ctx);
shortIdentifier = handler.getShortIdentifier(wrapDoc, authorityCommonSchemaName);
} catch (Exception e) {
if (logger.isDebugEnabled()) {
*/
@GET
@Produces("application/xml")
- public AuthCommonList getAuthorityList(@Context UriInfo ui) {
+ public AbstractCommonList getAuthorityList(@Context UriInfo ui) {
try {
MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(queryParams);
myFilter.setWhereClause(authorityCommonSchemaName+":refName='" + nameQ + "'");
}
getRepositoryClient(ctx).getFiltered(ctx, handler);
- return (AuthCommonList) handler.getCommonPartList();
+ return (AbstractCommonList) handler.getCommonPartList();
} catch (Exception e) {
throw bigReThrow(e, ServiceMessages.GET_FAILED);
}
@GET
@Path("{csid}/items")
@Produces("application/xml")
- public AuthItemCommonList getAuthorityItemList(
+ public AbstractCommonList getAuthorityItemList(
@PathParam("csid") String specifier,
@QueryParam(IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm,
@QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords,
+ myFilter.getWhereClause());
}
getRepositoryClient(ctx).getFiltered(ctx, handler);
- return (AuthItemCommonList) handler.getCommonPartList();
+ return (AbstractCommonList) handler.getCommonPartList();
} catch (Exception e) {
throw bigReThrow(e, ServiceMessages.LIST_FAILED);
}
import java.util.Map;
-import javax.management.RuntimeErrorException;
-
-import org.collectionspace.services.client.PoxPayloadIn;
-import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.common.api.RefName;
import org.collectionspace.services.common.context.MultipartServiceContext;
-import org.collectionspace.services.common.context.ServiceContext;
-import org.collectionspace.services.common.document.DocumentException;
-import org.collectionspace.services.common.document.DocumentNotFoundException;
import org.collectionspace.services.common.document.DocumentWrapper;
import org.collectionspace.services.common.service.ObjectPartType;
import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema;
-import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
-import org.collectionspace.services.nuxeo.util.NuxeoUtils;
+import org.collectionspace.services.nuxeo.client.java.DocHandlerBase;
import org.nuxeo.ecm.core.api.ClientException;
import org.nuxeo.ecm.core.api.DocumentModel;
* $LastChangedRevision: $
* $LastChangedDate: $
*/
-public abstract class AuthorityDocumentModelHandler<AuthCommon, AuthCommonList>
- extends RemoteDocumentModelHandlerImpl<AuthCommon, AuthCommonList> {
+public abstract class AuthorityDocumentModelHandler<AuthCommon>
+ extends DocHandlerBase<AuthCommon> {
private String authorityCommonSchemaName;
- /**
- * authority is used to stash JAXB object to use when handle is called
- * for Action.CREATE, Action.UPDATE or Action.GET
- */
- private AuthCommon authority;
- /**
- * authorityList is stashed when handle is called
- * for ACTION.GET_ALL
- */
- private AuthCommonList authorityList;
-
-
public AuthorityDocumentModelHandler(String authorityCommonSchemaName) {
this.authorityCommonSchemaName = authorityCommonSchemaName;
}
- /**
- * getCommonPart get associated authority
- * @return
- */
- @Override
- public AuthCommon getCommonPart() {
- return authority;
- }
-
- /**
- * setCommonPart set associated authority
- * @param authority
- */
- @Override
- public void setCommonPart(AuthCommon authority) {
- this.authority = authority;
- }
-
- /**
- * getCommonPartList get associated authority (for index/GET_ALL)
- * @return
- */
- @Override
- public AuthCommonList getCommonPartList() {
- return authorityList;
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#setCommonPartList(java.lang.Object)
- */
- @Override
- public void setCommonPartList(AuthCommonList authorityList) {
- this.authorityList = authorityList;
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPart(org.collectionspace.services.common.document.DocumentWrapper)
- */
- @Override
- public AuthCommon extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc)
- throws Exception {
- throw new UnsupportedOperationException();
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#fillCommonPart(java.lang.Object, org.collectionspace.services.common.document.DocumentWrapper)
- */
- @Override
- public void fillCommonPart(AuthCommon vocabularyObject, DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
- throw new UnsupportedOperationException();
- }
-
- /* (non-Javadoc)
+ /*
+ * Non standard injection of CSID into common part, since caller may access through
+ * shortId, and not know the CSID.
* @see org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl#extractPart(org.nuxeo.ecm.core.api.DocumentModel, java.lang.String, org.collectionspace.services.common.service.ObjectPartType)
*/
@Override
import org.collectionspace.services.common.repository.RepositoryClientFactory;
import org.collectionspace.services.common.service.ObjectPartType;
import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema;
+import org.collectionspace.services.nuxeo.client.java.DocHandlerBase;
import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
import org.collectionspace.services.nuxeo.util.NuxeoUtils;
import org.collectionspace.services.relation.RelationResource;
* $LastChangedRevision: $
* $LastChangedDate: $
*/
-public abstract class AuthorityItemDocumentModelHandler<AICommon, AICommonList>
- extends RemoteDocumentModelHandlerImpl<AICommon, AICommonList> {
+public abstract class AuthorityItemDocumentModelHandler<AICommon>
+ extends DocHandlerBase<AICommon> {
private final Logger logger = LoggerFactory.getLogger(AuthorityItemDocumentModelHandler.class);
private String authorityItemCommonSchemaName;
- //private final Logger logger = LoggerFactory.getLogger(AuthorityItemDocumentModelHandler.class);
- /**
- * item is used to stash JAXB object to use when handle is called
- * for Action.CREATE, Action.UPDATE or Action.GET
- */
- protected AICommon item;
- /**
- * itemList is stashed when handle is called
- * for ACTION.GET_ALL
- */
- protected AICommonList itemList;
-
/**
* inVocabulary is the parent Authority for this context
*/
}
- /**
- * getCommonPart get associated item
- * @return
- */
- @Override
- public AICommon getCommonPart() {
- return item;
- }
-
- @Override
- public void setCommonPart(AICommon item) {
- this.item = item;
- }
-
- /**
- * getCommonPartList get associated item (for index/GET_ALL)
- * @return
- */
- @Override
- public AICommonList getCommonPartList() {
- return itemList;
- }
-
- @Override
- public void setCommonPartList(AICommonList itemList) {
- this.itemList = itemList;
- }
-
- @Override
- public AICommon extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc)
- throws Exception {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void fillCommonPart(AICommon itemObject, DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
- throw new UnsupportedOperationException();
- }
-
/* (non-Javadoc)
* @see org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl#extractPart(org.nuxeo.ecm.core.api.DocumentModel, java.lang.String, org.collectionspace.services.common.service.ObjectPartType)
*/
* ILT - Authority item list type\r
* P - Proxy type\r
*/\r
-public interface AuthorityClient<LT extends AbstractCommonList, ILT extends AbstractCommonList, P extends AuthorityProxy<LT, ILT>> \r
- extends CollectionSpacePoxClient<LT, P> {\r
+public interface AuthorityClient<P extends AuthorityProxy> \r
+ extends CollectionSpacePoxClient<AbstractCommonList, P> {\r
\r
/** The uri path element for items in an authority */\r
public static String ITEMS = "items"; //used to construct uri's in service paths for authorities.\r
* which will filter list results to return only matched resources.\r
* @return the client response\r
*/\r
- public ClientResponse<ILT> readItemList(String inAuthority, String partialTerm, String keywords);\r
+ public ClientResponse<AbstractCommonList> readItemList(String inAuthority, String partialTerm, String keywords);\r
\r
- public ClientResponse<ILT> readItemList(String inAuthority, String partialTerm, String keywords, Boolean includeDeleted);\r
+ public ClientResponse<AbstractCommonList> readItemList(String inAuthority, String partialTerm, String keywords, Boolean includeDeleted);\r
\r
/**\r
* Read item list for named vocabulary, filtering by partial term match, or keywords. Only one of\r
* which will filter list results to return only matched resources.\r
* @return the client response\r
*/\r
- public ClientResponse<ILT> readItemListForNamedAuthority(String specifier, \r
+ public ClientResponse<AbstractCommonList> readItemListForNamedAuthority(String specifier, \r
String partialTerm, String keywords);\r
\r
- public ClientResponse<ILT> readItemListForNamedAuthority(String specifier, \r
+ public ClientResponse<AbstractCommonList> readItemListForNamedAuthority(String specifier, \r
String partialTerm, \r
String keywords,\r
Boolean includeDeleted);\r
import org.collectionspace.services.jaxb.AbstractCommonList;\r
\r
/*\r
- * LT - List type\r
- * ILT - Authority item list type\r
* P - Proxy type\r
*/\r
-public abstract class AuthorityClientImpl<LT extends AbstractCommonList, ILT extends AbstractCommonList, P extends AuthorityProxy<LT, ILT>>\r
- extends AbstractPoxServiceClientImpl<LT, P>\r
- implements AuthorityClient<LT, ILT, P> {\r
+public abstract class AuthorityClientImpl<P extends AuthorityProxy>\r
+ extends AbstractCommonListPoxServiceClientImpl<P>\r
+ implements AuthorityClient<P> {\r
\r
private static final String INCLUDE_DELETE_TRUE = Boolean.TRUE.toString();\r
/*\r
* @return the client response\r
*/\r
@Override\r
- public ClientResponse<ILT> \r
+ public ClientResponse<AbstractCommonList> \r
readItemList(String inAuthority, String partialTerm, String keywords) {\r
return getProxy().readItemList(inAuthority, partialTerm, keywords, INCLUDE_DELETE_TRUE);\r
}\r
\r
@Override\r
- public ClientResponse<ILT> \r
+ public ClientResponse<AbstractCommonList> \r
readItemList(String inAuthority, String partialTerm, String keywords, Boolean includeDeleted) {\r
return getProxy().readItemList(inAuthority, partialTerm, keywords, includeDeleted.toString());\r
}\r
*/\r
\r
@Override\r
- public ClientResponse<ILT> readItemListForNamedAuthority(\r
+ public ClientResponse<AbstractCommonList> readItemListForNamedAuthority(\r
String specifier, String partialTerm, String keywords) {\r
return getProxy().readItemListForNamedAuthority(specifier, partialTerm, keywords, INCLUDE_DELETE_TRUE);\r
}\r
\r
@Override\r
- public ClientResponse<ILT> readItemListForNamedAuthority(\r
+ public ClientResponse<AbstractCommonList> readItemListForNamedAuthority(\r
String specifier, \r
String partialTerm, \r
String keywords,\r
* ILT = Item list type\r
* LT = List type\r
*/\r
-public interface AuthorityProxy<LT extends AbstractCommonList, ILT extends AbstractCommonList> extends CollectionSpacePoxProxy<LT> {\r
+public interface AuthorityProxy extends CollectionSpaceCommonListPoxProxy {\r
\r
/*\r
* Basic CRUD operations\r
@GET\r
@Produces({"application/xml"})\r
@Path("/{csid}/items/")\r
- ClientResponse<ILT> readItemList(\r
+ ClientResponse<AbstractCommonList> readItemList(\r
@PathParam("csid") String vcsid,\r
@QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm,\r
@QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords,\r
@GET\r
@Produces({"application/xml"})\r
@Path("/urn:cspace:name({specifier})/items/")\r
- ClientResponse<ILT> readItemListForNamedAuthority(\r
+ ClientResponse<AbstractCommonList> readItemListForNamedAuthority(\r
@PathParam("specifier") String specifier,\r
@QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm,\r
@QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords,\r
<service:element>shortIdentifier</service:element>
<service:xpath>shortIdentifier</service:xpath>
</service:ListResultField>
+ <service:ListResultField>
+ <service:element>refName</service:element>
+ <service:xpath>refName</service:xpath>
+ </service:ListResultField>
<service:ListResultField>
<service:element>order</service:element>
<service:xpath>order</service:xpath>
<service:element>shortIdentifier</service:element>
<service:xpath>shortIdentifier</service:xpath>
</service:ListResultField>
+ <service:ListResultField>
+ <service:element>refName</service:element>
+ <service:xpath>refName</service:xpath>
+ </service:ListResultField>
</service:ListResultsFields>
</service:params>
</service:DocHandlerParams>
<service:element>shortIdentifier</service:element>
<service:xpath>shortIdentifier</service:xpath>
</service:ListResultField>
+ <service:ListResultField>
+ <service:element>refName</service:element>
+ <service:xpath>refName</service:xpath>
+ </service:ListResultField>
</service:ListResultsFields>
</service:params>
</service:DocHandlerParams>
<service:element>shortIdentifier</service:element>
<service:xpath>shortIdentifier</service:xpath>
</service:ListResultField>
+ <service:ListResultField>
+ <service:element>refName</service:element>
+ <service:xpath>refName</service:xpath>
+ </service:ListResultField>
</service:ListResultsFields>
</service:params>
</service:DocHandlerParams>
</tenant:serviceBindings>
<!-- end location service meta-data -->
<!-- begin taxonomyauthority service meta-data -->
- <tenant:serviceBindings id="Taxonomyauthorities" name="Taxonomyauthorities" version="0.1">
- <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/taxonomyauthorities/*/workflow/</service:uriPath>
- <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/taxonomyauthorities/*/items/*/workflow/</service:uriPath>
+ <tenant:serviceBindings id="Taxonomyauthority" name="Taxonomyauthority" version="0.1">
+ <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/taxonomyauthority/*/workflow/</service:uriPath>
+ <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/taxonomyauthority/*/items/*/workflow/</service:uriPath>
<!-- other URI paths using which this service could be accessed -->
<!-- <service:uriPath xmlns:service='http://collectionspace.org/services/common/service'>
- /taxonomyauthorities/*/items/
+ /taxonomyauthority/*/items/
</service:uriPath>-->
<service:repositoryDomain xmlns:service="http://collectionspace.org/services/common/service">default-domain</service:repositoryDomain>
<service:documentHandler xmlns:service="http://collectionspace.org/services/common/service">org.collectionspace.services.taxonomy.nuxeo.TaxonomyAuthorityDocumentModelHandler</service:documentHandler>
<service:element>shortIdentifier</service:element>
<service:xpath>shortIdentifier</service:xpath>
</service:ListResultField>
+ <service:ListResultField>
+ <service:element>refName</service:element>
+ <service:xpath>refName</service:xpath>
+ </service:ListResultField>
</service:ListResultsFields>
</service:params>
</service:DocHandlerParams>
DocumentModel docModel = iter.next();\r
String id = NuxeoUtils.getCsid(docModel);\r
item.put(fields[0], id);\r
- String uri = getServiceContextPath() + id;\r
+ String uri = getUri(docModel);\r
item.put(fields[1], uri);\r
GregorianCalendar cal = (GregorianCalendar)\r
docModel.getProperty(COLLECTIONSPACE_CORE_SCHEMA,\r
* ILT - Authority item list type\r
* P - Proxy type\r
*/\r
-public interface AuthorityWithContactsClient<LT extends AbstractCommonList, ILT extends AbstractCommonList, P extends AuthorityProxy<LT, ILT>>\r
- extends AuthorityClient<LT, ILT, P> {\r
+public interface AuthorityWithContactsClient<P extends AuthorityProxy>\r
+ extends AuthorityClient<P> {\r
/**\r
* Creates the contact.\r
*\r
* ILT - Authority item list type\r
* P - Proxy type\r
*/\r
-public abstract class AuthorityWithContactsClientImpl<LT extends AbstractCommonList, ILT extends AbstractCommonList, P extends AuthorityWithContactsProxy<LT, ILT>>\r
- extends AuthorityClientImpl<LT, ILT, P>\r
- implements AuthorityWithContactsClient<LT, ILT, P> {\r
+public abstract class AuthorityWithContactsClientImpl<P extends AuthorityWithContactsProxy>\r
+ extends AuthorityClientImpl<P>\r
+ implements AuthorityWithContactsClient<P> {\r
\r
@Override\r
public ClientResponse<Response> createContact(String parentcsid,\r
import javax.ws.rs.core.Response;\r
\r
import org.collectionspace.services.contact.ContactsCommonList;\r
-import org.collectionspace.services.jaxb.AbstractCommonList;\r
import org.jboss.resteasy.client.ClientResponse;\r
\r
/*\r
* ILT = Item list type\r
* LT = List type\r
*/\r
-public interface AuthorityWithContactsProxy<LT extends AbstractCommonList, ILT extends AbstractCommonList> extends AuthorityProxy<LT, ILT> {\r
+public interface AuthorityWithContactsProxy extends AuthorityProxy {\r
@GET\r
@Produces({"application/xml"})\r
@Path("/{parentcsid}/items/{itemcsid}/contacts/")\r
*/
package org.collectionspace.services.contact;
-//import java.util.List;
-
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
-//import javax.ws.rs.QueryParam;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MultivaluedMap;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.common.vocabulary.AuthorityResource;
-//import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema;
-//import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema;
-//import org.collectionspace.services.common.vocabulary.AuthorityResource.Specifier;
-//import org.collectionspace.services.common.vocabulary.AuthorityResource.SpecifierForm;
-//import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityItemDocumentModelHandler;
-//import org.collectionspace.services.common.AbstractMultiPartCollectionSpaceResourceImpl;
-//import org.collectionspace.services.common.ClientType;
-//import org.collectionspace.services.common.ServiceMain;
-//import org.collectionspace.services.common.authorityref.AuthorityRefDocList;
-//import org.collectionspace.services.common.authorityref.AuthorityRefList;
-//import org.collectionspace.services.common.context.MultipartServiceContextImpl;
-//import org.collectionspace.services.common.context.ServiceBindingUtils;
import org.collectionspace.services.common.context.ServiceContext;
-import org.collectionspace.services.common.document.BadRequestException;
import org.collectionspace.services.common.document.DocumentFilter;
import org.collectionspace.services.common.document.DocumentHandler;
-import org.collectionspace.services.common.document.DocumentNotFoundException;
-//import org.collectionspace.services.common.document.DocumentWrapper;
import org.collectionspace.services.contact.ContactResource;
import org.collectionspace.services.contact.ContactsCommon;
import org.collectionspace.services.contact.ContactsCommonList;
import org.collectionspace.services.contact.ContactJAXBSchema;
import org.collectionspace.services.contact.nuxeo.ContactDocumentModelHandler;
-//import org.collectionspace.services.common.repository.RepositoryClient;
-import org.collectionspace.services.common.security.UnauthorizedException;
-//import org.collectionspace.services.common.query.IQueryManager;
-//import org.collectionspace.services.common.query.QueryManager;
-//import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
-//import org.jboss.remoting.samples.chat.exceptions.InvalidArgumentException;
import org.jboss.resteasy.util.HttpResponseCodes;
-//import org.nuxeo.ecm.core.api.DocumentModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
*/
@Consumes("application/xml")
@Produces("application/xml")
-public abstract class AuthorityResourceWithContacts<AuthCommon, AuthCommonList, AuthItemCommonList, AuthItemHandler> extends //FIXME: REM - Why is this resource in this package instead of somewhere in 'common'?
- AuthorityResource<AuthCommon, AuthCommonList, AuthItemCommonList, AuthItemHandler> {
+public abstract class AuthorityResourceWithContacts<AuthCommon, AuthItemHandler> extends //FIXME: REM - Why is this resource in this package instead of somewhere in 'common'?
+ AuthorityResource<AuthCommon, AuthItemHandler> {
private ContactResource contactResource = new ContactResource(); // Warning: ContactResource is a singleton.
*/
package org.collectionspace.services.client;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.core.Response;
-
-//import org.collectionspace.services.common.authorityref.AuthorityRefList;
-import org.collectionspace.services.common.authorityref.AuthorityRefDocList;
-import org.collectionspace.services.contact.ContactsCommonList;
-import org.collectionspace.services.location.LocationauthoritiesCommonList;
-import org.collectionspace.services.location.LocationsCommonList;
-import org.collectionspace.services.client.LocationAuthorityProxy;
-
-import org.jboss.resteasy.client.ClientResponse;
-import org.jboss.resteasy.client.ProxyFactory;
-import org.jboss.resteasy.client.core.executors.ApacheHttpClientExecutor;
-import org.jboss.resteasy.plugins.providers.RegisterBuiltin;
-import org.jboss.resteasy.spi.ResteasyProviderFactory;
-
/**
* The Class LocationAuthorityClient.
*/
-public class LocationAuthorityClient extends AuthorityClientImpl<LocationauthoritiesCommonList, LocationsCommonList, LocationAuthorityProxy> {
+public class LocationAuthorityClient extends AuthorityClientImpl<LocationAuthorityProxy> {
public static final String SERVICE_NAME = "locationauthorities";
public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
public Class<LocationAuthorityProxy> getProxyClass() {
return LocationAuthorityProxy.class;
}
-
- /*
- * Proxied service calls.
- */
-
- /**
- * @return list
- * @see org.collectionspace.services.client.LocationAuthorityProxy#readList()
- */
- public ClientResponse<LocationauthoritiesCommonList> readList() {
- return getProxy().readList();
- }
}
package org.collectionspace.services.client;
-import org.jboss.resteasy.client.ClientResponse;
import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-
-import org.collectionspace.services.client.workflow.WorkflowClient;
-import org.collectionspace.services.location.LocationauthoritiesCommonList;
-import org.collectionspace.services.location.LocationsCommonList;
/**
* @version $Revision:$
@Path(LocationAuthorityClient.SERVICE_PATH + "/")
@Produces("application/xml")
@Consumes("application/xml")
-public interface LocationAuthorityProxy extends AuthorityProxy<LocationauthoritiesCommonList, LocationsCommonList> {
-
- // List Locationauthorities
- @GET
- ClientResponse<LocationauthoritiesCommonList> readList();
-
- /*
- * List results that must be overridden for the RESTEasy proxy generation to work correctly.
- */
-
- // List Items matching a partial term or keywords.
- @Override
- @GET
- @Produces({"application/xml"})
- @Path("/{csid}/items/")
- ClientResponse<LocationsCommonList> readItemList(
- @PathParam("csid") String vcsid,
- @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm,
- @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords,
- @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);
-
- // List Items for a named authority matching a partial term or keywords.
- @Override
- @GET
- @Produces({"application/xml"})
- @Path("/urn:cspace:name({specifier})/items/")
- ClientResponse<LocationsCommonList> readItemListForNamedAuthority(
- @PathParam("specifier") String specifier,
- @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm,
- @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords,
- @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);
-
- @Override
- @GET
- @Produces({"application/xml"})
- ClientResponse<LocationauthoritiesCommonList> readIncludeDeleted(
- @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);
-
- @Override
- @GET
- @Produces({"application/xml"})
- ClientResponse<LocationauthoritiesCommonList> keywordSearchIncludeDeleted(
- @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords,
- @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);
+public interface LocationAuthorityProxy extends AuthorityProxy {
}
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.common.AbstractCommonListUtils;
import org.collectionspace.services.contact.ContactsCommon;
import org.collectionspace.services.contact.ContactsCommonList;
import org.collectionspace.services.client.LocationAuthorityClient;
import org.collectionspace.services.client.LocationAuthorityClientUtils;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.location.LocationauthoritiesCommon;
-import org.collectionspace.services.location.LocationauthoritiesCommonList;
import org.collectionspace.services.location.LocationsCommon;
-import org.collectionspace.services.location.LocationsCommonList;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
/** The logger. */
private final String CLASS_NAME = LocationAuthorityServiceTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(LocationAuthorityServiceTest.class);
+ private final String REFNAME = "refName";
+ private final String DISPLAYNAME = "displayName";
@Override
public String getServicePathComponent() {
return new LocationAuthorityClient();
}
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
- */
- @Override
- protected AbstractCommonList getAbstractCommonList(
- ClientResponse<AbstractCommonList> response) {
- return response.getEntity(LocationsCommonList.class);
- }
-
@Override
protected PoxPayloadOut createInstance(String identifier) {
LocationAuthorityClient client = new LocationAuthorityClient();
// Submit the request to the service and store the response.
LocationAuthorityClient client = new LocationAuthorityClient();
- ClientResponse<LocationauthoritiesCommonList> res = client.readList();
+ ClientResponse<AbstractCommonList> res = client.readList();
try {
- LocationauthoritiesCommonList list = res.getEntity();
+ AbstractCommonList list = res.getEntity();
int statusCode = res.getStatus();
// Check the status code of the response: does it match
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
// Optionally output additional data about list members for debugging.
- boolean iterateThroughList = false;
- if (iterateThroughList && logger.isDebugEnabled()) {
- List<LocationauthoritiesCommonList.LocationauthorityListItem> items =
- list.getLocationauthorityListItem();
- int i = 0;
- for (LocationauthoritiesCommonList.LocationauthorityListItem item : items) {
- String csid = item.getCsid();
- logger.debug(testName + ": list-item[" + i + "] csid=" +
- csid);
- logger.debug(testName + ": list-item[" + i + "] displayName=" +
- item.getDisplayName());
- logger.debug(testName + ": list-item[" + i + "] URI=" +
- item.getUri());
- readItemList(csid, null);
- i++;
- }
+ if(logger.isTraceEnabled()){
+ AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
}
} finally {
res.releaseConnection();
// Submit the request to the service and store the response.
LocationAuthorityClient client = new LocationAuthorityClient();
- ClientResponse<LocationsCommonList> res = null;
+ ClientResponse<AbstractCommonList> res = null;
if(vcsid!= null) {
res = client.readItemList(vcsid, null, null);
} else if(shortId!= null) {
Assert.fail("readItemList passed null csid and name!");
}
try {
- LocationsCommonList list = res.getEntity();
+ AbstractCommonList list = res.getEntity();
int statusCode = res.getStatus();
// Check the status code of the response: does it match
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- List<LocationsCommonList.LocationListItem> items =
- list.getLocationListItem();
+ List<AbstractCommonList.ListItem> items =
+ list.getListItem();
int nItemsReturned = items.size();
// There will be one item created, associated with a
// known parent resource, by the createItem test.
}
Assert.assertEquals(nItemsReturned, nExpectedItems);
- int i = 0;
- for (LocationsCommonList.LocationListItem item : items) {
- Assert.assertTrue((null != item.getRefName()), "Item refName is null!");
- Assert.assertTrue((null != item.getDisplayName()), "Item displayName is null!");
- // Optionally output additional data about list members for debugging.
- boolean showDetails = true;
- if (showDetails && logger.isDebugEnabled()) {
- logger.debug(" " + testName + ": list-item[" + i + "] csid=" +
- item.getCsid());
- logger.debug(" " + testName + ": list-item[" + i + "] refName=" +
- item.getRefName());
- logger.debug(" " + testName + ": list-item[" + i + "] displayName=" +
- item.getDisplayName());
- logger.debug(" " + testName + ": list-item[" + i + "] URI=" +
- item.getUri());
- }
- i++;
- }
+ for (AbstractCommonList.ListItem item : items) {
+ String value =
+ AbstractCommonListUtils.ListItemGetElementValue(item, REFNAME);
+ Assert.assertTrue((null != value), "Item refName is null!");
+ value =
+ AbstractCommonListUtils.ListItemGetElementValue(item, DISPLAYNAME);
+ Assert.assertTrue((null != value), "Item displayName is null!");
+ }
+ if(logger.isTraceEnabled()){
+ AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
+ }
} finally {
res.releaseConnection();
}
</xs:sequence>
</xs:complexType>
- <!-- This is the base class for paginated lists -->
- <xs:complexType name="abstractCommonListItem">
- <xs:annotation>
- <xs:appinfo>
- <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
- </xs:appinfo>
- </xs:annotation>
- </xs:complexType>
-
- <!-- Location instances, as in nuxeo repository -->
- <xs:element name="locations-common-list">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="abstractCommonListItem">
- <xs:sequence>
- <xs:element name="location_list_item" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="displayName" type="xs:string"
- minOccurs="1" />
- <xs:element name="shortIdentifier" type="xs:string"
- minOccurs="1" />
- <!-- uri to retrieve location details -->
- <xs:element name="uri" type="xs:anyURI"
- minOccurs="1" />
- <xs:element name="refName" type="xs:string"
- minOccurs="1" />
- <xs:element name="csid" type="xs:string"
- minOccurs="1" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
-
</xs:schema>
</xs:complexType>
</xs:element>
- <!-- This is the base class for paginated lists -->
- <xs:complexType name="abstractCommonList">
- <xs:annotation>
- <xs:appinfo>
- <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
- </xs:appinfo>
- </xs:annotation>
- </xs:complexType>
-
-
- <!-- LocationAuthority instances, as in nuxeo repository -->
- <xs:element name="locationauthorities-common-list">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="abstractCommonList">
- <xs:sequence>
- <xs:element name="locationauthority-list-item" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="displayName" type="xs:string"
- minOccurs="1" />
- <xs:element name="refName" type="xs:string"
- minOccurs="1" />
- <xs:element name="shortIdentifier" type="xs:string"
- minOccurs="1" />
- <xs:element name="vocabType" type="xs:string"
- minOccurs="1" />
- <!-- uri to retrieve locationauthority details -->
- <xs:element name="uri" type="xs:anyURI"
- minOccurs="1" />
- <xs:element name="csid" type="xs:string"
- minOccurs="1" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
-
</xs:schema>
@Consumes("application/xml")
@Produces("application/xml")
public class LocationAuthorityResource
- extends AuthorityResource<LocationauthoritiesCommon, LocationauthoritiesCommonList,
- LocationsCommon, LocationDocumentModelHandler> {
+ extends AuthorityResource<LocationauthoritiesCommon,
+ LocationDocumentModelHandler> {
private final static String locationAuthorityServiceName = "locationauthorities";
private final static String LOCATIONAUTHORITIES_COMMON = "locationauthorities_common";
*/
package org.collectionspace.services.location.nuxeo;
-import java.util.Iterator;
-import java.util.List;
-
-import org.collectionspace.services.common.document.DocumentHandler.Action;
-import org.collectionspace.services.common.document.DocumentFilter;
-import org.collectionspace.services.common.document.DocumentWrapper;
-import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema;
import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityDocumentModelHandler;
-import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.location.LocationauthoritiesCommon;
-import org.collectionspace.services.location.LocationauthoritiesCommonList;
-import org.collectionspace.services.location.LocationauthoritiesCommonList.LocationauthorityListItem;
-
-import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
-import org.collectionspace.services.nuxeo.util.NuxeoUtils;
-import org.nuxeo.ecm.core.api.DocumentModel;
-import org.nuxeo.ecm.core.api.DocumentModelList;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* LocationAuthorityDocumentModelHandler
* $LastChangedDate: $
*/
public class LocationAuthorityDocumentModelHandler
- extends AuthorityDocumentModelHandler<LocationauthoritiesCommon, LocationauthoritiesCommonList> {
+ extends AuthorityDocumentModelHandler<LocationauthoritiesCommon> {
/**
* Common part schema label
super(COMMON_PART_LABEL);
}
- @Override
- public LocationauthoritiesCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
- LocationauthoritiesCommonList coList = extractPagingInfo(new LocationauthoritiesCommonList(),
- wrapDoc);
- AbstractCommonList commonList = (AbstractCommonList) coList;
- commonList.setFieldsReturned("displayName|refName|shortIdentifier|vocabType|uri|csid");
-
- //FIXME: iterating over a long list of documents is not a long term
- //strategy...need to change to more efficient iterating in future
- List<LocationauthoritiesCommonList.LocationauthorityListItem> list = coList.getLocationauthorityListItem();
- String label = getServiceContext().getCommonPartLabel();
- Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
- while(iter.hasNext()){
- DocumentModel docModel = iter.next();
- LocationauthorityListItem ilistItem = new LocationauthorityListItem();
- ilistItem.setDisplayName((String) docModel.getProperty(label,
- AuthorityJAXBSchema.DISPLAY_NAME));
- ilistItem.setRefName((String) docModel.getProperty(label,
- AuthorityJAXBSchema.REF_NAME));
- ilistItem.setShortIdentifier((String) docModel.getProperty(label,
- AuthorityJAXBSchema.SHORT_IDENTIFIER));
- ilistItem.setVocabType((String) docModel.getProperty(label,
- AuthorityJAXBSchema.VOCAB_TYPE));
- String id = getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString());
- ilistItem.setUri(getServiceContextPath() + id);
- ilistItem.setCsid(id);
- list.add(ilistItem);
- }
-
- return coList;
- }
-
/**
* getQProperty converts the given property to qualified schema property
* @param prop
*/
package org.collectionspace.services.location.nuxeo;
-import java.util.Iterator;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
import org.collectionspace.services.LocationJAXBSchema;
import org.collectionspace.services.client.LocationAuthorityClient;
-import org.collectionspace.services.common.document.DocumentFilter;
import org.collectionspace.services.common.document.DocumentWrapper;
-import org.collectionspace.services.common.service.ObjectPartType;
-import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema;
import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityItemDocumentModelHandler;
-import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
-import org.collectionspace.services.nuxeo.util.NuxeoUtils;
-import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.location.LocationsCommon;
-import org.collectionspace.services.location.LocationsCommonList;
-import org.collectionspace.services.location.LocationsCommonList.LocationListItem;
import org.nuxeo.ecm.core.api.DocumentModel;
-import org.nuxeo.ecm.core.api.DocumentModelList;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* LocationDocumentModelHandler
*
*/
public class LocationDocumentModelHandler
- extends AuthorityItemDocumentModelHandler<LocationsCommon, LocationsCommonList> {
+ extends AuthorityItemDocumentModelHandler<LocationsCommon> {
- /** The logger. */
- private final Logger logger = LoggerFactory.getLogger(LocationDocumentModelHandler.class);
/**
* Common part schema label
*/
return newStr.toString();
}
- /* (non-Javadoc)
- * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPartList(org.collectionspace.services.common.document.DocumentWrapper)
- */
- @Override
- public LocationsCommonList extractCommonPartList(
- DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
- LocationsCommonList coList = extractPagingInfo(new LocationsCommonList(), wrapDoc);
- AbstractCommonList commonList = (AbstractCommonList) coList;
- commonList.setFieldsReturned("displayName|refName|shortIdentifier|uri|csid");
- List<LocationsCommonList.LocationListItem> list = coList.getLocationListItem();
- Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
- String commonPartLabel = getServiceContext().getCommonPartLabel(
- "locations");
- while (iter.hasNext()) {
- DocumentModel docModel = iter.next();
- LocationListItem ilistItem = new LocationListItem();
- ilistItem.setDisplayName((String) docModel.getProperty(
- commonPartLabel, AuthorityItemJAXBSchema.DISPLAY_NAME));
- ilistItem.setShortIdentifier((String) docModel.getProperty(commonPartLabel,
- AuthorityItemJAXBSchema.SHORT_IDENTIFIER));
- ilistItem.setRefName((String) docModel.getProperty(commonPartLabel,
- AuthorityItemJAXBSchema.REF_NAME));
- String id = getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString());
- ilistItem.setUri("/locationauthorities/" + inAuthority + "/items/"
- + id);
- ilistItem.setCsid(id);
- list.add(ilistItem);
- }
-
- return coList;
- }
-
/**
* getQProperty converts the given property to qualified schema property
* @param prop
* https://source.collectionspace.org/collection-space/LICENSE.txt
*/
package org.collectionspace.services.client;
-import org.jboss.resteasy.client.ClientResponse;
-
-import org.collectionspace.services.organization.OrgauthoritiesCommonList;
-import org.collectionspace.services.organization.OrganizationsCommonList;
/**
* The Class OrgAuthorityClient.
*/
-public class OrgAuthorityClient extends AuthorityWithContactsClientImpl<OrgauthoritiesCommonList, OrganizationsCommonList, OrgAuthorityProxy> {
+public class OrgAuthorityClient extends AuthorityWithContactsClientImpl<OrgAuthorityProxy> {
public static final String SERVICE_NAME = "orgauthorities";
public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
public String getItemCommonPartName() {
return getCommonPartName(SERVICE_ITEM_NAME);
}
-
- /*
- * Proxied service call methods
- */
-
- /**
- * Read list.
- *
- * @return the client response
- */
- public ClientResponse<OrgauthoritiesCommonList> readList() {
- return getProxy().readList();
- }
}
package org.collectionspace.services.client;
import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-
-import org.collectionspace.services.organization.OrgauthoritiesCommonList;
-import org.collectionspace.services.organization.OrganizationsCommonList;
-import org.collectionspace.services.client.workflow.WorkflowClient;
-
-import org.jboss.resteasy.client.ClientResponse;
-
/**
* @version $Revision$
*/
@Path(OrgAuthorityClient.SERVICE_PATH + "/")
@Produces({"application/xml"})
@Consumes({"application/xml"})
-public interface OrgAuthorityProxy extends AuthorityWithContactsProxy<OrgauthoritiesCommonList, OrganizationsCommonList> {
- // List OrgAuthorities
- @GET
- ClientResponse<OrgauthoritiesCommonList> readList();
-
- @Override
- @GET
- @Produces({"application/xml"})
- ClientResponse<OrgauthoritiesCommonList> readIncludeDeleted(
- @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);
-
- @Override
- @GET
- @Produces({"application/xml"})
- ClientResponse<OrgauthoritiesCommonList> keywordSearchIncludeDeleted(
- @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords,
- @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);
-
-
- /*
- * List results that must be overridden for the RESTEasy proxy generation to work correctly.
- */
-
- // List Items matching a partial term or keywords.
- @Override
- @GET
- @Produces({"application/xml"})
- @Path("/{csid}/items/")
- ClientResponse<OrganizationsCommonList> readItemList(
- @PathParam("csid") String vcsid,
- @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm,
- @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords,
- @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);
-
- // List Items for a named authority matching a partial term or keywords.
- @Override
- @GET
- @Produces({"application/xml"})
- @Path("/urn:cspace:name({specifier})/items/")
- ClientResponse<OrganizationsCommonList> readItemListForNamedAuthority(
- @PathParam("specifier") String specifier,
- @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm,
- @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords,
- @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);
+public interface OrgAuthorityProxy extends AuthorityWithContactsProxy {
}
import javax.ws.rs.core.Response;
import org.collectionspace.services.OrganizationJAXBSchema;
-import org.collectionspace.services.PersonJAXBSchema;
import org.collectionspace.services.client.AuthorityClient;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.ContactClient;
import org.collectionspace.services.client.ContactClientUtils;
import org.collectionspace.services.client.PayloadOutputPart;
-import org.collectionspace.services.client.PersonAuthorityClient;
-import org.collectionspace.services.client.PersonAuthorityClientUtils;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.common.AbstractCommonListUtils;
import org.collectionspace.services.contact.ContactsCommon;
import org.collectionspace.services.contact.ContactsCommonList;
import org.collectionspace.services.client.OrgAuthorityClient;
import org.collectionspace.services.organization.MainBodyGroup;
import org.collectionspace.services.organization.MainBodyGroupList;
import org.collectionspace.services.organization.OrgauthoritiesCommon;
-import org.collectionspace.services.organization.OrgauthoritiesCommonList;
import org.collectionspace.services.organization.OrganizationsCommon;
-import org.collectionspace.services.organization.OrganizationsCommonList;
import org.jboss.resteasy.client.ClientResponse;
/** The logger. */
private final String CLASS_NAME = OrgAuthorityServiceTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
+ private final String REFNAME = "refName";
+ private final String DISPLAYNAME = "displayName";
@Override
public String getServicePathComponent() {
return new OrgAuthorityClient();
}
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
- */
- @Override
- protected AbstractCommonList getAbstractCommonList(
- ClientResponse<AbstractCommonList> response) {
- return response.getEntity(OrganizationsCommonList.class);
- }
-
// ---------------------------------------------------------------
// CRUD tests : CREATE tests
// ---------------------------------------------------------------
// Submit the request to the service and store the response.
OrgAuthorityClient client = new OrgAuthorityClient();
- ClientResponse<OrgauthoritiesCommonList> res = client.readList();
+ ClientResponse<AbstractCommonList> res = client.readList();
try {
- OrgauthoritiesCommonList list = res.getEntity();
+ AbstractCommonList list = res.getEntity();
int statusCode = res.getStatus();
// Check the status code of the response: does it match
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
// Optionally output additional data about list members for debugging.
- boolean iterateThroughList = false;
- if (iterateThroughList && logger.isDebugEnabled()) {
- List<OrgauthoritiesCommonList.OrgauthorityListItem> items =
- list.getOrgauthorityListItem();
- int i = 0;
- for (OrgauthoritiesCommonList.OrgauthorityListItem item : items) {
- String csid = item.getCsid();
- logger.debug(testName + ": list-item[" + i + "] csid=" +
- csid);
- logger.debug(testName + ": list-item[" + i + "] displayName=" +
- item.getDisplayName());
- logger.debug(testName + ": list-item[" + i + "] URI=" +
- item.getUri());
- readItemList(csid, null);
- i++;
- }
+ if(logger.isTraceEnabled()){
+ AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
}
} finally {
res.releaseConnection();
// Submit the request to the service and store the response.
OrgAuthorityClient client = new OrgAuthorityClient();
- ClientResponse<OrganizationsCommonList> res = null;
+ ClientResponse<AbstractCommonList> res = null;
if(vcsid!= null) {
res = client.readItemList(vcsid, null, null);
} else if(name!= null) {
Assert.fail("readItemList passed null csid and name!");
}
try {
- OrganizationsCommonList list = res.getEntity();
+ AbstractCommonList list = res.getEntity();
int statusCode = res.getStatus();
// Check the status code of the response: does it match
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- List<OrganizationsCommonList.OrganizationListItem> items =
- list.getOrganizationListItem();
+ List<AbstractCommonList.ListItem> items =
+ list.getListItem();
int nItemsReturned = items.size();
// There will be one item created, associated with a
// known parent resource, by the createItem test.
}
Assert.assertEquals(nItemsReturned, nExpectedItems);
- int i = 0;
- for (OrganizationsCommonList.OrganizationListItem item : items) {
- Assert.assertTrue((null != item.getRefName()), "Item refName is null!");
- Assert.assertTrue((null != item.getDisplayName()), "Item displayName is null!");
- // Optionally output additional data about list members for debugging.
- boolean showDetails = true;
- if (showDetails && logger.isDebugEnabled()) {
- logger.debug(" " + testName + ": list-item[" + i + "] csid=" +
- item.getCsid());
- logger.debug(" " + testName + ": list-item[" + i + "] refName=" +
- item.getRefName());
- logger.debug(" " + testName + ": list-item[" + i + "] displayName=" +
- item.getDisplayName());
- logger.debug(" " + testName + ": list-item[" + i + "] URI=" +
- item.getUri());
- }
- i++;
- }
+ for (AbstractCommonList.ListItem item : items) {
+ String value =
+ AbstractCommonListUtils.ListItemGetElementValue(item, REFNAME);
+ Assert.assertTrue((null != value), "Item refName is null!");
+ value =
+ AbstractCommonListUtils.ListItemGetElementValue(item, DISPLAYNAME);
+ Assert.assertTrue((null != value), "Item displayName is null!");
+ }
+ if(logger.isTraceEnabled()){
+ AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
+ }
} finally {
res.releaseConnection();
}
</xs:sequence>
</xs:complexType>
- <!-- This is the base class for paginated lists -->
- <xs:complexType name="abstractCommonListItem">
- <xs:annotation>
- <xs:appinfo>
- <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
- </xs:appinfo>
- </xs:annotation>
- </xs:complexType>
-
- <!-- Organization instances, as in nuxeo repository -->
- <xs:element name="organizations-common-list">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="abstractCommonListItem">
- <xs:sequence>
- <xs:element name="organization_list_item" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="displayName" type="xs:string"
- minOccurs="1" />
- <xs:element name="shortIdentifier" type="xs:string"
- minOccurs="1" />
- <!-- uri to retrieve organization details -->
- <xs:element name="uri" type="xs:anyURI"
- minOccurs="1" />
- <xs:element name="refName" type="xs:string"
- minOccurs="1" />
- <xs:element name="csid" type="xs:string"
- minOccurs="1" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
-
</xs:schema>
</xs:complexType>
</xs:element>
- <!-- This is the base class for paginated lists -->
- <xs:complexType name="abstractCommonList">
- <xs:annotation>
- <xs:appinfo>
- <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
- </xs:appinfo>
- </xs:annotation>
- </xs:complexType>
-
- <!-- OrgAuthority instances, as in nuxeo repository -->
- <xs:element name="orgauthorities-common-list">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="abstractCommonList">
- <xs:sequence>
- <xs:element name="orgauthority-list-item" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="displayName" type="xs:string"
- minOccurs="1" />
- <xs:element name="refName" type="xs:string"
- minOccurs="1" />
- <xs:element name="shortIdentifier" type="xs:string"
- minOccurs="1" />
- <xs:element name="vocabType" type="xs:string"
- minOccurs="1" />
- <!-- uri to retrieve orgauthority details -->
- <xs:element name="uri" type="xs:anyURI"
- minOccurs="1" />
- <xs:element name="csid" type="xs:string"
- minOccurs="1" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
-
</xs:schema>
@Consumes("application/xml")
@Produces("application/xml")
public class OrgAuthorityResource extends
- AuthorityResourceWithContacts<OrgauthoritiesCommon, OrgauthoritiesCommonList, OrganizationsCommon,
- OrganizationDocumentModelHandler> {
+ AuthorityResourceWithContacts<OrgauthoritiesCommon, OrganizationDocumentModelHandler> {
private final static String orgAuthorityServiceName = OrgAuthorityClient.SERVICE_NAME;
private final static String ORGAUTHORITIES_COMMON = "orgauthorities_common";
*/
package org.collectionspace.services.organization.nuxeo;
-import java.util.Iterator;
-import java.util.List;
-
-import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema;
-import org.collectionspace.services.common.document.DocumentWrapper;
import org.collectionspace.services.organization.OrgauthoritiesCommon;
-import org.collectionspace.services.organization.OrgauthoritiesCommonList;
-import org.collectionspace.services.organization.OrgauthoritiesCommonList.OrgauthorityListItem;
-
import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityDocumentModelHandler;
-import org.collectionspace.services.jaxb.AbstractCommonList;
-import org.collectionspace.services.nuxeo.util.NuxeoUtils;
-import org.nuxeo.ecm.core.api.DocumentModel;
-import org.nuxeo.ecm.core.api.DocumentModelList;
-//import org.slf4j.Logger;
-//import org.slf4j.LoggerFactory;
/**
* OrgAuthorityDocumentModelHandler
* $LastChangedDate$
*/
public class OrgAuthorityDocumentModelHandler
- extends AuthorityDocumentModelHandler<OrgauthoritiesCommon, OrgauthoritiesCommonList> {
+ extends AuthorityDocumentModelHandler<OrgauthoritiesCommon> {
/**
* Common part schema label
super(COMMON_PART_LABEL);
}
- /* (non-Javadoc)
- * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPartList(org.collectionspace.services.common.document.DocumentWrapper)
- */
- @Override
- public OrgauthoritiesCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
- OrgauthoritiesCommonList coList = this.extractPagingInfo(new OrgauthoritiesCommonList(), wrapDoc);
- AbstractCommonList commonList = (AbstractCommonList) coList;
- commonList.setFieldsReturned("displayName|refName|shortIdentifier|vocabType|uri|csid");
- List<OrgauthoritiesCommonList.OrgauthorityListItem> list = coList.getOrgauthorityListItem();
- Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
- String label = getServiceContext().getCommonPartLabel();
- while(iter.hasNext()){
- DocumentModel docModel = iter.next();
- OrgauthorityListItem ilistItem = new OrgauthorityListItem();
- ilistItem.setDisplayName((String) docModel.getProperty(label,
- AuthorityJAXBSchema.DISPLAY_NAME));
- ilistItem.setRefName((String) docModel.getProperty(label,
- AuthorityJAXBSchema.REF_NAME));
- ilistItem.setShortIdentifier((String) docModel.getProperty(label,
- AuthorityJAXBSchema.SHORT_IDENTIFIER));
- ilistItem.setVocabType((String) docModel.getProperty(label,
- AuthorityJAXBSchema.VOCAB_TYPE));
- String id = getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString());
- ilistItem.setUri(getServiceContextPath() + id);
- ilistItem.setCsid(id);
- list.add(ilistItem);
- }
-
- return coList;
- }
-
/**
* getQProperty converts the given property to qualified schema property
* @param prop
*/
package org.collectionspace.services.organization.nuxeo;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
import org.collectionspace.services.client.OrgAuthorityClient;
import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityItemDocumentModelHandler;
import org.collectionspace.services.OrganizationJAXBSchema;
import org.collectionspace.services.common.document.DocumentWrapper;
-import org.collectionspace.services.common.service.ObjectPartType;
-import org.collectionspace.services.jaxb.AbstractCommonList;
-import org.collectionspace.services.nuxeo.util.NuxeoUtils;
import org.collectionspace.services.organization.OrganizationsCommon;
-import org.collectionspace.services.organization.OrganizationsCommonList;
-import org.collectionspace.services.organization.OrganizationsCommonList.OrganizationListItem;
import org.nuxeo.ecm.core.api.DocumentModel;
-import org.nuxeo.ecm.core.api.DocumentModelList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* $LastChangedDate$
*/
public class OrganizationDocumentModelHandler
- extends AuthorityItemDocumentModelHandler<OrganizationsCommon, OrganizationsCommonList> {
+ extends AuthorityItemDocumentModelHandler<OrganizationsCommon> {
/** The logger. */
private final Logger logger = LoggerFactory.getLogger(OrganizationDocumentModelHandler.class);
return newStr.toString();
}
- /* (non-Javadoc)
- * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPartList(org.collectionspace.services.common.document.DocumentWrapper)
- */
- @Override
- public OrganizationsCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc)
- throws Exception {
- OrganizationsCommonList coList = this.extractPagingInfo(new OrganizationsCommonList(), wrapDoc);
- AbstractCommonList commonList = (AbstractCommonList) coList;
- commonList.setFieldsReturned("displayName|refName|shortIdentifier|uri|csid");
- List<OrganizationsCommonList.OrganizationListItem> list = coList.getOrganizationListItem();
- Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
- String commonPartLabel = getServiceContext().getCommonPartLabel("organizations");
- while(iter.hasNext()){
- DocumentModel docModel = iter.next();
- OrganizationListItem ilistItem = new OrganizationListItem();
- ilistItem.setDisplayName((String)
- docModel.getProperty(commonPartLabel,OrganizationJAXBSchema.DISPLAY_NAME ));
- ilistItem.setShortIdentifier((String) docModel.getProperty(commonPartLabel,
- OrganizationJAXBSchema.SHORT_IDENTIFIER));
- ilistItem.setRefName((String)
- docModel.getProperty(commonPartLabel, OrganizationJAXBSchema.REF_NAME));
- String id = getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString());
- ilistItem.setUri("/orgauthorities/" + this.inAuthority + "/items/" + id);
- ilistItem.setCsid(id);
- list.add(ilistItem);
- }
-
- return coList;
- }
-
/**
* getQProperty converts the given property to qualified schema property
* @param prop
*/
package org.collectionspace.services.client;
-//import javax.ws.rs.PathParam;
-import org.jboss.resteasy.client.ClientResponse;
-
-import org.collectionspace.services.person.PersonauthoritiesCommonList;
-import org.collectionspace.services.person.PersonsCommonList;
-import org.collectionspace.services.client.PersonAuthorityProxy;
-
/**
* The Class PersonAuthorityClient.
*/
-public class PersonAuthorityClient extends AuthorityWithContactsClientImpl<PersonauthoritiesCommonList, PersonsCommonList, PersonAuthorityProxy> {
+public class PersonAuthorityClient extends AuthorityWithContactsClientImpl<PersonAuthorityProxy> {
public static final String SERVICE_NAME = "personauthorities";
public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
public Class<PersonAuthorityProxy> getProxyClass() {
return PersonAuthorityProxy.class;
}
-
- /*
- * Proxied service call methods
- */
-
- public ClientResponse<PersonauthoritiesCommonList> readList() {
- return getProxy().readList();
- }
}
package org.collectionspace.services.client;
import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-
-import org.collectionspace.services.person.PersonauthoritiesCommonList;
-import org.collectionspace.services.person.PersonsCommonList;
-import org.collectionspace.services.client.workflow.WorkflowClient;
-
-import org.jboss.resteasy.client.ClientResponse;
/**
* @version $Revision:$
@Path(PersonAuthorityClient.SERVICE_PATH + "/")
@Produces({"application/xml"})
@Consumes({"application/xml"})
-public interface PersonAuthorityProxy extends AuthorityWithContactsProxy<PersonauthoritiesCommonList, PersonsCommonList> {
-
- // List Personauthorities
- @GET
- ClientResponse<PersonauthoritiesCommonList> readList();
+public interface PersonAuthorityProxy extends AuthorityWithContactsProxy {
- @Override
- @GET
- @Produces({"application/xml"})
- ClientResponse<PersonauthoritiesCommonList> readIncludeDeleted(
- @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);
-
- @Override
- @GET
- @Produces({"application/xml"})
- ClientResponse<PersonauthoritiesCommonList> keywordSearchIncludeDeleted(
- @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords,
- @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);
-
- /*
- * List results that must be overridden for the RESTEasy proxy generation to work correctly.
- */
-
- // List Items matching a partial term or keywords.
- @Override
- @GET
- @Produces({"application/xml"})
- @Path("/{csid}/items/")
- ClientResponse<PersonsCommonList> readItemList(
- @PathParam("csid") String vcsid,
- @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm,
- @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords,
- @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);
-
- // List Items for a named authority matching a partial term or keywords.
- @Override
- @GET
- @Produces({"application/xml"})
- @Path("/urn:cspace:name({specifier})/items/")
- ClientResponse<PersonsCommonList> readItemListForNamedAuthority(
- @PathParam("specifier") String specifier,
- @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm,
- @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords,
- @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);
}
import org.collectionspace.services.client.PersonAuthorityClientUtils;
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.jaxb.AbstractCommonList;
-import org.collectionspace.services.person.PersonsCommonList;
import org.jboss.resteasy.client.ClientResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Override
protected AbstractCommonList getAbstractCommonList(
ClientResponse<AbstractCommonList> response) {
- return response.getEntity(PersonsCommonList.class);
+ return response.getEntity(AbstractCommonList.class);
}
private String getPartialTermCommon() {
// Submit the request to the service and store the response.
PersonAuthorityClient client = new PersonAuthorityClient();
- ClientResponse<PersonsCommonList> res = null;
+ ClientResponse<AbstractCommonList> res = null;
if (authorityCsid != null) {
res = client.readItemList(authorityCsid, partialTerm, keywords);
} else {
Assert.fail("readItemListByPartialTerm passed null csid!");
}
- PersonsCommonList list = null;
+ AbstractCommonList list = null;
try {
int statusCode = res.getStatus();
res.releaseConnection();
}
- List<PersonsCommonList.PersonListItem> items = list.getPersonListItem();
+ List<AbstractCommonList.ListItem> items = list.getListItem();
int nItemsReturned = items.size();
return nItemsReturned;
import org.collectionspace.services.client.PersonAuthorityClientUtils;
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.jaxb.AbstractCommonList;
-import org.collectionspace.services.person.PersonsCommonList;
import org.jboss.resteasy.client.ClientResponse;
import org.slf4j.Logger;
@Override
protected AbstractCommonList getAbstractCommonList(
ClientResponse<AbstractCommonList> response) {
- return response.getEntity(PersonsCommonList.class);
+ return response.getEntity(AbstractCommonList.class);
}
@BeforeClass
// Submit the request to the service and store the response.
PersonAuthorityClient client = new PersonAuthorityClient();
- ClientResponse<PersonsCommonList> res = null;
+ ClientResponse<AbstractCommonList> res = null;
if (authorityCsid != null) {
res = client.readItemList(authorityCsid, partialTerm, keywords);
} else {
Assert.fail(testName+" passed null csid!");
}
- PersonsCommonList list = null;
+ AbstractCommonList list = null;
try {
int statusCode = res.getStatus();
Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
res.releaseConnection();
}
- List<PersonsCommonList.PersonListItem> items = list.getPersonListItem();
+ List<AbstractCommonList.ListItem> items = list.getListItem();
return (int)list.getTotalItems();
}
// ---------------------------------------------------------------
import org.collectionspace.services.client.ContactClient;
import org.collectionspace.services.client.ContactClientUtils;
-import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema;
+import org.collectionspace.services.common.AbstractCommonListUtils;
import org.collectionspace.services.contact.ContactsCommon;
import org.collectionspace.services.contact.ContactsCommonList;
import org.collectionspace.services.client.PersonAuthorityClientUtils;
import org.collectionspace.services.PersonJAXBSchema;
import org.collectionspace.services.person.PersonauthoritiesCommon;
-import org.collectionspace.services.person.PersonauthoritiesCommonList;
import org.collectionspace.services.person.PersonsCommon;
-import org.collectionspace.services.person.PersonsCommonList;
import org.jboss.resteasy.client.ClientResponse;
//import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
/** The logger. */
private final String CLASS_NAME = PersonAuthorityServiceTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
+ private final String REFNAME = "refName";
+ private final String DISPLAYNAME = "displayName";
@Override
public String getServicePathComponent() {
return new PersonAuthorityClient();
}
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
- */
- @Override
- protected AbstractCommonList getAbstractCommonList(
- ClientResponse<AbstractCommonList> response) {
- return response.getEntity(PersonsCommonList.class);
- }
-
// ---------------------------------------------------------------
// CRUD tests : CREATE tests
// ---------------------------------------------------------------
// Submit the request to the service and store the response.
PersonAuthorityClient client = new PersonAuthorityClient();
- PersonauthoritiesCommonList list = null;
- ClientResponse<PersonauthoritiesCommonList> res = client.readList();
+ AbstractCommonList list = null;
+ ClientResponse<AbstractCommonList> res = client.readList();
try {
int statusCode = res.getStatus();
}
// Optionally output additional data about list members for debugging.
- boolean iterateThroughList = false;
- if (iterateThroughList && logger.isDebugEnabled()) {
- List<PersonauthoritiesCommonList.PersonauthorityListItem> items =
- list.getPersonauthorityListItem();
- int i = 0;
- for (PersonauthoritiesCommonList.PersonauthorityListItem item : items) {
- String csid = item.getCsid();
- logger.debug(testName + ": list-item[" + i + "] csid=" +
- csid);
- logger.debug(testName + ": list-item[" + i + "] displayName=" +
- item.getDisplayName());
- logger.debug(testName + ": list-item[" + i + "] URI=" +
- item.getUri());
- readItemList(csid, null, testName);
- i++;
- }
+ // Optionally output additional data about list members for debugging.
+ if(logger.isTraceEnabled()){
+ AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
}
}
// Submit the request to the service and store the response.
PersonAuthorityClient client = new PersonAuthorityClient();
- ClientResponse<PersonsCommonList> res = null;
+ ClientResponse<AbstractCommonList> res = null;
if (vcsid!= null) {
res = client.readItemList(vcsid, null, null);
} else if (name!= null) {
} else {
Assert.fail("readItemList passed null csid and name!");
}
- PersonsCommonList list = null;
+ AbstractCommonList list = null;
try {
int statusCode = res.getStatus();
res.releaseConnection();
}
- List<PersonsCommonList.PersonListItem> items =
- list.getPersonListItem();
+ List<AbstractCommonList.ListItem> items =
+ list.getListItem();
int nItemsReturned = items.size();
// There will be one item created, associated with a
// known parent resource, by the createItem test.
}
Assert.assertEquals(nItemsReturned, nExpectedItems);
- int i = 0;
- for (PersonsCommonList.PersonListItem item : items) {
- Assert.assertTrue((null != item.getRefName()), "Item refName is null!");
- Assert.assertTrue((null != item.getDisplayName()), "Item displayName is null!");
- // Optionally output additional data about list members for debugging.
- boolean showDetails = true;
- if (showDetails && logger.isDebugEnabled()) {
- logger.debug(" " + testName + ": list-item[" + i + "] csid=" +
- item.getCsid());
- logger.debug(" " + testName + ": list-item[" + i + "] refName=" +
- item.getRefName());
- logger.debug(" " + testName + ": list-item[" + i + "] displayName=" +
- item.getDisplayName());
- logger.debug(" " + testName + ": list-item[" + i + "] URI=" +
- item.getUri());
- }
- i++;
+ for (AbstractCommonList.ListItem item : items) {
+ String value =
+ AbstractCommonListUtils.ListItemGetElementValue(item, REFNAME);
+ Assert.assertTrue((null != value), "Item refName is null!");
+ value =
+ AbstractCommonListUtils.ListItemGetElementValue(item, DISPLAYNAME);
+ Assert.assertTrue((null != value), "Item displayName is null!");
+ }
+ if(logger.isTraceEnabled()){
+ AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
}
}
</xs:sequence>
</xs:complexType>
- <!-- This is the base class for paginated lists -->
- <xs:complexType name="abstractCommonListItem">
- <xs:annotation>
- <xs:appinfo>
- <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
- </xs:appinfo>
- </xs:annotation>
- </xs:complexType>
-
- <!-- Person instances, as in nuxeo repository -->
- <xs:element name="persons-common-list">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="abstractCommonListItem">
- <xs:sequence>
- <xs:element name="person_list_item" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="displayName" type="xs:string"
- minOccurs="1" />
- <xs:element name="shortIdentifier" type="xs:string"
- minOccurs="1" />
- <!-- uri to retrieve person details -->
- <xs:element name="uri" type="xs:anyURI"
- minOccurs="1" />
- <xs:element name="refName" type="xs:string"
- minOccurs="1" />
- <xs:element name="csid" type="xs:string"
- minOccurs="1" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
-
</xs:schema>
</xs:complexType>
</xs:element>
- <!-- This is the base class for paginated lists -->
- <xs:complexType name="abstractCommonList">
- <xs:annotation>
- <xs:appinfo>
- <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
- </xs:appinfo>
- </xs:annotation>
- </xs:complexType>
-
-
- <!-- PersonAuthority instances, as in nuxeo repository -->
- <xs:element name="personauthorities-common-list">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="abstractCommonList">
- <xs:sequence>
- <xs:element name="personauthority-list-item" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="displayName" type="xs:string"
- minOccurs="1" />
- <xs:element name="refName" type="xs:string"
- minOccurs="1" />
- <xs:element name="shortIdentifier" type="xs:string"
- minOccurs="1" />
- <xs:element name="vocabType" type="xs:string"
- minOccurs="1" />
- <!-- uri to retrieve personauthority details -->
- <xs:element name="uri" type="xs:anyURI"
- minOccurs="1" />
- <xs:element name="csid" type="xs:string"
- minOccurs="1" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
-
</xs:schema>
@Consumes("application/xml")
@Produces("application/xml")
public class PersonAuthorityResource extends
- AuthorityResourceWithContacts<PersonauthoritiesCommon, PersonauthoritiesCommonList, PersonsCommon,
- PersonDocumentModelHandler> {
+ AuthorityResourceWithContacts<PersonauthoritiesCommon, PersonDocumentModelHandler> {
final Logger logger = LoggerFactory.getLogger(PersonAuthorityResource.class);
*/
package org.collectionspace.services.person.nuxeo;
-import java.util.Iterator;
-import java.util.List;
-
-import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema;
-import org.collectionspace.services.common.document.DocumentWrapper;
-import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.person.PersonauthoritiesCommon;
-import org.collectionspace.services.person.PersonauthoritiesCommonList;
-import org.collectionspace.services.person.PersonauthoritiesCommonList.PersonauthorityListItem;
import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityDocumentModelHandler;
-import org.collectionspace.services.nuxeo.util.NuxeoUtils;
-import org.nuxeo.ecm.core.api.DocumentModel;
-import org.nuxeo.ecm.core.api.DocumentModelList;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
/**
* PersonAuthorityDocumentModelHandler
*
* $LastChangedDate: $
*/
public class PersonAuthorityDocumentModelHandler
- extends AuthorityDocumentModelHandler<PersonauthoritiesCommon, PersonauthoritiesCommonList> {
+ extends AuthorityDocumentModelHandler<PersonauthoritiesCommon> {
/**
* Common part schema label
super(COMMON_PART_LABEL);
}
- @Override
- public PersonauthoritiesCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
- PersonauthoritiesCommonList coList = extractPagingInfo(new PersonauthoritiesCommonList(),
- wrapDoc);
- AbstractCommonList commonList = (AbstractCommonList) coList;
- commonList.setFieldsReturned("displayName|refName|shortIdentifier|vocabType|uri|csid");
-
- //FIXME: iterating over a long list of documents is not a long term
- //strategy...need to change to more efficient iterating in future
- List<PersonauthoritiesCommonList.PersonauthorityListItem> list = coList.getPersonauthorityListItem();
- Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
- String label = getServiceContext().getCommonPartLabel();
- while(iter.hasNext()){
- DocumentModel docModel = iter.next();
- PersonauthorityListItem ilistItem = new PersonauthorityListItem();
- ilistItem.setDisplayName((String) docModel.getProperty(label,
- AuthorityJAXBSchema.DISPLAY_NAME));
- ilistItem.setRefName((String) docModel.getProperty(label,
- AuthorityJAXBSchema.REF_NAME));
- ilistItem.setShortIdentifier((String) docModel.getProperty(label,
- AuthorityJAXBSchema.SHORT_IDENTIFIER));
- ilistItem.setVocabType((String) docModel.getProperty(label,
- AuthorityJAXBSchema.VOCAB_TYPE));
- String id = getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString());
- ilistItem.setUri(getServiceContextPath() + id);
- ilistItem.setCsid(id);
- list.add(ilistItem);
- }
-
- return coList;
- }
-
/**
* getQProperty converts the given property to qualified schema property
* @param prop
*/
package org.collectionspace.services.person.nuxeo;
-import java.util.Iterator;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.collectionspace.services.PersonJAXBSchema;
import org.collectionspace.services.common.document.DocumentWrapper;
import org.collectionspace.services.common.service.ObjectPartType;
-import org.collectionspace.services.nuxeo.util.NuxeoUtils;
-import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.person.PersonsCommon;
-import org.collectionspace.services.person.PersonsCommonList;
-import org.collectionspace.services.person.PersonsCommonList.PersonListItem;
-
import org.nuxeo.ecm.core.api.DocumentModel;
-import org.nuxeo.ecm.core.api.DocumentModelList;
-
-//import org.slf4j.Logger;
-//import org.slf4j.LoggerFactory;
/**
* PersonDocumentModelHandler
*
*/
public class PersonDocumentModelHandler
- extends AuthorityItemDocumentModelHandler<PersonsCommon, PersonsCommonList> {
+ extends AuthorityItemDocumentModelHandler<PersonsCommon> {
/** The logger. */
//private final Logger logger = LoggerFactory.getLogger(PersonDocumentModelHandler.class);
return unQObjectProperties;
}
- /* (non-Javadoc)
- * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPartList(org.collectionspace.services.common.document.DocumentWrapper)
- */
- @Override
- public PersonsCommonList extractCommonPartList(
- DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
- PersonsCommonList coList = extractPagingInfo(new PersonsCommonList(), wrapDoc);
- AbstractCommonList commonList = (AbstractCommonList) coList;
- commonList.setFieldsReturned("displayName|refName|shortIdentifier|uri|csid");
- List<PersonsCommonList.PersonListItem> list = coList.getPersonListItem();
- Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
- String commonPartLabel = getServiceContext().getCommonPartLabel(
- "persons");
- while (iter.hasNext()) {
- DocumentModel docModel = iter.next();
- PersonListItem ilistItem = new PersonListItem();
- ilistItem.setDisplayName((String) docModel.getProperty(
- commonPartLabel, PersonJAXBSchema.DISPLAY_NAME));
- ilistItem.setShortIdentifier((String) docModel.getProperty(commonPartLabel,
- PersonJAXBSchema.SHORT_IDENTIFIER));
- ilistItem.setRefName((String) docModel.getProperty(commonPartLabel,
- PersonJAXBSchema.REF_NAME));
- String id = getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString());
- ilistItem.setUri("/personauthorities/" + inAuthority + "/items/"
- + id);
- ilistItem.setCsid(id);
- list.add(ilistItem);
- }
-
- return coList;
- }
-
/**
* getQProperty converts the given property to qualified schema property
* @param prop
*/
package org.collectionspace.services.client;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.core.Response;
-
-//import org.collectionspace.services.common.authorityref.AuthorityRefList;
-import org.collectionspace.services.common.authorityref.AuthorityRefDocList;
-import org.collectionspace.services.taxonomy.TaxonomyauthorityCommonList;
-import org.collectionspace.services.taxonomy.TaxonCommonList;
-import org.collectionspace.services.client.TaxonomyAuthorityProxy;
-
-import org.jboss.resteasy.client.ClientResponse;
-import org.jboss.resteasy.client.ProxyFactory;
-import org.jboss.resteasy.client.core.executors.ApacheHttpClientExecutor;
-import org.jboss.resteasy.plugins.providers.RegisterBuiltin;
-import org.jboss.resteasy.spi.ResteasyProviderFactory;
-
/**
* The Class TaxonomyAuthorityClient.
*/
-public class TaxonomyAuthorityClient extends AuthorityClientImpl<TaxonomyauthorityCommonList, TaxonCommonList, TaxonomyAuthorityProxy> {
+public class TaxonomyAuthorityClient extends AuthorityClientImpl<TaxonomyAuthorityProxy> {
- public static final String SERVICE_NAME = "taxonomyauthorities";
+ public static final String SERVICE_NAME = "taxonomyauthority";
public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
- public static final String SERVICE_PAYLOAD_NAME = "taxonomyauthority";
+ public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME;
//
// Subitem constants
//
return SERVICE_PATH_COMPONENT;
}
- @Override
- public String getCommonPartName() {
- return getCommonPartName(SERVICE_PAYLOAD_NAME);
- }
-
@Override
public String getItemCommonPartName() {
return getCommonPartName(SERVICE_ITEM_PAYLOAD_NAME);
public Class<TaxonomyAuthorityProxy> getProxyClass() {
return TaxonomyAuthorityProxy.class;
}
-
- /*
- * Proxied service calls.
- */
- /**
- * @return list
- * @see org.collectionspace.services.client.TaxonomyAuthorityProxy#readList()
- */
- public ClientResponse<TaxonomyauthorityCommonList> readList() {
- return getProxy().readList();
- }
}
package org.collectionspace.services.client;
-import org.jboss.resteasy.client.ClientResponse;
import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-
-import org.collectionspace.services.client.workflow.WorkflowClient;
-import org.collectionspace.services.taxonomy.TaxonomyauthorityCommonList;
-import org.collectionspace.services.taxonomy.TaxonCommonList;
/**
* @version $Revision$
@Path(TaxonomyAuthorityClient.SERVICE_PATH + "/")
@Produces("application/xml")
@Consumes("application/xml")
-public interface TaxonomyAuthorityProxy extends AuthorityProxy<TaxonomyauthorityCommonList, TaxonCommonList> {
-
- // List Taxonomyauthority
- @GET
- ClientResponse<TaxonomyauthorityCommonList> readList();
-
- /*
- * List results that must be overridden for the RESTEasy proxy generation to work correctly.
- */
-
- // List Items matching a partial term or keywords.
- @Override
- @GET
- @Produces({"application/xml"})
- @Path("/{csid}/items/")
- ClientResponse<TaxonCommonList> readItemList(
- @PathParam("csid") String vcsid,
- @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm,
- @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords,
- @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);
-
- // List Items for a named authority matching a partial term or keywords.
- @Override
- @GET
- @Produces({"application/xml"})
- @Path("/urn:cspace:name({specifier})/items/")
- ClientResponse<TaxonCommonList> readItemListForNamedAuthority(
- @PathParam("specifier") String specifier,
- @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm,
- @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords,
- @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);
-
- @Override
- @GET
- @Produces({"application/xml"})
- ClientResponse<TaxonomyauthorityCommonList> readIncludeDeleted(
- @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);
-
- @Override
- @GET
- @Produces({"application/xml"})
- ClientResponse<TaxonomyauthorityCommonList> keywordSearchIncludeDeleted(
- @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords,
- @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);
+public interface TaxonomyAuthorityProxy extends AuthorityProxy {
}
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.client.TaxonomyAuthorityClient;
import org.collectionspace.services.client.TaxonomyAuthorityClientUtils;
+import org.collectionspace.services.common.AbstractCommonListUtils;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.taxonomy.TaxonAuthorGroup;
import org.collectionspace.services.taxonomy.TaxonAuthorGroupList;
import org.collectionspace.services.taxonomy.TaxonCitationList;
import org.collectionspace.services.taxonomy.TaxonomyauthorityCommon;
-import org.collectionspace.services.taxonomy.TaxonomyauthorityCommonList;
import org.collectionspace.services.taxonomy.TaxonCommon;
-import org.collectionspace.services.taxonomy.TaxonCommonList;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
/** The logger. */
private final String CLASS_NAME = TaxonomyAuthorityServiceTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(TaxonomyAuthorityServiceTest.class);
+ private final String REFNAME = "refName";
+ private final String DISPLAYNAME = "displayName";
@Override
public String getServicePathComponent() {
return new TaxonomyAuthorityClient();
}
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
- */
- @Override
- protected AbstractCommonList getAbstractCommonList(
- ClientResponse<AbstractCommonList> response) {
- return response.getEntity(TaxonCommonList.class);
- }
-
@Override
protected PoxPayloadOut createInstance(String identifier) {
TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
// Submit the request to the service and store the response.
TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
- ClientResponse<TaxonomyauthorityCommonList> res = client.readList();
+ ClientResponse<AbstractCommonList> res = client.readList();
try {
- TaxonomyauthorityCommonList list = res.getEntity();
+ AbstractCommonList list = res.getEntity();
int statusCode = res.getStatus();
// Check the status code of the response: does it match
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
// Optionally output additional data about list members for debugging.
- boolean iterateThroughList = false;
- if (iterateThroughList && logger.isDebugEnabled()) {
- List<TaxonomyauthorityCommonList.TaxonomyauthorityListItem> items =
- list.getTaxonomyauthorityListItem();
- int i = 0;
- for (TaxonomyauthorityCommonList.TaxonomyauthorityListItem item : items) {
- String csid = item.getCsid();
- logger.debug(testName + ": list-item[" + i + "] csid="
- + csid);
- logger.debug(testName + ": list-item[" + i + "] displayName="
- + item.getDisplayName());
- logger.debug(testName + ": list-item[" + i + "] URI="
- + item.getUri());
- readItemList(csid, null);
- i++;
- }
+ if(logger.isTraceEnabled()){
+ AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
}
} finally {
res.releaseConnection();
// Submit the request to the service and store the response.
TaxonomyAuthorityClient client = new TaxonomyAuthorityClient();
- ClientResponse<TaxonCommonList> res = null;
+ ClientResponse<AbstractCommonList> res = null;
if (vcsid != null) {
res = client.readItemList(vcsid, null, null);
} else if (shortId != null) {
Assert.fail("readItemList passed null csid and name!");
}
try {
- TaxonCommonList list = res.getEntity();
+ AbstractCommonList list = res.getEntity();
int statusCode = res.getStatus();
// Check the status code of the response: does it match
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- List<TaxonCommonList.TaxonListItem> items =
- list.getTaxonListItem();
+ List<AbstractCommonList.ListItem> items =
+ list.getListItem();
int nItemsReturned = items.size();
// There will be one item created, associated with a
// known parent resource, by the createItem test.
}
Assert.assertEquals(nItemsReturned, nExpectedItems);
- int i = 0;
- for (TaxonCommonList.TaxonListItem item : items) {
- Assert.assertTrue((null != item.getRefName()), "Item refName is null!");
- Assert.assertTrue((null != item.getDisplayName()), "Item displayName is null!");
- // Optionally output additional data about list members for debugging.
- boolean showDetails = true;
- if (showDetails && logger.isDebugEnabled()) {
- logger.debug(" " + testName + ": list-item[" + i + "] csid="
- + item.getCsid());
- logger.debug(" " + testName + ": list-item[" + i + "] refName="
- + item.getRefName());
- logger.debug(" " + testName + ": list-item[" + i + "] displayName="
- + item.getDisplayName());
- logger.debug(" " + testName + ": list-item[" + i + "] URI="
- + item.getUri());
- }
- i++;
+ for (AbstractCommonList.ListItem item : items) {
+ String value =
+ AbstractCommonListUtils.ListItemGetElementValue(item, REFNAME);
+ Assert.assertTrue((null != value), "Item refName is null!");
+ value =
+ AbstractCommonListUtils.ListItemGetElementValue(item, DISPLAYNAME);
+ Assert.assertTrue((null != value), "Item displayName is null!");
+ }
+ if(logger.isTraceEnabled()){
+ AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
}
} finally {
res.releaseConnection();
</xs:sequence>
</xs:complexType>
- <!-- This is the base class for paginated lists -->
- <xs:complexType name="abstractCommonListItem">
- <xs:annotation>
- <xs:appinfo>
- <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
- </xs:appinfo>
- </xs:annotation>
- </xs:complexType>
-
- <!-- Taxonomy instances, as in nuxeo repository -->
- <xs:element name="taxon-common-list">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="abstractCommonListItem">
- <xs:sequence>
- <xs:element name="taxon_list_item" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="displayName" type="xs:string"
- minOccurs="1" />
- <xs:element name="shortIdentifier" type="xs:string"
- minOccurs="1" />
- <!-- uri to retrieve taxon details -->
- <xs:element name="uri" type="xs:anyURI"
- minOccurs="1" />
- <xs:element name="refName" type="xs:string"
- minOccurs="1" />
- <xs:element name="csid" type="xs:string"
- minOccurs="1" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
-
</xs:schema>
</xs:complexType>
</xs:element>
- <!-- This is the base class for paginated lists -->
- <xs:complexType name="abstractCommonList">
- <xs:annotation>
- <xs:appinfo>
- <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
- </xs:appinfo>
- </xs:annotation>
- </xs:complexType>
-
-
- <!-- TaxonomyAuthority instances, as in nuxeo repository -->
- <xs:element name="taxonomyauthority-common-list">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="abstractCommonList">
- <xs:sequence>
- <xs:element name="taxonomyauthority-list-item" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="displayName" type="xs:string"
- minOccurs="1" />
- <xs:element name="refName" type="xs:string"
- minOccurs="1" />
- <xs:element name="shortIdentifier" type="xs:string"
- minOccurs="1" />
- <xs:element name="vocabType" type="xs:string"
- minOccurs="1" />
- <!-- uri to retrieve taxonomyauthority details -->
- <xs:element name="uri" type="xs:anyURI"
- minOccurs="1" />
- <xs:element name="csid" type="xs:string"
- minOccurs="1" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
-
</xs:schema>
@Consumes("application/xml")
@Produces("application/xml")
public class TaxonomyAuthorityResource
- extends AuthorityResource<TaxonomyauthorityCommon, TaxonomyauthorityCommonList, TaxonCommon, TaxonDocumentModelHandler> {
+ extends AuthorityResource<TaxonomyauthorityCommon, TaxonDocumentModelHandler> {
- private final static String taxonomyAuthorityServiceName = "taxonomyauthorities";
+ private final static String taxonomyAuthorityServiceName = "taxonomyauthority";
private final static String TAXONOMYAUTHORITY_COMMON = "taxonomyauthority_common";
private final static String taxonomyItemServiceName = "taxon";
private final static String TAXONOMYITEM_COMMON = "taxon_common";
*/
package org.collectionspace.services.taxonomy.nuxeo;
-import java.util.Iterator;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
import org.collectionspace.services.TaxonJAXBSchema;
-import org.collectionspace.services.client.TaxonomyAuthorityClient;
-import org.collectionspace.services.common.document.DocumentFilter;
import org.collectionspace.services.common.document.DocumentWrapper;
-import org.collectionspace.services.common.service.ObjectPartType;
-import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema;
import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityItemDocumentModelHandler;
-import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
-import org.collectionspace.services.nuxeo.util.NuxeoUtils;
-import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.taxonomy.TaxonCommon;
-import org.collectionspace.services.taxonomy.TaxonCommonList;
-import org.collectionspace.services.taxonomy.TaxonCommonList.TaxonListItem;
import org.nuxeo.ecm.core.api.DocumentModel;
-import org.nuxeo.ecm.core.api.DocumentModelList;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* TaxonomyDocumentModelHandler
*
*/
public class TaxonDocumentModelHandler
- extends AuthorityItemDocumentModelHandler<TaxonCommon, TaxonCommonList> {
+ extends AuthorityItemDocumentModelHandler<TaxonCommon> {
- /** The logger. */
- private final Logger logger = LoggerFactory.getLogger(TaxonDocumentModelHandler.class);
/**
* Common part schema label
*/
return newStr.toString();
}
- /* (non-Javadoc)
- * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPartList(org.collectionspace.services.common.document.DocumentWrapper)
- */
- @Override
- public TaxonCommonList extractCommonPartList(
- DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
- TaxonCommonList coList = extractPagingInfo(new TaxonCommonList(), wrapDoc);
- AbstractCommonList commonList = (AbstractCommonList) coList;
- commonList.setFieldsReturned("displayName|refName|shortIdentifier|uri|csid");
- List<TaxonCommonList.TaxonListItem> list = coList.getTaxonListItem();
- Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
- String commonPartLabel = getServiceContext().getCommonPartLabel("taxon");
- while (iter.hasNext()) {
- DocumentModel docModel = iter.next();
- TaxonListItem ilistItem = new TaxonListItem();
- ilistItem.setDisplayName((String) docModel.getProperty(
- commonPartLabel, AuthorityItemJAXBSchema.DISPLAY_NAME));
- ilistItem.setShortIdentifier((String) docModel.getProperty(commonPartLabel,
- AuthorityItemJAXBSchema.SHORT_IDENTIFIER));
- ilistItem.setRefName((String) docModel.getProperty(commonPartLabel,
- AuthorityItemJAXBSchema.REF_NAME));
- String id = getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString());
- ilistItem.setUri("/taxonomyauthorities/" + inAuthority + "/items/"
- + id);
- ilistItem.setCsid(id);
- list.add(ilistItem);
- }
-
- return coList;
- }
-
/**
* getQProperty converts the given property to qualified schema property
* @param prop
*/
package org.collectionspace.services.taxonomy.nuxeo;
-import java.util.Iterator;
-import java.util.List;
-
-import org.collectionspace.services.common.document.DocumentHandler.Action;
-import org.collectionspace.services.common.document.DocumentFilter;
-import org.collectionspace.services.common.document.DocumentWrapper;
-import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema;
import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityDocumentModelHandler;
-import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.taxonomy.TaxonomyauthorityCommon;
-import org.collectionspace.services.taxonomy.TaxonomyauthorityCommonList;
-import org.collectionspace.services.taxonomy.TaxonomyauthorityCommonList.TaxonomyauthorityListItem;
-
-import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
-import org.collectionspace.services.nuxeo.util.NuxeoUtils;
-import org.nuxeo.ecm.core.api.DocumentModel;
-import org.nuxeo.ecm.core.api.DocumentModelList;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* TaxonomyAuthorityDocumentModelHandler
* $LastChangedDate$
*/
public class TaxonomyAuthorityDocumentModelHandler
- extends AuthorityDocumentModelHandler<TaxonomyauthorityCommon, TaxonomyauthorityCommonList> {
+ extends AuthorityDocumentModelHandler<TaxonomyauthorityCommon> {
/**
* Common part schema label
return COMMON_PART_LABEL;
}
- @Override
- public TaxonomyauthorityCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
- TaxonomyauthorityCommonList coList = extractPagingInfo(new TaxonomyauthorityCommonList(),
- wrapDoc);
- AbstractCommonList commonList = (AbstractCommonList) coList;
- commonList.setFieldsReturned("displayName|refName|shortIdentifier|vocabType|uri|csid");
-
- //FIXME: iterating over a long list of documents is not a long term
- //strategy...need to change to more efficient iterating in future
- List<TaxonomyauthorityCommonList.TaxonomyauthorityListItem> list = coList.getTaxonomyauthorityListItem();
- // FIXME: This workaround - for the discrepancy between plural service
- // name / path ("taxonomyauthorities") and singular common part name
- // ("taxonomyauthority ... _common") in this service might be handled
- // in a cleaner way than below. Absent this workaround, values of fields
- // (other than URI and CSID) could not be obtained via the document model.
- // Perhaps this will be moot when we switch to the model of Person, et al.,
- // where SERVICE_PAYLOAD_NAME can be distinct from SERVICE_NAME.
- // String label = getServiceContext().getCommonPartLabel();
- String label = getCommonPartLabel();
- Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
- while(iter.hasNext()){
- DocumentModel docModel = iter.next();
- TaxonomyauthorityListItem ilistItem = new TaxonomyauthorityListItem();
- ilistItem.setDisplayName((String) docModel.getProperty(label,
- AuthorityJAXBSchema.DISPLAY_NAME));
- ilistItem.setRefName((String) docModel.getProperty(label,
- AuthorityJAXBSchema.REF_NAME));
- ilistItem.setShortIdentifier((String) docModel.getProperty(label,
- AuthorityJAXBSchema.SHORT_IDENTIFIER));
- ilistItem.setVocabType((String) docModel.getProperty(label,
- AuthorityJAXBSchema.VOCAB_TYPE));
- String id = getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString());
- ilistItem.setUri(getServiceContextPath() + id);
- ilistItem.setCsid(id);
- list.add(ilistItem);
- }
-
- return coList;
- }
-
- /**
- * getQProperty converts the given property to qualified schema property
- * @param prop
- * @return
- */
- @Override
- public String getQProperty(String prop) {
- return TaxonomyAuthorityConstants.NUXEO_SCHEMA_NAME + ":" + prop;
- }
}
*/
package org.collectionspace.services.client;
-import org.jboss.resteasy.client.ClientResponse;
-
-import org.collectionspace.services.vocabulary.VocabulariesCommonList;
-import org.collectionspace.services.vocabulary.VocabularyitemsCommonList;
-import org.collectionspace.services.client.VocabularyProxy;
-
/**
* The Class VocabularyClient.
*/
-public class VocabularyClient extends AuthorityClientImpl<VocabulariesCommonList, VocabularyitemsCommonList, VocabularyProxy> {
+public class VocabularyClient extends AuthorityClientImpl<VocabularyProxy> {
public static final String SERVICE_NAME = "vocabularies";
public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
public String getCommonPartItemName() {
return getCommonPartName(SERVICE_ITEM_PAYLOAD_NAME);
}
-
- /*
- * Service calls
- */
-
- /**
- * Read list.
- *
- * @return the client response
- */
- public ClientResponse<VocabulariesCommonList> readList() {
- return getProxy().readList();
- }
}
package org.collectionspace.services.client;
import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-
-import org.collectionspace.services.vocabulary.VocabulariesCommonList;
-import org.collectionspace.services.vocabulary.VocabularyitemsCommonList;
-import org.collectionspace.services.client.workflow.WorkflowClient;
-
-import org.jboss.resteasy.client.ClientResponse;
/**
* @version $Revision:$
@Path("/" + VocabularyClient.SERVICE_PATH_COMPONENT + "/")
@Produces({"application/xml"})
@Consumes({"application/xml"})
-public interface VocabularyProxy extends AuthorityProxy<VocabulariesCommonList, VocabularyitemsCommonList> {
- // List Vocabularies
- @GET
- @Produces({"application/xml"})
- ClientResponse<VocabulariesCommonList> readList();
-
- @Override
- @GET
- @Produces({"application/xml"})
- ClientResponse<VocabulariesCommonList> readIncludeDeleted(
- @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);
-
- @Override
- @GET
- @Produces({"application/xml"})
- ClientResponse<VocabulariesCommonList> keywordSearchIncludeDeleted(
- @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords,
- @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);
-
- /*
- * List results that must be overridden for the RESTEasy proxy generation to work correctly.
- */
-
- // List Items matching a partial term or keywords.
- @Override
- @GET
- @Produces({"application/xml"})
- @Path("/{csid}/items/")
- ClientResponse<VocabularyitemsCommonList> readItemList(
- @PathParam("csid") String vcsid,
- @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm,
- @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords,
- @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);
+public interface VocabularyProxy extends AuthorityProxy {
- // List Items for a named authority matching a partial term or keywords.
- @Override
- @GET
- @Produces({"application/xml"})
- @Path("/urn:cspace:name({specifier})/items/")
- ClientResponse<VocabularyitemsCommonList> readItemListForNamedAuthority(
- @PathParam("specifier") String specifier,
- @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm,
- @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords,
- @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);
}
import javax.ws.rs.core.Response;
import org.collectionspace.services.client.AuthorityClient;
+import org.collectionspace.services.common.AbstractCommonListUtils;
import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.VocabularyClientUtils;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.vocabulary.VocabulariesCommon;
-import org.collectionspace.services.vocabulary.VocabulariesCommonList;
import org.collectionspace.services.vocabulary.VocabularyitemsCommon;
-import org.collectionspace.services.vocabulary.VocabularyitemsCommonList;
import org.jboss.resteasy.client.ClientResponse;
import org.slf4j.Logger;
return new VocabularyClient();
}
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse)
- */
- @Override
- protected AbstractCommonList getAbstractCommonList(
- ClientResponse<AbstractCommonList> response) {
- return response.getEntity(VocabulariesCommonList.class);
- }
-
@Override
protected PoxPayloadOut createInstance(String identifier) {
VocabularyClient client = new VocabularyClient();
// Submit the request to the service and store the response.
VocabularyClient client = new VocabularyClient();
- ClientResponse<VocabulariesCommonList> res = client.readList();
- VocabulariesCommonList list = res.getEntity();
+ ClientResponse<AbstractCommonList> res = client.readList();
+ AbstractCommonList list = res.getEntity();
int statusCode = res.getStatus();
// Check the status code of the response: does it match
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
// Optionally output additional data about list members for debugging.
- boolean iterateThroughList = false;
- if (iterateThroughList && logger.isDebugEnabled()) {
- List<VocabulariesCommonList.VocabularyListItem> items =
- list.getVocabularyListItem();
- int i = 0;
- for (VocabulariesCommonList.VocabularyListItem item : items) {
- String csid = item.getCsid();
- logger.debug(testName + ": list-item[" + i + "] csid="
- + csid);
- logger.debug(testName + ": list-item[" + i + "] displayName="
- + item.getDisplayName());
- logger.debug(testName + ": list-item[" + i + "] URI="
- + item.getUri());
- readItemListInt(csid, null, "readList");
- i++;
- }
+ if(logger.isTraceEnabled()){
+ AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
}
}
// Submit the request to the service and store the response.
VocabularyClient client = new VocabularyClient();
- ClientResponse<VocabularyitemsCommonList> res = null;
+ ClientResponse<AbstractCommonList> res = null;
if (vcsid != null) {
res = client.readItemList(vcsid, null, null);
} else if (shortId != null) {
} else {
Assert.fail("Internal Error: readItemList both vcsid and shortId are null!");
}
- VocabularyitemsCommonList list = res.getEntity();
+ AbstractCommonList list = res.getEntity();
int statusCode = res.getStatus();
// Check the status code of the response: does it match
invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- List<VocabularyitemsCommonList.VocabularyitemListItem> items =
- list.getVocabularyitemListItem();
+ List<AbstractCommonList.ListItem> items = list.getListItem();
int nItemsReturned = items.size();
long nItemsTotal = list.getTotalItems();
if (logger.isDebugEnabled()) {
}
Assert.assertEquals(nItemsTotal, nItemsToCreateInList);
- // Optionally output additional data about list members for debugging.
- boolean iterateThroughList = true;
- if (iterateThroughList && logger.isDebugEnabled()) {
- logger.debug(" " + testName + ": checking items");
- int i = 0;
- for (VocabularyitemsCommonList.VocabularyitemListItem item : items) {
- logger.debug(" " + testName + ": list-item[" + i + "] csid="
- + item.getCsid());
- logger.debug(" " + testName + ": list-item[" + i + "] displayName="
- + item.getDisplayName());
- logger.debug(" " + testName + ": list-item[" + i + "] URI="
- + item.getUri());
- i++;
- }
+ if(logger.isTraceEnabled()){
+ AbstractCommonListUtils.ListItemsInAbstractCommonList(list, logger, testName);
}
}
</xs:sequence>
</xs:complexType>
</xs:element>
-
- <!-- This is the base class for paginated lists -->
- <xs:complexType name="abstractCommonList">
- <xs:annotation>
- <xs:appinfo>
- <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
- </xs:appinfo>
- </xs:annotation>
- </xs:complexType>
-
- <!-- Vocabulary instances, as in nuxeo repository -->
- <xs:element name="vocabularies-common-list">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="abstractCommonList">
- <xs:sequence>
- <xs:element name="vocabulary-list-item" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="displayName" type="xs:string"
- minOccurs="1" />
- <xs:element name="refName" type="xs:string"
- minOccurs="1" />
- <xs:element name="shortIdentifier" type="xs:string"
- minOccurs="1" />
- <xs:element name="vocabType" type="xs:string"
- minOccurs="1" />
- <!-- uri to retrieve vocabulary details -->
- <xs:element name="uri" type="xs:anyURI"
- minOccurs="1" />
- <xs:element name="csid" type="xs:string"
- minOccurs="1" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
-
</xs:schema>
</xs:sequence>
</xs:complexType>
</xs:element>
-
- <!-- This is the base class for paginated lists -->
- <xs:complexType name="abstractCommonListItem">
- <xs:annotation>
- <xs:appinfo>
- <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
- </xs:appinfo>
- </xs:annotation>
- </xs:complexType>
-
- <!-- Vocabularyitem instances, as in nuxeo repository -->
- <xs:element name="vocabularyitems-common-list">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="abstractCommonListItem">
- <xs:sequence>
- <xs:element name="vocabularyitem_list_item" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="displayName" type="xs:string"
- minOccurs="1"/>
- <xs:element name="shortIdentifier" type="xs:string"
- minOccurs="1"/>
- <xs:element name="order" type="xs:string"
- minOccurs="0"/>
- <!-- uri to retrieve vocabularyitem details -->
- <xs:element name="uri" type="xs:anyURI"
- minOccurs="1"/>
- <xs:element name="refName" type="xs:string"
- minOccurs="1"/>
- <xs:element name="csid" type="xs:string"
- minOccurs="1"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
-
</xs:schema>
@Path("/" + VocabularyClient.SERVICE_PATH_COMPONENT)
public class VocabularyResource extends
- AuthorityResource<VocabulariesCommon, VocabulariesCommonList, VocabularyitemsCommonList,
- VocabularyItemDocumentModelHandler> {
+ AuthorityResource<VocabulariesCommon, VocabularyItemDocumentModelHandler> {
private final static String vocabularyServiceName = VocabularyClient.SERVICE_PATH_COMPONENT;
*/
package org.collectionspace.services.vocabulary.nuxeo;
-import java.util.Iterator;
-import java.util.List;
-
-import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema;
import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityDocumentModelHandler;
-import org.collectionspace.services.common.document.DocumentWrapper;
import org.collectionspace.services.vocabulary.VocabulariesCommon;
-import org.collectionspace.services.vocabulary.VocabulariesCommonList;
-import org.collectionspace.services.vocabulary.VocabulariesCommonList.VocabularyListItem;
-
-import org.collectionspace.services.nuxeo.util.NuxeoUtils;
-import org.collectionspace.services.jaxb.AbstractCommonList;
-import org.nuxeo.ecm.core.api.DocumentModel;
-import org.nuxeo.ecm.core.api.DocumentModelList;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* VocabularyDocumentModelHandler
* $LastChangedDate: $
*/
public class VocabularyDocumentModelHandler
- extends AuthorityDocumentModelHandler<VocabulariesCommon, VocabulariesCommonList> {
+ extends AuthorityDocumentModelHandler<VocabulariesCommon> {
/**
* Common part schema label
public VocabularyDocumentModelHandler() {
super(COMMON_PART_LABEL);
}
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPartList(org.collectionspace.services.common.document.DocumentWrapper)
- */
- @Override
- public VocabulariesCommonList extractCommonPartList(
- DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
- String label = getServiceContext().getCommonPartLabel();
- VocabulariesCommonList coList = extractPagingInfo(new VocabulariesCommonList(), wrapDoc);
- AbstractCommonList commonList = (AbstractCommonList) coList;
- commonList.setFieldsReturned("displayName|refName|shortIdentifier|vocabType|uri|csid");
- List<VocabulariesCommonList.VocabularyListItem> list = coList.getVocabularyListItem();
- Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
- while(iter.hasNext()){
- DocumentModel docModel = iter.next();
- VocabularyListItem ilistItem = new VocabularyListItem();
- ilistItem.setDisplayName((String) docModel.getProperty(label,
- AuthorityJAXBSchema.DISPLAY_NAME));
- ilistItem.setRefName((String) docModel.getProperty(label,
- AuthorityJAXBSchema.REF_NAME));
- ilistItem.setShortIdentifier((String) docModel.getProperty(label,
- AuthorityJAXBSchema.SHORT_IDENTIFIER));
- ilistItem.setVocabType((String) docModel.getProperty(label,
- AuthorityJAXBSchema.VOCAB_TYPE));
- String id = getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString());
- ilistItem.setUri(getServiceContextPath() + id);
- ilistItem.setCsid(id);
- list.add(ilistItem);
- }
-
- return coList;
- }
/**
* getQProperty converts the given property to qualified schema property
*/
package org.collectionspace.services.vocabulary.nuxeo;
-import java.util.Iterator;
-import java.util.List;
-
import org.collectionspace.services.client.VocabularyClient;
-import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema;
-import org.collectionspace.services.common.document.DocumentWrapper;
import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityItemDocumentModelHandler;
-import org.collectionspace.services.nuxeo.util.NuxeoUtils;
-import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.vocabulary.VocabularyitemsCommon;
-import org.collectionspace.services.vocabulary.VocabularyitemsCommonList;
-import org.collectionspace.services.vocabulary.VocabularyitemsCommonList.VocabularyitemListItem;
-import org.nuxeo.ecm.core.api.DocumentModel;
-import org.nuxeo.ecm.core.api.DocumentModelList;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* VocabularyItemDocumentModelHandler
* $LastChangedDate: $
*/
public class VocabularyItemDocumentModelHandler
- extends AuthorityItemDocumentModelHandler<VocabularyitemsCommon, VocabularyitemsCommonList> {
+ extends AuthorityItemDocumentModelHandler<VocabularyitemsCommon> {
- private final Logger logger = LoggerFactory.getLogger(VocabularyItemDocumentModelHandler.class);
-
private static final String COMMON_PART_LABEL = "vocabularyitems_common";
public VocabularyItemDocumentModelHandler() {
public String getAuthorityServicePath(){
return VocabularyClient.SERVICE_PATH_COMPONENT; // CSPACE-3932
}
-
- @Override
- public VocabularyitemsCommonList extractCommonPartList(
- DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
- VocabularyitemsCommonList coList = extractPagingInfo(new VocabularyitemsCommonList(), wrapDoc);
- AbstractCommonList commonList = (AbstractCommonList) coList;
- commonList.setFieldsReturned("displayName|refName|shortIdentifier|order|uri|csid");
-
- List<VocabularyitemsCommonList.VocabularyitemListItem> list = coList.getVocabularyitemListItem();
- Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
- String commonPartLabel = getServiceContext().getCommonPartLabel("vocabularyItems");
- while (iter.hasNext()) {
- DocumentModel docModel = iter.next();
- VocabularyitemListItem ilistItem = new VocabularyitemListItem();
- ilistItem.setDisplayName((String) docModel.getProperty(commonPartLabel,
- AuthorityItemJAXBSchema.DISPLAY_NAME));
- ilistItem.setShortIdentifier((String) docModel.getProperty(commonPartLabel,
- AuthorityItemJAXBSchema.SHORT_IDENTIFIER));
- ilistItem.setRefName((String) docModel.getProperty(commonPartLabel,
- AuthorityItemJAXBSchema.REF_NAME));
- ilistItem.setOrder((String) docModel.getProperty(commonPartLabel,
- AuthorityItemJAXBSchema.ORDER));
- String id = getCsid(docModel);//NuxeoUtils.extractId(docModel.getPathAsString());
- ilistItem.setUri("/vocabularies/" + inAuthority + "/items/" + id);
- ilistItem.setCsid(id);
- list.add(ilistItem);
- }
-
- return coList;
- }
-
/**
* getQProperty converts the given property to qualified schema property
* @param prop