Package org.fao.geonet.repository

Examples of org.fao.geonet.repository.GroupRepository


                }

                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());
                    String  name  = group.getName();
          String  email = group.getEmail();

          if (email.trim().length() != 0) {
            String subject = "File " + theFile + " has been downloaded at "+dateTime;
View Full Code Here


   * @param context
   * @return
   * @throws java.sql.SQLException
   */
  Group getGroup(ServiceContext context) throws SQLException {
        final GroupRepository bean = context.getBean(GroupRepository.class);
        return bean.findOne(ReservedGroup.guest.getId());
  }
View Full Code Here

                }

        // 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();

          if (email.trim().length() != 0)
          {
View Full Code Here

    private void setUserGroups(final User user, final Element params, final ServiceContext context) throws Exception {
    String[] profiles = {Profile.UserAdmin.name(), Profile.Reviewer.name(), Profile.Editor.name(), Profile.RegisteredUser.name()};
        Collection<UserGroup> toAdd = new ArrayList<UserGroup>();
        Set<String> listOfAddedProfiles = new HashSet<String>();
        final GroupRepository groupRepository = context.getBean(GroupRepository.class);
        final UserGroupRepository userGroupRepository = context.getBean(UserGroupRepository.class);

        for (String profile : profiles) {
       
      @SuppressWarnings("unchecked")
            java.util.List<Element> userGroups = params.getChildren(Params.GROUPS + '_' + profile);
      for (Element element : userGroups) {
        String groupEl = element.getText();
        if (!groupEl.equals("")) {
          int groupId = Integer.valueOf(groupEl);
                    Group group = groupRepository.findOne(groupId);

                    // Combine all groups editor and reviewer groups
                    if (profile.equals(Profile.Reviewer.name())) {
                        final UserGroup userGroup = new UserGroup()
                                .setGroup(group)
View Full Code Here

    UserSession usrSess = context.getUserSession();
    Profile myProfile = usrSess.getProfile();
    String      myUserId  = usrSess.getUserId();

        final UserRepository userRepository = context.getBean(UserRepository.class);
        final GroupRepository groupRepository = context.getBean(GroupRepository.class);
        final UserGroupRepository userGroupRepository = context.getBean(UserGroupRepository.class);

        if (myProfile == Profile.Administrator || myProfile == Profile.UserAdmin || myUserId.equals(id)) {

      // -- get the profile of the user id supplied
            User user = userRepository.findOne(Integer.valueOf(id));
      if (user == null) {
        throw new IllegalArgumentException("user "+id+" doesn't exist");
            }

      String  theProfile = user.getProfile().name();

      //--- retrieve user groups of the user id supplied
      Element elGroups = new Element(Geonet.Elem.GROUPS);
      List<Group> theGroups;
            List<UserGroup> userGroups;

            if (myProfile == Profile.Administrator && theProfile.equals(Profile.Administrator.name())) {
                theGroups = groupRepository.findAll();

                for (Group group : theGroups) {
                    final Element element = group.asXml();
                    element.addContent(new Element("profile").setText(Profile.Administrator.name()));
                    elGroups.addContent(element);
View Full Code Here

                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();

                moreFields.add(SearchManager.makeField("_op" + operationId, String.valueOf(groupId), true, true));
                if(operationId == ReservedOperation.view.getId()) {
                    Group g = groupRepository.findOne(groupId);
                    if (g != null) {
                        moreFields.add(SearchManager.makeField("_groupPublished", g.getName(), true, true));
                    }
                }
            }
View Full Code Here

        final ServiceContext serviceContext = createServiceContext();
        loginAsAdmin(serviceContext);

        final User principal = serviceContext.getUserSession().getPrincipal();

        final GroupRepository bean = serviceContext.getBean(GroupRepository.class);
        Group group = bean.findAll().get(0);

        MetadataCategory category = serviceContext.getBean(MetadataCategoryRepository.class).findAll().get(0);

        final SourceRepository sourceRepository = serviceContext.getBean(SourceRepository.class);
        Source source = sourceRepository.save(new Source().setLocal(true).setName("GN").setUuid("sourceuuid"));
View Full Code Here

TOP

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

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.