class ResourceDetailsJaxrsService {

    public ClientResource createResourceViaForm(FormDataMultiPart multiPart, String parentUri, Boolean createFolders,
            String accept, boolean dryRun, Map<String, String[]> additionalProperties) throws ErrorDescriptorException {
        final FormDataBodyPart resourcePart = multiPart.getField(ResourceMultipartConstants.RESOURCE_PART_NAME);
        if (resourcePart != null) {
            final MediaType mediaType = resourcePart.getMediaType();
            final String clientType = ClientTypeHelper.extractClientType(mediaType);
            if(clientType == null){
                throw new IllegalParameterValueException("resource Media-Type", mediaType != null ? mediaType.toString() : "null");
            }
            final Class<? extends ClientResource> clientTypeClass = resourceConverterProvider
                    .getClientTypeClass(clientType);
            ClientResource clientObject = resourcePart.getEntityAs(clientTypeClass);
            Map<String, InputStream> partsMap = new HashMap<String, InputStream>();
            for (String currentPartName : multiPart.getFields().keySet()) {
                if (ResourceMultipartConstants.RESOURCE_PART_NAME.equals(currentPartName)) {
                    continue;
                }
                partsMap.put(currentPartName, multiPart.getField(currentPartName).getEntityAs(InputStream.class));
            }

            return createResource(clientObject, parentUri, createFolders, partsMap, dryRun, accept, additionalProperties);
        } else {
            ClientResource result = createFileViaForm(
                    multiPart.getField("data") != null ? multiPart.getField("data").getEntityAs(InputStream.class) : null, parentUri,
                    multiPart.getField("label") != null ? multiPart.getField("label").getValue() : null,
                    multiPart.getField("description") != null ? multiPart.getField("description").getValue() : null,
                    multiPart.getField("type") != null ? multiPart.getField("type").getValue() : null, createFolders, dryRun);
            return result;
        }

    }

}