blob: 549b2f7ac876b132e45e3438948bcbb2fda0cb86 [file] [log] [blame]
//------------------------------------------------------------------------------
// Copyright (c) 2005, 2007 IBM Corporation and others.
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// which accompanies this distribution, and is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// Contributors:
// IBM Corporation - initial implementation
//------------------------------------------------------------------------------
package org.eclipse.epf.publishing.services;
import java.net.URL;
import java.util.List;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.epf.common.utils.FileUtil;
import org.eclipse.epf.library.layout.Bookmark;
import org.eclipse.epf.library.layout.HtmlBuilder;
import org.eclipse.epf.library.layout.LayoutResources;
import org.eclipse.epf.publishing.PublishingPlugin;
/**
* The abstract base class for a Site Generator.
*
* @author Jinhua Xi
*/
public abstract class AbstractSiteGenerator implements ISiteGenerator {
private static final String WEB_INF_PATH = "docroot/WEB-INF"; //$NON-NLS-1$
private static final String WEB_INF_DIR = "WEB-INF"; //$NON-NLS-1$
protected String pubDir;
protected PublishHTMLOptions options;
protected HtmlBuilder builder;
public AbstractSiteGenerator(HtmlBuilder builder, PublishHTMLOptions options) {
this.options = options;
this.builder = builder;
this.pubDir = builder.getPublishDir();
}
public abstract HtmlBuilder getHtmlBuilder();
public abstract String getIndexFilePath();
public abstract String getNodeIconPath();
public abstract PublishOptions getPublishOptions();
public abstract void postPublish() throws Exception;
public abstract void prePublish() throws Exception;
public abstract void writePublishedBookmarks(List bookmarks, Bookmark defaultView)
throws Exception;
protected void copyCustomizedFiles() throws Exception {
if (options.bannerImage != null && options.bannerImage.length() > 0) {
FileUtil.copyFile(options.bannerImage, pubDir + "images"); //$NON-NLS-1$
options.bannerImage = FileUtil.getFileName(options.bannerImage);
} else {
options.bannerImage = "banner.gif"; //$NON-NLS-1$
}
if (options.isPublishDynamicWebApp()) {
URL plugin_url = PublishingPlugin.getDefault().getInstallURL();
String path = FileLocator.resolve(new URL(plugin_url, WEB_INF_PATH)).getPath();
String includes = "*.*, **/"; //$NON-NLS-1$
LayoutResources.copyDir(path, pubDir + WEB_INF_DIR, includes, null);
}
}
}