Search in sources :

Example 6 with InvalidArgumentException

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

the class BiPlatformRepositoryClientNavigationServiceTest method testGetDescendants.

@Test
public void testGetDescendants() {
    mLog.info("testGetDescendants..");
    // CASE 1: Provide a wrong key for the original BI platform repository
    try {
        navService.getDescendants("WRONG_REPOSITORY_ID", "/admin", null, 0, "filter", false, false);
    } catch (Exception exe) {
        assertTrue(exe instanceof InvalidArgumentException);
    }
    // CASE 2: Provide a right key, but the document is null
    try {
        navService.getDescendants(BiPlatformRepositoryClient.PLATFORMORIG, "/admin", null, 0, "filter", false, false);
    } catch (Exception exe) {
        assertTrue("Shouldn have thrown exception here", true);
    }
    // CASE 3: document is empty
    try {
        navService.setDoc(mockDocument);
        navService.getDescendants(BiPlatformRepositoryClient.PLATFORMORIG, "/admin", null, 0, "filter", false, false);
    } catch (Exception exe) {
        assertTrue(exe instanceof FolderNotValidException);
    }
    // CASE 4: the document has valid contents
    try {
        navService.setDoc(document);
        cmisObjects = navService.getDescendants(BiPlatformRepositoryClient.PLATFORMORIG, "/admin", null, 0, "filter", false, false);
        assertTrue(cmisObjects != null);
    } catch (Exception exe) {
        assertTrue("Shouldn't throw exception here", false);
        mLog.error("Exception in testGetDescendants() - Fails Unit Test");
    }
    // CASE 5: TypesOfFileableObjects.FOLDERS
    TypesOfFileableObjects fileableFolders = new TypesOfFileableObjects(TypesOfFileableObjects.FOLDERS);
    cmisObject.getProperties().getProperties().add(new PropertyString(PropertiesBase.OBJECTTYPEID, CmisObject.OBJECT_TYPE_FOLDER));
    try {
        navService.setDoc(document);
        cmisObjects = navService.getDescendants(BiPlatformRepositoryClient.PLATFORMORIG, "/admin", fileableFolders, 1, "filter", false, false);
        assertTrue(cmisObjects != null);
    } catch (Exception exe) {
        assertTrue("Shouldn't throw exception here", false);
        mLog.error("Exception in testGetDescendants() - Fails Unit Test");
    }
    // CASE 5: TypesOfFileableObjects.DOCUMENTS
    TypesOfFileableObjects fileableDocuments = new TypesOfFileableObjects(TypesOfFileableObjects.DOCUMENTS);
    try {
        navService.setDoc(document);
        cmisObjects = navService.getDescendants(BiPlatformRepositoryClient.PLATFORMORIG, "/admin", fileableDocuments, 0, "filter", false, false);
        assertTrue(cmisObjects != null);
    } catch (Exception exe) {
        assertTrue("Shouldn't throw exception here", false);
        mLog.error("Exception in testGetDescendants() - Fails Unit Test");
    }
}
Also used : PropertyString(org.pentaho.commons.util.repository.type.PropertyString) InvalidArgumentException(org.pentaho.commons.util.repository.exception.InvalidArgumentException) FolderNotValidException(org.pentaho.commons.util.repository.exception.FolderNotValidException) 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) TypesOfFileableObjects(org.pentaho.commons.util.repository.type.TypesOfFileableObjects) Test(org.junit.Test)

Example 7 with InvalidArgumentException

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

the class BiPlatformRepositoryClientNavigationService method getFolderParent.

public List<CmisObject> getFolderParent(String repositoryId, String folderId, String filter, boolean includeAllowableActions, boolean includeRelationships, boolean returnToRoot) 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 = getFolderElement(folderId);
    // 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)

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