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;
}
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;
}
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());
}
}
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);
}
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());
}
}
Aggregations