Package org.fao.geonet

Examples of org.fao.geonet.GeonetContext


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

  public void setupProxy(ServiceContext context)
  {
    GeonetContext  gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
    SettingManager sm = gc.getBean(SettingManager.class);

    setupProxy(sm);
  }
View Full Code Here


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

  private Element search(ServiceContext context) throws Exception
  {
    GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);

    context.info("Creating searcher");

    Element       params = buildParams();
    ServiceConfig config = new ServiceConfig();

    SearchManager searchMan = gc.getBean(SearchManager.class);
    MetaSearcher  searcher  = searchMan.newSearcher(SearchManager.LUCENE, Geonet.File.SEARCH_LUCENE);

    searcher.search(context, params, config);

    params.addContent(new Element("from").setText("1"));
View Full Code Here

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

  public static List<Integer> search(ServiceContext context, Element params) throws Exception
  {
    GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
    SearchManager sm = gc.getBean(SearchManager.class);

    MetaSearcher searcher = sm.newSearcher(SearchManager.LUCENE, Geonet.File.SEARCH_LUCENE);

        if(context.isDebugEnabled()) context.debug("Searching with params:\n"+ Xml.getString(params));
View Full Code Here

            // will not see those elements.
            Pair<String, Element> editXpathFilter = mds.getOperationFilter(ReservedOperation.editing);
            boolean filterEditOperationElements = editXpathFilter != null;
            List<Namespace> namespaces = mds.getNamespaces();
            if(context != null) {
                GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
                AccessManager am = gc.getBean(AccessManager.class);
                if (editXpathFilter != null) {
                    boolean canEdit = am.canEdit(context, id);
                    if(canEdit) {
                        filterEditOperationElements = false;
                    }
View Full Code Here

            if (profile == Profile.Administrator) {
          result = transform(result);
          addInfo(result);
        } else {
                // you're not an Administrator: only return harvest nodes from groups visible to you
                GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
                AccessManager am = gc.getBean(AccessManager.class);
                Set<Integer> groups = am.getVisibleGroups(context.getUserSession().getUserIdAsInt());
                result = transform(result);
                Element nodeGroup =  result.getChild("ownerGroup");
                if ((nodeGroup != null) && (groups.contains(Integer.valueOf(nodeGroup.getValue())))) {
                    addInfo(result);
                } else {
                    return null;
                }
            }
    } else {

            // id is null: return all (visible) nodes
            Element nodes = result.getChild("children");
      result = new Element("nodes");
      if (nodes != null) {
                // you're Administrator: all nodes are visible
                if (profile == Profile.Administrator) {
                    for (Object o : nodes.getChildren()) {
                        Element node = transform((Element) o);
                        addInfo(node);
                        result.addContent(node);
                    }
                } else {
                    // you're not an Adminstrator: only return nodes in groups visible to you
                    GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
                    AccessManager am = gc.getBean(AccessManager.class);
                    Set<Integer> groups = am.getVisibleGroups(context.getUserSession().getUserIdAsInt());
            for (Object o : nodes.getChildren()) {
              Element node = transform((Element) o);
                        Element nodeGroup =  node.getChild("ownerGroup");
                        if ((nodeGroup != null) && (groups.contains(Integer.valueOf(nodeGroup.getValue())))) {
View Full Code Here

               this.query = query;
               this.srvxtx = srvctx;

               try {

                       GeonetContext gc = (GeonetContext) this.srvxtx
                       .getHandlerContext(Geonet.CONTEXT_NAME);
                       SearchManager searchMan = gc.getBean(SearchManager.class);

                       metasearcher = searchMan.newSearcher(SearchManager.LUCENE,
                                       Geonet.File.SEARCH_Z3950_SERVER);

               } catch (Exception e) {
View Full Code Here

        // no search criteria supported in csw harvest, leave empty
        Element searches = new Element("searches");
    node.addContent(searches);

        // no privileges settings supported in csw harvest; use GN-specific setting (if enabled, make metadata public)
        GeonetContext geonetContext = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
        SettingManager sm = geonetContext.getBean(SettingManager.class);
        boolean metadataPublic = sm.getValueAsBool("system/csw/metadataPublic", false);
        if(metadataPublic) {
            // <privileges>
            //   <group id="1">
            //     <operation name="view" />
            //     <operation name="dynamic" />
            //     <operation name="featured" />
            //   </group>
            // </privileges>
            Element privileges = new Element("privileges");
            Element group = new Element("group");
            group.setAttribute("id", "1");
            Element operation1 = new Element("operation");
            operation1.setAttribute("name", "view");
            group.addContent(operation1);
            Element operation2 = new Element("operation");
            operation2.setAttribute("name", "dynamic");
            group.addContent(operation2);
            Element operation3 = new Element("operation");
            operation3.setAttribute("name", "featured");
            group.addContent(operation3);
            privileges.addContent(group);
            node.addContent(privileges);
        }

        /*
         heikki: not so easy as we can't identify harvesters from their target url or anything else
   
         for the moment, no updates take place, the harvester is simply saved

        // Check if harvester already exist
        // FIXME : Unable to find the getHarvesterID method from patch provided for now id is null
        // String id = hm.getHarvesterID(source);
    // Here we should do an update of an existing node if exist.
   
//    if (id == null) {
//     
//    } else {
//      node.setAttribute("id", id);
//      if (!hm.update(dbms, node))
//        return null;
//    }

         */

        GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
        HarvestManager hm = gc.getBean(HarvestManager.class);
        String uuid = hm.addHarvesterReturnUUID(node);
        node.setAttribute("uuid", uuid);
        node.addContent(new Element("info"));
        AbstractHarvester harvester = hm.getHarvester(uuid);
        String id = harvester.getID();
View Full Code Here

     */
    private boolean isRunning(Element harvester, ServiceContext context) throws Exception {
        if(Log.isDebugEnabled(Geonet.CSW_HARVEST))
            Log.debug(Geonet.CSW_HARVEST, "isRunning harvester:\n" + Xml.getString(harvester));

        GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
        String uuid = harvester.getAttribute("uuid").getValue();
        if(Log.isDebugEnabled(Geonet.CSW_HARVEST))
            Log.debug(Geonet.CSW_HARVEST, "uuid: " + uuid);
        AbstractHarvester abstractHarvester = gc.getBean(HarvestManager.class).getHarvester(uuid);
        if(Log.isDebugEnabled(Geonet.CSW_HARVEST))
            Log.debug(Geonet.CSW_HARVEST, "abstractHarvester: " + abstractHarvester);

    if(abstractHarvester == null) {return false;}
        abstractHarvester.addInfo(harvester);
View Full Code Here

         * Sends Harvest response using email.
         *
         * @param harvestResponse response to send
         */
        private void sendByEmail(String harvestResponse) {
            GeonetContext geonetContext = (GeonetContext) serviceContext.getHandlerContext(Geonet.CONTEXT_NAME);
            SettingManager settingManager = geonetContext.getBean(SettingManager.class);
            String host = settingManager.getValue("system/feedback/mailServer/host");
            String port = settingManager.getValue("system/feedback/mailServer/port");
            String to = responseHandler.substring(Protocol.EMAIL.toString().length());
            MailSender sender = new MailSender(serviceContext);
            sender.send(host, Integer.parseInt(port),
View Full Code Here

    this.context= context;
    this.params = params;

    result = new HarvestResult();

    GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
    dataMan = gc.getBean(DataManager.class);
    schemaMan = gc.getBean(SchemaManager.class);
  }
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.