// If the request is not redirected (in case of INSERT or DELETE) then
// assemble appropriate
// HtmlContentGenerator.
if (page == null) {
DatabaseWikiContentGenerator contentGenerator = new DatabaseWikiContentGenerator(
request, this.getTitle(), this.cssLinePrinter());
if ((isGetRequest) || (request.type().isCopy())) {// This is the
// default case
// where no
// action has
// been
// performed and
// no special
// content is
// requested
contentGenerator.put(
DatabaseWikiContentGenerator.ContentTimemachine,
new TimemachinePrinter(request));
contentGenerator.put(DatabaseWikiContentGenerator.ContentMenu,
new DataMenuPrinter(request, _layouter));
contentGenerator.put(
DatabaseWikiContentGenerator.ContentObjectLink,
new NodePathPrinter(request, _layouter));
contentGenerator.put(
DatabaseWikiContentGenerator.ContentAnnotation,
new ObjectAnnotationPrinter(request));
// contentGenerator.put(DatabaseWikiContentGenerator.ContentProvenance,
// new VersionIndexPrinter(request));
contentGenerator.put(
DatabaseWikiContentGenerator.ContentProvenance,
new ObjectProvenancePrinter(request, _layouter));
contentGenerator.put(
DatabaseWikiContentGenerator.ContentContent,
new DataNodePrinter(request, _layouter));
} else if (isIndexRequest) { // The case for the root of the
// DatabaseWiki
contentGenerator.put(
DatabaseWikiContentGenerator.ContentTimemachine,
new TimemachinePrinter(request));
contentGenerator.put(DatabaseWikiContentGenerator.ContentMenu,
new DataMenuPrinter(request, _layouter));
// TODO: This could be simplified by storing the mapping in a
// Map<String,IndexContentPrinter>
if (DatabaseLayouter.IndexAZMultiPage.equals(_layouter
.indexType())) {
contentGenerator.put(
DatabaseWikiContentGenerator.ContentContent,
new AZMultiPageIndexPrinter(request, database()
.content()));
} else if (DatabaseLayouter.IndexAZSinglePage.equals(_layouter
.indexType())) {
contentGenerator.put(
DatabaseWikiContentGenerator.ContentContent,
new AZSinglePageIndexPrinter(request, database()
.content()));
} else if (DatabaseLayouter.IndexMultiColumn.equals(_layouter
.indexType())) {
contentGenerator.put(
DatabaseWikiContentGenerator.ContentContent,
new MultiColumnIndexPrinter(request, database()
.content()));
} else if (DatabaseLayouter.IndexPartialList.equals(_layouter
.indexType())) {
contentGenerator.put(
DatabaseWikiContentGenerator.ContentContent,
new PartialIndexPrinter(request, database()
.content()));
} else {
contentGenerator
.put(DatabaseWikiContentGenerator.ContentContent,
new FullIndexPrinter(request, database()
.content()));
}
} else if (request.type().isSearch()) { // The case for a search
// request
DatabaseContent content = null;
String query = request.parameters()
.get(RequestParameter.ParameterSearch).value();
if (query != null) {
content = database().search(query);
} else {
content = database().content();
}
contentGenerator.put(
DatabaseWikiContentGenerator.ContentTimemachine,
new TimemachinePrinter(request));
contentGenerator.put(DatabaseWikiContentGenerator.ContentMenu,
new DataMenuPrinter(request, _layouter));
contentGenerator.put(
DatabaseWikiContentGenerator.ContentContent,
new SearchResultPrinter(request, content));
} else if ((request.type().isCreate()) || (request.type().isEdit())) { // The
// case
// for
// a
// create
// or
// edit
// request
contentGenerator.put(
DatabaseWikiContentGenerator.ContentObjectLink,
new NodePathPrinter(request, _layouter));
contentGenerator.put(
DatabaseWikiContentGenerator.ContentContent,
new DataUpdateFormPrinter(request, _layouter));
} else if (request.type().isCreateSchemaNode()) { // Creating a new
// schema node.
contentGenerator.put(
DatabaseWikiContentGenerator.ContentObjectLink,
new NodePathPrinter(request, _layouter));
contentGenerator.put(
DatabaseWikiContentGenerator.ContentContent,
new CreateSchemaNodeFormPrinter(request));
} else if ((request.type().isTimemachineChanges())
|| ((request.type().isTimemachinePrevious()))) {
if (request.node() != null) { // Showing version index
contentGenerator.put(
DatabaseWikiContentGenerator.ContentObjectLink,
new NodePathPrinter(request, _layouter));
}
contentGenerator.put(
DatabaseWikiContentGenerator.ContentTimemachine,
new TimemachinePrinter(request));
contentGenerator.put(
DatabaseWikiContentGenerator.ContentContent,
new VersionIndexPrinter(request));
} else if (request.type().isLayout()) { // Editing the layout
contentGenerator.put(
DatabaseWikiContentGenerator.ContentContent,
new LayoutEditor(request));
} else if (request.type().isPasteForm()) { // Pasting XML data from
// a URL
contentGenerator.put(
DatabaseWikiContentGenerator.ContentContent,
new InputFormPrinter(request, "Copy & Paste",
"Insert source URL",
RequestParameter.ParameterPaste,
RequestParameter.ParameterURL));
} else if (request.type().isStyleSheet()) { // Editing the
// stylesheet
contentGenerator.put(
DatabaseWikiContentGenerator.ContentContent,
new FileEditor(request, "Edit style sheet"));
} else if (request.type().isTemplate()) { // Editing the template
contentGenerator.put(
DatabaseWikiContentGenerator.ContentContent,
new FileEditor(request, "Edit template"));
} else if (request.type().isURLDecoding()) { // Editing the URL
// decoding rules
contentGenerator.put(
DatabaseWikiContentGenerator.ContentContent,
new FileEditor(request, "Edit URL decoding rules"));
} else if (request.type().isSettings()) { // The list of prior
// combinations of
// config files, can be
// used to revert.
contentGenerator.put(
DatabaseWikiContentGenerator.ContentContent,
new SettingsListingPrinter(request));
} else {
throw new WikiRequestException(
WikiRequestException.InvalidRequest, exchange.getRequestURI().toString());