class ResourceDetailsJaxrsService {

    public Response updateFileViaForm(InputStream stream, String uri, String label, String description, String type, boolean dryRun) throws ErrorDescriptorException {

        if (stream == null) {
            throw new MandatoryParameterNotFoundException("data");
        }
        // uri - uri of resource
        if (uri == null || "".equals(uri)) {
            throw new MandatoryParameterNotFoundException(PATH_PARAM_URI);
        } else if (uri.endsWith(Folder.SEPARATOR)) {
            throw new IllegalParameterValueException(PATH_PARAM_URI, uri);
        }
        if (type == null || "".equals(type)) {
            throw new MandatoryParameterNotFoundException("type");
        }

        uri = uri.startsWith(Folder.SEPARATOR) ? uri : Folder.SEPARATOR + uri;
        int lastSeparator = uri.lastIndexOf(Folder.SEPARATOR);
        String name = uri.substring(lastSeparator + Folder.SEPARATOR_LENGTH);
        String parentFolderUri = uri.substring(0, lastSeparator);
        parentFolderUri = parentFolderUri.equals("") ? Folder.SEPARATOR : parentFolderUri;

        Resource file;
        Response.Status status = Response.Status.OK;
        if (singleRepositoryService.getResource(uri) == null) {
            file = singleRepositoryService.createFileResource(stream, parentFolderUri, name, label == null ? name : label, description, type, true, dryRun);
            status = Response.Status.CREATED;
        } else {
            file = singleRepositoryService.updateFileResource(stream, parentFolderUri, name, label == null ? name : label, description, type, dryRun);
        }
        ClientResource clientFile = resourceConverterProvider.getToClientConverter(file).toClient(file, null);
        return Response.status(status).entity(clientFile).build();
    }

}