return vocabularyProxy.readItemList(vcsid);
}
+ /**
+ * Read item list for named vocabulary.
+ *
+ * @param specifier the specifier
+ * @return the client response
+ */
+ public ClientResponse<VocabularyitemsCommonList> readItemListForNamedVocabulary(String specifier) {
+ return vocabularyProxy.readItemListForNamedVocabulary(specifier);
+ }
+
/**
* Read item.
*
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
import org.collectionspace.services.vocabulary.VocabulariesCommonList;
import org.collectionspace.services.vocabulary.VocabularyitemsCommonList;
@Produces({"application/xml"})
@Path("/{vcsid}/items/")
ClientResponse<VocabularyitemsCommonList> readItemList(@PathParam("vcsid") String vcsid);
+
+ // List Items using the name of the Vocab
+ @GET
+ @Produces({"application/xml"})
+ @Path("/urn:cspace:name({specifier})/items")
+ ClientResponse<VocabularyitemsCommonList> readItemListForNamedVocabulary(@PathParam("specifier") String specifier);
//(C)reate Item
@POST
@Override
@Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
- dependsOnMethods = {"create", "createItem"})
+ dependsOnMethods = {"create", "createItem", "readItem"})
public void createList(String testName) throws Exception {
for (int i = 0; i < 3; i++) {
// Force create to reset the known resource info
item.getDisplayName());
logger.debug(testName + ": list-item[" + i + "] URI=" +
item.getUri());
- readItemList(csid);
+ readItemListInt(csid, null, "readList");
i++;
}
}
}
- @Test(dependsOnMethods = {"createList", "readItem"})
- public void readItemList() {
- readItemList(knownResourceId);
+ @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ dependsOnMethods = {"createList", "readItem"})
+ public void readItemList(String testName) {
+ readItemListInt(knownResourceId, null, testName);
}
- private void readItemList(String vcsid) {
+ @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ dependsOnMethods = {"createList", "readItem"})
+ public void readItemListByName(String testName) {
+ readItemListInt(null, knownResourceShortIdentifer, testName);
+ }
- final String testName = "readItemList";
+ private void readItemListInt(String vcsid, String shortId, String testName) {
// Perform setup.
setupReadList();
// Submit the request to the service and store the response.
VocabularyClient client = new VocabularyClient();
- ClientResponse<VocabularyitemsCommonList> res =
- client.readItemList(vcsid);
+ ClientResponse<VocabularyitemsCommonList> res = null;
+ if(vcsid!=null) {
+ res = client.readItemList(vcsid);
+ } else if(shortId!=null) {
+ res = client.readItemListForNamedVocabulary(shortId);
+ } else {
+ Assert.fail("Internal Error: readItemList both vcsid and shortId are null!");
+ }
VocabularyitemsCommonList list = res.getEntity();
int statusCode = res.getStatus();
return vocabularyItemObjectList;
}
+
+ /**
+ * Gets the vocabulary item list.
+ *
+ * @param parentcsid the parentcsid
+ * @param partialTerm the partial term
+ * @param ui the ui
+ *
+ * @return the vocabulary item list
+ */
+ @GET
+ @Path("urn:cspace:name({specifier})/items")
+ @Produces("application/xml")
+ public VocabularyitemsCommonList getVocabularyItemListByVocabName(
+ @PathParam("specifier") String specifier,
+ @QueryParam(IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm,
+ @Context UriInfo ui) {
+ try {
+ MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
+ String whereClause =
+ VocabularyJAXBSchema.VOCABULARIES_COMMON+
+ ":"+VocabularyJAXBSchema.SHORT_IDENTIFIER+
+ "='"+specifier+"'";
+ // Need to get an Authority by name
+ ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
+ String parentcsid = getRepositoryClient(ctx).findDocCSID(ctx, whereClause);
+ return getVocabularyItemList(parentcsid, partialTerm, ui);
+ } catch (UnauthorizedException ue) {
+ Response response = Response.status(
+ Response.Status.UNAUTHORIZED).entity("Index failed reason " + ue.getErrorReason()).type("text/plain").build();
+ throw new WebApplicationException(response);
+ } catch (Exception e) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Caught exception in getVocabularyItemListByVocabName", e);
+ }
+ Response response = Response.status(
+ Response.Status.INTERNAL_SERVER_ERROR).entity("Index failed").type("text/plain").build();
+ throw new WebApplicationException(response);
+ }
+
+ }
+
+
+
/**
* Update vocabulary item.
*