Search in sources :

Example 1 with GPAccount

use of org.geosdi.geoplatform.core.model.GPAccount in project geo-platform by geosdi.

the class SessionUtility method getLoggedAccount.

/**
 * @param httpServletRequest
 * @return {@link GPAccount}
 * @throws GPSessionTimeout
 */
public GPAccount getLoggedAccount(HttpServletRequest httpServletRequest) throws GPSessionTimeout {
    GPAccount account = null;
    HttpSession session = httpServletRequest.getSession();
    Object accountObj = session.getAttribute(SessionProperty.LOGGED_ACCOUNT.toString());
    if (accountObj != null && accountObj instanceof GPAccount) {
        account = (GPAccount) accountObj;
    } else {
        logger.info("\n*** Session Account null ***");
        throw new GPSessionTimeout("Session Timeout");
    }
    return account;
}
Also used : GPAccount(org.geosdi.geoplatform.core.model.GPAccount) HttpSession(javax.servlet.http.HttpSession) GPSessionTimeout(org.geosdi.geoplatform.gui.utility.GPSessionTimeout)

Example 2 with GPAccount

use of org.geosdi.geoplatform.core.model.GPAccount in project geo-platform by geosdi.

the class LayerService method getOrganizationUsers.

@Override
public ArrayList<GPSimpleUser> getOrganizationUsers(HttpServletRequest httpServletRequest) throws GeoPlatformException {
    ArrayList<GPSimpleUser> simpleUserList = null;
    try {
        GPAccount account = this.sessionUtility.getLoggedAccount(httpServletRequest);
        List<ShortAccountDTO> accounts = this.geoPlatformServiceClient.getAccounts(account.getOrganization().getName()).getAccounts();
        simpleUserList = Lists.newArrayList(this.dtoLayerConverter.convertToGPSimpleUser(accounts));
    } catch (GPSessionTimeout timeout) {
        throw new GeoPlatformException(timeout);
    } catch (ResourceNotFoundFault rnf) {
        logger.error("Failed to load Organization Users on SecurityService: " + rnf);
        throw new GeoPlatformException(rnf);
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new GeoPlatformException(ex.getMessage());
    }
    return simpleUserList;
}
Also used : GPAccount(org.geosdi.geoplatform.core.model.GPAccount) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) GPSessionTimeout(org.geosdi.geoplatform.gui.utility.GPSessionTimeout) GPSimpleUser(org.geosdi.geoplatform.gui.model.user.GPSimpleUser) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Example 3 with GPAccount

use of org.geosdi.geoplatform.core.model.GPAccount in project geo-platform by geosdi.

the class LayerService method searchProjects.

@Override
public BasePagingLoadResult<GPClientProject> searchProjects(PagingLoadConfig config, String searchText, String imageURL, HttpServletRequest httpServletRequest) throws GeoPlatformException {
    GPAccount account;
    try {
        account = this.sessionUtility.getLoggedAccount(httpServletRequest);
    } catch (GPSessionTimeout timeout) {
        throw new GeoPlatformException(timeout);
    }
    int start = config.getOffset();
    SearchRequest srq = new SearchRequest(searchText);
    try {
        Long projectsCount = this.geoPlatformServiceClient.getAccountProjectsCount(account.getId(), srq);
        if (projectsCount == 0l) {
            throw new GeoPlatformException("There are no results");
        }
        logger.debug("#############################PROJECT_COUNT : {}\n", projectsCount);
        int page = start == 0 ? start : start / config.getLimit();
        PaginatedSearchRequest psr = new PaginatedSearchRequest(searchText, config.getLimit(), page);
        List<ProjectDTO> projectsDTO = this.geoPlatformServiceClient.searchAccountProjects(account.getId(), psr);
        if (projectsDTO == null) {
            throw new GeoPlatformException("There are no results");
        }
        ArrayList<GPClientProject> clientProjects = new ArrayList<GPClientProject>();
        for (ProjectDTO projectDTO : projectsDTO) {
            GPClientProject clientProject = this.dtoLayerConverter.convertToGPCLientProject(projectDTO, imageURL);
            clientProjects.add(clientProject);
        }
        return new BasePagingLoadResult<GPClientProject>(clientProjects, config.getOffset(), projectsCount.intValue());
    } catch (ResourceNotFoundFault ex) {
        ex.printStackTrace();
        throw new GeoPlatformException(ex.getMessage());
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new GeoPlatformException(ex.getMessage());
    }
}
Also used : GPAccount(org.geosdi.geoplatform.core.model.GPAccount) GPClientProject(org.geosdi.geoplatform.gui.client.model.projects.GPClientProject) SearchRequest(org.geosdi.geoplatform.request.SearchRequest) PaginatedSearchRequest(org.geosdi.geoplatform.request.PaginatedSearchRequest) PaginatedSearchRequest(org.geosdi.geoplatform.request.PaginatedSearchRequest) ArrayList(java.util.ArrayList) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) GPSessionTimeout(org.geosdi.geoplatform.gui.utility.GPSessionTimeout) BasePagingLoadResult(com.extjs.gxt.ui.client.data.BasePagingLoadResult) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException)

Example 4 with GPAccount

use of org.geosdi.geoplatform.core.model.GPAccount in project geo-platform by geosdi.

the class LayerService method loadProject.

@Override
public ArrayList<GPFolderClientInfo> loadProject(long projectId, HttpServletRequest httpServletRequest) throws GeoPlatformException {
    GPAccount account;
    try {
        account = this.sessionUtility.getLoggedAccount(httpServletRequest);
    } catch (GPSessionTimeout timeout) {
        throw new GeoPlatformException(timeout);
    }
    List<FolderDTO> folderList = null;
    try {
        ProjectDTO project;
        if (account.isLoadExpandedFolders()) {
            project = geoPlatformServiceClient.getProjectWithExpandedFolders(projectId, account.getId());
        } else {
            project = geoPlatformServiceClient.getProjectWithRootFolders(projectId, account.getId());
        }
        folderList = project.getRootFolders();
    } catch (ResourceNotFoundFault rnf) {
        logger.debug("Returning no elements: " + rnf);
    }
    return this.dtoLayerConverter.convertOnlyFolders(folderList);
}
Also used : GPAccount(org.geosdi.geoplatform.core.model.GPAccount) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) GPSessionTimeout(org.geosdi.geoplatform.gui.utility.GPSessionTimeout) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException)

Example 5 with GPAccount

use of org.geosdi.geoplatform.core.model.GPAccount in project geo-platform by geosdi.

the class LayerService method loadDefaultProjectElements.

@Override
public GPClientProject loadDefaultProjectElements(HttpServletRequest httpServletRequest) throws GeoPlatformException {
    Long projectId;
    GPAccount account;
    try {
        account = this.sessionUtility.getLoggedAccount(httpServletRequest);
        projectId = this.sessionUtility.getDefaultProject(httpServletRequest);
    } catch (GPSessionTimeout timeout) {
        // System.out.println("Session timeout on loadDefaultProjectElements");
        throw new GeoPlatformException(timeout);
    }
    ProjectDTO projectDTO = null;
    try {
        GPProject project = this.geoPlatformServiceClient.getProjectDetail(projectId);
        if (account.isLoadExpandedFolders() || project.isShared()) {
            projectDTO = this.geoPlatformServiceClient.getProjectWithExpandedFolders(projectId, account.getId());
        } else {
            projectDTO = geoPlatformServiceClient.getProjectWithRootFolders(projectId, account.getId());
        }
    } catch (ResourceNotFoundFault rnf) {
        logger.error("Returning no elements: " + rnf);
    }
    try {
        return this.dtoLayerConverter.convertToGPClientProject(projectDTO);
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new GeoPlatformException(ex.getMessage());
    }
}
Also used : GPAccount(org.geosdi.geoplatform.core.model.GPAccount) GPProject(org.geosdi.geoplatform.core.model.GPProject) 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

GPAccount (org.geosdi.geoplatform.core.model.GPAccount)36 GeoPlatformException (org.geosdi.geoplatform.gui.global.GeoPlatformException)17 GPSessionTimeout (org.geosdi.geoplatform.gui.utility.GPSessionTimeout)17 ResourceNotFoundFault (org.geosdi.geoplatform.exception.ResourceNotFoundFault)16 GPDAOException (org.geosdi.geoplatform.persistence.dao.exception.GPDAOException)9 GPUser (org.geosdi.geoplatform.core.model.GPUser)8 IOException (java.io.IOException)7 MalformedURLException (java.net.MalformedURLException)6 IllegalParameterFault (org.geosdi.geoplatform.exception.IllegalParameterFault)5 GPAccountProject (org.geosdi.geoplatform.core.model.GPAccountProject)4 GPProject (org.geosdi.geoplatform.core.model.GPProject)4 ArrayList (java.util.ArrayList)3 Query (javax.persistence.Query)3 GPApplication (org.geosdi.geoplatform.core.model.GPApplication)3 GPMessage (org.geosdi.geoplatform.core.model.GPMessage)3 InfoPreview (org.geosdi.geoplatform.responce.InfoPreview)3 MessageDTO.convertToGPMessage (org.geosdi.geoplatform.response.MessageDTO.convertToGPMessage)3 Date (java.util.Date)2 HttpSession (javax.servlet.http.HttpSession)2 ProcessEPSGResultRequest (org.geosdi.geoplatform.request.ProcessEPSGResultRequest)2