Package org.fao.geonet.kernel

Examples of org.fao.geonet.kernel.AccessManager


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

  public Element exec(Element params, ServiceContext context) throws Exception
  {
    AccessManager am = context.getBean(AccessManager.class);

    String metadataId = Utils.getIdentifierFromParameters(params, context);

    //-----------------------------------------------------------------------
    //--- check access

    Metadata info = context.getBean(MetadataRepository.class).findOne(metadataId);

    if (info == null)
      throw new MetadataNotFoundEx(metadataId);

        Element ownerId = new Element("ownerid").setText(info.getSourceInfo().getOwner() + "");
        Element groupOwner = new Element("groupOwner").setText(info.getSourceInfo().getGroupOwner() + "");
        Element hasOwner = new Element("owner");
        if (am.isOwner(context, metadataId))
            hasOwner.setText("true");
        else
      hasOwner.setText("false");

    //--- get all operations

        OperationRepository opRepository = context.getBean(OperationRepository.class);
        List<Operation> operationList = opRepository.findAll();


        // elOper is for returned XML and keeps backwards compatibility
        Element elOper = new Element(Geonet.Elem.OPERATIONS);

        for (Operation operation : operationList) {
            elOper.addContent(operation.asXml());
        }

        //-----------------------------------------------------------------------
    //--- retrieve groups operations

    Set<Integer> userGroups = am.getUserGroups(context.getUserSession(), context.getIpAddress(), false);

    Element elGroup = context.getBean(GroupRepository.class).findAllAsXml();

        final UserGroupRepository userGroupRepository = context.getBean(UserGroupRepository.class);
        OperationAllowedRepository opAllowRepository = context.getBean(OperationAllowedRepository.class);
View Full Code Here


        GeonetContext gc = (GeonetContext) context
                .getHandlerContext(Geonet.CONTEXT_NAME);
        DataManager dataMan = gc.getBean(DataManager.class);
        SchemaManager schemaMan = gc.getBean(SchemaManager.class);
        AccessManager accessMan = gc.getBean(AccessManager.class);

        report.incrementProcessedRecords();

        // When a record is deleted the UUID is in the selection manager
        // and when retrieving id, return null
        if (id == null) {
            report.incrementNullRecords();
            return null;
        }

        int iId = Integer.valueOf(id);

        Metadata metadataEntity =  context.getBean(MetadataRepository.class).findOne(iId);
        MetadataDataInfo info = metadataEntity.getDataInfo();

        // Get metadata title from the index
        String metadataTitle = LuceneSearcher.getMetadataFromIndexById(context.getLanguage(), id, "title");
        if (StringUtils.isEmpty(metadataTitle)) metadataTitle = metadataEntity.getUuid();

        if (info == null) {
            MassiveReplaceReportEntry notFoundEntry =
                    new MassiveReplaceReportEntry(id, "", null);
            report.addNotFound(notFoundEntry);

        } else if (!accessMan.isOwner(context, id)) {
            MassiveReplaceReportEntry notOwnerEntry =
                    new MassiveReplaceReportEntry(metadataEntity.getUuid(), metadataTitle, null);
            report.addNotEditable(notOwnerEntry);
        } else {
View Full Code Here

    public Element serviceSpecificExec(Element params, ServiceContext context) throws Exception
  {
    GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
    DataManager   dm = gc.getBean(DataManager.class);
    AccessManager accessMan = gc.getBean(AccessManager.class);
    UserSession   us = context.getUserSession();

    context.info("Get selected metadata");
    SelectionManager sm = SelectionManager.getManager(us);

    Set<Integer> metadata = new HashSet<Integer>();
    Set<String> notFound = new HashSet<String>();
    Set<Integer> notOwner = new HashSet<Integer>();

    synchronized(sm.getSelection(SELECTION_METADATA)) {
    for (Iterator<String> iter = sm.getSelection(SELECTION_METADATA).iterator(); iter.hasNext();) {
      String uuid = iter.next();

      //--- check access

      Metadata info = context.getBean(MetadataRepository.class).findOneByUuid(uuid);
      if (info == null) {
        notFound.add(uuid);
      } else if (!accessMan.isOwner(context, String.valueOf(info.getId()))) {
        notOwner.add(info.getId());
      } else {

        //--- remove old operations
        boolean skip = false;
View Full Code Here

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

  public Element exec(Element params, ServiceContext context) throws Exception
  {
    AccessManager am = context.getBean(AccessManager.class);

    String id = Utils.getIdentifierFromParameters(params, context);

    //-----------------------------------------------------------------------
    //--- check access
    int iLocalId = Integer.parseInt(id);

        final Metadata metadata = context.getBean(MetadataRepository.class).findOne(iLocalId);
        if (metadata == null) {
      throw new IllegalArgumentException("Metadata not found --> " + id);
        }

    Element isOwner = new Element("owner");
    if (am.isOwner(context, id)) {
      isOwner.setText("true");
        } else {
      isOwner.setText("false");
        }
View Full Code Here

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

  public Element exec(Element params, ServiceContext context) throws Exception
  {
    GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
    AccessManager am = gc.getBean(AccessManager.class);
    UserSession   us = context.getUserSession();

    Element ownerId = new Element("ownerid").setText(us.getUserId());
    Element hasOwner = new Element("owner").setText("true");

    //--- get all operations
        List<Operation> operationList = context.getBean(OperationRepository.class).findAll();

        // elOper is for returned XML and keeps backwards compatibility
        Element elOper = new Element(Geonet.Elem.OPERATIONS);

        for (Operation operation : operationList) {
            elOper.addContent(operation.asXml());
        }

    //--- retrieve groups operations
    Set<Integer> userGroups = am.getUserGroups(context.getUserSession(), context.getIpAddress(), false);

    Element elGroup = context.getBean(GroupRepository.class).findAllAsXml();

    @SuppressWarnings("unchecked")
        List<Element> list = elGroup.getChildren();
View Full Code Here

  public Element serviceSpecificExec(Element params, ServiceContext context) throws Exception
  {
    GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
    DataManager   dataMan   = gc.getBean(DataManager.class);
    AccessManager accessMan = gc.getBean(AccessManager.class);

    String id = Utils.getIdentifierFromParameters(params, context);
   
    //-----------------------------------------------------------------------
    //--- check access

    Element md = dataMan.getMetadataNoInfo(context, id);

    if (md == null)
      throw new IllegalArgumentException("Metadata not found --> " + id);

    if (!accessMan.canEdit(context, id))
      throw new OperationNotAllowedEx();

    //-----------------------------------------------------------------------
    //--- set metadata into the subversion repo
View Full Code Here

  public Element serviceSpecificExec(Element params, ServiceContext context) throws Exception
  {
    GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);

    DataManager dm = gc.getBean(DataManager.class);
    AccessManager accessMan = gc.getBean(AccessManager.class);
    UserSession us = context.getUserSession();


    context.info("Get selected metadata");
    SelectionManager sm = SelectionManager.getManager(us);

    Set<Integer> metadata = new HashSet<Integer>();
    Set<Integer> notFound = new HashSet<Integer>();
    Set<Integer> notOwner = new HashSet<Integer>();

    synchronized(sm.getSelection("metadata")) {
    for (Iterator<String> iter = sm.getSelection("metadata").iterator(); iter.hasNext();) {
      String uuid = (String) iter.next();
      String id   = dm.getMetadataId(uuid);
               
      //--- check access

            final MetadataRepository metadataRepository = context.getBean(MetadataRepository.class);
            Metadata info = metadataRepository.findOne(id);
      if (info == null) {
        notFound.add(Integer.valueOf(id));
      } else if (!accessMan.isOwner(context, id)) {
        notOwner.add(Integer.valueOf(id));
      } else {

        //--- remove old operations
                info.getCategories().clear();
View Full Code Here

            return requestedGroups;

        } else {
            GeonetContext gc = (GeonetContext) context
                    .getHandlerContext(Geonet.CONTEXT_NAME);
            AccessManager am = gc.getBean(AccessManager.class);
            Set<Integer> userGroups = am.getUserGroups(context.getUserSession(), context.getIpAddress(), false);

            // If no specific group requested, filter by user groups
            if (requestedGroups.isEmpty()) {

                return userGroups;
View Full Code Here

  public Element exec(Element params, ServiceContext context) throws Exception
  {
    GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
    DataManager   dataMan   = gc.getBean(DataManager.class);
    AccessManager accessMan = gc.getBean(AccessManager.class);
    UserSession   session   = context.getUserSession();

    Set<Integer> metadata = new HashSet<Integer>();
    Set<Integer> notFound = new HashSet<Integer>();
    Set<Integer> notOwner = new HashSet<Integer>();

        if(context.isDebugEnabled())
            context.debug("Get selected metadata");
    SelectionManager sm = SelectionManager.getManager(session);

    synchronized(sm.getSelection("metadata")) {
    for (Iterator<String> iter = sm.getSelection("metadata").iterator(); iter.hasNext();) {
      String uuid = (String) iter.next();
            if(context.isDebugEnabled())
                context.debug("Deleting metadata with uuid:"+ uuid);

      String id   = dataMan.getMetadataId(uuid);
      //--- Metadata may have been deleted since selection
      if (id != null) {
        //-----------------------------------------------------------------------
        //--- check access
        Element md = dataMan.getMetadataNoInfo(context, id);
 
        if (md == null) {
          notFound.add(Integer.valueOf(id));
        } else if (!accessMan.isOwner(context, id)) {
          notOwner.add(Integer.valueOf(id));
        } else {
 
          //--- now set metadata into subversion repo
          dataMan.versionMetadata(context, id, md);
View Full Code Here

  public Element serviceSpecificExec(Element params, ServiceContext context) throws Exception
  {
    GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
    DataManager   dataMan   = gc.getBean(DataManager.class);
    AccessManager accessMan = gc.getBean(AccessManager.class);

        boolean backupFile = Util.getParam(params, Params.BACKUP_FILE, true);
    String id = Utils.getIdentifierFromParameters(params, context);

        // If send a non existing uuid, Utils.getIdentifierFromParameters returns null
        if (id == null)
            throw new IllegalArgumentException("Metadata internal identifier or UUID not found.");

    //-----------------------------------------------------------------------
    //--- check access

        Metadata metadata = context.getBean(MetadataRepository.class).findOne(id);

    if (metadata == null)
      throw new IllegalArgumentException("Metadata with identifier " + id + " not found.");

    if (!accessMan.canEdit(context, id))
      throw new OperationNotAllowedEx();

    //-----------------------------------------------------------------------
    //--- backup metadata in 'removed' folder
View Full Code Here

TOP

Related Classes of org.fao.geonet.kernel.AccessManager

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.