Search in sources :

Example 16 with GPUser

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

the class LayerService method setLayerRefreshTime.

@Override
public void setLayerRefreshTime(String emiteResource, String layerUUID, int secondToRefresh, HttpServletRequest httpServletRequest) throws GeoPlatformException {
    try {
        GPAccount account = this.sessionUtility.getLoggedAccount(httpServletRequest);
        if (account instanceof GPUser) {
            String username = ((GPUser) account).getUsername();
            if (secondToRefresh > 0) {
                logger.debug("Request to subscribe layer refresh for: " + username + " - " + layerUUID);
                httpServletRequest.getSession().setMaxInactiveInterval(-1);
                this.geoPlatformTrackingClient.subscribeLayerNotification(username, emiteResource, layerUUID, secondToRefresh);
            } else if (account instanceof GPUser) {
                logger.debug("Request to UNsubscribe layer refresh for: " + username + " - " + layerUUID);
                this.geoPlatformTrackingClient.unscribeLayerNotification(username, layerUUID);
            }
        }
    } catch (GPSessionTimeout timeout) {
        throw new GeoPlatformException(timeout);
    }
}
Also used : GPAccount(org.geosdi.geoplatform.core.model.GPAccount) GPUser(org.geosdi.geoplatform.core.model.GPUser) GPSessionTimeout(org.geosdi.geoplatform.gui.utility.GPSessionTimeout) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException)

Example 17 with GPUser

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

the class UserService method updateUser.

@Override
public Long updateUser(IGPUserManageDetail userDetail, HttpServletRequest httpServletRequest) throws GeoPlatformException {
    this.getCheckLoggedUser(httpServletRequest);
    logger.debug("\nUser to UPDATE:\n{}", userDetail);
    Long userID = null;
    try {
        GPUser user = this.dtoUserConverter.convertToGPUser(userDetail);
        userID = geoPlatformServiceClient.updateUser(user);
    } catch (IllegalParameterFault ipf) {
        throw new GeoPlatformException(ipf.getMessage());
    } catch (ResourceNotFoundFault rnnf) {
        throw new GeoPlatformException(rnnf.getMessage());
    }
    return userID;
}
Also used : IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) GPUser(org.geosdi.geoplatform.core.model.GPUser) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException)

Example 18 with GPUser

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

the class UserService method updateUserTreeOptions.

@Override
public Long updateUserTreeOptions(IGPTreeOptions userTreeOptions, HttpServletRequest httpServletRequest) throws GeoPlatformException {
    GPUser gPUser = this.getCheckLoggedUser(httpServletRequest);
    logger.debug("\nUserTreeOptions to UPDATE:\n{}", userTreeOptions);
    Long accountProjectID = null;
    try {
        gPUser.setLoadExpandedFolders(userTreeOptions.isLoadExpandedFolders());
        accountProjectID = geoPlatformServiceClient.updateUser(gPUser);
    } catch (IllegalParameterFault ipf) {
        throw new GeoPlatformException(ipf.getMessage());
    } catch (ResourceNotFoundFault rnnf) {
        throw new GeoPlatformException(rnnf.getMessage());
    }
    return accountProjectID;
}
Also used : IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) GPUser(org.geosdi.geoplatform.core.model.GPUser) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException)

Example 19 with GPUser

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

the class UserService method insertUser.

@Override
public Long insertUser(IGPUserManageDetail userDetail, String organization, HttpServletRequest httpServletRequest, boolean checkUserSession, boolean sendEmail) throws GeoPlatformException {
    if (checkUserSession) {
        this.getCheckLoggedUser(httpServletRequest);
    }
    logger.debug("\nUser to INSERT (of the organization \"{}\"):\n{}", organization, userDetail);
    Long iserId = null;
    try {
        GPUser user = this.dtoUserConverter.convertToGPUser(userDetail);
        user.setOrganization(new GPOrganization(organization));
        iserId = geoPlatformServiceClient.insertAccount(new InsertAccountRequest(user, sendEmail));
    } catch (IllegalParameterFault ipf) {
        throw new GeoPlatformException(ipf.getMessage());
    }
    return iserId;
}
Also used : InsertAccountRequest(org.geosdi.geoplatform.request.InsertAccountRequest) IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) GPUser(org.geosdi.geoplatform.core.model.GPUser) GPOrganization(org.geosdi.geoplatform.core.model.GPOrganization) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException)

Example 20 with GPUser

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

the class UserService method searchUsers.

@Override
public PagingLoadResult<GPUserManageDetail> searchUsers(PagingLoadConfig config, String searchText, String organization, HttpServletRequest httpServletRequest) {
    GPUser user = this.getCheckLoggedUser(httpServletRequest);
    SearchRequest srq = new SearchRequest(searchText);
    Long usersCount = this.geoPlatformServiceClient.getUsersCount(organization, srq);
    int start = config.getOffset();
    int page = start == 0 ? start : start / config.getLimit();
    PaginatedSearchRequest psr = new PaginatedSearchRequest(searchText, config.getLimit(), page);
    List<UserDTO> userList = null;
    try {
        userList = this.geoPlatformServiceClient.searchUsers(user.getId(), psr).getSearchUsers();
        if (userList == null) {
            throw new GeoPlatformException("There are no results");
        }
    } catch (ResourceNotFoundFault rnnf) {
        // TODO Better message
        throw new GeoPlatformException(rnnf.getMessage());
    }
    List<GPUserManageDetail> searchUsers = new ArrayList<GPUserManageDetail>();
    for (UserDTO userDTO : userList) {
        GPUserManageDetail userDetail = this.dtoUserConverter.convertToGPUserManageDetail(userDTO);
        searchUsers.add(userDetail);
    }
    return new BasePagingLoadResult<GPUserManageDetail>(searchUsers, config.getOffset(), usersCount.intValue());
}
Also used : PaginatedSearchRequest(org.geosdi.geoplatform.request.PaginatedSearchRequest) SearchRequest(org.geosdi.geoplatform.request.SearchRequest) GPUser(org.geosdi.geoplatform.core.model.GPUser) PaginatedSearchRequest(org.geosdi.geoplatform.request.PaginatedSearchRequest) UserDTO(org.geosdi.geoplatform.response.UserDTO) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) ArrayList(java.util.ArrayList) BasePagingLoadResult(com.extjs.gxt.ui.client.data.BasePagingLoadResult) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException) GPUserManageDetail(org.geosdi.geoplatform.gui.client.model.GPUserManageDetail) IGPUserManageDetail(org.geosdi.geoplatform.gui.global.security.IGPUserManageDetail)

Aggregations

GPUser (org.geosdi.geoplatform.core.model.GPUser)33 Test (org.junit.Test)15 GPAccount (org.geosdi.geoplatform.core.model.GPAccount)8 IllegalParameterFault (org.geosdi.geoplatform.exception.IllegalParameterFault)7 InsertAccountRequest (org.geosdi.geoplatform.request.InsertAccountRequest)7 GeoPlatformException (org.geosdi.geoplatform.gui.global.GeoPlatformException)6 GPDAOException (org.geosdi.geoplatform.persistence.dao.exception.GPDAOException)6 GPOrganization (org.geosdi.geoplatform.core.model.GPOrganization)4 ResourceNotFoundFault (org.geosdi.geoplatform.exception.ResourceNotFoundFault)4 UserDTO (org.geosdi.geoplatform.response.UserDTO)4 Query (javax.persistence.Query)3 ClientErrorException (javax.ws.rs.ClientErrorException)3 GPRestExceptionMessage (org.geosdi.geoplatform.exception.rs.GPRestExceptionMessage)3 PaginatedSearchRequest (org.geosdi.geoplatform.request.PaginatedSearchRequest)3 SearchRequest (org.geosdi.geoplatform.request.SearchRequest)3 ArrayList (java.util.ArrayList)2 GPApplication (org.geosdi.geoplatform.core.model.GPApplication)2 GPSessionTimeout (org.geosdi.geoplatform.gui.utility.GPSessionTimeout)2 UserDTOResponse (org.geosdi.geoplatform.response.UserDTOResponse)2 BasePagingLoadResult (com.extjs.gxt.ui.client.data.BasePagingLoadResult)1