@Override public GPClientProject loadDefaultProjectElements(HttpServletRequest httpServletRequest) throws GeoPlatformException { Long projectId = null; 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); } return this.dtoLayerConverter.convertToGPClientProject(projectDTO); }
@Override public void setDefaultProject(Long projectID, HttpServletRequest httpServletRequest) throws GeoPlatformException { try { GPAccount account = this.sessionUtility.getLoggedAccount(httpServletRequest); GPProject updatedProjecd = this.geoPlatformServiceClient.updateDefaultProject(account.getId(), projectID); this.sessionUtility.storeLoggedAccountAndDefaultProject( account, updatedProjecd.getId(), httpServletRequest); } catch (GPSessionTimeout timeout) { throw new GeoPlatformException(timeout); } catch (ResourceNotFoundFault ex) { logger.error("An Error Occured : " + ex.getMessage()); throw new GeoPlatformException(ex); } }
@Override public boolean shareProjectToUsers( long idSharedProject, List<Long> accountIDsProject, HttpServletRequest httpServletRequest) throws GeoPlatformException { boolean result = false; 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; }