Package org.fao.geonet

Examples of org.fao.geonet.GeonetContext


   *
   * @param context
   * @return
   */
  public String getDataDir(ServiceContext context) {
    GeonetContext gc = (GeonetContext) context
        .getHandlerContext(Geonet.CONTEXT_NAME);
    String dataDir = gc.getBean(ServiceConfig.class).getMandatoryValue(
        Geonet.Config.DATA_DIR);

    return dataDir;
  }
View Full Code Here


   *            See {@link AccessManager}.
   * @throws Exception
   */
    public void checkPrivilege(ServiceContext context, String id,
            ReservedOperation operation) throws Exception {
        GeonetContext gc = (GeonetContext) context
                .getHandlerContext(Geonet.CONTEXT_NAME);

        AccessManager accessMan = gc.getBean(AccessManager.class);

        Set<Operation> hsOper = accessMan.getOperations(context, id, context.getIpAddress());
       
        for (Operation op : hsOper) {
            if (op.is(operation)) {
View Full Code Here

    }
  }

  public void checkEditPrivilege(ServiceContext context, String id)
      throws Exception {
    GeonetContext gc = (GeonetContext) context
        .getHandlerContext(Geonet.CONTEXT_NAME);
    AccessManager am = gc.getBean(AccessManager.class);

    if (!am.canEdit(context, id))
      denyAccess(context);
  }
View Full Code Here

  /**
   * @return the absolute path of the folder choosen to store all deleted
   *         metadata
   */
  public String getRemovedDir(ServiceContext context) {
    GeonetContext gc = (GeonetContext) context
        .getHandlerContext(Geonet.CONTEXT_NAME);

    String remDir = gc.getBean(SettingManager.class).getValue(
        "system/removedMetadata/dir");

    if (!new File(remDir).isAbsolute())
      remDir = context.getAppPath() + remDir;

View Full Code Here

    Lib.resource.checkEditPrivilege(context, id);

    //-----------------------------------------------------------------------
    //--- environment vars

    GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);

    DataManager dataMan = gc.getBean(DataManager.class);

    //--- check if the metadata has been modified from last time

    if (version != null && !dataMan.getVersion(id).equals(version))
      throw new ConcurrentUpdateEx(id);
View Full Code Here

            }
        }

  private void removeOldThumbnail(ServiceContext context, String id, String type, boolean indexAfterChange) throws Exception
  {
    GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);

    DataManager dataMan = gc.getBean(DataManager.class);

    Element result = dataMan.getThumbnails(context, id);

    if (result == null)
      throw new IllegalArgumentException("Metadata not found --> " + id);
View Full Code Here

    public static String getCodelistTranslation(Object codelist, Object value, Object langCode) {
        String codeListValue = (String) value;
        if (codeListValue != null && codelist != null && langCode != null) {
            String translation = codeListValue;
            try {
                final GeonetContext gc = (GeonetContext) ServiceContext.get().getHandlerContext(Geonet.CONTEXT_NAME);
                Translator t = new CodeListTranslator(gc.getBean(SchemaManager.class),
                        (String) langCode,
                        (String) codelist);
                translation = t.translate(codeListValue);
            } catch (Exception e) {
                Log.error(Geonet.GEONETWORK, "Failed to translate codelist " + e.getMessage());
View Full Code Here

     * @return
     * @throws Exception
     */
  public Element exec(Element inParams, ServiceContext context) throws Exception
  {
    GeonetContext  gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
    SettingManager sm = gc.getBean(SettingManager.class);

    Element params = (Element)inParams.clone();

    // --- if we have a parameter specified in the config then use it instead
    // --- of the usual params
    String ptype = _config.getValue("type");
    if (ptype != null) {
      params.removeContent();
      params.addContent(new Element("type").setText(ptype));
    }

    Element result = new Element("root");

    @SuppressWarnings("unchecked")
        List<Element> types = params.getChildren("type");
    for (Element el : types) {
      String type = el.getText();

      if (type.equals("site")) {
        result.addContent(gc.getBean(SettingManager.class).getValues(
                        new String[]{
                                SettingManager.SYSTEM_SITE_NAME_PATH,
                                "system/site/organization",
                                SettingManager.SYSTEM_SITE_SITE_ID_PATH,
                                "system/platform/version",
                                "system/platform/subVersion"
                                }));
      } else if (type.equals("config")) {
        // Return a set of properties which define what
        // to display or not in the user interface
              final List<Setting> publicSettings = context.getBean(SettingRepository.class).findAllByInternal(false);
              List<String> publicSettingsKey = new ArrayList<String>();
              for(Setting s : publicSettings) {
                publicSettingsKey.add(s.getName());
              }
              result.addContent(new Element("config").addContent(gc.getBean(SettingManager.class).getValues(
                  publicSettingsKey.toArray(new String[0]))));
            } else if (type.equals("inspire")) {
        result.addContent(gc.getBean(SettingManager.class).getValues(
                    new String[]{
                                 "system/inspire/enableSearchPanel",
                                 "system/inspire/enable"
                                 }));
            } else if (type.equals("harvester")) {
          result.addContent(gc.getBean(SettingManager.class).getValues(
                        new String[]{ "system/harvester/enableEditing"}));
     
      } else if (type.equals("userGroupOnly")) {
                result.addContent(gc.getBean(SettingManager.class).getValues(
                        new String[]{"system/metadataprivs/usergrouponly"}));

            } else if (type.equals("categories")) {
        result.addContent(context.getBean(MetadataCategoryRepository.class).findAllAsXml());

            } else if (type.equals("groups"))   {
                String profile = params.getChildText("profile");
                Element r = getGroups(context, Profile.findProfileIgnoreCase(profile), false);
        result.addContent(r);

            } else if (type.equals("groupsIncludingSystemGroups")) {
                Element r = getGroups(context, null, true);
                result.addContent(r);

            } else if (type.equals("operations")) {
        result.addContent(context.getBean(OperationRepository.class).findAllAsXml());

            } else if (type.equals("regions")) {
            RegionsDAO dao = context.getApplicationContext().getBean(RegionsDAO.class);
            Element regions = dao.createSearchRequest(context).xmlResult();
        result.addContent(regions);
      } else if (type.equals("isolanguages")) {
                result.addContent(context.getBean(IsoLanguageRepository.class).findAllAsXml());

            } else if (type.equals("sources")) {
        result.addContent(getSources(context, sm));

            } else if (type.equals("users")) {
        result.addContent(getUsers(context));

            } else if (type.equals("templates"))   {
        result.addContent(getTemplates(context));

            } else if (type.equals("z3950repositories")) {
        result.addContent(getZRepositories(context, sm));

            } else if (type.equals("me")) {
        result.addContent(getMyInfo(context));
     
            } else if (type.equals("auth")) {
        result.addContent(getAuth(context));

            } else if (type.equals(READ_ONLY)) {
                result.addContent(getReadOnly(gc));
            } else if (type.equals(INDEX)) {
                result.addContent(getIndex(gc));
            } else if (type.equals("schemas")) {
        result.addContent(getSchemas(gc.getBean(SchemaManager.class)));

            } else if (type.equals("status")) {
        result.addContent(context.getBean(StatusValueRepository.class).findAllAsXml());

            } else {
View Full Code Here

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

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

    setupProxy(sm, req);
  }
View Full Code Here

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

  public CredentialsProvider setupProxy(ServiceContext context, HttpClientBuilder client)
  {
    GeonetContext  gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
    SettingManager sm = gc.getBean(SettingManager.class);

    return setupProxy(sm, client);
  }
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.