Search in sources :

Example 11 with GPOrganization

use of org.geosdi.geoplatform.core.model.GPOrganization 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 12 with GPOrganization

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

the class GPServerDAOImpl method searchPagebleServers.

/**
 * @param page
 * @param size
 * @param organizationName
 * @param titleOrAliasName
 * @return {@link List<GeoPlatformServer>}
 * @throws GPDAOException
 */
@Override
public List<GeoPlatformServer> searchPagebleServers(Integer page, Integer size, String organizationName, GPCapabilityType type, String titleOrAliasName) throws GPDAOException {
    checkArgument((organizationName != null) && !(organizationName.trim().isEmpty()), "The Parameter organizationName must not ne null or an empty string.");
    checkArgument(type != null, "The Parameter type must not ne null.");
    try {
        CriteriaBuilder builder = super.criteriaBuilder();
        CriteriaQuery<GeoPlatformServer> criteriaQuery = super.createCriteriaQuery();
        Root<GeoPlatformServer> root = criteriaQuery.from(this.persistentClass);
        criteriaQuery.select(root);
        List<Predicate> predicates = Lists.newArrayList();
        if ((titleOrAliasName != null) && !(titleOrAliasName.trim().isEmpty())) {
            predicates.add(builder.or(builder.like(builder.lower(root.get("title")), titleOrAliasName.toLowerCase()), builder.like(builder.lower(root.get("aliasName")), titleOrAliasName.toLowerCase())));
        }
        Join<GeoPlatformServer, GPOrganization> join = root.join("organization");
        predicates.add(builder.equal(join.get("name"), organizationName));
        predicates.add(builder.equal(root.get("serverType"), type));
        criteriaQuery.where(predicates.stream().toArray(Predicate[]::new)).orderBy(builder.asc(root.get("aliasName")));
        TypedQuery<GeoPlatformServer> typedQuery = this.entityManager.createQuery(criteriaQuery);
        Integer firstResult = (page == 0) ? 0 : ((page * size));
        typedQuery.setFirstResult(firstResult);
        typedQuery.setMaxResults(size);
        return typedQuery.getResultList();
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new GPDAOException(ex);
    }
}
Also used : GeoPlatformServer(org.geosdi.geoplatform.core.model.GeoPlatformServer) GPDAOException(org.geosdi.geoplatform.persistence.dao.exception.GPDAOException) GPOrganization(org.geosdi.geoplatform.core.model.GPOrganization) GPDAOException(org.geosdi.geoplatform.persistence.dao.exception.GPDAOException)

Example 13 with GPOrganization

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

the class CSWServiceDelegate method getAllCSWServers.

/**
 * @see {@link GeoPlatformCSWService#getAllCSWServers(String)} ()}
 */
@Override
public List<ServerCSWDTO> getAllCSWServers(String organizationName) throws ResourceNotFoundFault {
    GPOrganization organization = organizationDao.findByName(organizationName);
    if (organization == null) {
        throw new ResourceNotFoundFault("Organization with name " + organizationName + "was not found.");
    }
    List<GeoPlatformServer> found = serverDao.findAll(organization.getId(), GPCapabilityType.CSW);
    return convertServerList(found);
}
Also used : GeoPlatformServer(org.geosdi.geoplatform.core.model.GeoPlatformServer) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) GPOrganization(org.geosdi.geoplatform.core.model.GPOrganization)

Example 14 with GPOrganization

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

the class GPAclDelegate method saveRole.

@Override
public Boolean saveRole(WSSaveRoleRequest saveRoleReq) throws IllegalParameterFault {
    if (saveRoleReq == null) {
        throw new IllegalParameterFault("The WSSaveRoleRequest must not " + "be null.");
    }
    String organization = saveRoleReq.getOrganization();
    String role = saveRoleReq.getRole();
    AclSid sid = sidDao.findBySid(role, false, organization);
    if (sid != null) {
        throw new IllegalParameterFault("Authority (Role) \"" + role + "\" already exist");
    }
    GPOrganization org = organizationDao.findByName(organization);
    if (org == null) {
        throw new IllegalParameterFault("Organization \"" + organization + "\" not found");
    }
    sid = new AclSid(false, role, org);
    sidDao.persist(sid);
    return true;
}
Also used : IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) GPOrganization(org.geosdi.geoplatform.core.model.GPOrganization)

Example 15 with GPOrganization

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

the class GPServerDelegate method getAllServers.

@Override
public ServerDTOContainer getAllServers(String organizationName) throws ResourceNotFoundFault {
    GPOrganization organization = organizationDao.findByName(organizationName);
    if (organization == null) {
        throw new ResourceNotFoundFault("Organization with name " + organizationName + "was not found.");
    }
    List<GeoPlatformServer> found = serverDao.findAll(organization.getId(), WMS);
    return new ServerDTOContainer(convertToServerList(found));
}
Also used : GeoPlatformServer(org.geosdi.geoplatform.core.model.GeoPlatformServer) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) GPOrganization(org.geosdi.geoplatform.core.model.GPOrganization) ServerDTOContainer(org.geosdi.geoplatform.response.ServerDTOContainer)

Aggregations

GPOrganization (org.geosdi.geoplatform.core.model.GPOrganization)20 GeoPlatformServer (org.geosdi.geoplatform.core.model.GeoPlatformServer)6 IllegalParameterFault (org.geosdi.geoplatform.exception.IllegalParameterFault)6 GPUser (org.geosdi.geoplatform.core.model.GPUser)4 Test (org.junit.Test)4 ResourceNotFoundFault (org.geosdi.geoplatform.exception.ResourceNotFoundFault)3 GPDAOException (org.geosdi.geoplatform.persistence.dao.exception.GPDAOException)3 InsertAccountRequest (org.geosdi.geoplatform.request.InsertAccountRequest)3 MalformedURLException (java.net.MalformedURLException)2 ShortAccountDTO (org.geosdi.geoplatform.response.ShortAccountDTO)2 IOException (java.io.IOException)1 URL (java.net.URL)1 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1 ClientErrorException (javax.ws.rs.ClientErrorException)1 CatalogCapabilities (org.geosdi.geoplatform.connector.api.capabilities.model.csw.CatalogCapabilities)1 GPApplication (org.geosdi.geoplatform.core.model.GPApplication)1 GPAuthServer (org.geosdi.geoplatform.core.model.GPAuthServer)1 GPRestExceptionMessage (org.geosdi.geoplatform.exception.rs.GPRestExceptionMessage)1 GeoPlatformException (org.geosdi.geoplatform.gui.global.GeoPlatformException)1 AreaInfo (org.geosdi.geoplatform.gui.responce.AreaInfo)1