* Most of the authority child classes will/should use this implementation. However, the Vocabulary service's item schema is
* different enough that it will have to override this method in it's resource class.
*/
+ @Override
protected String getOrderByField() {
String result = null;
import java.util.ArrayList;\r
import java.util.List;\r
\r
+import org.collectionspace.services.common.context.ServiceContext;\r
+import org.collectionspace.services.common.document.DocumentException;\r
import org.collectionspace.services.common.document.DocumentHandler;\r
import org.collectionspace.services.config.RepositoryClientConfigType;\r
import org.collectionspace.services.config.ServiceConfig;\r
+import org.collectionspace.services.config.service.DocHandlerParams;\r
import org.collectionspace.services.config.service.ServiceBindingType;\r
import org.collectionspace.services.config.tenant.TenantBindingType;\r
import org.collectionspace.services.config.types.PropertyItemType;\r
\r
final static Logger logger = LoggerFactory.getLogger(ServiceConfigUtils.class);\r
\r
+ /*\r
+ * Returns the document handler parameters that were loaded at startup from the\r
+ * tenant bindings config file.\r
+ */\r
+ public static DocHandlerParams.Params getDocHandlerParams(ServiceContext ctx) throws DocumentException {\r
+ ServiceBindingType sb = ctx.getServiceBinding();\r
+ DocHandlerParams dhb = sb.getDocHandlerParams();\r
+ if (dhb != null && dhb.getParams() != null) {\r
+ return dhb.getParams();\r
+ }\r
+ throw new DocumentException("No DocHandlerParams configured for: "\r
+ + sb.getName());\r
+ }\r
+ \r
/**\r
* Creates the document handler instance.\r
* \r
abstract protected String getRefnameDisplayName(DocumentWrapper<WT> docWrapper);
+ abstract protected String getOrderByField();
+
/*
* Should return a reference name for the wrapper object
*/
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;
result = getStringValue(docModel, schema, field);
} catch (Exception e) {
- // TODO Auto-generated catch block
if (logger.isWarnEnabled()) {
logger.warn(String.format("Call failed to getRefnameDisplayName() for class %s", this.getClass().getName()));
}