*/
protected void doExecute() throws Exception {
super.doExecute();
// create new document
DocumentManager documentManager = null;
ServiceSelector selector = null;
ResourceType resourceType = null;
try {
documentManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
String language = getParameterAsString(LANGUAGE);
Document initialDocument = getInitialDocument();
Document document;
String title = getDublinCoreParameter(DublinCore.ELEMENT_TITLE).trim();
if (createVersion()) {
document = documentManager.addVersion(initialDocument, getArea(), language, true);
document.getLink().setLabel(title);
} else {
if (initialDocument == null) {
selector = (ServiceSelector) this.manager
.lookup(ResourceType.ROLE + "Selector");
resourceType = (ResourceType) selector.select(getDocumentTypeName());
String sampleName = getParameterAsString(SAMPLE, resourceType.getSampleNames()[0]);
ResourceType.Sample sample = resourceType.getSample(sampleName);
document = documentManager.add(getDocumentFactory(), resourceType, sample.getUri(),
getPublication(), getArea(), getNewDocumentPath(), language,
getSourceExtension(), title, getVisibleInNav());
document.setMimeType(sample.getMimeType());
} else {
document = documentManager.add(initialDocument, getArea(),
getNewDocumentPath(), language, getSourceExtension(), title,
getVisibleInNav());
}
}