final static String URN_PREFIX_ID = "id(";
final static int URN_ID_PREFIX_LEN = URN_PREFIX_LEN + URN_PREFIX_ID.length();
final static String FETCH_SHORT_ID = "_fetch_";
+ final static String PARENT_WILDCARD = "_ALL_";
+
final Logger logger = LoggerFactory.getLogger(AuthorityResource.class);
public enum SpecifierForm {
// Note that docType defaults to the ServiceName, so we're fine with that.
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = null;
- String parentcsid = lookupParentCSID(specifier, "getAuthorityItemList", "LIST", queryParams);
+ String parentcsid = PARENT_WILDCARD.equals(specifier)?null:
+ lookupParentCSID(specifier, "getAuthorityItemList", "LIST", queryParams);
ctx = createServiceContext(getItemServiceName(), queryParams);
+
+ // For the wildcard case, parentcsid is null, but docHandler will deal with this.
// We omit the parentShortId, only needed when doing a create...
- DocumentHandler handler = createItemDocumentHandler(ctx,
- parentcsid, null);
+ DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid, null);
+
DocumentFilter myFilter = handler.getDocumentFilter();
// Need to make the default sort order for authority items
// be on the displayName field
if (sortBy == null || sortBy.isEmpty()) {
myFilter.setOrderByClause(qualifiedDisplayNameField);
}
-
- myFilter.appendWhereClause(authorityItemCommonSchemaName + ":"
- + AuthorityItemJAXBSchema.IN_AUTHORITY + "="
- + "'" + parentcsid + "'",
- IQueryManager.SEARCH_QUALIFIER_AND);
+
+ // If we are not wildcarding the parent, add a restriction
+ if(parentcsid!=null) {
+ myFilter.appendWhereClause(authorityItemCommonSchemaName + ":"
+ + AuthorityItemJAXBSchema.IN_AUTHORITY + "="
+ + "'" + parentcsid + "'",
+ IQueryManager.SEARCH_QUALIFIER_AND);
+ }
if (Tools.notBlank(termStatus)) {
// Start with the qualified termStatus field
import org.collectionspace.services.relation.RelationsCommonList;
import org.collectionspace.services.relation.RelationsDocListItem;
import org.collectionspace.services.relation.RelationshipType;
+import org.nuxeo.ecm.core.api.ClientException;
import org.nuxeo.ecm.core.api.DocumentModel;
import org.nuxeo.ecm.core.api.model.PropertyException;
import org.nuxeo.ecm.core.api.model.PropertyNotFoundException;
/**
* inVocabulary is the parent Authority for this context
*/
- protected String inAuthority;
- protected String authorityRefNameBase;
+ protected String inAuthority = null;
+ protected String authorityRefNameBase = null;
// Used to determine when the displayName changes as part of the update.
protected String oldDisplayNameOnUpdate = null;
protected String oldRefNameOnUpdate = null;
this.authorityItemCommonSchemaName = authorityItemCommonSchemaName;
}
- public String getInAuthority() {
- return inAuthority;
- }
-
public void setInAuthority(String inAuthority) {
this.inAuthority = inAuthority;
}
public String getUri(DocumentModel docModel) {
// Laramie20110510 CSPACE-3932
String authorityServicePath = getAuthorityServicePath();
+ if(inAuthority==null) { // Only happens on queries to wildcarded authorities
+ try {
+ inAuthority = (String) docModel.getProperty(authorityItemCommonSchemaName,
+ AuthorityItemJAXBSchema.IN_AUTHORITY);
+ } catch (ClientException pe) {
+ throw new RuntimeException("Could not get parent specifier for item!");
+ }
+ }
return "/" + authorityServicePath + '/' + inAuthority + '/' + AuthorityClient.ITEMS + '/' + getCsid(docModel);
}
- public String getAuthorityRefNameBase() {
+ protected String getAuthorityRefNameBase() {
return this.authorityRefNameBase;
}
* @throws Exception the exception
*/
private void handleInAuthority(DocumentModel docModel) throws Exception {
+ if(inAuthority==null) { // Only happens on queries to wildcarded authorities
+ throw new IllegalStateException("Trying to Create an object with no inAuthority value!");
+ }
docModel.setProperty(authorityItemCommonSchemaName,
AuthorityItemJAXBSchema.IN_AUTHORITY, inAuthority);
}