Search in sources :

Example 6 with GPAccountProject

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

the class MapService method saveBaseLayer.

// @Override
// public String layerAuthenticate(String userName, String password, String url) throws GeoPlatformException {
// HTTPUtils hTTPUtils = new HTTPUtils(userName, password);
// String responce = null;
// try {
// logger.info("Layer: " + url);
// responce = hTTPUtils.get("http://localhost:8989/geoserver");
// logger.info("Auth Responce: " + responce);
// } catch (MalformedURLException mfe) {
// System.out.println("Url tazzo: " + mfe);
// }
// return responce;
// }
@Override
public void saveBaseLayer(String baseLayer, HttpServletRequest httpServletRequest) throws GeoPlatformException {
    GPAccount account;
    Long projectID;
    try {
        account = this.sessionUtility.getLoggedAccount(httpServletRequest);
        projectID = this.sessionUtility.getDefaultProject(httpServletRequest);
    } catch (GPSessionTimeout timeout) {
        throw new GeoPlatformException(timeout);
    }
    try {
        GPAccountProject accountProject = this.geoPlatformServiceClient.getAccountProjectByAccountAndProjectIDs(account.getId(), projectID);
        accountProject.setBaseLayer(baseLayer);
        this.geoPlatformServiceClient.updateAccountProject(accountProject);
    } catch (ResourceNotFoundFault rnff) {
        logger.error("Error on MapService: " + rnff);
        throw new GeoPlatformException(rnff);
    } catch (IllegalParameterFault ipf) {
        logger.error("Error on MapService: " + ipf);
        throw new GeoPlatformException(ipf);
    }
}
Also used : GPAccount(org.geosdi.geoplatform.core.model.GPAccount) GPAccountProject(org.geosdi.geoplatform.core.model.GPAccountProject) 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)

Example 7 with GPAccountProject

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

the class GPViewportDelegate method replaceViewportList.

@Override
public void replaceViewportList(ManageViewportRequest request) throws ResourceNotFoundFault, IllegalParameterFault {
    if (request == null) {
        throw new IllegalParameterFault("The ManageViewportRequest must " + "not be null.");
    }
    Long accountProjectID = request.getAccountProjectID();
    ArrayList<GPViewport> viewportList = request.getViewportList();
    GPAccountProject accountProject = this.accountProjectDao.find(accountProjectID);
    if (accountProject == null) {
        throw new ResourceNotFoundFault("AccountProject not found", accountProjectID);
    }
    List<GPViewport> oldViewportList = this.viewportDao.findByAccountProjectID(accountProjectID);
    for (GPViewport viewport : oldViewportList) {
        this.viewportDao.removeById(viewport.getId());
    }
    if (viewportList != null) {
        for (GPViewport viewport : viewportList) {
            this.insertViewport(accountProjectID, viewport);
        }
    }
}
Also used : GPViewport(org.geosdi.geoplatform.core.model.GPViewport) IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) GPAccountProject(org.geosdi.geoplatform.core.model.GPAccountProject) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault)

Example 8 with GPAccountProject

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

the class GPViewportDelegate method insertViewport.

private Long insertViewport(Long accountProjectID, GPViewport viewport) throws ResourceNotFoundFault, IllegalParameterFault {
    GPAccountProject accountProject = this.accountProjectDao.find(accountProjectID);
    if (accountProject == null) {
        throw new ResourceNotFoundFault("AccountProject not found", accountProjectID);
    }
    viewport.setAccountProject(accountProject);
    EntityCorrectness.checkViewport(viewport);
    viewportDao.persist(viewport);
    return viewport.getId();
}
Also used : GPAccountProject(org.geosdi.geoplatform.core.model.GPAccountProject) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault)

Example 9 with GPAccountProject

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

the class GPTrackingServiceImpl method sendSharedProjectNotification.

/**
 * @see GPTrackingService#sendSharedProjectNotification(java.lang.Long,
 * org.geosdi.geoplatform.services.XMPPSubjectServerEnum, java.lang.String,
 * org.geosdi.geoplatform.responce.collection.XmppAttributesMap)
 */
@Override
public void sendSharedProjectNotification(Long projectID, XMPPSubjectEnum subject, String text, XmppAttributesMap attributesMap) throws ResourceNotFoundFault {
    GPProject project = projectDao.find(projectID);
    if (project == null) {
        throw new ResourceNotFoundFault("Project not found", projectID);
    }
    // TODO assert
    EntityCorrectness.checkProjectLog(project);
    if (!project.isShared()) {
        // TODO assert
        throw new EntityCorrectnessException("The Project must be shared.");
    }
    List<GPAccountProject> accounts = accountProjectDao.findNotOwnersByProjectID(projectID);
    // TODO assert
    EntityCorrectness.checkAccountProjectListLog(accounts);
    Roster roster = this.connection.getRoster();
    Message message = this.createUnknowMessage(subject, text, attributesMap);
    for (GPAccountProject accountProject : accounts) {
        GPAccount account = accountProject.getAccount();
        // TODO assert
        EntityCorrectness.checkAccountLog(account);
        // If user have this project as default
        if (accountProject.isDefaultProject()) {
            // Username for User
            String naturalID = account.getNaturalID();
            String recipient = this.createXmppUri(naturalID);
            logger.trace("\n\n*** Recipient XMPP uri: {} ***", recipient);
            // If user is online send the message
            Presence presence = roster.getPresence(recipient);
            if (presence.isAvailable()) {
                logger.info("\n*** Send Message to online user \"{}\" ***", naturalID);
                message.setTo(recipient);
                connection.sendPacket(message);
            }
        }
    }
}
Also used : EntityCorrectnessException(org.geosdi.geoplatform.services.development.EntityCorrectnessException) GPAccount(org.geosdi.geoplatform.core.model.GPAccount) GPProject(org.geosdi.geoplatform.core.model.GPProject) GPAccountProject(org.geosdi.geoplatform.core.model.GPAccountProject) Roster(org.jivesoftware.smack.Roster) Message(org.jivesoftware.smack.packet.Message) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) Presence(org.jivesoftware.smack.packet.Presence)

Example 10 with GPAccountProject

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

the class MapService method replaceViewportList.

@Override
public void replaceViewportList(List<GPClientViewport> viewportList, HttpServletRequest httpServletRequest) throws GeoPlatformException {
    GPAccount account;
    Long projectID;
    try {
        account = this.sessionUtility.getLoggedAccount(httpServletRequest);
        projectID = this.sessionUtility.getDefaultProject(httpServletRequest);
    } catch (GPSessionTimeout timeout) {
        throw new GeoPlatformException(timeout);
    }
    try {
        GPAccountProject accountProject = this.geoPlatformServiceClient.getAccountProjectByAccountAndProjectIDs(account.getId(), projectID);
        this.geoPlatformServiceClient.replaceViewportList(new ManageViewportRequest(accountProject.getId(), convertClientViewportToDTO(viewportList)));
    } catch (ResourceNotFoundFault | IllegalParameterFault rnff) {
        logger.error("Error on MapService: " + rnff);
        throw new GeoPlatformException(rnff);
    }
}
Also used : GPAccount(org.geosdi.geoplatform.core.model.GPAccount) GPAccountProject(org.geosdi.geoplatform.core.model.GPAccountProject) IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) ManageViewportRequest(org.geosdi.geoplatform.request.viewport.ManageViewportRequest) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) GPSessionTimeout(org.geosdi.geoplatform.gui.utility.GPSessionTimeout) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException)

Aggregations

GPAccountProject (org.geosdi.geoplatform.core.model.GPAccountProject)20 GPDAOException (org.geosdi.geoplatform.persistence.dao.exception.GPDAOException)11 ResourceNotFoundFault (org.geosdi.geoplatform.exception.ResourceNotFoundFault)7 GPAccount (org.geosdi.geoplatform.core.model.GPAccount)4 IllegalParameterFault (org.geosdi.geoplatform.exception.IllegalParameterFault)4 GPViewport (org.geosdi.geoplatform.core.model.GPViewport)3 GeoPlatformException (org.geosdi.geoplatform.gui.global.GeoPlatformException)3 GPSessionTimeout (org.geosdi.geoplatform.gui.utility.GPSessionTimeout)3 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Lists (com.google.common.collect.Lists)1 FALSE (java.lang.Boolean.FALSE)1 TRUE (java.lang.Boolean.TRUE)1 List (java.util.List)1 TypedQuery (javax.persistence.TypedQuery)1 javax.persistence.criteria (javax.persistence.criteria)1 GPAccountProjectDAO (org.geosdi.geoplatform.core.dao.GPAccountProjectDAO)1 GPProject (org.geosdi.geoplatform.core.model.GPProject)1 GPAbstractJpaDAO (org.geosdi.geoplatform.persistence.dao.jpa.GPAbstractJpaDAO)1 ManageViewportRequest (org.geosdi.geoplatform.request.viewport.ManageViewportRequest)1 EntityCorrectnessException (org.geosdi.geoplatform.services.development.EntityCorrectnessException)1