use of org.pentaho.commons.util.repository.type.CmisObject in project pentaho-platform by pentaho.
the class BiPlatformRepositoryClientNavigationService method getChildren.
public List<CmisObject> getChildren(String repositoryId, String folderId, TypesOfFileableObjects type, String filter, boolean includeAllowableActions, boolean includeRelationships, int maxItems, int skipCount) throws InvalidArgumentException, ConstraintViolationException, FilterNotValidException, RuntimeException, UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, PermissionDeniedException, FolderNotValidException {
Collection filters = null;
if (!StringUtil.isEmpty(filter)) {
filters = getFilterCollection(filter);
}
if (!repositoryId.equals(BiPlatformRepositoryClient.PLATFORMORIG)) {
throw new InvalidArgumentException();
}
List<CmisObject> objects = new ArrayList<CmisObject>();
// get the element for the specified object
Element objectElement = getFolderElement(folderId);
addChildren(objects, objectElement, type, filters, maxItems, skipCount, 1, 1);
return objects;
}
use of org.pentaho.commons.util.repository.type.CmisObject in project pentaho-platform by pentaho.
the class BiPlatformRepositoryClientNavigationService method getObjectParent.
public List<CmisObject> getObjectParent(String repositoryId, String objectId, String filter, boolean includeAllowableActions, boolean includeRelationships) throws InvalidArgumentException, ConstraintViolationException, FilterNotValidException, RuntimeException, UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, PermissionDeniedException, FolderNotValidException {
if (!repositoryId.equals(BiPlatformRepositoryClient.PLATFORMORIG)) {
throw new InvalidArgumentException();
}
List<CmisObject> objects = new ArrayList<CmisObject>();
// get the element for the specified object
Element objectElement = getObjectElement(objectId);
if (objectElement == null) {
return objects;
}
// get the parent node
Element parentElement = objectElement.getParent();
if (parentElement == null) {
return objects;
}
CmisObject parent = createCmisObjectFromElement(parentElement, 0);
objects.add(parent);
return objects;
}
use of org.pentaho.commons.util.repository.type.CmisObject in project pentaho-platform by pentaho.
the class BiPlatformRepositoryClientNavigationService method createCmisObjectFromElement.
private CmisObject createCmisObjectFromElement(Element element, int depth) {
CmisObject object = new CmisObjectImpl();
CmisProperties properties = new CmisProperties();
List<CmisProperty> propList = properties.getProperties();
// is this a folder or a file?
boolean isDirectory = false;
// $NON-NLS-1$
Attribute attr = element.attribute("isDirectory");
if (attr != null) {
// $NON-NLS-1$
isDirectory = "true".equalsIgnoreCase(attr.getText());
}
// set the base properties
String objectId = getObjectId(element);
Calendar lastModifiedDate = getLastModifiedDate(element);
String name = getName(element);
String localizedName = getLocalizedName(element);
String extension = getExtension(element);
boolean visible = getVisible(element);
propList.add(new PropertyId(PropertiesBase.OBJECTID, objectId));
propList.add(new PropertyDateTime(PropertiesBase.LASTMODIFICATIONDATE, lastModifiedDate));
if (isDirectory) {
propList.add(new PropertyString(PropertiesBase.OBJECTTYPEID, CmisObject.OBJECT_TYPE_FOLDER));
} else {
propList.add(new PropertyString(PropertiesBase.OBJECTTYPEID, extension));
propList.add(new PropertyBoolean(PropertiesDocument.CONTENTSTREAMALLOWED, true));
}
propList.add(new PropertyString(CmisObject.NAME, name));
propList.add(new PropertyString(CmisObject.LOCALIZEDNAME, localizedName));
propList.add(new PropertyBoolean(CmisObject.VISIBLE, visible));
object.setProperties(properties);
return object;
}
use of org.pentaho.commons.util.repository.type.CmisObject in project pentaho-platform by pentaho.
the class BiPlatformRepositoryClientNavigationService method getDescendants.
public List<CmisObject> getDescendants(String repositoryId, String folderId, TypesOfFileableObjects type, int depth, String filter, boolean includeAllowableActions, boolean includeRelationships) throws InvalidArgumentException, ConstraintViolationException, FilterNotValidException, RuntimeException, UpdateConflictException, ObjectNotFoundException, OperationNotSupportedException, PermissionDeniedException, FolderNotValidException {
Collection filters = null;
if (!StringUtil.isEmpty(filter)) {
filters = getFilterCollection(filter);
}
if (!repositoryId.equals(BiPlatformRepositoryClient.PLATFORMORIG)) {
throw new InvalidArgumentException();
}
List<CmisObject> objects = new ArrayList<CmisObject>();
// get the element for the specified object
Element objectElement = getFolderElement(folderId);
addChildren(objects, objectElement, type, filters, 0, 0, depth, 1);
return objects;
}
use of org.pentaho.commons.util.repository.type.CmisObject in project pentaho-platform by pentaho.
the class BiPlatformRepositoryClientNavigationService method addChildren.
protected void addChildren(List<CmisObject> objects, Element objectElement, TypesOfFileableObjects type, Collection filters, int maxItems, int skipCount, int depth, int level) {
if (objectElement == null) {
return;
}
CmisObject object;
int skipped = 0;
boolean ok = false;
for (Object element : objectElement.elements()) {
ok = false;
object = createCmisObjectFromElement((Element) element, 0);
if (type == null || type.getValue().equals(TypesOfFileableObjects.ANY)) {
ok = true;
} else if (TypesOfFileableObjects.FOLDERS.equals(type.getValue()) && CmisObject.OBJECT_TYPE_FOLDER.equals(object.findStringProperty(PropertiesBase.OBJECTTYPEID, null))) {
ok = true;
} else if (TypesOfFileableObjects.DOCUMENTS.equals(type.getValue()) && !CmisObject.OBJECT_TYPE_FOLDER.equals(object.findStringProperty(PropertiesBase.OBJECTTYPEID, null))) {
// TODO support policies
ok = true;
}
if (ok && filters != null) {
String objectType = object.findStringProperty(PropertiesBase.OBJECTTYPEID, null);
if (!filters.contains(objectType)) {
ok = false;
}
}
if (ok && skipCount > 0) {
if (skipped < skipCount) {
ok = false;
skipped++;
}
}
if (ok && maxItems > 0) {
if (objects.size() >= maxItems) {
break;
}
}
if (ok) {
objects.add(object);
// see if we have to recurse
}
if (depth > 0 && level < depth && CmisObject.OBJECT_TYPE_FOLDER.equals(object.findStringProperty(PropertiesBase.OBJECTTYPEID, null))) {
addChildren(objects, (Element) element, type, filters, maxItems, skipCount, depth, level + 1);
}
}
}
Aggregations