Java Code Examples for org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectListImpl#setNumItems()
The following examples show how to use
org.apache.chemistry.opencmis.commons.impl.dataobjects.ObjectListImpl#setNumItems() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CmisUtils.java From iaf with Apache License 2.0 | 6 votes |
public static ObjectList xml2ObjectList(Element result, IPipeLineSession context) { ObjectListImpl objectList = new ObjectListImpl(); objectList.setNumItems(CmisUtils.parseBigIntegerAttr(result, "numberOfItems")); objectList.setHasMoreItems(CmisUtils.parseBooleanAttr(result, "hasMoreItems")); List<ObjectData> objects = new ArrayList<ObjectData>(); Element objectsElem = XmlUtils.getFirstChildTag(result, "objects"); for (Node type : XmlUtils.getChildTags(objectsElem, "objectData")) { ObjectData objectData = xml2ObjectData((Element) type, context); objects.add(objectData); } objectList.setObjects(objects); return objectList; }
Example 2
Source File: CmisServiceImpl.java From document-management-system with GNU General Public License v2.0 | 5 votes |
@Override public ObjectList getCheckedOutDocs(String repositoryId, String folderId, String filter, String orderBy, Boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter, BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) { log.debug("getCheckedOutDocs({}, {}, {})", new Object[]{repositoryId, folderId, filter}); ObjectListImpl result = new ObjectListImpl(); result.setHasMoreItems(false); result.setNumItems(BigInteger.ZERO); List<ObjectData> emptyList = Collections.emptyList(); result.setObjects(emptyList); return result; }
Example 3
Source File: LDRepository.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
public ObjectList getContentChanges(Holder<String> changeLogToken, int max) throws CmisPermissionDeniedException { log.debug("getContentChanges {}", changeLogToken.getValue()); if (changeLogToken == null) throw new CmisInvalidArgumentException("Missing change log token holder"); long minDate; try { minDate = Long.parseLong(changeLogToken.getValue()); } catch (NumberFormatException e) { throw new CmisInvalidArgumentException("Invalid change log token"); } ObjectListImpl ol = new ObjectListImpl(); List<ObjectData> odsDocs = getDocumentLastChanges(minDate, max); List<ObjectData> odsFolders = getFolderLastChanges(minDate, max); //put together the 2 lists List<ObjectData> complex = new ArrayList<ObjectData>(); complex.addAll(odsDocs); complex.addAll(odsFolders); // log.debug("Before sort"); // for (ObjectData objectData : complex) { // log.debug("ChangeTime {}", objectData.getChangeEventInfo().getChangeTime().getTime()); // } // sort the content of list complex by date Collections.sort(complex, new Comparator<ObjectData>() { public int compare(ObjectData o1, ObjectData o2) { return o1.getChangeEventInfo().getChangeTime().getTime() .compareTo(o2.getChangeEventInfo().getChangeTime().getTime()); } }); // log.debug("After sort"); // for (ObjectData objectData : complex) { // log.debug("ChangeTime {} {} {} {}", objectData.getChangeEventInfo().getChangeType(), objectData.getId() ,objectData.getChangeEventInfo().getChangeTime().getTime(), objectData.getChangeEventInfo().getChangeTime().getTime().getTime()); // } boolean hasMoreItems = complex.size() > max; if (hasMoreItems) { complex = complex.subList(0, max); } ol.setObjects(complex); Date date = null; if (complex.size() > 0) { //ol.setNumItems(BigInteger.valueOf(complex.size())); ol.setNumItems(BigInteger.valueOf(-1)); //ol.setHasMoreItems(true); ol.setHasMoreItems(Boolean.valueOf(hasMoreItems)); date = ((ObjectData)complex.get(complex.size() -1)).getChangeEventInfo().getChangeTime().getTime(); // log.debug("date {}", date); // log.debug("date.getTime {}", date.getTime()); } else { ol.setHasMoreItems(Boolean.valueOf(false)); ol.setNumItems(BigInteger.ZERO); } String latestChangeLogToken = date == null ? null : String.valueOf(date.getTime()); log.debug("latestChangeLogToken {}", latestChangeLogToken); changeLogToken.setValue(latestChangeLogToken); return ol; }
Example 4
Source File: CMISConnector.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
public ObjectList getObjectRelationships(NodeRef nodeRef, RelationshipDirection relationshipDirection, String typeId, String filter, Boolean includeAllowableActions, BigInteger maxItems, BigInteger skipCount) { ObjectListImpl result = new ObjectListImpl(); result.setHasMoreItems(false); result.setNumItems(BigInteger.ZERO); result.setObjects(new ArrayList<ObjectData>()); if (nodeRef.getStoreRef().getProtocol().equals(VersionBaseModel.STORE_PROTOCOL)) { // relationships from and to versions are not preserved return result; } // get relationships List<AssociationRef> assocs = new ArrayList<AssociationRef>(); if (relationshipDirection == RelationshipDirection.SOURCE || relationshipDirection == RelationshipDirection.EITHER) { assocs.addAll(nodeService.getTargetAssocs(nodeRef, RegexQNamePattern.MATCH_ALL)); } if (relationshipDirection == RelationshipDirection.TARGET || relationshipDirection == RelationshipDirection.EITHER) { assocs.addAll(nodeService.getSourceAssocs(nodeRef, RegexQNamePattern.MATCH_ALL)); } int skip = (skipCount == null ? 0 : skipCount.intValue()); int max = (maxItems == null ? Integer.MAX_VALUE : maxItems.intValue()); int counter = 0; boolean hasMore = false; if (max > 0) { // filter relationships that not map the CMIS domain model for (AssociationRef assocRef : assocs) { TypeDefinitionWrapper assocTypeDef = getOpenCMISDictionaryService().findAssocType(assocRef.getTypeQName()); if (assocTypeDef == null || getType(assocRef.getSourceRef()) == null || getType(assocRef.getTargetRef()) == null) { continue; } if ((typeId != null) && !assocTypeDef.getTypeId().equals(typeId)) { continue; } counter++; if (skip > 0) { skip--; continue; } max--; if (max > 0) { try { result.getObjects().add( createCMISObject(createNodeInfo(assocRef), filter, includeAllowableActions, IncludeRelationships.NONE, RENDITION_NONE, false, false/*, cmisVersion*/)); } catch(CmisObjectNotFoundException e) { // ignore objects that have not been found (perhaps because their type is unknown to CMIS) } } else { hasMore = true; } } } result.setNumItems(BigInteger.valueOf(counter)); result.setHasMoreItems(hasMore); return result; }
Example 5
Source File: AlfrescoCmisServiceImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
@Override public ObjectList getObjectRelationships( String repositoryId, String objectId, Boolean includeSubRelationshipTypes, RelationshipDirection relationshipDirection, String typeId, String filter, Boolean includeAllowableActions, BigInteger maxItems, BigInteger skipCount, ExtensionsData extension) { checkRepositoryId(repositoryId); // what kind of object is it? CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object"); if (info.isVariant(CMISObjectVariant.ASSOC)) { throw new CmisInvalidArgumentException("Object is a relationship!"); } if (info.isVariant(CMISObjectVariant.VERSION)) { throw new CmisInvalidArgumentException("Object is a document version!"); } // check if the relationship base type is requested if (BaseTypeId.CMIS_RELATIONSHIP.value().equals(typeId)) { boolean isrt = (includeSubRelationshipTypes == null ? false : includeSubRelationshipTypes.booleanValue()); if (isrt) { // all relationships are a direct subtype of the base type in // Alfresco -> remove filter typeId = null; } else { // there are no relationships of the base type in Alfresco -> // return empty list ObjectListImpl result = new ObjectListImpl(); result.setHasMoreItems(false); result.setNumItems(BigInteger.ZERO); result.setObjects(new ArrayList<ObjectData>()); return result; } } return connector.getObjectRelationships( info.getNodeRef(), relationshipDirection, typeId, filter, includeAllowableActions, maxItems, skipCount); }