Search in sources :

Example 1 with InsertFolderRequest

use of org.geosdi.geoplatform.request.folder.InsertFolderRequest 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 2 with InsertFolderRequest

use of org.geosdi.geoplatform.request.folder.InsertFolderRequest in project geo-platform by geosdi.

the class ServiceTest method createAndInsertFolder.

protected long createAndInsertFolder(String folderName, GPProject project, int position, GPFolder parent, int numberOfDescendants) throws ResourceNotFoundFault, IllegalParameterFault {
    GPFolder folder = this.createFolder(folderName, project, position, parent);
    folder.setNumberOfDescendants(numberOfDescendants);
    return gpWSClient.insertFolder(new InsertFolderRequest(project.getId(), folder));
}
Also used : InsertFolderRequest(org.geosdi.geoplatform.request.folder.InsertFolderRequest)

Example 3 with InsertFolderRequest

use of org.geosdi.geoplatform.request.folder.InsertFolderRequest in project geo-platform by geosdi.

the class LayerService method saveFolderForUser.

@Override
public Long saveFolderForUser(String folderName, int position, int numberOfDescendants, boolean isChecked, HttpServletRequest httpServletRequest) throws GeoPlatformException {
    GPFolder folder = new GPFolder();
    folder.setName(folderName);
    folder.setPosition(position);
    folder.setShared(false);
    Long projectId;
    try {
        projectId = this.sessionUtility.getDefaultProject(httpServletRequest);
        this.sessionUtility.getLoggedAccount(httpServletRequest);
    } catch (GPSessionTimeout timeout) {
        throw new GeoPlatformException(timeout);
    }
    folder.setNumberOfDescendants(numberOfDescendants);
    folder.setChecked(isChecked);
    Long savedFolderId;
    try {
        savedFolderId = this.geoPlatformServiceClient.insertFolder(new InsertFolderRequest(projectId, folder));
    } catch (IllegalParameterFault ilg) {
        logger.error("Error on LayerService: " + ilg);
        throw new GeoPlatformException("Parameter incorrect on saveFoldeForUser");
    } catch (ResourceNotFoundFault rnff) {
        logger.error("Error on LayerService: " + rnff);
        throw new GeoPlatformException(rnff);
    }
    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)

Example 4 with InsertFolderRequest

use of org.geosdi.geoplatform.request.folder.InsertFolderRequest in project geo-platform by geosdi.

the class GPJacksonFolderSupportTest method insertFolderRequestDataMapperTest.

@Test
public void insertFolderRequestDataMapperTest() throws Exception {
    InsertFolderRequest insertFolderRequest = jacksonSupport.getDefaultMapper().readValue(Thread.currentThread().getContextClassLoader().getResourceAsStream(INSERT_FOLDER_REQUEST_DATA_JSON), InsertFolderRequest.class);
    logger.info("\n\n@@@@@@@@@@@@@@@@@@@@INSERT_FOLDER_REQUEST_DATA_MAPPING" + " : {}\n\n", insertFolderRequest);
    super.marshall(insertFolderRequest);
}
Also used : InsertFolderRequest(org.geosdi.geoplatform.request.folder.InsertFolderRequest) Test(org.junit.Test)

Aggregations

InsertFolderRequest (org.geosdi.geoplatform.request.folder.InsertFolderRequest)4 GPFolder (org.geosdi.geoplatform.core.model.GPFolder)2 IllegalParameterFault (org.geosdi.geoplatform.exception.IllegalParameterFault)2 ResourceNotFoundFault (org.geosdi.geoplatform.exception.ResourceNotFoundFault)2 GeoPlatformException (org.geosdi.geoplatform.gui.global.GeoPlatformException)2 GPSessionTimeout (org.geosdi.geoplatform.gui.utility.GPSessionTimeout)2 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 Test (org.junit.Test)1