import org.collectionspace.services.common.StoredValuesUriTemplate;
import org.collectionspace.services.common.UriInfoWrapper;
import org.collectionspace.services.common.UriTemplateFactory;
-import org.collectionspace.services.common.UriTemplateRegistry;
import org.collectionspace.services.common.UriTemplateRegistryKey;
import org.collectionspace.services.common.api.RefName;
import org.collectionspace.services.common.api.Tools;
final static String SEARCH_TYPE_TERMSTATUS = "ts";
public final static String hierarchy = "hierarchy";
+
+ private static final Integer PAGE_NUM_FROM_QUERYPARAMS = null;
+ private static final Integer PAGE_SIZE_FROM_QUERYPARAMS = null;
protected Class<AuthCommon> authCommonClass;
protected Class<?> resourceClass;
uriInfo = new UriInfoWrapper(uriInfo);
AuthorityRefDocList authRefDocList = null;
try {
- authRefDocList = getReferencingObjects(null, parentSpecifier, itemSpecifier, uriInfo);
+ authRefDocList = getReferencingObjects(null, parentSpecifier, itemSpecifier, uriInfo, PAGE_NUM_FROM_QUERYPARAMS, PAGE_SIZE_FROM_QUERYPARAMS, true, true);
} catch (Exception e) {
throw bigReThrow(e, ServiceMessages.GET_FAILED);
}
ServiceContext<PoxPayloadIn, PoxPayloadOut> existingContext,
String parentspecifier,
String itemspecifier,
- UriInfo uriInfo) throws Exception {
+ UriInfo uriInfo,
+ Integer pageNum,
+ Integer pageSize,
+ boolean useDefaultOrderByClause,
+ boolean computeTotal) throws Exception {
AuthorityRefDocList authRefDocList = null;
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(getItemServiceName(), uriInfo);
}
AuthorityItemDocumentModelHandler handler = (AuthorityItemDocumentModelHandler)createItemDocumentHandler(ctx, parentcsid, null);
- authRefDocList = handler.getReferencingObjects(ctx, serviceTypes, getRefPropName(), itemcsid);
+ authRefDocList = handler.getReferencingObjects(ctx, serviceTypes, getRefPropName(), itemcsid, pageNum, pageSize, useDefaultOrderByClause, computeTotal);
return authRefDocList;
}
private final Logger logger = LoggerFactory.getLogger(AuthorityItemDocumentModelHandler.class);
+ private static final Integer PAGE_SIZE_FROM_QUERYPARAMS = null;
+ private static final Integer PAGE_NUM_FROM_QUERYPARAMS = null;
+
protected String authorityCommonSchemaName;
protected String authorityItemCommonSchemaName;
private String authorityItemTermGroupXPathBase;
//
DocumentModel docModel = wrapDoc.getWrappedObject();
if (transitionDef.getName().equalsIgnoreCase(WorkflowClient.WORKFLOWTRANSITION_DELETE)) {
- AuthorityRefDocList refsToAllObjects = getReferencingObjects(ctx, docModel, RefObjsSearchType.ALL);
- AuthorityRefDocList refsToSoftDeletedObjects = getReferencingObjects(ctx, docModel, RefObjsSearchType.DELETED_ONLY);
+ AuthorityRefDocList refsToAllObjects = getReferencingObjectsForStateTransitions(ctx, docModel, RefObjsSearchType.ALL);
+ AuthorityRefDocList refsToSoftDeletedObjects = getReferencingObjectsForStateTransitions(ctx, docModel, RefObjsSearchType.DELETED_ONLY);
if (refsToAllObjects.getTotalItems() > 0) {
if (refsToAllObjects.getTotalItems() > refsToSoftDeletedObjects.getTotalItems()) {
//
ServiceContext ctx = getServiceContext();
DocumentModel docModel = wrapDoc.getWrappedObject();
- AuthorityRefDocList refsToAllObjects = getReferencingObjects(ctx, docModel, RefObjsSearchType.ALL);
- AuthorityRefDocList refsToSoftDeletedObjects = getReferencingObjects(ctx, docModel, RefObjsSearchType.DELETED_ONLY);
+ AuthorityRefDocList refsToAllObjects = getReferencingObjectsForStateTransitions(ctx, docModel, RefObjsSearchType.ALL);
+ AuthorityRefDocList refsToSoftDeletedObjects = getReferencingObjectsForStateTransitions(ctx, docModel, RefObjsSearchType.DELETED_ONLY);
if (refsToAllObjects.getTotalItems() > 0) {
if (refsToAllObjects.getTotalItems() > refsToSoftDeletedObjects.getTotalItems()) {
//
* @throws Exception
*/
@SuppressWarnings("rawtypes")
- private AuthorityRefDocList getReferencingObjects(ServiceContext ctx, DocumentModel docModel, RefObjsSearchType searchType) throws Exception {
- AuthorityRefDocList result = null;
+ private AuthorityRefDocList getReferencingObjectsForStateTransitions(
+ ServiceContext ctx,
+ DocumentModel docModel,
+ RefObjsSearchType searchType) throws Exception {
+ AuthorityRefDocList referenceList = null;
if (ctx.getUriInfo() == null) {
//
//
boolean doesContainValue = ctx.getUriInfo().getQueryParameters().containsKey(WorkflowClient.WORKFLOW_QUERY_DELETED_QP);
String previousValue = ctx.getUriInfo().getQueryParameters().getFirst(WorkflowClient.WORKFLOW_QUERY_DELETED_QP);
+
try {
if (doesContainValue) {
ctx.getUriInfo().getQueryParameters().remove(WorkflowClient.WORKFLOW_QUERY_DELETED_QP);
}
AuthorityResource authorityResource = (AuthorityResource)ctx.getResource(getAuthorityServicePath());
- result = getReferencingObjects(authorityResource, ctx, docModel, searchType);
+ referenceList = getReferencingObjects(authorityResource, ctx, docModel, searchType, PAGE_NUM_FROM_QUERYPARAMS, PAGE_SIZE_FROM_QUERYPARAMS, true, true); // useDefaultOrderByClause=true, computeTotal=true
} finally {
if (doesContainValue) {
ctx.getUriInfo().getQueryParameters().addFirst(WorkflowClient.WORKFLOW_QUERY_DELETED_QP, previousValue);
}
}
- return result;
+ return referenceList;
}
+ @SuppressWarnings("rawtypes")
+ private AuthorityRefDocList getReferencingObjectsForMarkingTerm(
+ ServiceContext ctx,
+ DocumentModel docModel,
+ RefObjsSearchType searchType) throws Exception {
+ AuthorityRefDocList referenceList = null;
+
+ if (ctx.getUriInfo() == null) {
+ //
+ // We need a UriInfo object so we can pass "query" params to the AuthorityResource's getReferencingObjects() method
+ //
+ ctx.setUriInfo(this.getServiceContext().getUriInfo()); // try to get a UriInfo instance from the handler's context
+ }
+
+ //
+ // Since the call to get referencing objects might indirectly use the WorkflowClient.WORKFLOW_QUERY_NONDELETED query param, we need to
+ // temporarily remove that query param if it is set. If set, we'll save the value and reset once we're finished.
+ //
+ boolean doesContainValue = ctx.getUriInfo().getQueryParameters().containsKey(WorkflowClient.WORKFLOW_QUERY_DELETED_QP);
+ String previousValue = ctx.getUriInfo().getQueryParameters().getFirst(WorkflowClient.WORKFLOW_QUERY_DELETED_QP);
+
+ try {
+ if (doesContainValue) {
+ ctx.getUriInfo().getQueryParameters().remove(WorkflowClient.WORKFLOW_QUERY_DELETED_QP);
+ }
+ AuthorityResource authorityResource = (AuthorityResource)ctx.getResource(getAuthorityServicePath());
+ referenceList = getReferencingObjects(authorityResource, ctx, docModel, searchType, 0, 1, false, false); // pageNum=0, pageSize=1, useDefaultOrderClause=false, computeTotal=false
+ } finally {
+ if (doesContainValue) {
+ ctx.getUriInfo().getQueryParameters().addFirst(WorkflowClient.WORKFLOW_QUERY_DELETED_QP, previousValue);
+ }
+ }
+
+ return referenceList;
+ }
+
@SuppressWarnings({ "rawtypes", "unchecked" })
- private AuthorityRefDocList getReferencingObjects(AuthorityResource authorityResource, ServiceContext ctx, DocumentModel docModel, RefObjsSearchType searchType) throws Exception {
+ private AuthorityRefDocList getReferencingObjects(
+ AuthorityResource authorityResource,
+ ServiceContext ctx,
+ DocumentModel docModel,
+ RefObjsSearchType searchType,
+ Integer pageNum,
+ Integer pageSize,
+ boolean useDefaultOrderByClause,
+ boolean computeTotal) throws Exception {
AuthorityRefDocList result = null;
String inAuthorityCsid = (String) docModel.getProperty(authorityItemCommonSchemaName, AuthorityItemJAXBSchema.IN_AUTHORITY);
ctx.getUriInfo().getQueryParameters().addFirst(WorkflowClient.WORKFLOW_QUERY_ONLY_DELETED_QP, Boolean.TRUE.toString()); // Add the wf_only_deleted query param to get only soft-deleted items
break;
}
- result = authorityResource.getReferencingObjects(ctx, inAuthorityCsid, itemCsid, ctx.getUriInfo());
+ result = authorityResource.getReferencingObjects(ctx, inAuthorityCsid, itemCsid, ctx.getUriInfo(), pageNum, pageSize, useDefaultOrderByClause, computeTotal);
} finally {
//
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
List<String> serviceTypes,
String propertyName,
- String itemcsid) throws Exception {
+ String itemcsid,
+ Integer pageNum,
+ Integer pageSize,
+ boolean useDefaultOrderByClause,
+ boolean computeTotal) throws Exception {
AuthorityRefDocList authRefDocList = null;
CoreSessionInterface repoSession = (CoreSessionInterface) ctx.getCurrentRepositorySession();
boolean releaseRepoSession = false;
releaseRepoSession = true;
}
DocumentFilter myFilter = getDocumentFilter();
+ if (pageSize != null) {
+ myFilter.setPageSize(pageSize);
+ }
+ if (pageNum != null) {
+ myFilter.setStartPage(pageNum);
+ }
+ myFilter.setUseDefaultOrderByClause(useDefaultOrderByClause);
try {
DocumentWrapper<DocumentModel> wrapper = repoClient.getDoc(repoSession, ctx, itemcsid);
DocumentModel docModel = wrapper.getWrappedObject();
String refName = (String) NuxeoUtils.getProperyValue(docModel, AuthorityItemJAXBSchema.REF_NAME); //docModel.getPropertyValue(AuthorityItemJAXBSchema.REF_NAME);
authRefDocList = RefNameServiceUtils.getAuthorityRefDocs(
- repoSession, ctx, repoClient,
+ repoSession,
+ ctx,
+ repoClient,
serviceTypes,
refName,
propertyName,
- myFilter, true /*computeTotal*/);
+ myFilter,
+ useDefaultOrderByClause,
+ computeTotal /*computeTotal*/);
} catch (PropertyException pe) {
throw pe;
} catch (DocumentException de) {
return result;
}
+
+ private boolean isTermReferenced(DocumentModel docModel) throws Exception {
+ boolean result = false;
+
+ AuthorityRefDocList referenceList = null;
+ String wf_deletedStr = (String) getServiceContext().getQueryParams().getFirst(WorkflowClient.WORKFLOW_QUERY_DELETED_QP);
+ if (wf_deletedStr != null && Tools.isFalse(wf_deletedStr)) {
+ //
+ // if query param 'wf_deleted=false', we won't count references to soft-deleted records
+ //
+ referenceList = getReferencingObjectsForMarkingTerm(getServiceContext(), docModel, RefObjsSearchType.NON_DELETED);
+ } else {
+ //
+ // if query param 'wf_deleted=true' or missing, we count references to soft-deleted and active records
+ //
+ referenceList = getReferencingObjectsForMarkingTerm(getServiceContext(), docModel, RefObjsSearchType.ALL);
+ }
+
+ if (referenceList.getTotalItems() > 0) {
+ result = true;
+ }
+
+ return result;
+ }
+
+ @SuppressWarnings("unchecked")
@Override
protected Object getListResultValue(DocumentModel docModel, // REM - CSPACE-5133
String schema, ListResultField field) throws DocumentException {
- Object result = null;
+ Object result = null;
String fieldXPath = field.getXpath();
if (fieldXPath.equalsIgnoreCase(AuthorityClient.REFERENCED) == false) {
result = NuxeoUtils.getXPathValue(docModel, schema, field.getXpath());
} else {
//
- // Special case for the 'referenced' list result field.
+ // Check to see if the request is asking us to mark terms as referenced or not.
//
- // Set result value of field 'referenced' to 'true' if item is being referenced; otherwise, 'false'
- //
- try {
- result = Boolean.FALSE.toString();
- AuthorityRefDocList referenceList = null;
-
- String wf_deletedStr = (String) getServiceContext().getQueryParams().getFirst(WorkflowClient.WORKFLOW_QUERY_DELETED_QP);
- if (wf_deletedStr != null && Tools.isFalse(wf_deletedStr)) {
- //
- // if query param 'wf_deleted=false', we won't count references to soft-deleted records
- //
- referenceList = getReferencingObjects(getServiceContext(), docModel, RefObjsSearchType.NON_DELETED);
- } else {
- //
- // if query param 'wf_deleted=true' or missing, we count references to soft-deleted and active records
- //
- referenceList = getReferencingObjects(getServiceContext(), docModel, RefObjsSearchType.ALL);
- }
-
- if (referenceList.getTotalItems() > 0) {
- result = Boolean.TRUE.toString();
- }
-
- return result;
+ String markIfReferencedStr = (String) getServiceContext().getQueryParams().getFirst(AuthorityClient.MARK_IF_REFERENCED_QP);
+ if (Tools.isTrue(markIfReferencedStr) == false) {
+ return null; // leave the <referenced> element as null since they're not asking for it
+ } else try {
+ return Boolean.toString(isTermReferenced(docModel)); // set the <referenced> element to either 'true' or 'false'
} catch (Exception e) {
String msg = String.format("Failed while trying to find records referencing term CSID='%s'.", docModel.getName());
throw new DocumentException(msg, e);
public static final Boolean INCLUDE_DELETED_ITEMS = true;
public static final Boolean INCLUDE_RELATIONS = true;
public static final Boolean DONT_INCLUDE_RELATIONS = !INCLUDE_RELATIONS;
+ public static final String MARK_IF_REFERENCED_QP = "markIfReferenced";
/*
* Basic CRUD operations
/** The max page size. */
protected int pageSizeMax = DEFAULT_PAGE_SIZE_MAX_INIT; // The largest page size allowed. Can be overridden in the service-config.xml
+
/** The default page size. */
public static int defaultPageSize = DEFAULT_PAGE_SIZE_INIT; // Default page size if one is specified in the service-config.xml
+
/** The start page. */
protected int startPage; // Pagination offset for list results
+
/** The page size. */
protected int pageSize; // Pagination limit for list results
+ /** Flag to see if we should use default orderBy clause */
+ protected boolean useDefaultOrderByClause = true;
+
/** The total number of items for a query result -independent of paging restrictions.
*
*/
this.startPage = (theStartPage > 0) ? theStartPage : 0;
this.pageSize = (thePageSize > 0) ? thePageSize : defaultPageSize;
}
+
+ public void setUseDefaultOrderByClause(boolean flag) {
+ this.useDefaultOrderByClause = flag;
+ }
+
+ public boolean getUseDefaultOrderByClause() {
+ return this.useDefaultOrderByClause;
+ }
/**
* Sets the pagination.
* @return the order by clause
*/
public String getOrderByClause() {
- return this.orderByClause;
+ return this.orderByClause;
}
/**
String refName,
String targetField,
String orderByClause,
- int pageSize,
int pageNum,
+ int pageSize,
boolean computeTotal) throws DocumentException, DocumentNotFoundException {
List<String> docTypes = Arrays.asList(IRelationsManager.DOC_TYPE);
String query = String.format("%s:%s = '%s'", IRelationsManager.SERVICE_COMMONPART_NAME, targetField, escapedRefName);
NuxeoRepositoryClientImpl nuxeoRepoClient = (NuxeoRepositoryClientImpl) repoClient;
- DocumentWrapper<DocumentModelList> docListWrapper = nuxeoRepoClient.findDocs(ctx, repoSession,
- docTypes, query, orderByClause, pageSize, pageNum, computeTotal);
+ DocumentWrapper<DocumentModelList> docListWrapper = nuxeoRepoClient.findDocs(ctx,
+ repoSession,
+ docTypes,
+ query,
+ orderByClause,
+ pageNum,
+ pageSize,
+ true, // useDefaultOrderByClause if 'orderByClause' is null
+ computeTotal);
DocumentModelList docList = docListWrapper.getWrappedObject();
return docList;
oldRefName,
targetField,
ORDER_BY_VALUE,
- DEFAULT_PAGE_SIZE,
currentPage,
+ DEFAULT_PAGE_SIZE,
true);
if (docModelList == null) {
ServiceContext<IT, OT> ctx,
List<String> docTypes,
String where,
- int pageSize, int pageNum, boolean computeTotal)
- throws DocumentNotFoundException, DocumentException;
+ int pageNum,
+ int pageSize,
+ boolean useDefaultOrderByClause,
+ boolean computeTotal) throws DocumentNotFoundException, DocumentException;
/**
* Reindex a single resource/document.
String whereClauseAdditions,
String orderByClause,
int pageSize,
+ boolean useDefaultOrderByClause,
boolean computeTotal) throws DocumentException, DocumentNotFoundException {
this.ctx = ctx;
// into this initial page fetch. There's no need to compute totals
// when fetching subsequent pages.
- firstPageDocList = fetchPage(0, computeTotal);
+ firstPageDocList = fetchPage(0, computeTotal, useDefaultOrderByClause);
}
/**
* @throws DocumentNotFoundException
* @throws DocumentException
*/
- private DocumentModelList fetchPage(int pageNum, boolean computeTotal) throws DocumentNotFoundException, DocumentException {
- return RefNameServiceUtils.findAuthorityRefDocs(ctx, repoClient, repoSession,
- serviceTypes, refName, refPropName, queriedServiceBindings, authRefFieldsByService,
- whereClauseAdditions, orderByClause, pageSize, pageNum, computeTotal);
+ private DocumentModelList fetchPage(int pageNum, boolean computeTotal, boolean useDefaultOrderByClause) throws DocumentNotFoundException, DocumentException {
+ return RefNameServiceUtils.findAuthorityRefDocs(ctx,
+ repoClient,
+ repoSession,
+ serviceTypes,
+ refName,
+ refPropName,
+ queriedServiceBindings,
+ authRefFieldsByService,
+ whereClauseAdditions,
+ orderByClause,
+ pageNum,
+ pageSize,
+ useDefaultOrderByClause,
+ computeTotal);
}
@Override
DocumentModelList nextPageDocList = null;
try {
- nextPageDocList = fetchPage(nextPageNum, false);
+ nextPageDocList = fetchPage(nextPageNum, false, true);
}
catch(DocumentException e) {}
List<String> serviceTypes,
String refName,
String refPropName, // authRef or termRef, authorities or vocab terms.
- DocumentFilter filter, boolean computeTotal)
- throws DocumentException, DocumentNotFoundException {
+ DocumentFilter filter,
+ boolean useDefaultOrderByClause,
+ boolean computeTotal) throws DocumentException, DocumentNotFoundException {
AuthorityRefDocList wrapperList = new AuthorityRefDocList();
AbstractCommonList commonList = (AbstractCommonList) wrapperList;
int pageNum = filter.getStartPage();
// of possibly referencing documents will be false positives,
// so use a page size of double the requested page size to
// account for those.
- DocumentModelList docList = findAllAuthorityRefDocs(ctx, repoClient, repoSession,
- serviceTypes, refName, refPropName, queriedServiceBindings, authRefFieldsByService,
- filter.getWhereClause(), null, 2*pageSize, computeTotal);
+ DocumentModelList docList = findAllAuthorityRefDocs(ctx,
+ repoClient,
+ repoSession,
+ serviceTypes,
+ refName,
+ refPropName,
+ queriedServiceBindings,
+ authRefFieldsByService,
+ filter.getWhereClause(),
+ null, // orderByClause
+ 2*pageSize,
+ useDefaultOrderByClause,
+ computeTotal);
if (docList == null) { // found no authRef fields - nothing to process
return wrapperList;
boolean morePages = true;
while (morePages) {
- docList = findAuthorityRefDocs(ctx, repoClient, repoSession,
- getRefNameServiceTypes(), oldRefName, refPropName,
- queriedServiceBindings, authRefFieldsByService, WHERE_CLAUSE_ADDITIONS_VALUE, ORDER_BY_VALUE, pageSize, currentPage, false);
+ docList = findAuthorityRefDocs(ctx,
+ repoClient,
+ repoSession,
+ getRefNameServiceTypes(),
+ oldRefName,
+ refPropName,
+ queriedServiceBindings,
+ authRefFieldsByService,
+ WHERE_CLAUSE_ADDITIONS_VALUE,
+ ORDER_BY_VALUE,
+ currentPage,
+ pageSize,
+ true, // useDefaultOrderByClause
+ false); // computeTotal
if (docList == null) {
logger.debug("updateAuthorityRefDocs: no documents could be found that referenced the old refName");
String whereClauseAdditions,
String orderByClause,
int pageSize,
+ boolean useDefaultOrderByClause,
boolean computeTotal) throws DocumentException, DocumentNotFoundException {
- return new LazyAuthorityRefDocList(ctx, repoClient, repoSession,
- serviceTypes, refName, refPropName, queriedServiceBindings, authRefFieldsByService,
- whereClauseAdditions, orderByClause, pageSize, computeTotal);
+ return new LazyAuthorityRefDocList(ctx,
+ repoClient,
+ repoSession,
+ serviceTypes,
+ refName,
+ refPropName,
+ queriedServiceBindings,
+ authRefFieldsByService,
+ whereClauseAdditions,
+ orderByClause,
+ pageSize,
+ useDefaultOrderByClause,
+ computeTotal);
}
protected static DocumentModelList findAuthorityRefDocs(
Map<String, List<AuthRefConfigInfo>> authRefFieldsByService,
String whereClauseAdditions,
String orderByClause,
- int pageSize,
int pageNum,
+ int pageSize,
+ boolean useDefaultOrderByClause,
boolean computeTotal) throws DocumentException, DocumentNotFoundException {
// Get the service bindings for this tenant
- TenantBindingConfigReaderImpl tReader =
- ServiceMain.getInstance().getTenantBindingConfigReader();
+ TenantBindingConfigReaderImpl tReader = ServiceMain.getInstance().getTenantBindingConfigReader();
+
// We need to get all the procedures, authorities, and objects.
List<ServiceBindingType> servicebindings = tReader.getServiceBindingsByType(ctx.getTenantId(), serviceTypes);
if (servicebindings == null || servicebindings.isEmpty()) {
}
// Now we have to issue the search
NuxeoRepositoryClientImpl nuxeoRepoClient = (NuxeoRepositoryClientImpl) repoClient;
- DocumentWrapper<DocumentModelList> docListWrapper = nuxeoRepoClient.findDocs(ctx, repoSession,
- docTypes, query, orderByClause, pageSize, pageNum, computeTotal);
+ DocumentWrapper<DocumentModelList> docListWrapper = nuxeoRepoClient.findDocs(
+ ctx,
+ repoSession,
+ docTypes,
+ query,
+ orderByClause,
+ pageNum,
+ pageSize,
+ useDefaultOrderByClause,
+ computeTotal);
// Now we gather the info for each document into the list and return
DocumentModelList docList = docListWrapper.getWrappedObject();
return docList;
}
+
private static final boolean READY_FOR_COMPLEX_QUERY = true;
private static String computeWhereClauseForAuthorityRefDocs(
List<String> docTypes,
String whereClause,
String orderByClause,
- int pageSize,
int pageNum,
+ int pageSize,
+ boolean useDefaultOrderByClause,
boolean computeTotal)
throws DocumentNotFoundException, DocumentException {
DocumentWrapper<DocumentModelList> wrapDoc = null;
}
DocumentModelList docList = null;
QueryContext queryContext = new QueryContext(ctx, whereClause, orderByClause);
- String query = NuxeoUtils.buildNXQLQuery(docTypes, queryContext);
+ String query = NuxeoUtils.buildNXQLQuery(docTypes, queryContext, useDefaultOrderByClause);
if (logger.isDebugEnabled()) {
logger.debug("findDocs() NXQL: " + query);
}
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
DocumentHandler handler,
CoreSessionInterface repoSession,
- List<String> docTypes)
- throws DocumentNotFoundException, DocumentException {
+ List<String> docTypes) throws DocumentNotFoundException, DocumentException {
DocumentWrapper<DocumentModelList> wrapDoc = null;
DocumentFilter filter = handler.getDocumentFilter();
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
List<String> docTypes,
String whereClause,
- int pageSize, int pageNum, boolean computeTotal)
- throws DocumentNotFoundException, TransactionException, DocumentException {
+ int pageNum,
+ int pageSize,
+ boolean useDefaultOrderByClause,
+ boolean computeTotal) throws DocumentNotFoundException, TransactionException, DocumentException {
CoreSessionInterface repoSession = null;
DocumentWrapper<DocumentModelList> wrapDoc = null;
try {
repoSession = getRepositorySession(ctx);
- wrapDoc = findDocs(ctx, repoSession, docTypes, whereClause, null,
- pageSize, pageNum, computeTotal);
+ wrapDoc = findDocs(ctx,
+ repoSession,
+ docTypes,
+ whereClause,
+ null,
+ pageNum,
+ pageSize,
+ useDefaultOrderByClause,
+ computeTotal);
} catch (IllegalArgumentException iae) {
throw iae;
} catch (Exception e) {
* @param queryContext the query context
* @return an NXQL query
*/
- static public final String buildNXQLQuery(List<String> docTypes, QueryContext queryContext) throws Exception {
+ static public final String buildNXQLQuery(List<String> docTypes, QueryContext queryContext, boolean useDefaultOrderByClause) throws Exception {
StringBuilder query = new StringBuilder(queryContext.getSelectClause());
boolean fFirst = true;
for (String docType : docTypes) {
appendNXQLWhere(query, queryContext);
if (Tools.notBlank(queryContext.getOrderByClause())) {
appendNXQLOrderBy(query, queryContext.getOrderByClause(), null);
- } else {
+ } else if (useDefaultOrderByClause == true) {
// Across a set of mixed DocTypes, updatedAt is the most sensible default ordering
appendNXQLOrderBy(query, DocumentFilter.ORDER_BY_LAST_UPDATED, null);
}
return query.toString();
}
+ static public final String buildNXQLQuery(List<String> docTypes, QueryContext queryContext) throws Exception {
+ return buildNXQLQuery(docTypes, queryContext, true);
+ }
+
static public DocumentModel getDocFromCsid(
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
CoreSessionInterface repoSession,