Package org.fao.geonet.repository

Examples of org.fao.geonet.repository.OperationAllowedRepository


  public Element serviceSpecificExec(Element params, ServiceContext context) throws Exception
  {
    String id = Util.getParam(params, Params.ID);


        OperationAllowedRepository operationAllowedRepo = context.getBean(OperationAllowedRepository.class);
        UserGroupRepository userGroupRepo = context.getBean(UserGroupRepository.class);
        GroupRepository groupRepo = context.getBean(GroupRepository.class);

    Integer iId = Integer.valueOf(id);
        List<Integer> reindex = operationAllowedRepo.findAllIds(OperationAllowedSpecs.hasGroupId(iId), OperationAllowedId_.metadataId);

        operationAllowedRepo.deleteAllByIdAttribute(OperationAllowedId_.groupId, iId);
        userGroupRepo.deleteAllByIdAttribute(UserGroupId_.groupId, Arrays.asList(iId));
        groupRepo.delete(iId);
    //--- reindex affected metadata

    GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
View Full Code Here


                // case, all operations need to be transfered to
                // the new group if not already defined.
                dm.unsetOperation(context, mdId, sourceGrp, opId);

                if (!targetPriv.contains(priv)) {
                    OperationAllowedRepository repository = context.getBean(OperationAllowedRepository.class);
                    OperationAllowedId id = new OperationAllowedId()
                            .setGroupId(targetGrp)
                            .setMetadataId(mdId)
                            .setOperationId(opId);
                    OperationAllowed operationAllowed = new OperationAllowed(id );
                    repository.save(operationAllowed);
                }
            }

            // Collect all metadata ids
            metadata.add(mdId);
View Full Code Here

     * @param groupId
     * @return
     * @throws java.sql.SQLException
     */
    private Set<String> retrievePrivileges(ServiceContext context, Integer userId, int groupId) throws SQLException {
        OperationAllowedRepository opAllowedRepo = context.getBean(OperationAllowedRepository.class);
        final List<OperationAllowed> opsAllowed;
        if (userId == null) {
            opsAllowed = opAllowedRepo.findAllById_GroupId(groupId);
        } else {
            opsAllowed = opAllowedRepo.findAllWithOwner(userId, Optional.of(hasGroupId(groupId)));
        }

        Set<String> result = new HashSet<String>();
        for (OperationAllowed elem : opsAllowed) {
            int opId = elem.getId().getOperationId();
View Full Code Here

         int iId = Integer.parseInt(id);

         final MetadataRepository metadataRepository = context.getBean(MetadataRepository.class);
         Metadata metadata = metadataRepository.findOne(iId);
         OperationAllowedRepository repository = context.getBean(OperationAllowedRepository.class);
         repository.deleteAllByIdAttribute(OperationAllowedId_.metadataId, iId);
         addPrivileges(id, params.privileges, localGroups, dataMan, context, log);

         metadata.getCategories().clear();
         addCategories(metadata, params.categories, localCateg, context, log, null);
View Full Code Here

    //--------------------------------------------------------------------------

    private Vector<OperationAllowedId> retrievePrivileges(ServiceContext context, String id, String userId, String groupId) throws Exception {

        OperationAllowedRepository opAllowRepo = context.getBean(OperationAllowedRepository.class);

        Integer iMetadataId = Integer.valueOf(id);
        Integer iUserId = Integer.valueOf(userId);
        Integer iGroupId = Integer.valueOf(groupId);
        Specification<OperationAllowed> spec =
                where(hasMetadataId(iMetadataId))
                        .and(hasGroupId(iGroupId));

        List<OperationAllowed> operationsAllowed = opAllowRepo.findAllWithOwner(iUserId, Optional.of(spec));

        Vector<OperationAllowedId> result = new Vector<OperationAllowedId>();
        for (OperationAllowed operationAllowed : operationsAllowed) {
            result.add(operationAllowed.getId());
        }
View Full Code Here

      } else {
                if(context.isDebugEnabled()) {
                    context.debug("Sending email notification for file : " + theFile);
                }

                OperationAllowedRepository opAllowedRepo = context.getBean(OperationAllowedRepository.class);
                List<OperationAllowed> opsAllowed = opAllowedRepo.findByMetadataId(id);

                final GroupRepository groupRepository = context.getBean(GroupRepository.class);

                for (OperationAllowed opAllowed : opsAllowed) {
                    Group group = groupRepository.findOne(opAllowed.getId().getGroupId());
View Full Code Here

                    context.debug("Sending email notification for file : "+ file);
                }

        // send emails about downloaded file to groups with notify privilege

                OperationAllowedRepository opAllowedRepo = context.getBean(OperationAllowedRepository.class);
                final GroupRepository groupRepository = context.getBean(GroupRepository.class);

                List<OperationAllowed> opsAllowed = opAllowedRepo.findByMetadataId(id);
               
        for (OperationAllowed opAllowed : opsAllowed) {
                    Group group = groupRepository.findOne(opAllowed.getId().getGroupId());
          String  name  = group.getName();
          String  email = group.getEmail();
View Full Code Here

  //---
  //--------------------------------------------------------------------------

  private boolean hasInternetGroup(ServiceContext context, int id) throws SQLException
  {
      OperationAllowedRepository operationAllowedRepository = context.getBean(OperationAllowedRepository.class);

        final Specification<OperationAllowed> hasGroupId = OperationAllowedSpecs.hasGroupId(ReservedGroup.all.getId());
        final Specification<OperationAllowed> hasMetadataId = OperationAllowedSpecs.hasMetadataId(id);
        final Specifications<OperationAllowed> spec = Specifications.where(hasGroupId).and(hasMetadataId);
        List<OperationAllowed> opsAllowed = operationAllowedRepository.findAll(spec);
    return !opsAllowed.isEmpty();
  }
View Full Code Here

            if (groupOwner != null) {
                moreFields.add(SearchManager.makeField("_groupOwner", groupOwner, true, true));
            }

            // get privileges
            OperationAllowedRepository operationAllowedRepository = _applicationContext.getBean(OperationAllowedRepository.class);
            GroupRepository groupRepository = _applicationContext.getBean(GroupRepository.class);
            List<OperationAllowed> operationsAllowed = operationAllowedRepository.findAllById_MetadataId(id$);

            for (OperationAllowed operationAllowed : operationsAllowed) {
                OperationAllowedId operationAllowedId = operationAllowed.getId();
                int groupId = operationAllowedId.getGroupId();
                int operationId = operationAllowedId.getOperationId();
View Full Code Here

     * @param metadataId
     * @param skipAllIntranet
     * @throws Exception
     */
    public void deleteMetadataOper(ServiceContext context, String metadataId, boolean skipAllIntranet) throws Exception {
        OperationAllowedRepository operationAllowedRepository = context.getBean(OperationAllowedRepository.class);
       
        if (skipAllIntranet) {
            operationAllowedRepository.deleteAllByMetadataIdExceptGroupId(Integer.valueOf(metadataId), ReservedGroup.intranet.getId());
        } else {
            operationAllowedRepository.deleteAllByIdAttribute(OperationAllowedId_.metadataId, Integer.valueOf(metadataId));
        }
    }
View Full Code Here

TOP

Related Classes of org.fao.geonet.repository.OperationAllowedRepository

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.