// String imageContentURN = "urn:hash::md5:" + MD5.dumpBytes(hash);
URI imageContentURN;
try {
imageContentURN = hashStore.storeContent(fileContent);
} catch (Exception e) {
throw new HandlerException(e);
}
Model model = resource.getModel();
Resource contentResource = model.createResource(imageContentURN
.toString());
RemoveHandler.removeVariant(resource, contentResource.toString(),
mimeType.toString());
resource.addProperty(RDF.type, DOCUMENT.Document);
Resource documentVariant = model
.createResource(DOCUMENT.DocumentVariant);
resource.addProperty(DOCUMENT.variant, documentVariant);
documentVariant.addProperty(DOCUMENT.contentType, mimeType.toString());
documentVariant.addProperty(DOCUMENT.content, contentResource);
documentVariant.addProperty(DOCUMENT.contentLength, model
.createTypedLiteral(fileContent.length));
Literal createdLit = model.createTypedLiteral(new W3CDateFormat()
.format(new Date()), XSDDatatype.XSDdateTime);
documentVariant.addProperty(DCTerms.created, createdLit);
if ((language != null) && (!language.equals("independent"))) {
documentVariant.addProperty(DC.language, language);
}
Set variantsSet = new HashSet();
variantsSet.add(documentVariant);
FormatConverter[] formatConverters = getFormatConverters(resource
.getModel(), hashStore);
for (int i = 0; i < formatConverters.length; i++) {
Collection sourceFormats = Arrays.asList(formatConverters[i].getSourceFormats());
if (sourceFormats.contains(mimeType)) {
Resource newVariant = model.createResource();
MimeType[] targetTypes = formatConverters[i].getTargetFormats();
for (int j = 0; j < targetTypes.length; j++) {
MimeType targetType = targetTypes[j];
try {
formatConverters[i].transform(resource, mimeType, targetType, documentVariant, newVariant);
} catch (IOException e) {
throw new HandlerException(e);
}
variantsSet.add(newVariant);
resource.addProperty(DOCUMENT.variant, newVariant);
}
}
}
AudioContentProcessor.readProperties(mimeType, fileContent,
documentVariant);
try {
createWebDavResource(resource);
} catch (URISyntaxException e) {
throw new HandlerException(e);
}
}
}