use of org.geosdi.geoplatform.request.SearchRequest 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.request.SearchRequest in project geo-platform by geosdi.
the class GPCatalogFinderService method searchCSWServers.
@Override
public PagingLoadResult<GPCSWServerBeanModel> searchCSWServers(PagingLoadConfig config, String searchText, String organization, HttpServletRequest httpServletRequest) throws GeoPlatformException {
SearchRequest srq = new SearchRequest(searchText);
int serversCount = geoPlatformCSWClient.getCSWServersCount(srq, organization);
ArrayList<GPCSWServerBeanModel> searchServers;
if (serversCount == 0) {
logger.info("\n*** No catalog found ***");
searchServers = new ArrayList<GPCSWServerBeanModel>(0);
} else {
int start = config.getOffset();
int page = start == 0 ? start : start / config.getLimit();
PaginatedSearchRequest psr = new PaginatedSearchRequest(searchText, config.getLimit(), page);
List<ServerCSWDTO> serverList = geoPlatformCSWClient.searchCSWServers(psr, organization);
searchServers = new ArrayList<GPCSWServerBeanModel>(serverList.size());
for (ServerCSWDTO serverDTO : serverList) {
searchServers.add(this.convertServerDTO(serverDTO));
}
}
return new BasePagingLoadResult<GPCSWServerBeanModel>(searchServers, config.getOffset(), serversCount);
}
use of org.geosdi.geoplatform.request.SearchRequest in project geo-platform by geosdi.
the class SecurityService method xmppGetDataLogin.
@Override
public XMPPLoginDetails xmppGetDataLogin(String userName, HttpServletRequest httpServletRequest) throws GeoPlatformException {
XMPPLoginDetails xMPPLoginDetails = null;
if (userName != null) {
GPUser user;
try {
user = geoPlatformServiceClient.getUserDetailByUsername(new SearchRequest(userName, LikePatternType.CONTENT_EQUALS));
xMPPLoginDetails = new XMPPLoginDetails();
xMPPLoginDetails.setUsername(user.getUsername());
xMPPLoginDetails.setPassword(user.getPassword());
xMPPLoginDetails.setHostXmppServer(this.hostXmppServer);
} catch (ResourceNotFoundFault ex) {
logger.error("SecurityService", "Unable to find user with username: " + userName + " Error: " + ex);
throw new GeoPlatformException("Unable to find user with username: " + userName);
}
}
return xMPPLoginDetails;
}
use of org.geosdi.geoplatform.request.SearchRequest in project geo-platform by geosdi.
the class SecurityService method casLogin.
@Override
public IGPAccountDetail casLogin(HttpServletRequest httpServletRequest) throws GeoPlatformException {
Assertion casAssertion = (AssertionImpl) httpServletRequest.getSession().getAttribute(AbstractCasFilter.CONST_CAS_ASSERTION);
IGPAccountDetail accountDetail = null;
if (casAssertion != null && casAssertion.getPrincipal() != null && casAssertion.getPrincipal().getName() != null) {
String casUserName = casAssertion.getPrincipal().getName();
GPUser user;
try {
user = geoPlatformServiceClient.getUserDetailByUsername(new SearchRequest(casUserName, LikePatternType.CONTENT_EQUALS));
geoPlatformServiceClient.getAccountPermission(user.getId());
accountDetail = this.executeLoginOnGPAccount(user, geoPlatformServiceClient.getAccountPermission(user.getId()), null, httpServletRequest);
} catch (ResourceNotFoundFault ex) {
logger.info("SecurityService", "Unable to find user with username or email: " + casUserName + " Error: " + ex);
accountDetail = this.createNewCASUser(casUserName, httpServletRequest);
} catch (SOAPFaultException ex) {
logger.error("Error on SecurityService: " + ex + " password incorrect");
throw new GeoPlatformException("Password incorrect");
}
}
return accountDetail;
}
use of org.geosdi.geoplatform.request.SearchRequest in project geo-platform by geosdi.
the class RSAccountTest method testRetrieveUserRest.
@Test
public void testRetrieveUserRest() throws ResourceNotFoundFault {
// Number of Account Like
long numAccountsLike = gpWSClient.getAccountsCount(new SearchRequest(usernameTest, LikePatternType.CONTENT_EQUALS));
Assert.assertEquals("Number of Account Like", 1L, numAccountsLike);
// Get User from Id
// Get UserDTO from Id
UserDTOResponse userDTOResponse = gpWSClient.getShortUser(idUserTest);
UserDTO userDTOFromWS = userDTOResponse.getUserDTO();
Assert.assertNotNull(userDTOFromWS);
Assert.assertEquals("Error found UserDTO from Id", idUserTest, userDTOFromWS.getId().longValue());
// Get GPUser from Id
GPUser userFromWS = gpWSClient.getUserDetail(idUserTest);
Assert.assertNotNull(userFromWS);
Assert.assertEquals("Error found GPUser from Id", idUserTest, userFromWS.getId().longValue());
// Get User from Username
// Get UserDTO from Username
userDTOFromWS = gpWSClient.getShortUserByUsername(new SearchRequest(usernameTest, LikePatternType.CONTENT_EQUALS)).getUserDTO();
Assert.assertNotNull(userDTOFromWS);
Assert.assertEquals("Error found UserDTO from Username", idUserTest, userDTOFromWS.getId().longValue());
// Get GPUser from Username
userFromWS = gpWSClient.getUserDetailByUsername(new SearchRequest(usernameTest, LikePatternType.CONTENT_EQUALS));
Assert.assertNotNull(userFromWS);
Assert.assertEquals("Error found GPUser from Username", idUserTest, userFromWS.getId().longValue());
}
Aggregations