Search in sources :

Example 1 with GPSessionTimeout

use of org.geosdi.geoplatform.gui.utility.GPSessionTimeout in project geo-platform by geosdi.

the class SessionUtility method getDefaultProject.

/**
 * @param httpServletRequest
 * @return {@link Long}
 * @throws GPSessionTimeout
 */
public Long getDefaultProject(HttpServletRequest httpServletRequest) throws GPSessionTimeout {
    HttpSession session = httpServletRequest.getSession();
    Long projectId = (Long) session.getAttribute(SessionProperty.DEFAULT_PROJECT.toString());
    if (projectId != null) {
        return projectId;
    } else {
        logger.info("\n*** Session Project ID null ***");
        throw new GPSessionTimeout("Session Timeout");
    }
}
Also used : HttpSession(javax.servlet.http.HttpSession) GPSessionTimeout(org.geosdi.geoplatform.gui.utility.GPSessionTimeout)

Example 2 with GPSessionTimeout

use of org.geosdi.geoplatform.gui.utility.GPSessionTimeout 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 3 with GPSessionTimeout

use of org.geosdi.geoplatform.gui.utility.GPSessionTimeout in project geo-platform by geosdi.

the class OGCService method getCapabilitiesAuth.

@Override
public ArrayList<? extends GPLayerGrid> getCapabilitiesAuth(String serverUrl, HttpServletRequest httpServletRequest, Long idServer) throws GeoPlatformException {
    try {
        HttpSession session = httpServletRequest.getSession();
        String token = (String) session.getAttribute("GOOGLE_TOKEN");
        /**
         *@TODO think a way to have this configured*
         */
        String authValue = httpServletRequest.getHeader("iv-user");
        // Enumeration<String> headerNames = httpServletRequest.getHeaderNames();
        List<WMSHeaderParam> headerParams = Lists.newArrayList();
        if ((authValue != null) && !(authValue.trim().isEmpty())) {
            headerParams.add(new WMSHeaderParam("iv-user", authValue));
        }
        // List<WMSHeaderParam> headerKeyValues = Collections.list(headerNames)
        // .stream()
        // .filter(key -> ((httpServletRequest.getHeader(key) != null)))
        // .map(key -> new WMSHeaderParam(key, httpServletRequest.getHeader(key)))
        // .collect(toList());
        logger.trace("###########################HEADERS_TO_PASS_TO_SERVICE : {}\n", headerParams);
        RequestByID req = new RequestByID(idServer);
        GSAccount gsAccount = this.sessionUtility.getLoggedAccount(httpServletRequest).getGsAccount();
        String authKey = null;
        if (gsAccount != null) {
            authKey = gsAccount.getAuthkey();
        }
        ServerDTO server = geoPlatformWMSServiceClient.getCapabilitiesAuth(serverUrl, req, token, authKey, headerParams);
        return dtoServerConverter.createRasterLayerList(server.getLayerList());
    } catch (ResourceNotFoundFault ex) {
        logger.error("Error GetCapabilities: " + ex);
        throw new GeoPlatformException(ex.getMessage());
    } catch (GPSessionTimeout timeout) {
        throw new GeoPlatformException(timeout);
    }
}
Also used : WMSHeaderParam(org.geosdi.geoplatform.services.request.WMSHeaderParam) ServerDTO(org.geosdi.geoplatform.response.ServerDTO) HttpSession(javax.servlet.http.HttpSession) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) GSAccount(org.geosdi.geoplatform.core.model.GSAccount) GPSessionTimeout(org.geosdi.geoplatform.gui.utility.GPSessionTimeout) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException) RequestByID(org.geosdi.geoplatform.request.RequestByID)

Example 4 with GPSessionTimeout

use of org.geosdi.geoplatform.gui.utility.GPSessionTimeout in project geo-platform by geosdi.

the class DeleteTreeElementCommand method execute.

@Override
public DeleteTreeElementResponse execute(DeleteTreeElementRequest request, HttpServletRequest httpServletRequest) {
    logger.debug("##################### Executing {} Command", this.getClass().getSimpleName());
    MementoSaveRemove memento = request.getMemento();
    Preconditions.checkNotNull(memento, "The MementoSaveRemove must not be " + "null.");
    try {
        this.sessionUtility.getLoggedAccount(httpServletRequest);
    } catch (GPSessionTimeout timeout) {
        throw new GeoPlatformException(timeout);
    }
    GPWebServiceMapData map = this.dtoMementoConverter.convertDescendantMap(memento.getWsDescendantMap());
    boolean result = false;
    switch(request.getElementType()) {
        case COMPOSITE:
            try {
                result = this.geoPlatformServiceClient.saveDeletedFolderAndTreeModifications(new WSDeleteFolderAndTreeModifications(memento.getIdBaseElement(), map));
            } catch (ResourceNotFoundFault ex) {
                logger.error("Failed to Delete Folder Element : " + ex);
                throw new GeoPlatformException(ex);
            }
            break;
        case LEAF:
            try {
                result = this.geoPlatformServiceClient.saveDeletedLayerAndTreeModifications(new WSDeleteLayerAndTreeModificationsRequest(memento.getIdBaseElement(), map));
            } catch (ResourceNotFoundFault ex) {
                logger.error("Failed to Delete Layer Element : " + ex);
                throw new GeoPlatformException(ex);
            }
            break;
    }
    return new DeleteTreeElementResponse(result);
}
Also used : DeleteTreeElementResponse(org.geosdi.geoplatform.gui.client.command.memento.toolbar.DeleteTreeElementResponse) WSDeleteLayerAndTreeModificationsRequest(org.geosdi.geoplatform.request.layer.WSDeleteLayerAndTreeModificationsRequest) GPWebServiceMapData(org.geosdi.geoplatform.response.collection.GPWebServiceMapData) WSDeleteFolderAndTreeModifications(org.geosdi.geoplatform.request.folder.WSDeleteFolderAndTreeModifications) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) GPSessionTimeout(org.geosdi.geoplatform.gui.utility.GPSessionTimeout) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException) MementoSaveRemove(org.geosdi.geoplatform.gui.client.model.memento.save.bean.MementoSaveRemove)

Example 5 with GPSessionTimeout

use of org.geosdi.geoplatform.gui.utility.GPSessionTimeout in project geo-platform by geosdi.

the class SaveFolderPropertiesCommand method execute.

@Override
public SaveFolderPropertiesResponse execute(SaveFolderPropertiesRequest request, HttpServletRequest httpServletRequest) {
    logger.info("##################### Executing {} Command", this.getClass().getSimpleName());
    try {
        this.sessionUtility.getLoggedAccount(httpServletRequest);
    } catch (GPSessionTimeout timeout) {
        throw new GeoPlatformException(timeout);
    }
    try {
        MementoFolderOriginalProperties memento = request.getMementoFolderOriginalProperties();
        geoPlatformServiceClient.saveFolderProperties(memento.getIdBaseElement(), memento.getName(), memento.isChecked(), memento.isExpanded());
    } catch (ResourceNotFoundFault ex) {
        SaveFolderPropertiesCommand.logger.error("Failed to save folder on LayerService: " + ex);
        throw new GeoPlatformException(ex);
    } catch (IllegalParameterFault ex) {
        SaveFolderPropertiesCommand.logger.error("Failed to save folder on LayerService: " + ex);
        throw new GeoPlatformException(ex);
    }
    logger.debug("#################### After sending project notification");
    return new SaveFolderPropertiesResponse(Boolean.TRUE);
}
Also used : IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) GPSessionTimeout(org.geosdi.geoplatform.gui.utility.GPSessionTimeout) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException) MementoFolderOriginalProperties(org.geosdi.geoplatform.gui.client.model.memento.save.storage.MementoFolderOriginalProperties) SaveFolderPropertiesResponse(org.geosdi.geoplatform.gui.client.command.memento.basic.SaveFolderPropertiesResponse)

Aggregations

GPSessionTimeout (org.geosdi.geoplatform.gui.utility.GPSessionTimeout)56 GeoPlatformException (org.geosdi.geoplatform.gui.global.GeoPlatformException)39 ResourceNotFoundFault (org.geosdi.geoplatform.exception.ResourceNotFoundFault)35 GPAccount (org.geosdi.geoplatform.core.model.GPAccount)17 IllegalParameterFault (org.geosdi.geoplatform.exception.IllegalParameterFault)15 GPLoginEvent (org.geosdi.geoplatform.gui.impl.map.event.GPLoginEvent)15 IOException (java.io.IOException)12 MalformedURLException (java.net.MalformedURLException)11 GPWebServiceMapData (org.geosdi.geoplatform.response.collection.GPWebServiceMapData)9 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)7 RpcTokenException (com.google.gwt.user.client.rpc.RpcTokenException)6 XsrfToken (com.google.gwt.user.client.rpc.XsrfToken)6 HttpSession (javax.servlet.http.HttpSession)4 GPFolder (org.geosdi.geoplatform.core.model.GPFolder)4 List (java.util.List)3 GPAccountProject (org.geosdi.geoplatform.core.model.GPAccountProject)3 GPProject (org.geosdi.geoplatform.core.model.GPProject)3 DisplayLayersProgressBarEvent (org.geosdi.geoplatform.gui.puregwt.progressbar.layers.event.DisplayLayersProgressBarEvent)3 ButtonEvent (com.extjs.gxt.ui.client.event.ButtonEvent)2 Button (com.extjs.gxt.ui.client.widget.button.Button)2