Search in sources :

Example 16 with IllegalParameterFault

use of org.geosdi.geoplatform.exception.IllegalParameterFault in project geo-platform by geosdi.

the class GPLayerDelegate method saveDragAndDropLayerAndTreeModifications.

@Override
public Boolean saveDragAndDropLayerAndTreeModifications(WSDDLayerAndTreeModificationsRequest ddLayerReq) throws ResourceNotFoundFault, IllegalParameterFault {
    if (ddLayerReq == null) {
        throw new IllegalParameterFault("The WSDDLayerAndTreeModificationsRequest must not be null.");
    }
    Long layerMovedID = ddLayerReq.getLayerMovedID();
    Long newParentID = ddLayerReq.getNewParentID();
    int newPosition = ddLayerReq.getNewPosition();
    GPWebServiceMapData descendantsMapData = ddLayerReq.getDescendantsMapData();
    GPLayer layerMoved = this.getLayerDetail(layerMovedID);
    if (newParentID == null) {
        throw new IllegalParameterFault("New folder parent NOT declared");
    }
    GPFolder folderParent = folderDao.find(newParentID);
    if (folderParent == null) {
        throw new ResourceNotFoundFault("The new parent does not exists", newParentID);
    }
    // TODO assert
    EntityCorrectness.checkFolderLog(folderParent);
    layerMoved.setFolder(folderParent);
    int startFirstRange = 0, endFirstRange = 0;
    if (layerMoved.getPosition() < newPosition) {
        // Drag & Drop to top
        startFirstRange = newPosition;
        endFirstRange = layerMoved.getPosition() + 1;
    } else if (layerMoved.getPosition() > newPosition) {
        // Drag & Drop to bottom
        startFirstRange = layerMoved.getPosition() - 1;
        endFirstRange = newPosition;
    }
    int shiftValue = 1;
    List<GPFolder> matchingFoldersFirstRange = folderDao.findByPositionAndProjectID(layerMoved.getProject().getId(), startFirstRange, endFirstRange);
    List<GPLayer> matchingLayersFirstRange = layerDao.findByPositionAndProjectID(layerMoved.getProject().getId(), startFirstRange, endFirstRange);
    if (layerMoved.getPosition() < newPosition) {
        // Drag & Drop to top
        this.executeFoldersModifications(matchingFoldersFirstRange, -shiftValue);
        this.executeLayersModifications(matchingLayersFirstRange, -shiftValue);
    } else if (layerMoved.getPosition() > newPosition) {
        // Drag & Drop to bottom
        this.executeFoldersModifications(matchingFoldersFirstRange, shiftValue);
        this.executeLayersModifications(matchingLayersFirstRange, shiftValue);
    }
    folderDao.update(matchingFoldersFirstRange);
    layerDao.update(matchingLayersFirstRange);
    layerMoved.setPosition(newPosition);
    layerDao.update(layerMoved);
    folderDao.updateAncestorsDescendants(descendantsMapData.getDescendantsMap());
    return TRUE;
}
Also used : IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) GPWebServiceMapData(org.geosdi.geoplatform.response.collection.GPWebServiceMapData) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault)

Example 17 with IllegalParameterFault

use of org.geosdi.geoplatform.exception.IllegalParameterFault in project geo-platform by geosdi.

the class WSAccountTest method testInsertDuplicateUserWRTEmail.

@Test
public void testInsertDuplicateUserWRTEmail() {
    GPUser user = super.createUser("duplicate-email", organizationTest, USER);
    user.setEmailAddress(super.userTest.getEmailAddress());
    try {
        gpWSClient.insertAccount(new InsertAccountRequest(user, FALSE));
        fail("User already exist wrt email");
    } catch (IllegalParameterFault ex) {
        if (!ex.getMessage().toLowerCase().contains("email")) {
            // Must be fail for other reasons
            fail("Not fail for User already exist wrt email, but for: " + ex.getMessage());
        }
    }
}
Also used : InsertAccountRequest(org.geosdi.geoplatform.request.InsertAccountRequest) IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) GPUser(org.geosdi.geoplatform.core.model.GPUser) Test(org.junit.Test)

Example 18 with IllegalParameterFault

use of org.geosdi.geoplatform.exception.IllegalParameterFault in project geo-platform by geosdi.

the class CSWEntityCorrectness method checkCSWServer.

// ==========================================================================
// === Server
// ==========================================================================
public static void checkCSWServer(GeoPlatformServer server) throws IllegalParameterFault {
    if (server.getServerType() != GPCapabilityType.CSW) {
        throw new IllegalParameterFault("Server is not a CSW server.");
    }
    String url = server.getServerUrl();
    if (url == null) {
        throw new IllegalParameterFault("Server URL must not be null.");
    }
    if (!url.startsWith("http://") && !url.startsWith("https://")) {
        throw new IllegalParameterFault("URL must be start with \"http://\" or \"https://\".");
    }
    GPOrganization organization = server.getOrganization();
    if (organization == null) {
        throw new IllegalParameterFault("Server Organization must not be null.");
    }
}
Also used : IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) GPOrganization(org.geosdi.geoplatform.core.model.GPOrganization)

Example 19 with IllegalParameterFault

use of org.geosdi.geoplatform.exception.IllegalParameterFault in project geo-platform by geosdi.

the class GPFolderDelegate method saveFolderProperties.

@Override
public Long saveFolderProperties(Long folderID, String name, boolean checked, boolean expanded) throws ResourceNotFoundFault, IllegalParameterFault {
    GPFolder folder = folderDao.find(folderID);
    if (folder == null) {
        throw new ResourceNotFoundFault("Folder not found", folderID);
    }
    // TODO assert
    EntityCorrectness.checkFolderLog(folder);
    if (name == null || name.trim().length() == 0) {
        throw new IllegalParameterFault("Folder \"name\" cannot be null or empty");
    }
    folder.setName(name);
    folder.setChecked(checked);
    folder.setExpanded(expanded);
    folderDao.update(folder);
    return folder.getId();
}
Also used : GPFolder(org.geosdi.geoplatform.core.model.GPFolder) IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault)

Example 20 with IllegalParameterFault

use of org.geosdi.geoplatform.exception.IllegalParameterFault in project geo-platform by geosdi.

the class GPFolderDelegate method insertFolder.

// <editor-fold defaultstate="collapsed" desc="Folder">
// =========================================================================
// === Folder
// =========================================================================
@Override
public Long insertFolder(InsertFolderRequest insertFolderRequest) throws ResourceNotFoundFault, IllegalParameterFault {
    Long projectID = insertFolderRequest.getProjectID();
    GPFolder folder = insertFolderRequest.getFolder();
    if (projectID == null) {
        throw new IllegalParameterFault("The projectID must not be null.");
    }
    if (folder == null) {
        throw new IllegalParameterFault("The GPFolder passed in Request must " + "not be null.");
    }
    GPProject project = projectDao.find(projectID);
    if (project == null) {
        throw new ResourceNotFoundFault("Project not found", projectID);
    }
    // TODO assert
    EntityCorrectness.checkProjectLog(project);
    folder.setProject(project);
    // TODO assert
    EntityCorrectness.checkFolder(folder);
    folderDao.persist(folder);
    return folder.getId();
}
Also used : GPFolder(org.geosdi.geoplatform.core.model.GPFolder) GPProject(org.geosdi.geoplatform.core.model.GPProject) IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault)

Aggregations

IllegalParameterFault (org.geosdi.geoplatform.exception.IllegalParameterFault)56 ResourceNotFoundFault (org.geosdi.geoplatform.exception.ResourceNotFoundFault)32 GeoPlatformException (org.geosdi.geoplatform.gui.global.GeoPlatformException)22 GPSessionTimeout (org.geosdi.geoplatform.gui.utility.GPSessionTimeout)15 GPWebServiceMapData (org.geosdi.geoplatform.response.collection.GPWebServiceMapData)11 IOException (java.io.IOException)8 MalformedURLException (java.net.MalformedURLException)8 GPFolder (org.geosdi.geoplatform.core.model.GPFolder)7 GPUser (org.geosdi.geoplatform.core.model.GPUser)7 GPOrganization (org.geosdi.geoplatform.core.model.GPOrganization)6 GPAccount (org.geosdi.geoplatform.core.model.GPAccount)5 GPAccountProject (org.geosdi.geoplatform.core.model.GPAccountProject)4 Test (org.junit.Test)4 URL (java.net.URL)3 InsertAccountRequest (org.geosdi.geoplatform.request.InsertAccountRequest)3 BasePagingLoadResult (com.extjs.gxt.ui.client.data.BasePagingLoadResult)2 GPCSWConnectorBuilder (org.geosdi.geoplatform.connector.GPCSWConnectorBuilder)2 GPCatalogConnectorStore (org.geosdi.geoplatform.connector.GPCatalogConnectorStore)2 BasicPreemptiveSecurityConnector (org.geosdi.geoplatform.connector.server.security.BasicPreemptiveSecurityConnector)2 GPSecurityConnector (org.geosdi.geoplatform.connector.server.security.GPSecurityConnector)2