public Element exec(Element params, ServiceContext context) throws Exception {

    Path harvestingLogoDirectory = Resources.locateHarvesterLogosDir(context);
    Path nodeLogoDirectory = Resources.locateLogosDir(context);

    String file = Util.getParam(params, Params.FNAME);
    String asFavicon = Util.getParam(params, Params.FAVICON, "0");

    if (file.contains("..")) {
      throw new BadParameterEx("Invalid character found in resource name.", file);
    }

    if ("".equals(file)) {
      throw new Exception("Logo name is not defined.");
    }

    SettingManager settingMan = context.getBean(SettingManager.class);
    String nodeUuid = settingMan.getSiteId();

    try {
      Path logoFilePath = harvestingLogoDirectory.resolve(file);
      if (!Files.exists(logoFilePath)) {
        logoFilePath = context.getAppPath().resolve("images/harvesting/" + file);
      }
      try (InputStream inputStream = Files.newInputStream(logoFilePath)) {
        BufferedImage source = ImageIO.read(inputStream);

        if ("1".equals(asFavicon)) {
          createFavicon(source, nodeLogoDirectory.resolve("favicon.png"));
        } else {
          Path logo = nodeLogoDirectory.resolve(nodeUuid + ".png");
          Path defaultLogo = nodeLogoDirectory.resolve("logo.png");

          if (!file.endsWith(".png")) {
            try (OutputStream logoOut = Files.newOutputStream(logo);
                OutputStream defLogoOut = Files.newOutputStream(defaultLogo); ) {
              ImageIO.write(source, "png", logoOut);
              ImageIO.write(source, "png", defLogoOut);
            }
          } else {
            Files.deleteIfExists(logo);
            IO.copyDirectoryOrFile(logoFilePath, logo, false);
            Files.deleteIfExists(defaultLogo);
            IO.copyDirectoryOrFile(logoFilePath, defaultLogo, false);
          }
        }
      }
    } catch (Exception e) {
      throw new Exception(
          "Unable to move uploaded thumbnail to destination directory. Error: " + e.getMessage());
    }

    Element response = new Element("response");
    response.addContent(new Element("status").setText("Logo set."));
    return response;
  }
  public Element exec(Element params, ServiceContext context) throws Exception {

    GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME);
    SchemaManager scm = gc.getBean(SchemaManager.class);

    String schema = Util.getParam(params, Params.SCHEMA);
    String urlStr, uuid, fname;
    uuid = "";
    URL url = null;

    // -- try the file name argument then the url then the uuid of a metadata
    // -- record to which a schema is attached
    fname = Util.getParam(params, Params.FNAME, "");
    if ("".equals(fname)) {
      urlStr = Util.getParam(params, Params.URL, "");
      if ("".equals(urlStr)) {
        uuid = Util.getParam(params, Params.UUID, "");
        if ("".equals(uuid)) {
          throw new IllegalArgumentException("One of fname, url or uuid must be supplied");
        }
      } else {
        try {
          url = new URL(urlStr);
        } catch (MalformedURLException mu) {
          throw new OperationAbortedEx("URL " + urlStr + " is malformed: " + mu.getMessage());
        }
      }
    }

    // -- test if schema to be updated exists, if not then chuck a fit and exit
    if (!scm.existsSchema(schema)) {
      throw new OperationAbortedEx("Schema doesn't exist");
    }

    SchemaUtils su = new SchemaUtils();
    return su.updateSchema(context, schema, fname, url, uuid, scm);
  }
 public void update(Element node) throws BadInputEx {
   super.update(node);
   Element site = node.getChild("site");
   server = Util.getParam(site, "server", "");
   port = Util.getParam(site, "port", 5151);
   setUsername(Util.getParam(site, "username", ""));
   setPassword(Util.getParam(site, "password", ""));
   database = Util.getParam(site, "database", "");
   icon = Util.getParam(site, "icon", "arcsde.gif");
 }