@JSONExported @Admin public JSONObject upload( @Parameter(value = "file", required = true) final FileItem file, @Parameter(value = "description", required = true) final String fileName, final JSONObject serializer) throws ORMException, FileNotFoundException, IOException { final String relativePath = getRelativePath(fileName) + iconsFileStore.getExtension(file.getName()); if (iconsFileStore.isImage(file)) { iconsFileStore.save(file, relativePath); } else { throw ORMExceptionType.ORM_ICONS_UNSUPPORTED_TYPE.createException(); } return serializer; }
@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; }