Search in sources :

Example 1 with InvalidArgumentException

use of org.pentaho.commons.util.repository.exception.InvalidArgumentException 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 InvalidArgumentException

use of org.pentaho.commons.util.repository.exception.InvalidArgumentException 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 InvalidArgumentException

use of org.pentaho.commons.util.repository.exception.InvalidArgumentException 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 4 with InvalidArgumentException

use of org.pentaho.commons.util.repository.exception.InvalidArgumentException in project pentaho-platform by pentaho.

the class BiPlatformRepositoryClientNavigationServiceTest method testObjectParent.

@Test
public void testObjectParent() {
    mLog.info("testObjectParent..");
    // CASE 1: Provide a wrong key for the original BI platform repository
    try {
        navService.getObjectParent("WRONG_REPOSITORY_ID", "objectId", "filter", false, false);
    } catch (Exception exe) {
        assertTrue(exe instanceof InvalidArgumentException);
    }
    // CASE 2: Provide a right key, but document is null
    try {
        cmisObjects = navService.getObjectParent(BiPlatformRepositoryClient.PLATFORMORIG, "/admin/training/sales_data.csv", "filter", false, false);
    } catch (Exception exe) {
        assertTrue("Should have thrown NPE here, as lNavService doc is null", true);
    }
    // CASE 3: the document is empty
    try {
        navService.setDoc(mockDocument);
        cmisObjects = navService.getObjectParent(BiPlatformRepositoryClient.PLATFORMORIG, "/admin/training/sales_data.csv", "filter", false, false);
    } catch (Exception exe) {
        assertTrue(exe instanceof ObjectNotFoundException);
    }
    // CASE 4: now the document has valid contents
    try {
        navService.setDoc(document);
        cmisObjects = navService.getObjectParent(BiPlatformRepositoryClient.PLATFORMORIG, "/admin/sales_data.csv", "filter", false, false);
        assertTrue(cmisObjects != null);
        assertTrue(cmisObjects.get(0).getProperties() != null);
        CmisObject lCmisObject = cmisObjects.get(0);
        assertTrue(CmisObject.OBJECT_TYPE_FOLDER.equals(lCmisObject.findStringProperty(PropertiesBase.OBJECTTYPEID, null)));
    } catch (Exception exe) {
        assertTrue("Shouldn't throw exception here", false);
        mLog.error("Problem testing testObjectParent() - Fails Unit Test");
    }
}
Also used : InvalidArgumentException(org.pentaho.commons.util.repository.exception.InvalidArgumentException) ObjectNotFoundException(org.pentaho.commons.util.repository.exception.ObjectNotFoundException) CmisObject(org.pentaho.commons.util.repository.type.CmisObject) OperationNotSupportedException(org.pentaho.commons.util.repository.exception.OperationNotSupportedException) InvalidArgumentException(org.pentaho.commons.util.repository.exception.InvalidArgumentException) ObjectNotFoundException(org.pentaho.commons.util.repository.exception.ObjectNotFoundException) FolderNotValidException(org.pentaho.commons.util.repository.exception.FolderNotValidException) Test(org.junit.Test)

Example 5 with InvalidArgumentException

use of org.pentaho.commons.util.repository.exception.InvalidArgumentException in project pentaho-platform by pentaho.

the class BiPlatformRepositoryClientNavigationServiceTest method testGetFolderParent.

@Test
public void testGetFolderParent() {
    mLog.info("testGetFolderParent..");
    // CASE 1: Provide a wrong key for the original BI platform repository
    try {
        navService.getFolderParent("WRONG_REPOSITORY_ID", "/admin/sales_data.csv", "filter", false, false, false);
    } catch (Exception exe) {
        assertTrue(exe instanceof InvalidArgumentException);
    }
    // CASE 2: Provide a right key, but the document is null
    try {
        cmisObjects = navService.getFolderParent(BiPlatformRepositoryClient.PLATFORMORIG, "/admin/sales_data.csv", "filter", false, false, false);
    } catch (Exception exe) {
        assertTrue("Should have thrown exception here", true);
    }
    // CASE 3: document is empty
    try {
        navService.setDoc(mockDocument);
        navService.getFolderParent(BiPlatformRepositoryClient.PLATFORMORIG, "/admin/sales_data.csv", "filter", false, false, false);
    } catch (Exception exe) {
        assertTrue(exe instanceof FolderNotValidException);
    }
    // CASE 4: now the document has valid contents
    try {
        navService.setDoc(document);
        cmisObjects = navService.getFolderParent(BiPlatformRepositoryClient.PLATFORMORIG, "/admin", "filter", false, false, false);
        assertTrue(cmisObjects != null);
        assertTrue(cmisObjects.get(0).getProperties() != null);
        CmisObject lCmisObject = cmisObjects.get(0);
        assertTrue("".equals(lCmisObject.findStringProperty(PropertiesBase.OBJECTTYPEID, null)));
    } catch (Exception exe) {
        assertTrue("Shouldn't throw exception here", false);
        mLog.error("Exception in testGetFolderParent() - Fails Unit Test");
    }
}
Also used : InvalidArgumentException(org.pentaho.commons.util.repository.exception.InvalidArgumentException) FolderNotValidException(org.pentaho.commons.util.repository.exception.FolderNotValidException) CmisObject(org.pentaho.commons.util.repository.type.CmisObject) OperationNotSupportedException(org.pentaho.commons.util.repository.exception.OperationNotSupportedException) InvalidArgumentException(org.pentaho.commons.util.repository.exception.InvalidArgumentException) ObjectNotFoundException(org.pentaho.commons.util.repository.exception.ObjectNotFoundException) FolderNotValidException(org.pentaho.commons.util.repository.exception.FolderNotValidException) Test(org.junit.Test)

Aggregations

InvalidArgumentException (org.pentaho.commons.util.repository.exception.InvalidArgumentException)7 CmisObject (org.pentaho.commons.util.repository.type.CmisObject)6 ArrayList (java.util.ArrayList)4 Element (org.dom4j.Element)4 Test (org.junit.Test)3 FolderNotValidException (org.pentaho.commons.util.repository.exception.FolderNotValidException)3 ObjectNotFoundException (org.pentaho.commons.util.repository.exception.ObjectNotFoundException)3 OperationNotSupportedException (org.pentaho.commons.util.repository.exception.OperationNotSupportedException)3 Collection (java.util.Collection)2 PropertyString (org.pentaho.commons.util.repository.type.PropertyString)1 TypesOfFileableObjects (org.pentaho.commons.util.repository.type.TypesOfFileableObjects)1