Package org.fao.geonet

Examples of org.fao.geonet.GeonetContext


   *            Metadata record id to search for feature catalogue for.
   * @return String Feature catalogue uuid.
   * @throws Exception
   */
  private static String getFeatureCatalogID(ServiceContext context, int metadataId) throws Exception {
    GeonetContext gc = (GeonetContext) context
        .getHandlerContext(Geonet.CONTEXT_NAME);
    DataManager dm = gc.getBean(DataManager.class);

        List<MetadataRelation> relations = context.getBean(MetadataRelationRepository.class).findAllById_MetadataId(metadataId);

    if (relations.isEmpty()) {
      return "";
View Full Code Here


  // --- Constructor
  // ---
  // --------------------------------------------------------------------------

  public Harvester(Logger log, ServiceContext context, Z3950Params params) {
    GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
    this.context = context;
    this.log = log;
    this.searchMan = gc.getBean(SearchManager.class);
    this.dataMan = gc.getBean(DataManager.class);
    this.settingMan = gc.getBean(SettingManager.class);
    this.context = context;
    this.params = params;
  }
View Full Code Here

    this.log     = log;
    this.context = context;
    this.request = req;
    this.params  = params;

    GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
    dataMan = gc.getBean(DataManager.class);
    result  = new HarvestResult();

    //--- save remote categories and groups into hashmaps for a fast access

        // Before 2.11 response contains groups. Now group is used.
View Full Code Here

      else
      {
        String id = dataMan.getMetadataId(ri.uuid);

        // look up value of localrating/enable
        GeonetContext  gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
        SettingManager settingManager = gc.getBean(SettingManager.class);
        boolean localRating = settingManager.getValueAsBool("system/localrating/enable", false);
       
        if (id == null)  {
          addMetadata(ri, localRating);
        }
View Full Code Here

    @Override
    public Iterable<Pair<String, String>> getFormats(ServiceContext context, Metadata metadata) throws Exception {
        String schema = metadata.getDataInfo().getSchemaId();
        if (schema.contains("iso19139") && !schema.equals("iso19139")) {
            // ie. this is an ISO profil.
            GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
            DataManager dm = gc.getBean(DataManager.class);
            MetadataSchema metadataSchema = dm.getSchema(schema);
            String path = metadataSchema.getSchemaDir() + "/convert/to19139.xsl";

            String data19139 = formatData(metadata, true, path);
            return Collections.singleton(Pair.read(FILE_METADATA_19139, data19139));
View Full Code Here

        new Element("format").setText(format.toString())).addContent(
        new Element("rating").setText(rating)).addContent(
        new Element("popularity").setText(popularity));

    if (!skipUUID) {
      GeonetContext gc = (GeonetContext) context
          .getHandlerContext(Geonet.CONTEXT_NAME);

      general.addContent(new Element("uuid").setText(uuid));
      general.addContent(new Element("siteId").setText(siteId));
            general.addContent(new Element("siteName")
          .setText(gc.getBean(SettingManager.class).getSiteName()));
    }

    return general;
  }
View Full Code Here

    HashMap<String, ArrayList<String>> hmPriv = new HashMap<String, ArrayList<String>>();

    // --- retrieve accessible groups

    GeonetContext gc = (GeonetContext) context
        .getHandlerContext(Geonet.CONTEXT_NAME);
    AccessManager am = gc.getBean(AccessManager.class);

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

    // --- scan query result to collect info
View Full Code Here

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

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

    return gc.getBean(DataManager.class).getKeywords();
  }
View Full Code Here

    //--- Service
    //---
    //--------------------------------------------------------------------------

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


        int ownerId = context.getUserSession().getUserIdAsInt();
        Profile userProfile = context.getUserSession().getProfile();

        if (userProfile == null) {
            throw new OperationNotAllowedEx("Unauthorized user attempted to list editable metadata ");
        }

        Specifications<Metadata> spec;
        // if the user is an admin, return all metadata
        if(userProfile == Profile.Administrator) {
            spec = where(MetadataSpecs.isHarvested(false));
        } else if(userProfile == Profile.Reviewer || userProfile == Profile.UserAdmin) {
            final List<UserGroup> groups = context.getBean(UserGroupRepository.class).findAll(UserGroupSpecs.hasUserId(ownerId));
            List<Integer> groupIds = Lists.transform(groups, new Function<UserGroup, Integer>() {
                @Nullable
                @Override
                public Integer apply(@Nonnull UserGroup input) {
                    return input.getId().getGroupId();
                }
            });
            spec = where(MetadataSpecs.isHarvested(false)).and(MetadataSpecs.isOwnedByOneOfFollowingGroups(groupIds));
            // if the user is a reviewer, return all metadata of the user's groups
        } else if(userProfile == Profile.Editor) {
            spec = where(MetadataSpecs.isOwnedByUser(ownerId)).and(MetadataSpecs.isHarvested(false));
            // if the user is an editor, return metadata owned by this user
        } else {
            throw new OperationNotAllowedEx("Unauthorized user " + ownerId + " attempted to list editable metadata ");
        }

        // Sorting
        String sortBy = sortByParameter(params);

        Sort order = null;
        if(sortBy.equals("date")) {
            order = new Sort(Sort.Direction.DESC, Metadata_.dataInfo + "." + MetadataDataInfo_.changeDate);
        } else if(sortBy.equals("popularity")) {
            order = new Sort(Sort.Direction.DESC, Metadata_.dataInfo + "." + MetadataDataInfo_.popularity);
        } else if(sortBy.equals("rating")) {
            order = new Sort(Sort.Direction.DESC, Metadata_.dataInfo + "." + MetadataDataInfo_.rating);
        } else {
            throw new IllegalArgumentException("Unknown sortBy parameter: "+sortBy);
        }

        List<Metadata> metadataList = context.getBean(MetadataRepository.class).findAll(spec, order);
        _response = new Element("response");

        for (Metadata rec : metadataList) {
            String  id = "" + rec.getId();
            boolean forEditing = false, withValidationErrors = false, keepXlinkAttributes = false;
            Element md = gc.getBean(DataManager.class).getMetadata(context, id, forEditing, withValidationErrors, keepXlinkAttributes);
            _response.addContent(md);
        }

        Element currentSortBySelect = new Element(SORT_BY);
        currentSortBySelect.setText(sortBy);
View Full Code Here

        Element info = params.getChild(Edit.RootChild.INFO, Edit.NAMESPACE);
        int iId;
        String id;
        String uuid;
        GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
        DataManager dm = gc.getBean(DataManager.class);

        if (info == null) {
            String mdId = Utils.getIdentifierFromParameters(params, context);
            if (mdId == null)
                throw new MetadataNotFoundEx("Metadata not found.");
View Full Code Here

TOP

Related Classes of org.fao.geonet.GeonetContext

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.