Search in sources :

Example 1 with CmisObject

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;
}
Also used : InvalidArgumentException(org.pentaho.commons.util.repository.exception.InvalidArgumentException) Element(org.dom4j.Element) ArrayList(java.util.ArrayList) Collection(java.util.Collection) CmisObject(org.pentaho.commons.util.repository.type.CmisObject)

Example 2 with CmisObject

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;
}
Also used : InvalidArgumentException(org.pentaho.commons.util.repository.exception.InvalidArgumentException) Element(org.dom4j.Element) ArrayList(java.util.ArrayList) CmisObject(org.pentaho.commons.util.repository.type.CmisObject)

Example 3 with CmisObject

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;
}
Also used : CmisObjectImpl(org.pentaho.commons.util.repository.type.CmisObjectImpl) PropertyString(org.pentaho.commons.util.repository.type.PropertyString) PropertyBoolean(org.pentaho.commons.util.repository.type.PropertyBoolean) Attribute(org.dom4j.Attribute) Calendar(java.util.Calendar) CmisProperties(org.pentaho.commons.util.repository.type.CmisProperties) CmisProperty(org.pentaho.commons.util.repository.type.CmisProperty) PropertyString(org.pentaho.commons.util.repository.type.PropertyString) PropertyId(org.pentaho.commons.util.repository.type.PropertyId) CmisObject(org.pentaho.commons.util.repository.type.CmisObject) PropertyDateTime(org.pentaho.commons.util.repository.type.PropertyDateTime)

Example 4 with CmisObject

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;
}
Also used : InvalidArgumentException(org.pentaho.commons.util.repository.exception.InvalidArgumentException) Element(org.dom4j.Element) ArrayList(java.util.ArrayList) Collection(java.util.Collection) CmisObject(org.pentaho.commons.util.repository.type.CmisObject)

Example 5 with CmisObject

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);
        }
    }
}
Also used : Element(org.dom4j.Element) CmisObject(org.pentaho.commons.util.repository.type.CmisObject) CmisObject(org.pentaho.commons.util.repository.type.CmisObject) PropertyString(org.pentaho.commons.util.repository.type.PropertyString)

Aggregations

CmisObject (org.pentaho.commons.util.repository.type.CmisObject)8 InvalidArgumentException (org.pentaho.commons.util.repository.exception.InvalidArgumentException)6 Element (org.dom4j.Element)5 ArrayList (java.util.ArrayList)4 Collection (java.util.Collection)2 Test (org.junit.Test)2 FolderNotValidException (org.pentaho.commons.util.repository.exception.FolderNotValidException)2 ObjectNotFoundException (org.pentaho.commons.util.repository.exception.ObjectNotFoundException)2 OperationNotSupportedException (org.pentaho.commons.util.repository.exception.OperationNotSupportedException)2 PropertyString (org.pentaho.commons.util.repository.type.PropertyString)2 Calendar (java.util.Calendar)1 Attribute (org.dom4j.Attribute)1 CmisObjectImpl (org.pentaho.commons.util.repository.type.CmisObjectImpl)1 CmisProperties (org.pentaho.commons.util.repository.type.CmisProperties)1 CmisProperty (org.pentaho.commons.util.repository.type.CmisProperty)1 PropertyBoolean (org.pentaho.commons.util.repository.type.PropertyBoolean)1 PropertyDateTime (org.pentaho.commons.util.repository.type.PropertyDateTime)1 PropertyId (org.pentaho.commons.util.repository.type.PropertyId)1