* different enough that it will have to override this method in it's resource class.
*/
@Override
- protected String getOrderByField() {
+ protected String getOrderByField(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx) {
String result = null;
result = NuxeoUtils.getPrimaryElPathPropertyName(
return result;
}
- protected String getPartialTermMatchField() {
+ @Override
+ protected String getPartialTermMatchField(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx) {
String result = null;
result = NuxeoUtils.getMultiElPathPropertyName(
public ServiceContextFactory<PoxPayloadIn, PoxPayloadOut> getServiceContextFactory() {\r
return MultipartServiceContextFactory.get();\r
}\r
+ \r
+ abstract protected String getOrderByField(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx); \r
\r
+ abstract protected String getPartialTermMatchField(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx);\r
+ \r
@Override\r
public DocumentHandler createDocumentHandler(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx) throws Exception {\r
return createDocumentHandler(ctx, ctx.getCommonPartLabel(), getCommonPartClass());\r
import org.collectionspace.services.common.api.RefName;\r
import org.collectionspace.services.common.api.Tools;\r
import org.collectionspace.services.common.authorityref.AuthorityRefList;\r
+import org.collectionspace.services.common.config.ServiceConfigUtils;\r
import org.collectionspace.services.common.context.ServiceContext;\r
import org.collectionspace.services.common.document.DocumentFilter;\r
import org.collectionspace.services.common.document.DocumentHandler;\r
import org.collectionspace.services.common.vocabulary.RefNameServiceUtils;\r
import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.AuthRefConfigInfo;\r
import org.collectionspace.services.config.ClientType;\r
+import org.collectionspace.services.config.service.DocHandlerParams;\r
+import org.collectionspace.services.config.service.ListResultField;\r
import org.collectionspace.services.jaxb.AbstractCommonList;\r
import org.collectionspace.services.nuxeo.client.java.DocumentModelHandler;\r
import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;\r
}\r
\r
//======================== UTILITY : getDocModelForRefName ========================================\r
+\r
+ /*\r
+ * Used get the order by field for list results if one is not specified with an HTTP query param.\r
+ * \r
+ * (non-Javadoc)\r
+ * @see org.collectionspace.services.common.document.AbstractDocumentHandlerImpl#getOrderByField()\r
+ */\r
+ @Override\r
+ protected String getOrderByField(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx) {\r
+ String result = null;\r
+ \r
+ DocHandlerParams.Params params = null;\r
+ try {\r
+ result = getPartialTermMatchField(ctx);\r
+ if (result == null) {\r
+ throw new Exception();\r
+ }\r
+ } catch (Exception e) {\r
+ if (logger.isWarnEnabled()) {\r
+ logger.warn(String.format("Call failed to getOrderByField() for class %s", this.getClass().getName()));\r
+ }\r
+ }\r
+ \r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ protected String getPartialTermMatchField(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx) {\r
+ String result = null;\r
+ \r
+ DocHandlerParams.Params params = null;\r
+ try {\r
+ params = ServiceConfigUtils.getDocHandlerParams(ctx);\r
+ ListResultField field = params.getRefnameDisplayNameField();\r
+ result = field.getSchema() + ":" + field.getXpath();\r
+ } catch (Exception e) {\r
+ if (logger.isWarnEnabled()) {\r
+ logger.warn(String.format("Call failed to getPartialTermMatchField() for class %s", this.getClass().getName()));\r
+ }\r
+ }\r
+ \r
+ return result;\r
+ }\r
+ \r
/*\r
* ResourceBase create and update calls will set the resourceMap into the service context\r
* for all inheriting resource classes. Just use ServiceContext.getResourceMap() to get\r
return getDocModelForAuthorityItem(repoSession, RefName.AuthorityItem.parse(refName));\r
}\r
\r
+ \r
}\r
}
abstract protected String getRefnameDisplayName(DocumentWrapper<WT> docWrapper);
-
- abstract protected String getOrderByField();
-
+
/*
* Should return a reference name for the wrapper object
*/
import org.collectionspace.services.client.workflow.WorkflowClient;
import org.collectionspace.services.common.ResourceBase;
import org.collectionspace.services.common.authorityref.AuthorityRefList;
+import org.collectionspace.services.common.config.ServiceConfigUtils;
import org.collectionspace.services.common.context.JaxRsContext;
import org.collectionspace.services.common.context.MultipartServiceContext;
import org.collectionspace.services.common.context.ServiceBindingUtils;
+ MultipartServiceContext.class.getName());
}
}
-
- /*
- * Returns the document handler parameters that were loaded at startup from the
- * tenant bindings config file.
- */
- public DocHandlerParams.Params getDocHandlerParams() throws DocumentException {
- MultipartServiceContext sc = (MultipartServiceContext) getServiceContext();
- ServiceBindingType sb = sc.getServiceBinding();
- DocHandlerParams dhb = sb.getDocHandlerParams();
- if (dhb != null && dhb.getParams() != null) {
- return dhb.getParams();
- }
- throw new DocumentException("No DocHandlerParams configured for: "
- + sb.getName());
- }
@Override
protected String getRefnameDisplayName(DocumentWrapper<DocumentModel> docWrapper) {
return getRefnameDisplayName(docWrapper.getWrappedObject());
}
-
- /*
- * Used get the order by field for list results if one is not specified with an HTTP query param.
- *
- * (non-Javadoc)
- * @see org.collectionspace.services.common.document.AbstractDocumentHandlerImpl#getOrderByField()
- */
- @Override
- protected String getOrderByField() {
- String result = null;
- DocHandlerParams.Params params = null;
- try {
- params = getDocHandlerParams();
- ListResultField field = params.getRefnameDisplayNameField();
- result = field.getSchema() + ":" + field.getXpath();
- } catch (Exception e) {
- if (logger.isWarnEnabled()) {
- logger.warn(String.format("Call failed to getOrderByField() for class %s", this.getClass().getName()));
- }
- }
-
- return result;
- }
-
private String getRefnameDisplayName(DocumentModel docModel) { // Look in the tenant bindings to see what field should be our display name for our refname value
String result = null;
+ ServiceContext ctx = this.getServiceContext();
DocHandlerParams.Params params = null;
try {
- params = getDocHandlerParams();
+ params = ServiceConfigUtils.getDocHandlerParams(ctx);
ListResultField field = params.getRefnameDisplayNameField();
String schema = field.getSchema();
if (schema == null || schema.trim().isEmpty()) {
- schema = getServiceContext().getCommonPartLabel();
+ schema = ctx.getCommonPartLabel();
}
result = getStringValue(docModel, schema, field);