protected void initParameters() {
super.initParameters();
Publication _publication = this.getPublication();
ServiceSelector siteManagerSelector = null;
SiteManager siteManager = null;
Vector docs = new Vector();
Vector checkedOut = new Vector();
String request = getSourceURL();
if (request.endsWith(".html"))
request = request.substring(0, request.indexOf(".html"));
if (!request.endsWith("/"))
request = request + "/";
if (request.indexOf("webdav") > -1) {
request = request.replaceFirst("webdav", "authoring");
}
try {
siteManagerSelector = (ServiceSelector) this.manager.lookup(SiteManager.ROLE
+ "Selector");
siteManager = (SiteManager) siteManagerSelector.select(_publication.getSiteManagerHint());
Document[] documents = siteManager.getDocuments(getDocumentFactory(),
_publication,
Publication.AUTHORING_AREA);
for (int i = 0; i < documents.length; i++) {
String test = documents[i].getCanonicalWebappURL().replaceFirst("/[^/]*.html", "");
if (!test.endsWith("/"))
test = test + "/";
if (test.equals(request)) {
docs.add(documents[i]);
Node node = documents[i].getRepositoryNode();
if (node.isCheckedOut()) {
checkedOut.add(node.getCheckoutUserId());
}
else {
checkedOut.add(null);
}
}
}
//FIXME: This is a workaround for the error
// "This usecase can only be invoked on documents!"
// triggered in (superclass) DocumentUsecase.doCheckPreconditions()
// when the usecase parameter "document" is not set properly.
if (docs.size() > 0) {
setParameter(DOCUMENT, docs.get(0));
}
setParameter(DOCUMENTS, docs);
setParameter(RC, checkedOut);
setParameter(SOURCEURL, request);
SimpleDateFormat format = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss zzz");
setParameter(DATEFORMAT, format);
Date rootModDate = new Date();
setParameter("rootModDate", rootModDate);
String defaultLang = _publication.getDefaultLanguage();
setParameter("defaultLang", defaultLang);
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
if (siteManagerSelector != null) {
if (siteManager != null) {
siteManagerSelector.release(siteManager);
}
this.manager.release(siteManagerSelector);
}
}
}