Search in sources :

Example 1 with IllegalParameterFault

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

the class SaveFolderPropertiesCommand method execute.

@Override
public SaveFolderPropertiesResponse execute(SaveFolderPropertiesRequest request, HttpServletRequest httpServletRequest) {
    logger.info("##################### Executing {} Command", this.getClass().getSimpleName());
    try {
        this.sessionUtility.getLoggedAccount(httpServletRequest);
    } catch (GPSessionTimeout timeout) {
        throw new GeoPlatformException(timeout);
    }
    try {
        MementoFolderOriginalProperties memento = request.getMementoFolderOriginalProperties();
        geoPlatformServiceClient.saveFolderProperties(memento.getIdBaseElement(), memento.getName(), memento.isChecked(), memento.isExpanded());
    } catch (ResourceNotFoundFault ex) {
        SaveFolderPropertiesCommand.logger.error("Failed to save folder on LayerService: " + ex);
        throw new GeoPlatformException(ex);
    } catch (IllegalParameterFault ex) {
        SaveFolderPropertiesCommand.logger.error("Failed to save folder on LayerService: " + ex);
        throw new GeoPlatformException(ex);
    }
    logger.debug("#################### After sending project notification");
    return new SaveFolderPropertiesResponse(Boolean.TRUE);
}
Also used : IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) GPSessionTimeout(org.geosdi.geoplatform.gui.utility.GPSessionTimeout) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException) MementoFolderOriginalProperties(org.geosdi.geoplatform.gui.client.model.memento.save.storage.MementoFolderOriginalProperties) SaveFolderPropertiesResponse(org.geosdi.geoplatform.gui.client.command.memento.basic.SaveFolderPropertiesResponse)

Example 2 with IllegalParameterFault

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

the class LayerService method shareProjectToUsers.

@Override
public boolean shareProjectToUsers(long idSharedProject, List<Long> accountIDsProject, HttpServletRequest httpServletRequest) throws GeoPlatformException {
    boolean result;
    try {
        GPAccount account = this.sessionUtility.getLoggedAccount(httpServletRequest);
        result = this.geoPlatformServiceClient.updateAccountsProjectSharing(new PutAccountsProjectRequest(idSharedProject, accountIDsProject));
        if (result) {
            MessageDTO message = new MessageDTO();
            message.setCommands(Lists.newArrayList(GPMessageCommandType.OPEN_PROJECT));
            message.setCommandsProperties("" + idSharedProject);
            message.setCreationDate(new Date());
            message.setSenderID(account.getId());
            message.setSubject("Project Shared");
            String sharerName;
            if (account instanceof GPUser) {
                GPUser user = (GPUser) account;
                sharerName = user.getName();
            } else {
                sharerName = account.getNaturalID();
            }
            GPProject project = this.geoPlatformServiceClient.getProjectDetail(idSharedProject);
            message.setText(sharerName + " shared with you the " + project.getName() + " project. Do you want to open it?");
            message.setRecipientIDs(accountIDsProject);
            this.geoPlatformServiceClient.insertMultiMessage(message);
        }
    } catch (GPSessionTimeout timeout) {
        throw new GeoPlatformException(timeout);
    } catch (ResourceNotFoundFault | IllegalParameterFault rnf) {
        logger.error("Failed to save Shared project to Accounts for Shared Project with id: " + idSharedProject + "on SecurityService: " + rnf);
        throw new GeoPlatformException(rnf);
    }
    return result;
}
Also used : GPAccount(org.geosdi.geoplatform.core.model.GPAccount) IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) GPUser(org.geosdi.geoplatform.core.model.GPUser) PutAccountsProjectRequest(org.geosdi.geoplatform.request.PutAccountsProjectRequest) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) GPSessionTimeout(org.geosdi.geoplatform.gui.utility.GPSessionTimeout) Date(java.util.Date) GPProject(org.geosdi.geoplatform.core.model.GPProject) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException)

Example 3 with IllegalParameterFault

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

the class LayerService method saveFolder.

@Override
public Long saveFolder(Long idParentFolder, String folderName, int position, int numberOfDescendants, boolean isChecked, HttpServletRequest httpServletRequest) throws GeoPlatformException {
    try {
        this.sessionUtility.getLoggedAccount(httpServletRequest);
    } catch (GPSessionTimeout timeout) {
        throw new GeoPlatformException(timeout);
    }
    GPFolder gpFolder = null;
    try {
        gpFolder = geoPlatformServiceClient.getFolderDetail(idParentFolder);
    } catch (Exception e) {
        logger.error("LayerService", "Ubable to load Folder with ID : " + idParentFolder);
        throw new GeoPlatformException("The Folder with ID : " + idParentFolder + " was deleted.");
    }
    GPFolder folder = new GPFolder();
    folder.setName(folderName);
    folder.setPosition(position);
    folder.setShared(false);
    folder.setParent(gpFolder);
    folder.setNumberOfDescendants(numberOfDescendants);
    folder.setChecked(isChecked);
    Long projectId;
    // folder.setProject(project);
    Long savedFolderId = null;
    try {
        projectId = this.sessionUtility.getDefaultProject(httpServletRequest);
        savedFolderId = this.geoPlatformServiceClient.insertFolder(new InsertFolderRequest(projectId, folder));
    } catch (IllegalParameterFault ilg) {
        logger.error("Error on LayerService: " + ilg);
        throw new GeoPlatformException("Parameter incorrect on saveFolde");
    } catch (ResourceNotFoundFault rnff) {
        logger.error("Error on LayerService: " + rnff);
        throw new GeoPlatformException(rnff);
    } catch (GPSessionTimeout timeout) {
        throw new GeoPlatformException(timeout);
    }
    return savedFolderId;
}
Also used : GPFolder(org.geosdi.geoplatform.core.model.GPFolder) InsertFolderRequest(org.geosdi.geoplatform.request.folder.InsertFolderRequest) IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) GPSessionTimeout(org.geosdi.geoplatform.gui.utility.GPSessionTimeout) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Example 4 with IllegalParameterFault

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

the class LayerService method saveLayerProperties.

@Override
public boolean saveLayerProperties(MementoLayerOriginalProperties memento, HttpServletRequest httpServletRequest) throws GeoPlatformException {
    boolean result;
    try {
        this.sessionUtility.getLoggedAccount(httpServletRequest);
    } catch (GPSessionTimeout timeout) {
        throw new GeoPlatformException(timeout);
    }
    RasterPropertiesDTO dto = this.dtoMementoConverter.convertMementoProperties(memento);
    try {
        result = geoPlatformServiceClient.saveLayerProperties(dto);
    } catch (ResourceNotFoundFault ex) {
        this.logger.error("Failed to save layers on LayerService: {}", ex.getMessage());
        throw new GeoPlatformException(ex);
    } catch (IllegalParameterFault ex) {
        this.logger.error("Failed to save layers on LayerService: {}", ex.getMessage());
        throw new GeoPlatformException(ex);
    }
    return result;
}
Also used : IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) GPSessionTimeout(org.geosdi.geoplatform.gui.utility.GPSessionTimeout) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException)

Example 5 with IllegalParameterFault

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

the class LayerService method saveAddedFolderAndTreeModifications.

@Override
public Long saveAddedFolderAndTreeModifications(MementoSaveAddedFolder memento, HttpServletRequest httpServletRequest) throws GeoPlatformException {
    try {
        this.sessionUtility.getLoggedAccount(httpServletRequest);
    } catch (GPSessionTimeout timeout) {
        throw new GeoPlatformException(timeout);
    }
    GPWebServiceMapData map = this.dtoMementoConverter.convertDescendantMap(memento.getWsDescendantMap());
    Long idSavedFolder;
    try {
        Long projectId = this.sessionUtility.getDefaultProject(httpServletRequest);
        GPFolder gpFolder = this.dtoLayerConverter.convertMementoFolder(memento.getAddedFolder());
        idSavedFolder = this.geoPlatformServiceClient.saveAddedFolderAndTreeModifications(new WSAddFolderAndTreeModificationsRequest(projectId, memento.getAddedFolder().getIdParent(), gpFolder, map));
    } catch (ResourceNotFoundFault ex) {
        this.logger.error("Failed to save folder on LayerService: " + ex);
        throw new GeoPlatformException(ex);
    } catch (IllegalParameterFault ilg) {
        logger.error("Error on LayerService: " + ilg);
        throw new GeoPlatformException("Parameter incorrect on saveAddedFolderAndTreeModifications");
    } catch (GPSessionTimeout timeout) {
        throw new GeoPlatformException(timeout);
    } catch (Exception ex) {
        throw new GeoPlatformException(ex.getMessage());
    }
    return idSavedFolder;
}
Also used : GPFolder(org.geosdi.geoplatform.core.model.GPFolder) WSAddFolderAndTreeModificationsRequest(org.geosdi.geoplatform.request.folder.WSAddFolderAndTreeModificationsRequest) IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) GPWebServiceMapData(org.geosdi.geoplatform.response.collection.GPWebServiceMapData) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) GPSessionTimeout(org.geosdi.geoplatform.gui.utility.GPSessionTimeout) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

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