class ResourceDetailsJaxrsService {

    public Response defaultPutHandler(InputStream stream, String uri, String sourceUri, String disposition,
            String description, String rawMimeType, String accept, Boolean createFolders, Boolean overwrite,
            String renameTo, boolean dryRun, Map<String, String[]> additionalProperties) throws ErrorDescriptorException {
        Response response;
        if (sourceUri != null) {
            // uri - parent folder uri
            String newUri = singleRepositoryService.moveResource(sourceUri, uri, createFolders, overwrite, renameTo);
            // if user copies file, we have to return descriptor, not its content
            // (matters only '+json' or '+xml' part, so file here works for all kinds of resources))
            if (MediaType.APPLICATION_JSON.equals(accept)) {
                accept = ResourceMediaType.FILE_JSON;
            } else {
                accept = ResourceMediaType.FILE_XML;
            }
            response = getResourceDetails(newUri, accept, false, null, null, additionalProperties);
        } else {
            // uri - uri of resource
            if (uri == null || uri.endsWith(Folder.SEPARATOR)) {
                throw new IllegalParameterValueException(PATH_PARAM_URI, 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;
            String type = extractType(rawMimeType, name);

            Resource file;
            Response.Status status = Response.Status.OK;
            String label = name;
            if (disposition != null) {
                if (!disposition.contains("filename=") || disposition.endsWith("filename=")) {
                    throw new IllegalParameterValueException("Content-Disposition", disposition);
                } else {
                    label = disposition.split("filename=")[1];
                }
            }

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

        return response;
    }

}