Example #1
0
  @JSONExported
  @Admin
  public JSONObject remove(final JSONObject serializer, @Parameter("name") final String fileName)
      throws JSONException {

    iconsFileStore.remove(getRelativePath(fileName));
    return serializer;
  }
Example #2
0
  @JSONExported
  @Admin
  public JSONObject update(
      @Parameter(value = "file", required = false) final FileItem file,
      @Parameter(value = "name", required = true) final String fileName,
      @Parameter(value = "description", required = true) final String newFileName,
      final JSONObject serializer)
      throws JSONException, AuthException, ORMException, IOException {

    if (!"".equals(file.getName())) { // replace the file
      if (iconsFileStore.isImage(file)) {
        iconsFileStore.remove(getRelativePath(fileName));
        iconsFileStore.save(file, getRelativePath(newFileName));
      } else {
        throw ORMExceptionType.ORM_ICONS_UNSUPPORTED_TYPE.createException();
      }
    } else { // rename the existing file
      iconsFileStore.rename(getRelativePath(fileName), getRelativePath(newFileName));
    }

    return serializer;
  }