Unfortunately quite a large update, combined BaseDispatcher and DispatcherServlet into a modern, standard compliant CCMDispatcherServlet, modified various classes to enable CCM installed in any arbitrary context, not just ROOT. Part 1. Currently it works for ScientificCMS only, for other bundles StylesheetPaths.txt has to be modified.

git-svn-id: https://svn.libreccm.org/ccm/trunk@2557 8810af33-2d31-482b-a856-94f89814c4df
master
pb 2014-03-06 12:53:03 +00:00
parent c21769dfc8
commit 13b7c7cf2e
208 changed files with 2349 additions and 1184 deletions

View File

@ -131,7 +131,7 @@ public class SiteProxyGenerator extends AtoZGeneratorAbstractImpl {
ParameterMap map = new ParameterMap();
map.setParameter("oid", m_oid.toString());
URL here = Web.getContext().getRequestURL();
URL here = Web.getWebContext().getRequestURL();
return (new URL(here.getScheme(), here.getServerName(), here
.getServerPort(), "", "", "/redirect/", map)).toString();

View File

@ -93,7 +93,7 @@ public class CategoryGenerator extends AtoZGeneratorAbstractImpl {
ParameterMap map = new ParameterMap();
map.setParameter("oid", m_oid.toString());
URL here = Web.getContext().getRequestURL();
URL here = Web.getWebContext().getRequestURL();
return (new URL(here.getScheme(), here.getServerName(), here
.getServerPort(), "", "", "/redirect/", map)).toString();

View File

@ -125,7 +125,7 @@ public class ItemGenerator extends AtoZGeneratorAbstractImpl {
ParameterMap map = new ParameterMap();
map.setParameter("oid", m_oid.toString());
URL here = Web.getContext().getRequestURL();
URL here = Web.getWebContext().getRequestURL();
return (new URL(here.getScheme(), here.getServerName(), here
.getServerPort(), "", "", "/redirect/", map)).toString();

View File

@ -252,7 +252,7 @@ public class BookmarkEditPane extends DynamicListWizard {
public Component getComponent(List list, PageState state,
Object value, String key, int index, boolean isSelected) {
Bookmarks app = (Bookmarks) Web.getContext()
Bookmarks app = (Bookmarks) Web.getWebContext()
.getApplication();
BookmarkCollection bColl = app.getBookmarks();
final long size = bColl.size();

View File

@ -79,7 +79,7 @@ public class BookmarkPortlet extends AppPortlet {
if (!PermissionService.checkPermission(
new PermissionDescriptor(PrivilegeDescriptor.READ,
app,
Web.getContext().getUser()))) {
Web.getWebContext().getUser()))) {
return null;
}
return (URL.getDispatcherPath() + app.getPrimaryURL());

View File

@ -54,8 +54,8 @@ public class SimplePage extends com.arsdigita.ui.SimplePage {
* Two xml attributes are added in addition to the bebop standard
* implementation.
*/
if (Web.getContext().getRequestURL() != null) {
page.addAttribute("url", Web.getContext().getRequestURL().toString());
if (Web.getWebContext().getRequestURL() != null) {
page.addAttribute("url", Web.getWebContext().getRequestURL().toString());
page.addAttribute("textOnly", "/text".equals(
DispatcherHelper

View File

@ -253,7 +253,7 @@ public class FormItem extends ContentPage implements XMLGenerator {
generateXMLBody(fake, element, c);
String action = form.getAction();
if (action == null) {
final URL requestURL = Web.getContext().getRequestURL();
final URL requestURL = Web.getWebContext().getRequestURL();
if (requestURL == null) {
action = state.getRequest().getRequestURI();

View File

@ -192,7 +192,7 @@ public class FormSectionItem extends ContentPage
String action = c.getAction();
if (action == null) {
final URL requestURL = Web.getContext().getRequestURL();
final URL requestURL = Web.getWebContext().getRequestURL();
if (requestURL == null) {
action = state.getRequest().getRequestURI();

View File

@ -72,7 +72,7 @@ public class SurveyXMLGenerator extends SimpleXMLGenerator {
String action = pForm.getAction();
if (action == null) {
final URL requestURL = Web.getContext().getRequestURL();
final URL requestURL = Web.getWebContext().getRequestURL();
if (requestURL == null) {
action = state.getRequest().getRequestURI();

View File

@ -60,12 +60,9 @@ public abstract class CMS {
return s_initialContext;
}
};
private static final CMSConfig s_config = new CMSConfig();
static {
s_log.debug("Static initializer starting...");
s_config.load();
s_log.debug("Static initializer finished.");
}
/** Config object containing various parameter */
private static final CMSConfig s_config = CMSConfig.getInstanceOf();
/**

View File

@ -76,7 +76,7 @@ public final class CMSConfig extends AbstractConfig {
*
* @return The <code>CMSConfig</code> record; it cannot be null
*/
public static synchronized CMSConfig getInstance() {
public static synchronized CMSConfig getInstanceOf() {
if (s_config == null) {
s_config = new CMSConfig();
s_config.load();
@ -668,7 +668,9 @@ public final class CMSConfig extends AbstractConfig {
// Moved to publishToFile.PublishToFileConfig as of version 6.0.2
// private final Parameter m_disableItemPfs;
// private final Parameter m_publishToFileClass;
/**
/**
* Constructor, but do NOT instantiate this class directly.
*
* @see ContentSection#getConfig()

View File

@ -174,7 +174,7 @@ public class ContentBundle extends ContentItem {
s_log.debug("Item id is: " + instance.getID());
final Workflow workflow = template.instantiateNewWorkflow();
workflow.setObjectID(instance.getID());
workflow.start(Web.getContext().getUser());
workflow.start(Web.getWebContext().getUser());
workflow.save();
}

View File

@ -146,7 +146,7 @@ public class ContentCenterServlet extends BaseApplicationServlet {
// ContentCenter workspace = (ContentCenter) app;
/* Check user and privilegies */
if (Web.getContext().getUser() == null) { // user not logged in
if (Web.getWebContext().getUser() == null) { // user not logged in
throw new LoginSignal(sreq); // send to login page
}
// Check whether logged in user has access to at least one content section

View File

@ -1330,7 +1330,7 @@ public class ContentItem extends VersionedACSObject implements CustomCopy {
Assert.isTrue(isLive(), "Attempt to republish non live item " + getOID());
//ToDo Remove item from cache
if (CMSConfig.getInstance().getEnableXmlCache()) {
if (CMSConfig.getInstanceOf().getEnableXmlCache()) {
XMLDeliveryCache.getInstance().removeFromCache(getOID());
}
@ -1974,7 +1974,7 @@ public class ContentItem extends VersionedACSObject implements CustomCopy {
}
/*final AssociationCopierLoader assocCopierLoader =
AssociationCopierLoader.getInstance();
AssociationCopierLoader.getInstanceOf();
final AssociationCopier assocCopier = assocCopierLoader.
getAssociationCopierFor(property, source);
if (assocCopier != null) {

View File

@ -125,7 +125,7 @@ public class ContentSection extends Application {
private final static String ITEM_QUERY = "com.arsdigita.cms.ItemsInSection";
private final static String SECTION_ID = "sectionId";
private static final CMSConfig s_config = CMSConfig.getInstance();
private static final CMSConfig s_config = CMSConfig.getInstanceOf();
/* DO NOT use CMSConfig constructor to instantiate !
private static final CMSConfig s_config = new CMSConfig();

View File

@ -305,7 +305,9 @@ public class ContentSectionServlet extends BaseApplicationServlet {
sreq = DispatcherHelper.restoreOriginalRequest(sreq);
rd.forward(sreq, sresp);
} else {
// sresp.sendError(404, packageURL + " not found on this server.");
if (s_log.isDebugEnabled()) {
s_log.debug("No dispatcher found for" + rd);
}
String requestUri = sreq.getRequestURI(); // same as ctx.getRemainingURLPart()
sresp.sendError(404, requestUri + " not found on this server.");
}

View File

@ -200,7 +200,7 @@ public class CustomizableContentItemXMLRenderer
//Build paginator
//Get pageNumber from request URL
URL requestUrl = Web.getContext().getRequestURL();
URL requestUrl = Web.getWebContext().getRequestURL();
String pageNumberValue = requestUrl.getParameter("pageNumber");
long pageNumber;
if (pageNumberValue == null) {

View File

@ -493,7 +493,7 @@ class DomainCopier extends DomainService {
* @param dobj
*/
private void checkXmlCache(final DomainObject dobj) {
if ((dobj instanceof ContentItem) && CMSConfig.getInstance().getEnableXmlCache()) {
if ((dobj instanceof ContentItem) && CMSConfig.getInstanceOf().getEnableXmlCache()) {
final ContentItem item = (ContentItem) dobj;
XMLDeliveryCache.getInstance().removeFromCache(item.getOID());
}

View File

@ -97,7 +97,7 @@ public class Initializer extends CompoundInitializer {
/** Creates a s_logging category with name = to the full name of class */
private static Logger s_log = Logger.getLogger(Initializer.class);
/** Configuration object for the CMS module */
private static final CMSConfig s_conf = CMSConfig.getInstance();
private static final CMSConfig s_conf = CMSConfig.getInstanceOf();
/**
* Constructor, adds db connection information and various sub-initializers

View File

@ -24,8 +24,8 @@ public final class XMLDeliveryCache {
* The real cache.
*/
private CacheTable cache = new CacheTable(XMLDeliveryCache.class.getName(),
CMSConfig.getInstance().getXmlCacheSize(),
CMSConfig.getInstance().getXmlCacheSize(),
CMSConfig.getInstanceOf().getXmlCacheSize(),
CMSConfig.getInstanceOf().getXmlCacheSize(),
true);
/**
* Maps from the OID of the master version of an item in the cache to the OID of the item in the cache.

View File

@ -218,7 +218,7 @@ public abstract class CompoundContentItemPanel
parent.newChildElement("nav:paginator",
"http://ccm.redhat.com/navigation");
URL requestURL = Web.getContext().getRequestURL();
URL requestURL = Web.getWebContext().getRequestURL();
ParameterMap map = new ParameterMap();

View File

@ -49,7 +49,7 @@ public class GenericOrgaUnitPaginator<T extends DataQuery> {
"nav:paginator",
"http://ccm.redhat.com/navigation");
final URL requestUrl = Web.getContext().getRequestURL();
final URL requestUrl = Web.getWebContext().getRequestURL();
final ParameterMap parameters = new ParameterMap();
if (requestUrl.getParameterMap() != null) {

View File

@ -60,7 +60,7 @@ public class Paginator {
final Element paginatorElem = parent.newChildElement(
"nav:paginator", "http://ccm.redhat.com/navigation");
final URL requestUrl = Web.getContext().getRequestURL();
final URL requestUrl = Web.getWebContext().getRequestURL();
final ParameterMap parameters = new ParameterMap();

View File

@ -17,7 +17,6 @@
package com.arsdigita.cms.dispatcher;
import com.arsdigita.cms.Asset;
import com.arsdigita.kernel.NoValidURLException;
import com.arsdigita.kernel.URLFinder;
import com.arsdigita.persistence.OID;
@ -25,28 +24,27 @@ import com.arsdigita.web.Web;
import com.arsdigita.web.WebConfig;
/**
* @author mbooth@redhat.com
* Implementation of URLFinder for Assets.
*
* Implementation of URLFinder for Assets
* @author mbooth@redhat.com
*/
public class AssetURLFinder implements URLFinder {
/**
*
* find URL for an asset
*
* @param oid the OID of the asset
* @param context the context of the lookup (live/draft)
*
*/
* Find URL for an asset.
*
* @param oid the OID of the asset
* @param context the context of the lookup (live/draft)
* @return
*/
public String find(OID oid, String context) throws NoValidURLException {
if( !"live".equals( context ) )
throw new NoValidURLException("No draft URL for assets");
WebConfig config = Web.getConfig();
StringBuffer url = new StringBuffer();
url.append( config.getDispatcherServletPath() );
url.append( config.getDispatcherContextPath() );
StringBuilder url = new StringBuilder();
url.append( Web.getConfig().getDispatcherServletPath() );
// Must be wrong! ContextPath is before ServletPath!
// url.append( Web.getConfig().getDispatcherContextPath() );
url.append( "/cms-service/stream/asset/?asset_id=" );
url.append( oid.get( Asset.ID ).toString() );
@ -54,11 +52,11 @@ public class AssetURLFinder implements URLFinder {
}
/**
*
* find URL for an asset in the live context
*
* @param oid the OID of the asset
*/
* Find URL for an asset in the live context
*
* @param oid the OID of the asset
* @return
*/
public String find(OID oid) throws NoValidURLException {
return find(oid, "live");
}

View File

@ -34,7 +34,6 @@ import com.arsdigita.dispatcher.RequestContext;
import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.kernel.Kernel;
// import com.arsdigita.kernel.KernelContext;
import com.arsdigita.kernel.User;
import com.arsdigita.kernel.permissions.PermissionDescriptor;
import com.arsdigita.kernel.permissions.PermissionService;
@ -150,6 +149,7 @@ public class CMSPage extends Page implements ResourceHandler {
* This method is called by the {@link com.arsdigita.dispatcher.Dispatcher}
* that initializes this page.
*/
@Override
public synchronized void init() {
s_log.debug("Initializing the page");
@ -196,6 +196,7 @@ public class CMSPage extends Page implements ResourceHandler {
* On the other hand, if deprecated, implementing ResourceHandler
* may not be required
*/
@Override
public ContentSection getContentSection(HttpServletRequest request) {
// Resets all content sections associations.
// return ContentSectionDispatcher.getContentSection(request);
@ -261,6 +262,7 @@ public class CMSPage extends Page implements ResourceHandler {
*
* @pre m_transformer != null
*/
@Override
public void dispatch(final HttpServletRequest request,
final HttpServletResponse response ,
RequestContext actx
@ -270,6 +272,7 @@ public class CMSPage extends Page implements ResourceHandler {
DeveloperSupport.startStage("CMSPage.dispatch: serve page");
CMSExcursion excursion = new CMSExcursion() {
@Override
public void excurse() throws IOException, ServletException {
Application app = Application.getCurrentApplication(request);
ContentSection section = null;
@ -350,7 +353,7 @@ public class CMSPage extends Page implements ResourceHandler {
// /**
// * @deprecated Use Kernel.getContext().getParty() if possible and
// * Web.getContext().getUser() if necessary.
// * Web.getWebContext().getUser() if necessary.
// */
// public static User getCurrentUser(PageState state) {
// return (User) Kernel.getContext().getParty();

View File

@ -97,7 +97,7 @@ public class ContentItemDispatcher implements Dispatcher {
final ContentItem item = getContentItem(request);
//get the Content Section
final ContentSection section =
(ContentSection) Web.getContext().getApplication();
(ContentSection) Web.getWebContext().getApplication();
Assert.exists(item);

View File

@ -220,7 +220,7 @@ public class MultilingualItemResolver extends AbstractItemResolver implements It
public String getCurrentContext(final PageState state) {
s_log.debug("Getting the current context");
// XXX need to use Web.getContext().getRequestURL() here.
// XXX need to use Web.getWebContext().getRequestURL() here.
String url = state.getRequest().getRequestURI();
final ContentSection section =
@ -410,6 +410,7 @@ public class MultilingualItemResolver extends AbstractItemResolver implements It
* @param item The content item
* @param request The HTTP request
* @return The master page
* @throws javax.servlet.ServletException
*/
@Override
public CMSPage getMasterPage(final ContentItem item,

View File

@ -194,7 +194,7 @@ public class SimpleXMLGenerator implements XMLGenerator {
final XMLDeliveryCache xmlCache = XMLDeliveryCache.getInstance();
if (CMSConfig.getInstance().getEnableXmlCache() && xmlCache.isCached(item.getOID(), useContext, listMode)) {
if (CMSConfig.getInstanceOf().getEnableXmlCache() && xmlCache.isCached(item.getOID(), useContext, listMode)) {
xmlCache.retrieveFromCache(content, item.getOID(), useContext, listMode);
} else {
final ContentItemXMLRenderer renderer = new ContentItemXMLRenderer(content);
@ -239,7 +239,7 @@ public class SimpleXMLGenerator implements XMLGenerator {
//Only published items
//Only the XML of the item itself, no extra XML
if (CMSConfig.getInstance().getEnableXmlCache() && item.isLiveVersion()) {
if (CMSConfig.getInstanceOf().getEnableXmlCache() && item.isLiveVersion()) {
xmlCache.cache(item.getOID(), item, content, useContext, listMode);
}
}

View File

@ -38,7 +38,7 @@ import com.arsdigita.util.servlet.HttpHost;
import com.arsdigita.util.servlet.HttpResourceLocator;
import com.arsdigita.web.Host;
import com.arsdigita.web.Web;
import com.arsdigita.web.WebConfig;
import java.io.File;
import java.io.IOException;
import java.io.OutputStreamWriter;
@ -47,6 +47,7 @@ import java.math.BigDecimal;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.Logger;
/**
@ -185,20 +186,18 @@ public class PublishToFile implements PublishToFileListener {
* @return the source URL for fetching the item
*/
public static URL getSource(final String path) {
if (Assert.isEnabled()) {
Assert.exists(path, String.class);
Assert.isTrue(path.startsWith("/"), "Path starts with '/'");
}
final WebConfig config = Web.getConfig();
final HttpHost host = Web.getConfig().getHost();
// def scheme, no query str
final HttpResourceLocator hrl = new HttpResourceLocator
(host,
config.getDispatcherContextPath(),
config.getDispatcherServletPath(),
(Web.getConfig().getHost(),
Web.getConfig().getDispatcherContextPath(),
Web.getConfig().getDispatcherServletPath(),
path,
null);

View File

@ -189,7 +189,7 @@ public class IntermediaQueryEngine extends BaseQueryEngine {
Calendar startCal = GregorianCalendar.getInstance();
startCal.setTime(start);
/*
Calendar truncCal = GregorianCalendar.getInstance();
Calendar truncCal = GregorianCalendar.getInstanceOf();
truncCal.set(Calendar.DAY_OF_YEAR, startCal.get(Calendar.DAY_OF_YEAR));
truncCal.set(Calendar.YEAR, startCal.get(Calendar.YEAR));
truncCal.set(Calendar.MINUTE, 0);

View File

@ -142,7 +142,7 @@ public class BrowsePane extends LayoutPanel implements Resettable {
().getRootFolder();
BigDecimal folderID = root.getID();
User user = Web.getContext().getUser();
User user = Web.getWebContext().getUser();
if ( user != null ) {
Folder homeFolder = Folder.getUserHomeFolder(user,CMS.getContext().getContentSection());
if ( homeFolder != null ) {

View File

@ -20,8 +20,6 @@ package com.arsdigita.cms.ui;
import com.arsdigita.bebop.*;
import com.arsdigita.bebop.page.PageTransformer;
import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.dispatcher.Utilities;
import com.arsdigita.kernel.Kernel;
import com.arsdigita.kernel.User;
@ -143,6 +141,9 @@ public class CMSApplicationPage extends Page {
*
* This method is called by the various servlets serving the various pages
* of the CMS package, before serving and displaying the page.
* @param sreq
* @param sresp
* @param app
*/
public synchronized void init(HttpServletRequest sreq,
HttpServletResponse sresp,
@ -344,7 +345,7 @@ public class CMSApplicationPage extends Page {
// document it in the classes. Probably remove one ore the other
// way from the API if possible.
User user = (User) Kernel.getContext().getParty();
// User user = Web.getContext().getUser();
// User user = Web.getWebContext().getUser();
if ( user != null ) {
pageElement.addAttribute("name",user.getDisplayName());
}

View File

@ -64,7 +64,7 @@ public class CMSItemSearchPage extends CMSApplicationPage {
private ItemSearchCreateItemPane m_create;
private BigDecimalParameter m_sectionId;
private int m_lastTab;
private static final CMSConfig s_conf = CMSConfig.getInstance();
private static final CMSConfig s_conf = CMSConfig.getInstanceOf();
private static final boolean LIMIT_TO_CONTENT_SECTION = false;
public static final String CONTENT_SECTION = "section_id";
@ -309,7 +309,7 @@ public class CMSItemSearchPage extends CMSApplicationPage {
public void excurse()
throws IOException, ServletException {
ContentSection section = null;
Application app = Web.getContext().getApplication();
Application app = Web.getWebContext().getApplication();
if (app instanceof ContentSection) {
section = (ContentSection) app;
} else {

View File

@ -180,7 +180,7 @@ public class ContentSectionPage extends CMSPage implements ActionListener {
}
SecurityManager sm = CMS.getContext().getSecurityManager();
User user = Web.getContext().getUser();
User user = Web.getWebContext().getUser();
//m_tabbedPane.setTabVisible(state, m_userAdminPane, sm.canAccess(user, SecurityConstants.STAFF_ADMIN));
if (ContentSection.getConfig().getHideAdminTabs()) {

View File

@ -191,7 +191,7 @@ public class FlatItemList extends SegmentedPanel
m_homeFolderLabel = new Label(new PrintListener() {
public final void prepare(final PrintEvent e) {
Label label = (Label) e.getTarget();
User user = Web.getContext().getUser();
User user = Web.getWebContext().getUser();
Folder folder = Folder.getUserHomeFolder(user, CMS.getContext().getContentSection());
if (folder != null) {
@ -448,12 +448,12 @@ public class FlatItemList extends SegmentedPanel
} else if (source == m_togglePrivateAction) {
togglePermissions(s);
} else if (source == m_setHomeFolderAction) {
User user = Web.getContext().getUser();
User user = Web.getWebContext().getUser();
Folder folder = m_folder.getFolder(s);
user = (User) DomainObjectFactory.newInstance(user.getOID());
Folder.setUserHomeFolder(user, folder);
} else if( source == m_removeHomeFolderAction) {
User user = Web.getContext().getUser();
User user = Web.getWebContext().getUser();
ContentSection section = CMS.getContext().getContentSection();
UserHomeFolderMap map = UserHomeFolderMap.findUserHomeFolderMap(user, section);
if (map != null) {

View File

@ -58,7 +58,7 @@ public class FormSecurityListener implements FormSubmissionListener {
public final void submitted(final FormSectionEvent e)
throws FormProcessException {
final PageState state = e.getPageState();
final User user = Web.getContext().getUser();
final User user = Web.getWebContext().getUser();
final SecurityManager sm = Utilities.getSecurityManager(state);
if (m_item == null) {

View File

@ -42,7 +42,7 @@ public class ImageSelectPage extends CMSPage {
private final StringParameter m_imageComponentKey;
private final MapComponentSelectionModel m_imageComponent;
private final ImageComponentSelectListener m_selectListener;
private static final CMSConfig s_conf = CMSConfig.getInstance();
private static final CMSConfig s_conf = CMSConfig.getInstanceOf();
public static final String CONTENT_SECTION = "section_id";
public static final String RESULT = "result";

View File

@ -61,7 +61,7 @@ public class ItemSearchFlatBrowsePane extends SimpleContainer {
private final QueryFieldsRequestLocal queryFields = new QueryFieldsRequestLocal();
//private final List<String> queryFields = new ArrayList<String>();
//private final Submit submit;
private final static CMSConfig CMS_CONFIG = CMSConfig.getInstance();
private final static CMSConfig CMS_CONFIG = CMSConfig.getInstanceOf();
public ItemSearchFlatBrowsePane() {
//super(name);

View File

@ -64,7 +64,7 @@ public class ItemSearchPage extends CMSPage {
private ItemSearchCreateItemPane m_create;
private BigDecimalParameter m_sectionId;
private int m_lastTab;
private static final CMSConfig s_conf = CMSConfig.getInstance();
private static final CMSConfig s_conf = CMSConfig.getInstanceOf();
private static final boolean LIMIT_TO_CONTENT_SECTION = false;
public static final String CONTENT_SECTION = "section_id";
@ -305,7 +305,7 @@ public class ItemSearchPage extends CMSPage {
public void excurse()
throws IOException, ServletException {
ContentSection section = null;
Application app = Web.getContext().getApplication();
Application app = Web.getWebContext().getApplication();
if (app instanceof ContentSection) {
section = (ContentSection) app;
} else {

View File

@ -104,7 +104,7 @@ public class UserAdminPane extends SimpleContainer {
if ( !isVisible(state) ) { return; }
SecurityManager sm = CMS.getContext().getSecurityManager();
User user = Web.getContext().getUser();
User user = Web.getWebContext().getUser();
if ( !sm.canAccess(user,SecurityConstants.STAFF_ADMIN) ) {
m_deniedLabel.generateXML(state, parent);

View File

@ -170,7 +170,7 @@ public class ApplyWorkflowFormSection extends FormSection implements FormInitLis
boolean result = false;
if (super.isVisible(state) &&
getSecurityManager(state).canAccess
(Web.getContext().getUser(), SecurityConstants.APPLY_ALTERNATE_WORKFLOWS,
(Web.getWebContext().getUser(), SecurityConstants.APPLY_ALTERNATE_WORKFLOWS,
m_creationSelector.getFolder(state))) {
TaskCollection t = m_listener.getCollection(state);
if (t.next()) {
@ -192,7 +192,7 @@ public class ApplyWorkflowFormSection extends FormSection implements FormInitLis
*/
public void applyWorkflow(PageState state, ContentItem item) {
final BigDecimal flowID = (BigDecimal) m_radio.getValue(state);
User user = Web.getContext().getUser();
User user = Web.getWebContext().getUser();
final ContentSection section = m_creationSelector.getContentSection(state);
Folder f = m_creationSelector.getFolder(state);
final WorkflowTemplate template;
@ -246,7 +246,7 @@ public class ApplyWorkflowFormSection extends FormSection implements FormInitLis
TaskCollection templates = super.getCollection(state);
Filter f = templates.addInSubqueryFilter
("id", "com.arsdigita.cms.getWorkflowTemplateUserFilter");
f.set("userId", Web.getContext().getUser().getID());
f.set("userId", Web.getWebContext().getUser().getID());
return templates;
}

View File

@ -677,7 +677,7 @@ class CategoryItemPane extends BaseItemPane {
*/
private boolean isItemEditable(ContentItem item, PageState state) {
BigDecimal id = item.getID();
User user = Web.getContext().getUser();
User user = Web.getWebContext().getUser();
ContentItem ci = new ContentItem(new OID(ContentItem.class.getName(),
Integer.parseInt(id.toString())));
Iterator permissions = PermissionService.getImpliedPrivileges(

View File

@ -141,7 +141,7 @@ public class ContentSectionContainer extends CMSContainer {
ContentSection section = form.getContentSection(state);
SecurityManager sm = new SecurityManager(section);
Folder folder = null;
User user = Web.getContext().getUser();
User user = Web.getWebContext().getUser();
if (user != null) {
folder = Folder.getUserHomeFolder(user, section);
}
@ -438,7 +438,7 @@ public class ContentSectionContainer extends CMSContainer {
int row, int column) {
ContentSection section = (ContentSection) value;
Folder folder = null;
User user = Web.getContext().getUser();
User user = Web.getWebContext().getUser();
if (user != null) {
folder = Folder.getUserHomeFolder(user, section);
}

View File

@ -444,7 +444,7 @@ public class TasksPanel extends CMSContainer {
ContentSection sec = (ContentSection) m_sectionSel.getSelectedObject(s);
Assert.exists(sec);
User user = Web.getContext().getUser();
User user = Web.getWebContext().getUser();
if (user != null) {
Folder folder = Folder.getUserHomeFolder(user, sec);
if (folder != null) {
@ -670,7 +670,7 @@ public class TasksPanel extends CMSContainer {
String sectionPath = item.getContentSection().getPath();
if (wf != null) {
User user = Web.getContext().getUser();
User user = Web.getWebContext().getUser();
Engine engine = Engine.getInstance(CMSEngine.CMS_ENGINE_TYPE);
Iterator i = engine.getEnabledTasks(user, wf.getID()).iterator();
if (i.hasNext()) {

View File

@ -193,7 +193,7 @@ public class MainPage extends CMSApplicationPage implements ActionListener {
}
SecurityManager sm = CMS.getContext().getSecurityManager();
User user = Web.getContext().getUser();
User user = Web.getWebContext().getUser();
m_tabbedPane.setTabVisible(state,
m_userAdminPane,
sm.canAccess(user,

View File

@ -76,7 +76,7 @@ public class ContentSoonExpiredPane extends SimpleContainer {
if ( !isVisible(state) ) { return; }
SecurityManager sm = CMS.getContext().getSecurityManager();
User user = Web.getContext().getUser();
User user = Web.getWebContext().getUser();
DataTable dt = getDataTable();
DataQuery dq = dt.getDataQuery(state);
@ -198,7 +198,7 @@ public class ContentSoonExpiredPane extends SimpleContainer {
int row, int column) {
boolean canEdit = false;
BigDecimal id = (BigDecimal) key;
User user = Web.getContext().getUser();
User user = Web.getWebContext().getUser();
ContentItem ci = getItemFromIdString(id.toString());
Iterator permissions = PermissionService.getImpliedPrivileges(ci.getOID(), user.getOID());
while (permissions.hasNext()) {

View File

@ -292,7 +292,7 @@ public class FolderManipulator extends SimpleContainer
d.addError(globalize("cms.ui.folder.not_within_same_folder"));
}
// check create item permission
User user = Web.getContext().getUser();
User user = Web.getWebContext().getUser();
if (!sm.canAccess(user, SecurityManager.NEW_ITEM, target)) {
d.addError(globalize("cms.ui.folder.no_permission_for_item"));
}
@ -606,7 +606,7 @@ public class FolderManipulator extends SimpleContainer
@Override
public boolean isVisible(PageState state) {
if (super.isVisible(state)
&& (modelBuilder.getFolderSize(state) >= CMSConfig.getInstance().
&& (modelBuilder.getFolderSize(state) >= CMSConfig.getInstanceOf().
getFolderAtoZShowLimit())) {
return true;
} else {

View File

@ -104,7 +104,7 @@ public class Summary extends CMSContainer {
ContentItem item = getContentItem(state);
ContentSection section = getContentSection(state);
User user = Web.getContext().getUser();
User user = Web.getWebContext().getUser();
// NOT USED - CUSTOMIZED SUMMARY
// Take advantage of caching in the CMS Dispatcher.
@ -350,7 +350,7 @@ public class Summary extends CMSContainer {
String key = state.getControlEventName();
String value = state.getControlEventValue();
if (RESTART_WORKFLOW.equals(key)) {
User user = Web.getContext().getUser();
User user = Web.getWebContext().getUser();
ContentItem item = getContentItem(state);
ContentSection section = item.getContentSection();
Workflow w = Workflow.getObjectWorkflow(item);
@ -397,7 +397,7 @@ public class Summary extends CMSContainer {
TaskCollection templates = item.getContentSection().getWorkflowTemplates();
Filter f = templates.addInSubqueryFilter
("id", "com.arsdigita.cms.getWorkflowTemplateUserFilter");
f.set("userId", Web.getContext().getUser().getID());
f.set("userId", Web.getWebContext().getUser().getID());
templates.addEqualsFilter(ACSObject.ID, workflow.getWorkflowTemplate().getID());
PrivilegeDescriptor pd = PrivilegeDescriptor.get(SecurityConstants.CMS_WORKFLOW_ADMIN);

View File

@ -136,7 +136,7 @@ public class ItemLifecycleAdminPane extends BaseItemPane {
final PageState state = e.getPageState();
if (CMSConfig.getInstance().getThreadedPublishing()
if (CMSConfig.getInstanceOf().getThreadedPublishing()
&& PublishLock.getInstance().isLocked(m_item.getContentItem(
state))) {
if (PublishLock.getInstance().hasError(m_item.getContentItem(

View File

@ -75,9 +75,10 @@ import java.text.DateFormat;
import org.apache.log4j.Logger;
/**
* This class contains the component which displays the information for a particular lifecycle, with
* the ability to edit and delete. This information also includes the associated phases for this
* lifecycle, also with the ability to add, edit, and delete.
* This class contains the component which displays the information for a
* particular lifecycle, with the ability to edit and delete. This information
* also includes the associated phases for this lifecycle, also with the ability
* to add, edit, and delete.
*
* @author Michael Pih
* @author Jack Chung
@ -89,7 +90,7 @@ import org.apache.log4j.Logger;
class ItemLifecycleItemPane extends BaseItemPane {
private static final Logger s_log = Logger.getLogger(
ItemLifecycleItemPane.class);
ItemLifecycleItemPane.class);
private final ContentItemRequestLocal m_item;
private final LifecycleRequestLocal m_lifecycle;
private final SimpleContainer m_detailPane;
@ -284,12 +285,12 @@ class ItemLifecycleItemPane extends BaseItemPane {
public final void actionPerformed(final ActionEvent e) {
final PageState state = e.getPageState();
final ContentItem item = m_item.getContentItem(state);
final User user = Web.getContext().getUser();
final User user = Web.getWebContext().getUser();
/*
* jensp 2011-12-14: Check is threaded publishing is active. If yes, execute publishing in a thread.
*/
if (CMSConfig.getInstance().getThreadedPublishing()) {
if (CMSConfig.getInstanceOf().getThreadedPublishing()) {
final Republisher republisher = new Republisher(item, user);
final Thread thread = new Thread(republisher);
thread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@ -307,10 +308,10 @@ class ItemLifecycleItemPane extends BaseItemPane {
item.getOID().toString()),
ex);
if ((CMSConfig.getInstance().
if ((CMSConfig.getInstanceOf().
getPublicationFailureSender()
== null)
&& (CMSConfig.getInstance().
&& (CMSConfig.getInstanceOf().
getPublicationFailureReceiver() == null)) {
return;
}
@ -318,7 +319,7 @@ class ItemLifecycleItemPane extends BaseItemPane {
final PartyCollection receiverParties = Party.retrieveAllParties();
Party receiver = null;
receiverParties.addEqualsFilter("primaryEmail",
CMSConfig.getInstance().
CMSConfig.getInstanceOf().
getPublicationFailureReceiver());
if (receiverParties.next()) {
receiver = receiverParties.getParty();
@ -328,7 +329,7 @@ class ItemLifecycleItemPane extends BaseItemPane {
final PartyCollection senderParties = Party.retrieveAllParties();
Party sender = null;
senderParties.addEqualsFilter("primaryEmail",
CMSConfig.getInstance().
CMSConfig.getInstanceOf().
getPublicationFailureReceiver());
if (senderParties.next()) {
sender = senderParties.getParty();
@ -430,12 +431,12 @@ class ItemLifecycleItemPane extends BaseItemPane {
public final void actionPerformed(final ActionEvent e) {
final PageState state = e.getPageState();
final ContentItem item = m_item.getContentItem(state);
final User user = Web.getContext().getUser();
final User user = Web.getWebContext().getUser();
/**
* jensp 2011-12-14: Execute is a thread if threaded publishing is active.
*/
if (CMSConfig.getInstance().getThreadedPublishing()) {
if (CMSConfig.getInstanceOf().getThreadedPublishing()) {
final Republisher republisher = new Republisher(item, user);
final Thread thread = new Thread(republisher);
thread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@ -453,10 +454,10 @@ class ItemLifecycleItemPane extends BaseItemPane {
item.getOID().toString()),
ex);
if ((CMSConfig.getInstance().
if ((CMSConfig.getInstanceOf().
getPublicationFailureSender()
== null)
&& (CMSConfig.getInstance().
&& (CMSConfig.getInstanceOf().
getPublicationFailureReceiver() == null)) {
return;
}
@ -464,7 +465,7 @@ class ItemLifecycleItemPane extends BaseItemPane {
final PartyCollection receiverParties = Party.retrieveAllParties();
Party receiver = null;
receiverParties.addEqualsFilter("primaryEmail",
CMSConfig.getInstance().
CMSConfig.getInstanceOf().
getPublicationFailureReceiver());
if (receiverParties.next()) {
receiver = receiverParties.getParty();
@ -474,7 +475,7 @@ class ItemLifecycleItemPane extends BaseItemPane {
final PartyCollection senderParties = Party.retrieveAllParties();
Party sender = null;
senderParties.addEqualsFilter("primaryEmail",
CMSConfig.getInstance().
CMSConfig.getInstanceOf().
getPublicationFailureReceiver());
if (senderParties.next()) {
sender = senderParties.getParty();
@ -656,7 +657,7 @@ class ItemLifecycleItemPane extends BaseItemPane {
FormProcessException {
final PageState state = fse.getPageState();
final FormData data = fse.getFormData();
final User user = Web.getContext().getUser();
final User user = Web.getWebContext().getUser();
String selected = (String) data.get(LIFECYCLE_ACTION);
final ContentItem item = m_item.getContentItem(state);
@ -666,7 +667,7 @@ class ItemLifecycleItemPane extends BaseItemPane {
* active.
*/
if (REPUBLISH.equals(selected)) {
if (CMSConfig.getInstance().getThreadedPublishing()) {
if (CMSConfig.getInstanceOf().getThreadedPublishing()) {
final RepublishRunner runner = new RepublishRunner(item, user);
final Thread thread = new Thread(runner);
thread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@ -684,10 +685,10 @@ class ItemLifecycleItemPane extends BaseItemPane {
item.getOID().toString()),
ex);
if ((CMSConfig.getInstance().
if ((CMSConfig.getInstanceOf().
getPublicationFailureSender()
== null)
&& (CMSConfig.getInstance().
&& (CMSConfig.getInstanceOf().
getPublicationFailureReceiver() == null)) {
return;
}
@ -695,7 +696,7 @@ class ItemLifecycleItemPane extends BaseItemPane {
final PartyCollection receiverParties = Party.retrieveAllParties();
Party receiver = null;
receiverParties.addEqualsFilter("primaryEmail",
CMSConfig.getInstance().
CMSConfig.getInstanceOf().
getPublicationFailureReceiver());
if (receiverParties.next()) {
receiver = receiverParties.getParty();
@ -705,7 +706,7 @@ class ItemLifecycleItemPane extends BaseItemPane {
final PartyCollection senderParties = Party.retrieveAllParties();
Party sender = null;
senderParties.addEqualsFilter("primaryEmail",
CMSConfig.getInstance().
CMSConfig.getInstanceOf().
getPublicationFailureReceiver());
if (senderParties.next()) {
sender = senderParties.getParty();
@ -753,7 +754,7 @@ class ItemLifecycleItemPane extends BaseItemPane {
}
}
} else if (REPUBLISH_AND_RESET.equals(selected)) {
if (CMSConfig.getInstance().getThreadedPublishing()) {
if (CMSConfig.getInstanceOf().getThreadedPublishing()) {
final RepublishAndResetRunner runner = new RepublishAndResetRunner(item, user);
final Thread thread = new Thread(runner);
thread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@ -771,10 +772,10 @@ class ItemLifecycleItemPane extends BaseItemPane {
item.getOID().toString()),
ex);
if ((CMSConfig.getInstance().
if ((CMSConfig.getInstanceOf().
getPublicationFailureSender()
== null)
&& (CMSConfig.getInstance().
&& (CMSConfig.getInstanceOf().
getPublicationFailureReceiver() == null)) {
return;
}
@ -782,7 +783,7 @@ class ItemLifecycleItemPane extends BaseItemPane {
final PartyCollection receiverParties = Party.retrieveAllParties();
Party receiver = null;
receiverParties.addEqualsFilter("primaryEmail",
CMSConfig.getInstance().
CMSConfig.getInstanceOf().
getPublicationFailureReceiver());
if (receiverParties.next()) {
receiver = receiverParties.getParty();
@ -792,7 +793,7 @@ class ItemLifecycleItemPane extends BaseItemPane {
final PartyCollection senderParties = Party.retrieveAllParties();
Party sender = null;
senderParties.addEqualsFilter("primaryEmail",
CMSConfig.getInstance().
CMSConfig.getInstanceOf().
getPublicationFailureReceiver());
if (senderParties.next()) {
sender = senderParties.getParty();

View File

@ -86,8 +86,7 @@ import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
/**
* <p>
* A form to select and apply a lifecycle to a content item.</p>
* <p>A form to select and apply a lifecycle to a content item.</p>
*
* @author Michael Pih
* @author Xixi D'moon &lt;xdmoon@redhat.com&gt;
@ -97,7 +96,8 @@ import org.apache.log4j.Logger;
*/
class ItemLifecycleSelectForm extends BaseForm {
private static final Logger s_log = Logger.getLogger(ItemLifecycleSelectForm.class);
private static final Logger s_log =
Logger.getLogger(ItemLifecycleSelectForm.class);
private final static String LIFECYCLE = "lifecycle";
private final static String START_DATE = "start_date";
private final static String END_DATE = "end_date";
@ -347,8 +347,8 @@ class ItemLifecycleSelectForm extends BaseForm {
}
/**
* jensp 2011-12-14: Some larger changes to the behavior of the process listener. The real
* action has been moved to the
* jensp 2011-12-14: Some larger changes to the behavior of the process
* listener. The real action has been moved to the
* @link{Publisher} class. If threaded publishing is active, the publish
* process runs in a separate thread (the item is locked before using
* {@link PublishLock}. If threaded publishing is not active, nothing has
@ -363,7 +363,7 @@ class ItemLifecycleSelectForm extends BaseForm {
final ContentItem item = m_item.getContentItem(state);
final Publisher publisher = new Publisher(state);
if (CMSConfig.getInstance().getThreadedPublishing()) {
if (CMSConfig.getInstanceOf().getThreadedPublishing()) {
final Runnable threadAction = new Runnable() {
@Override
@ -391,9 +391,9 @@ class ItemLifecycleSelectForm extends BaseForm {
item.getOID().toString()),
ex);
if ((CMSConfig.getInstance().getPublicationFailureSender()
if ((CMSConfig.getInstanceOf().getPublicationFailureSender()
== null)
&& (CMSConfig.getInstance().
&& (CMSConfig.getInstanceOf().
getPublicationFailureReceiver() == null)) {
return;
}
@ -402,7 +402,7 @@ class ItemLifecycleSelectForm extends BaseForm {
retrieveAllParties();
Party receiver = null;
receiverParties.addEqualsFilter("primaryEmail",
CMSConfig.getInstance().
CMSConfig.getInstanceOf().
getPublicationFailureReceiver());
if (receiverParties.next()) {
receiver = receiverParties.getParty();
@ -413,7 +413,7 @@ class ItemLifecycleSelectForm extends BaseForm {
retrieveAllParties();
Party sender = null;
senderParties.addEqualsFilter("primaryEmail", CMSConfig.
getInstance().getPublicationFailureReceiver());
getInstanceOf().getPublicationFailureReceiver());
if (senderParties.next()) {
sender = senderParties.getParty();
}
@ -446,7 +446,7 @@ class ItemLifecycleSelectForm extends BaseForm {
publisher.publish();
}
if (CMSConfig.getInstance().getThreadedPublishing()) {
if (CMSConfig.getInstanceOf().getThreadedPublishing()) {
throw new RedirectSignal(
URL.getDispatcherPath()
+ ContentItemPage.getItemURL(item,
@ -486,7 +486,7 @@ class ItemLifecycleSelectForm extends BaseForm {
* java.util.Date startDate = (java.util.Date)
* m_startDate.getValue(state);
*
* final Calendar start = Calendar.getInstance();
* final Calendar start = Calendar.getInstanceOf();
* start.setTime(startDate); start.set(Calendar.AM_PM,
* startAmpm.intValue()); start.set(Calendar.MINUTE,
* startMinute.intValue()); start.set(Calendar.AM_PM,
@ -502,7 +502,7 @@ class ItemLifecycleSelectForm extends BaseForm {
* m_endDate.getValue(state);
*
* if (endDate != null) { final Calendar end =
* Calendar.getInstance();
* Calendar.getInstanceOf();
*
* end.setTime(endDate); end.set(Calendar.AM_PM,
* endAmpm.intValue()); end.set(Calendar.MINUTE,
@ -575,7 +575,7 @@ class ItemLifecycleSelectForm extends BaseForm {
* item.save();
*
* final Workflow workflow = m_workflow.getWorkflow(state); try {
* finish(workflow, item, Web.getContext().getUser()); } catch
* finish(workflow, item, Web.getWebContext().getUser()); } catch
* (TaskException te) { throw new FormProcessException(te); } //
* redirect to /content-center if streamlined creation mode is
* active. if
@ -689,7 +689,7 @@ class ItemLifecycleSelectForm extends BaseForm {
workflowOid = null;
}
user = Web.getContext().getUser();
user = Web.getWebContext().getUser();
}
/**
@ -698,8 +698,8 @@ class ItemLifecycleSelectForm extends BaseForm {
public void publish() {
/**
* We have to create a new instance here since it is not possible to access the same
* data object from multiple threads.
* We have to create a new instance here since it is not possible to
* access the same data object from multiple threads.
*/
final OID oid = OID.valueOf(oidStr);
final ContentItem item = (ContentItem) DomainObjectFactory.
@ -1003,12 +1003,14 @@ class ItemLifecycleSelectForm extends BaseForm {
}
/**
* Find out at which date a notification (about an item that is about to expire) should be sent,
* based on the endDate (== date at which the item is unpublished) and the notification period.
* Find out at which date a notification (about an item that is about to
* expire) should be sent, based on the endDate (== date at which the item
* is unpublished) and the notification period.
*
* @param endDate the endDate of the lifecycle, i.e. the date when the item is going to be
* unpublished
* @param notification how many hours the users shouls be notified in advance
* @param endDate the endDate of the lifecycle, i.e. the date when the item
* is going to be unpublished
* @param notification how many hours the users shouls be notified in
* advance
*/
private java.util.Date computeNotificationDate(java.util.Date endDate,
int notificationPeriod) {

View File

@ -81,7 +81,7 @@ public class TaskPortletRenderer extends AbstractPortletRenderer {
Label dueday;
Date dday;
User currentUser = Web.getContext().getUser();
User currentUser = Web.getWebContext().getUser();
Date currentDate = new Date();
final int numTasks = m_portlet.getMaxNumTasks();

View File

@ -150,7 +150,7 @@ public final class AssignedTaskSection extends Section {
protected final Object initialValue(final PageState state) {
final Workflow workflow = m_flow.getWorkflow(state);
final Engine engine = Engine.getInstance(CMSEngine.CMS_ENGINE_TYPE);
return engine.getEnabledTasks(Web.getContext().getUser(), workflow.getID());
return engine.getEnabledTasks(Web.getWebContext().getUser(), workflow.getID());
}
final ArrayList getTasks(final PageState state) {
@ -160,7 +160,7 @@ public final class AssignedTaskSection extends Section {
final void restartWorkflow(final PageState state) {
final Workflow workflow = m_flow.getWorkflow(state);
workflow.start(Web.getContext().getUser());
workflow.start(Web.getWebContext().getUser());
workflow.save();
// Lock tasks if not locked
@ -176,7 +176,7 @@ public final class AssignedTaskSection extends Section {
final CMSTask task = (CMSTask) iter.next();
if (relevant(task) && !task.isLocked()) {
task.lock(Web.getContext().getUser());
task.lock(Web.getWebContext().getUser());
task.save();
}
}
@ -189,7 +189,7 @@ public final class AssignedTaskSection extends Section {
final CMSTask task = (CMSTask) iter.next();
if (relevant(task) && task.isLocked()) {
task.unlock(Web.getContext().getUser());
task.unlock(Web.getWebContext().getUser());
task.save();
}
}

View File

@ -69,7 +69,7 @@ public final class AssignedTaskTable extends Table {
if (column == 1) {
final CMSTask task = new CMSTask(new BigDecimal(e.getRowKey()
.toString()));
User currentUser = Web.getContext().getUser();
User currentUser = Web.getWebContext().getUser();
User lockingUser = task.getLockedUser();
if (task.isLocked() && lockingUser != null
&& lockingUser.equals(currentUser)) {
@ -92,7 +92,7 @@ public final class AssignedTaskTable extends Table {
User lockingUser = (User) value;
if (lockingUser != null) {
StringBuilder sb = new StringBuilder("Locked by <br />");
if (lockingUser.equals(Web.getContext().getUser())) {
if (lockingUser.equals(Web.getWebContext().getUser())) {
sb.append("you");
p.add(new ControlLink(new Label(
gz("cms.ui.workflow.task.unlock"))));

View File

@ -63,7 +63,7 @@ class AssignedTaskTableModelBuilder extends AbstractTableModelBuilder {
Assert.exists(engine, Engine.class);
m_iter = engine.getEnabledTasks(Web.getContext().getUser(), workflow.getID()).iterator();
m_iter = engine.getEnabledTasks(Web.getWebContext().getUser(), workflow.getID()).iterator();
} else {
m_iter = Collections.emptyList().iterator();
}

View File

@ -138,7 +138,7 @@ abstract class BaseWorkflowItemPane extends BaseItemPane {
User lockingUser = task.getLockedUser();
boolean visible = task.isEnabled() &&
(lockingUser == null ||
lockingUser.equals(Web.getContext().getUser()));
lockingUser.equals(Web.getWebContext().getUser()));
return visible;
}
@ -148,7 +148,7 @@ abstract class BaseWorkflowItemPane extends BaseItemPane {
try {
m_task.getTask(state).finish
(Web.getContext().getUser());
(Web.getWebContext().getUser());
} catch (TaskException te) {
throw new UncheckedWrapperException(te);
}

View File

@ -66,7 +66,7 @@ class CommentAddForm extends BaseForm {
final PageState state = e.getPageState();
final CMSTask task = m_task.getTask(state);
final User user = Web.getContext().getUser();
final User user = Web.getWebContext().getUser();
final TaskComment comment = new TaskComment
(task.getID(), user, (String) m_comment.getValue(state));

View File

@ -95,7 +95,7 @@ final class ItemWorkflowItemPane extends BaseWorkflowItemPane {
final Workflow workflow = m_workflow.getWorkflow
(state);
workflow.stop(Web.getContext().getUser());
workflow.stop(Web.getWebContext().getUser());
}
}
}
@ -125,7 +125,7 @@ final class ItemWorkflowItemPane extends BaseWorkflowItemPane {
final Workflow workflow = m_workflow.getWorkflow
(state);
workflow.start(Web.getContext().getUser());
workflow.start(Web.getWebContext().getUser());
}
}
}

View File

@ -92,7 +92,7 @@ class ItemWorkflowSelectForm extends CMSForm {
final Workflow flow = template.instantiateNewWorkflow();
flow.setObjectID(itemID);
flow.start(Web.getContext().getUser());
flow.start(Web.getWebContext().getUser());
flow.save();
}
}

View File

@ -154,7 +154,7 @@ public final class TaskFinishForm extends CommentAddForm {
s_log.debug("The task is approved; finishing the task");
try {
task.finish(Web.getContext().getUser());
task.finish(Web.getWebContext().getUser());
finishedTask = true;
} catch (TaskException te) {
throw new FormValidationException(te.toString());
@ -183,14 +183,14 @@ public final class TaskFinishForm extends CommentAddForm {
+ "it");
try {
task.finish(Web.getContext().getUser());
task.finish(Web.getWebContext().getUser());
finishedTask = true;
} catch (TaskException te) {
throw new FormValidationException(te.toString());
}
}
if (finishedTask) {
Iterator tasks = Engine.getInstance(CMSEngine.CMS_ENGINE_TYPE).getEnabledTasks(Web.getContext().getUser(),
Iterator tasks = Engine.getInstance(CMSEngine.CMS_ENGINE_TYPE).getEnabledTasks(Web.getWebContext().getUser(),
task.getParentID()).iterator();
if (tasks.hasNext()) {
CMSTask thisTask = (CMSTask) tasks.next();

View File

@ -155,7 +155,7 @@ final class TaskItemPane extends BaseItemPane {
private boolean assigned(final PageState state) {
final Workflow workflow = m_workflow.getWorkflow(state);
final User user = Web.getContext().getUser();
final User user = Web.getWebContext().getUser();
final CMSTask task = m_task.getTask(state);
final Engine engine = Engine.getInstance(CMSEngine.CMS_ENGINE_TYPE);
@ -230,7 +230,7 @@ final class TaskItemPane extends BaseItemPane {
if (hasAdmin(state)) {
final CMSTask task = m_task.getTask(state);
task.lock(Web.getContext().getUser());
task.lock(Web.getWebContext().getUser());
task.save();
}
}
@ -256,7 +256,7 @@ final class TaskItemPane extends BaseItemPane {
if (hasAdmin(state)) {
final CMSTask task = m_task.getTask(state);
task.unlock(Web.getContext().getUser());
task.unlock(Web.getWebContext().getUser());
task.save();
}
}

View File

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<!--- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
basic web.xml for ccm-cms
These specific web.xml snippets must be integrated before CMS can be
used in a CCM installation.
Alternatively a complete web.xml file from an installation bundle may
be used.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<servlet>
<servlet-name>content-section</servlet-name>
<servlet-class>com.arsdigita.cms.ContentSectionServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>content-type-xsl</servlet-name>
<servlet-class>com.arsdigita.cms.dispatcher.ContentTypeXSLServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>content-item-xsl</servlet-name>
<servlet-class>com.arsdigita.cms.dispatcher.ContentItemXSLServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>template-xsl</servlet-name>
<servlet-class>com.arsdigita.cms.dispatcher.TemplateXSLServlet</servlet-class>
</servlet>
<!--
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SERVLET MAPPINGS SECTION basically requirred by ccm-cms
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-->
<servlet-mapping>
<servlet-name>content-section</servlet-name>
<url-pattern>/themes/servlet/content-section/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>content-item-xsl</servlet-name>
<url-pattern>/themes/servlet/content-item/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>content-type-xsl</servlet-name>
<url-pattern>/themes/servlet/content-type/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>template-xsl</servlet-name>
<url-pattern>/themes/servlet/template/*</url-pattern>
</servlet-mapping>
</web-app>

View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<!--- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
basic web.xml for ccm-cms
These specific web.xml snippets must be integrated before CMS can be
used in a CCM installation.
Alternatively a complete web.xml file from an installation bundle may
be used.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<servlet>
<servlet-name>TextOnlyServlet</servlet-name>
<display-name>Text Only Servlet</display-name>
<servlet-class>com.arsdigita.web.InternalPrefixerServlet</servlet-class>
<init-param>
<param-name>prefix</param-name>
<param-value>/text</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>PrintFriendlyServlet</servlet-name>
<display-name>Printer Friendly Output Servlet</display-name>
<servlet-class>com.arsdigita.web.InternalPrefixerServlet</servlet-class>
<init-param>
<param-name>prefix</param-name>
<param-value>/print</param-value>
</init-param>
</servlet>
<!--
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SERVLET MAPPINGS SECTION basically requirred by ccm-cms
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-->
<servlet-mapping>
<servlet-name>TextOnlyServlet</servlet-name>
<url-pattern>/text/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>PrintFriendlyServlet</servlet-name>
<url-pattern>/print/*</url-pattern>
</servlet-mapping>
</web-app>

View File

@ -21,7 +21,7 @@
ContentSection section =
ContentSectionServlet.getContentSection(request);
if (Web.getContext().getUser() == null) {
if (Web.getWebContext().getUser() == null) {
throw new LoginSignal(request);
} else if (! ContentSectionServlet.checkAdminAccess(request, section)) {
throw new com.arsdigita.cms.dispatcher.AccessDeniedException();

View File

@ -31,7 +31,7 @@
ContentSectionServlet.getContentSection(request);
if (Web.getContext().getUser() == null) {
if (Web.getWebContext().getUser() == null) {
throw new LoginSignal(request);
} else if (! ContentSectionServlet.checkAdminAccess(request, section)) {
throw new com.arsdigita.cms.dispatcher.AccessDeniedException();

View File

@ -44,7 +44,7 @@ public class WebAuditingSaveInfo implements AuditingSaveInfo {
private String m_ip;
public WebAuditingSaveInfo() {
m_user = Web.getContext().getUser();
m_user = Web.getWebContext().getUser();
// The user may be null.
HttpServletRequest req = Web.getRequest();

View File

@ -216,7 +216,7 @@ public class Form extends FormSection implements BebopConstants {
String url = null;
if (m_action == null) {
final URL requestURL = Web.getContext().getRequestURL();
final URL requestURL = Web.getWebContext().getRequestURL();
if (requestURL == null) {
url = s.getRequest().getRequestURI();

View File

@ -976,7 +976,7 @@ public class PageState {
* @return the URI to which the current request was made
*/
public String getRequestURI() {
final URL url = Web.getContext().getRequestURL();
final URL url = Web.getWebContext().getRequestURL();
if (url == null) {
return m_request.getRequestURI();

View File

@ -88,7 +88,7 @@ public class MySitePage extends Page {
Element elt = new Element("bebop:message", BEBOP_XML_NS);
elt.setText("MySite: dynamic page header. You requested: " +
Web.getContext().getRequestURL());
Web.getWebContext().getRequestURL());
parent.addContent(elt);
}

View File

@ -140,6 +140,7 @@ public class BebopApplicationServlet extends BaseApplicationServlet {
* @throws ServletException
* @throws IOException
*/
@Override
protected final void doService(final HttpServletRequest sreq,
final HttpServletResponse sresp,
final Application app)
@ -174,6 +175,12 @@ public class BebopApplicationServlet extends BaseApplicationServlet {
* Provides the opportunity for subclasses to do some preprocessing
* of a given url, before it is handed off to main service process.
* One typical action is to ensure permissions.
* @param sreq
* @param sresp
* @param app
* @param url
* @throws javax.servlet.ServletException
* @throws java.io.IOException
*/
protected void preprocessRequest(HttpServletRequest sreq,
HttpServletResponse sresp,

View File

@ -47,6 +47,8 @@ public class PageDispatcher implements Dispatcher {
/**
* Creates a new page dispatcher for a page object and a
* PresentationManager.
* @param page
* @param pres
*/
public PageDispatcher(final Page page,
final PresentationManager pres) {
@ -57,6 +59,7 @@ public class PageDispatcher implements Dispatcher {
/**
* Creates a new page dispatcher for a page object. Uses the
* default presentation manager.
* @param page
*/
public PageDispatcher(final Page page) {
m_page = page;
@ -66,7 +69,11 @@ public class PageDispatcher implements Dispatcher {
/**
* Serves the Bebop page using the specified
* <code>PresentationManager</code>.
* @param req
* @param resp
* @param ctx
*/
@Override
public void dispatch(final HttpServletRequest req,
final HttpServletResponse resp,
final RequestContext ctx)

View File

@ -60,10 +60,10 @@ import javax.xml.transform.stream.StreamResult;
import org.apache.log4j.Logger;
/**
* A class for managing and obtaining a Stylesheet based on the
* current request's location in the site map. First, we try to find
* a stylesheet specific to this site node. If we can't find one,
* then we walk up the site map until we find a parent of this site
* A class for managing and obtaining a Stylesheet based on the current
* request's location in the site map.
* First, we try to find a stylesheet specific to this site node. If we can't
* find one, then we walk up the site map until we find a parent of this site
* node that has a stylesheet associated with it.
*
* If we haven't found one by the time we reach the root, then we'll
@ -106,7 +106,7 @@ public class PageTransformer implements PresentationManager {
new XSLParameterGenerator() {
@Override
public String generateValue(HttpServletRequest request) {
return Web.getContext().getRequestURL().getContextPath();
return Web.getWebContext().getRequestURL().getContextPath();
}
});
@ -115,7 +115,7 @@ public class PageTransformer implements PresentationManager {
new XSLParameterGenerator() {
@Override
public String generateValue(HttpServletRequest request) {
return Web.getContext().getRequestURL().getContextPath()
return Web.getWebContext().getRequestURL().getContextPath()
+ com.arsdigita.web.URL.INTERNAL_THEME_DIR;
}
@ -318,12 +318,11 @@ public class PageTransformer implements PresentationManager {
}
/**
* Serves an XML Document, getting and applying the appropriate
* XSLT. Also allows for parameters to be set for the
* transformer. These will become top-level xsl:params in the
* stylesheet. The "contextPath" parameter will always be passed
* to XSLT, which is the value of
* <code>req.getContextPath()</code>.
* Serves an XML Document, getting and applying the appropriate XSLT.
* Also allows for parameters to be set for the transformer. These will
* become top-level xsl:params in the stylesheet.
* The "contextPath" parameter will always be passed to XSLT, which is the
* value of <code>req.getWebContextPath()</code>.
*
* @param doc the Bebop page to serve
* @param req the servlet request
@ -347,8 +346,8 @@ public class PageTransformer implements PresentationManager {
Profiler.startOp("XSLT");
try {
final String charset = Globalization.getDefaultCharset(Kernel.
getContext().getLocale());
final String charset = Globalization.getDefaultCharset(
Kernel.getContext().getLocale());
final String output = req.getParameter("output");
s_log.info("output=" + output);
@ -358,7 +357,7 @@ public class PageTransformer implements PresentationManager {
boolean fancyErrors = Bebop.getConfig().wantFancyXSLErrors()
|| Boolean.TRUE.equals(req.getAttribute(
FANCY_ERRORS));
FANCY_ERRORS));
// Get the stylesheet transformer object corresponding to the
// current request.
@ -383,8 +382,7 @@ public class PageTransformer implements PresentationManager {
endTransaction(req);
// Transformers are not thread-safe, so we assume we have
// exclusive
// use of xf here. But we could recycle it.
// exclusive use of xf here. But we could recycle it.
xf.clearParameters();
if (params != null) {
@ -490,8 +488,8 @@ public class PageTransformer implements PresentationManager {
}
/**
* Ends the current transaction. Is a performance optimization to end ASAP before
* serving the page.
* Ends the current transaction. Is a performance optimization to end
* ASAP before serving the page.
*
* @param req HTTP request.
*/
@ -509,6 +507,8 @@ public class PageTransformer implements PresentationManager {
* XSLStylesheets. If this is called a second time with the same
* parameter name then all previous calls are overwritten and
* only the last registered generator is used.
* @param parameterName
* @param parameterGenerator
*/
public static void registerXSLParameterGenerator(String parameterName,
XSLParameterGenerator parameterGenerator) {
@ -518,6 +518,7 @@ public class PageTransformer implements PresentationManager {
/**
* This removes the parameter from the list of parameters that
* will be added to stylesheets
* @param parameterName
*/
public static void removeXSLParameterGenerator(String parameterName) {
s_XSLParameters.remove(parameterName);
@ -526,14 +527,18 @@ public class PageTransformer implements PresentationManager {
/**
* This is a Collection of all names of XSL Parameters that have been
* registered
* @return
*/
public static Collection getXSLParameterNames() {
return s_XSLParameters.keySet();
}
/**
* This takes a name and request and returns the value that should
* be used in the XSL for the given name
* This takes a name and request and returns the value that should
* be used in the XSL for the given name
* @param name
* @param request
* @return
*/
public static String getXSLParameterValue(String name,
HttpServletRequest request) {
@ -547,8 +552,10 @@ public class PageTransformer implements PresentationManager {
}
/**
* This takes in a transformer and adds all of the registered
* xsl paraemters.
* This takes in a transformer and adds all of the registered
* xsl paraemters.
* @param transformer
* @param request
*/
public static void addXSLParameters(Transformer transformer,
HttpServletRequest request) {

View File

@ -33,7 +33,7 @@ public class ApplicationCategoryPicker extends ObjectCategoryPicker {
}
protected ACSObject getObject(PageState state) {
return Web.getContext().getApplication();
return Web.getWebContext().getApplication();
}
protected String getContext(PageState state) {

View File

@ -280,7 +280,7 @@ class Permission extends DomainObject {
*
*/
private void setCreationInfo() {
User user = Web.getContext().getUser();
User user = Web.getWebContext().getUser();
// The user may be null.
HttpServletRequest req = Web.getRequest();

View File

@ -490,7 +490,7 @@ public class UserContext {
*/
public static String encodeReturnURL(HttpServletRequest req) {
StringBuilder returnURL = new StringBuilder(100);
returnURL.append(Web.getContext().getRequestURL().getRequestURI());
returnURL.append(Web.getWebContext().getRequestURL().getRequestURI());
returnURL.append('?');
// convert posted parameters to URL parameters

View File

@ -82,6 +82,7 @@ public class CompoundInitializer implements Initializer {
*
* @param evt The data init event.
*/
@Override
public void init(DataInitEvent evt) {
int i = 1;
for (Iterator it = m_inits.iterator(); it.hasNext(); i++) {
@ -102,6 +103,7 @@ public class CompoundInitializer implements Initializer {
*
* @param evt The domain init event.
*/
@Override
public void init(DomainInitEvent evt) {
int i = 1;
for (Iterator it = m_inits.iterator(); it.hasNext(); i++) {
@ -142,6 +144,7 @@ public class CompoundInitializer implements Initializer {
*
* @param evt The legacy init event.
*/
@Override
public void init(ContextInitEvent evt) {
int i = 1;
for (Iterator it = m_inits.iterator(); it.hasNext(); i++) {
@ -164,6 +167,7 @@ public class CompoundInitializer implements Initializer {
*
* @param evt The context close event.
*/
@Override
public void close(ContextCloseEvent evt) {
s_log.info("CompoundInitializer.close(ContextCloseEvent) invoked");

View File

@ -200,7 +200,7 @@ public class ResultsPane extends SimpleComponent {
long end,
long objectCount) {
Element paginator = Search.newElement("paginator");
URL url = Web.getContext().getRequestURL();
URL url = Web.getWebContext().getRequestURL();
ParameterMap map = new ParameterMap();
Iterator current = url.getParameterMap().keySet().iterator();

View File

@ -18,8 +18,8 @@
*/
package com.arsdigita.templating;
import com.arsdigita.web.Web;
import com.arsdigita.web.Application;
import com.arsdigita.web.Web;
import javax.servlet.http.HttpServletRequest;
@ -31,10 +31,22 @@ import java.net.URLEncoder;
*/
public class ApplicationOIDPatternGenerator implements PatternGenerator {
/**
* Looks up the current application and returns its OID as String.
* The Return type is (unneccessarily) String[] due to the current API, but
* currently never returns more than just one value (one OID).
*
* @param key placeholder from the pattern string, without surrounding
* colons, constantly "oid" here.
* @param req current HttpServletRequest
* @return OID as String in an Array of Strings. This array is never longer
* as one element.
*/
@Override
public String[] generateValues(String key,
HttpServletRequest req) {
final Application application = Web.getContext().getApplication();
final Application application = Web.getWebContext().getApplication();
if (application != null) {
String[] oid = new String[1];

View File

@ -48,52 +48,24 @@ public class ApplicationPatternGenerator implements PatternGenerator {
* @param req
* @return
*/
@Override
public String[] generateValues(String key,
HttpServletRequest req) {
s_log.debug("Processing Application with key: " + key );
final Application app = Web.getContext().getApplication();
final Application app = Web.getWebContext().getApplication();
if (app != null) {
String[] returnValue = { app.getApplicationType().getName() };
s_log.debug("Found application >>"+returnValue+"<< in Application.");
return returnValue;
}
// SiteNodeRequestContext is deprecated and replaced by web.WebContext
// used in the code above (Web.getContext().
// This code should never be executed.
// Findings: SideNode is requirred for modules which dont use
// legacy-compatible applications but package-type apps. content-center
// and cms-service are 2 examples. Code can be eliminated when all apps
// will use web.Application for loading and instantiation.
// UPDATE
// CMS had been migrated. It is only necessary for the root package,
// which is "Main Site" = acs-subsite which is used by some login
// redirects.
s_log.debug("ApplicationType for >>" +key +
"<< not found. Trying SiteNodes instead.");
throw new IllegalArgumentException(
"No ApplicationType found for type name " + key);
/*
SiteNodeRequestContext ctx = (SiteNodeRequestContext)
DispatcherHelper.getRequestContext(req);
SiteNode node = ctx.getSiteNode();
if (node != null) {
String[] returnValue = {
node.getPackageInstance().getType().getKey()
};
s_log.debug("Found node >>" + returnValue + "<< in SiteNodes.");
return returnValue;
}
s_log.debug("ApplicationType for " +key +
" could not be found in SiteNodes either. Returning empty String[]");
*/
// return new String[] {};
}
}

View File

@ -28,16 +28,39 @@ import org.apache.log4j.Logger;
/**
* Generates a set of patterns corresponding to the current
* web application prefix
* host name. (actually just retrieves the current hostname from configuration
* file, StringArray returned is for sake of methods consistency)
*/
public class HostPatternGenerator implements PatternGenerator {
/** Internal logger instance to faciliate debugging. Enable logging output
* by editing /WEB-INF/conf/log4j.properties int the runtime environment
* and set com.arsdigita.templating.HostPatternGenerator=DEBUG
* by uncommenting or adding the line. */
private static final Logger s_log =
Logger.getLogger(URLPatternGenerator.class);
Logger.getLogger(HostPatternGenerator.class);
/**
* Looks up the hostname from configuration and returns it as String.
* The Return type is (unneccessarily) String[] due to the current API, but
* currently never returns more than just one value (one hostname:port).
*
* @param key placeholder from the pattern string, without surrounding
* colons, constantly "host" here.
* @param req current HttpServletRequest
* @return Hostname (including port if any), retrieved from CCM
* configuration
*/
@Override
public String[] generateValues(String key,
HttpServletRequest req) {
HttpHost host = Web.getConfig().getHost();
String hostName = host.toString();
if (s_log.isDebugEnabled()) {
s_log.debug("Generating Values for key: " + key + " [" +
"Hostname retrieved: >>" + hostName + "<<]");
}
return new String[] { host.toString() };
}

View File

@ -94,7 +94,7 @@ import org.apache.log4j.Logger;
* </tr>
* <tr>
* <td> <code>::application::</code> </td>
* <td> Current application name </td>
* <td> Current CCM Application name </td>
* <td> <code>navigation</code> </td>
* </tr>
* <tr>
@ -145,7 +145,6 @@ import org.apache.log4j.Logger;
* and add it in a custom integration package Initializer (e.g. ccm-ldn-aplaws)
* by following code:
* // Register additional PatternStyleSheetResolver for Web app.
* // With all modules installing in one context no longer required.
* PatternStylesheetResolver.registerPatternGenerator(
* "[myKey]",
* new [My]PatternGenerator()
@ -156,7 +155,10 @@ import org.apache.log4j.Logger;
*/
public class PatternStylesheetResolver implements StylesheetResolver {
/** Logger instance for debugging. */
/** Internal logger instance to faciliate debugging. Enable logging output
* by editing /WEB-INF/conf/log4j.properties int the runtime environment
* and set com.arsdigita.templating.PatternStylesheetResolver=DEBUG
* by uncommenting or adding the line. */
private static final Logger s_log = Logger.getLogger
(PatternStylesheetResolver.class);
@ -176,6 +178,8 @@ public class PatternStylesheetResolver implements StylesheetResolver {
s_generators.put(key, gen);
}
/* Statiic initializer block to initialize the standard pattern generators
* at load time. */
static {
s_log.debug("Static initalizer starting...");
registerPatternGenerator
@ -195,60 +199,20 @@ public class PatternStylesheetResolver implements StylesheetResolver {
s_log.debug("Static initalizer finished.");
}
/** Complete path to the file specifing stylesheet patterns. Configurable
* by configuration option in TemplatingConfig */
private String m_path = null;
// This is a List of Lists.
/** A List of Lists each of its lists containing one pattern to resolve
* a probably appropriate stylesheet to apply. (i.e. one row of the
* file m_path above) */
private List m_paths = null;
/**
*
* @param path
*/
private void loadPaths(String path) {
if (s_log.isInfoEnabled()) {
s_log.info("Loading paths from " + path);
}
m_path = path;
try {
// Read the source file.
ClassLoader cload = Thread.currentThread().getContextClassLoader();
InputStream stream = cload.getResourceAsStream(path.substring(1));
s_log.debug("got stream using path " + path.substring(1));
s_log.debug("stream.available is " + stream.available());
m_paths = new ArrayList();
LineNumberReader file = new LineNumberReader
(new InputStreamReader(stream));
String line;
int lineNum;
while ((line = file.readLine()) != null) {
lineNum = file.getLineNumber();
// Ignore blank lines and comments.
line = line.trim();
s_log.debug("line is " + line);
if ("".equals(line) || line.startsWith("#")
|| line.startsWith("!") || line.startsWith("//")) {
continue;
}
// Split up the line.
List list = StringUtils.splitUp(line, "/::\\w+::/");
// Save the split line.
m_paths.add(list);
}
} catch (IOException ex) {
throw new UncheckedWrapperException(
"cannot read XSLT paths from " + path, ex);
} catch (Exception e) {
s_log.debug("loadPaths threw exception " + e);
}
}
/**
*
* @param request
* @return
*/
@Override
public URL resolve(HttpServletRequest request) {
synchronized(this) {
if (m_paths == null) {
@ -273,10 +237,19 @@ public class PatternStylesheetResolver implements StylesheetResolver {
String[] bits = (String[])files.next();
String resource = StringUtils.join(bits, "");
// UGLY HACK
// If a placeholder returns an empty string (as in the example of
// the root webapp) the provided string contains a "//" as there is
// a slash before as well as after the placeholder in the pattern
// string. It's ugly so we'll replace it.
resource = resource.replace("//","/");
// The hack destroys the http protocol as well so we need another hack
resource = resource.replace("http:/","http://");
if (s_log.isInfoEnabled()) {
s_log.info("Looking to see if resource " + resource + " exists");
}
//java.net.URL url = Web.findResource(resource);
URL origURL = null;
try {
origURL = new URL(resource);
@ -289,8 +262,8 @@ public class PatternStylesheetResolver implements StylesheetResolver {
s_log.info("origURL is " + origURL);
}
final URL xfrmedURL = (origURL == null) ?
null : Templating.transformURL(origURL);
final URL xfrmedURL = (origURL==null) ? null : Templating
.transformURL(origURL);
if (s_log.isInfoEnabled()) {
s_log.info("Transformed resource is " + xfrmedURL);
@ -303,6 +276,10 @@ public class PatternStylesheetResolver implements StylesheetResolver {
}
if (is != null) {
is.close();
// xfrmedURL may test for existence either as http request
// or as a file lookup. Anyway we return the original URL
// which used to be a http request.
// Note: we are returning the URL, not the resource!
return origURL;
}
} catch (FileNotFoundException ex) {
@ -311,13 +288,13 @@ public class PatternStylesheetResolver implements StylesheetResolver {
}
// fall through & try next pattern
} catch (IOException ex) {
throw new UncheckedWrapperException(
"cannot open stream " + resource, ex);
throw new UncheckedWrapperException("cannot open stream " +
resource, ex);
}
}
throw new RuntimeException
("no path to XSL stylesheet found; " + "try modifying " + m_path);
throw new RuntimeException("no path to XSL stylesheet found; " +
"try modifying " + m_path);
}
/**
@ -339,20 +316,24 @@ public class PatternStylesheetResolver implements StylesheetResolver {
while (!queue.isEmpty()) {
String[] bits = (String[])queue.removeFirst();
if (s_log.isDebugEnabled()) {
s_log.debug("Process queue entry " + StringUtils.join(bits, ""));
s_log.debug("Process queue entry " + StringUtils.join(bits, ""));
}
boolean clean = true;
for (int i = 0 ; i < bits.length && clean ; i++) {
if (bits[i].startsWith("::") &&
bits[i].endsWith("::")) {
if (bits[i].startsWith("::") && bits[i].endsWith("::")) {
clean = false;
String[] vals = getValues(
bits[i].substring(2, bits[i].length() - 2),
values,
request);
String[] vals = getValues(bits[i]
.substring(2, bits[i].length()-2),
values,
request);
if (vals != null) {
for (int k = 0 ; k < vals.length ; k++) {
String[] newBits = new String[bits.length];
// In case the pattern for an element is an empty
// string (e.g. for the ROOT webapp) the slash before
// as well as after the placeholder are added
// resulting in a "//" which does no harm but is
// ugly.
for (int j = 0 ; j < bits.length ; j++) {
if (j == i) {
newBits[j] = vals[k];
@ -405,4 +386,50 @@ public class PatternStylesheetResolver implements StylesheetResolver {
return vals;
}
/**
*
* @param path
*/
private void loadPaths(String path) {
if (s_log.isInfoEnabled()) {
s_log.info("Loading paths from " + path);
}
m_path = path;
try {
// Read the source file.
ClassLoader cload = Thread.currentThread().getContextClassLoader();
InputStream stream = cload.getResourceAsStream(path.substring(1));
s_log.debug("got stream using path " + path.substring(1));
s_log.debug("stream.available is " + stream.available());
m_paths = new ArrayList();
LineNumberReader file = new LineNumberReader
(new InputStreamReader(stream));
String line;
int lineNum;
while ((line = file.readLine()) != null) {
lineNum = file.getLineNumber();
// Ignore blank lines and comments.
line = line.trim();
s_log.debug("line is " + line);
if ("".equals(line) || line.startsWith("#")
|| line.startsWith("!") || line.startsWith("//")) {
continue;
}
// Split up the line.
List list = StringUtils.splitUp(line, "/::\\w+::/");
// Save the split line.
m_paths.add(list);
}
} catch (IOException ex) {
throw new UncheckedWrapperException(
"cannot read XSLT paths from " + path, ex);
} catch (Exception e) {
s_log.debug("loadPaths threw exception " + e);
}
}
}

View File

@ -34,6 +34,7 @@ public class PrefixPatternGenerator implements PatternGenerator {
* @param req
* @return
*/
@Override
public String[] generateValues(String key,
HttpServletRequest req) {
String value = DispatcherHelper.getDispatcherPrefix(req);

View File

@ -35,21 +35,24 @@ import javax.xml.transform.stream.StreamSource;
import org.apache.log4j.Logger;
/**
* An implementation of the URIResolver interface that keeps track of
* all the URLs that have been loaded. If you set this as the URI
* resolver for a Transformer then this will track all the
* <code>xsl:import</code> and <code>xsl:include</code> statements.
* An implementation of the URIResolver interface that keeps track of all the
* URLs that have been loaded.
* If you set this as the URI resolver for a Transformer then this will track
* all the <code>xsl:import</code> and <code>xsl:include</code> statements.
*
* @version $Id: SimpleURIResolver.java 287 2005-02-22 00:29:02Z sskracic $
*/
final class SimpleURIResolver implements URIResolver {
private static final Logger s_log = Logger.getLogger
(SimpleURIResolver.class);
(SimpleURIResolver.class);
private final Set m_uniqueStylesheetURIs;
private final List m_stylesheetURIs;
/**
* Constructor, just initializes internal properties.
*/
public SimpleURIResolver() {
m_uniqueStylesheetURIs = new HashSet();
m_stylesheetURIs = new ArrayList();
@ -70,10 +73,11 @@ final class SimpleURIResolver implements URIResolver {
* @param href the url to resolve
* @param base the base url to resolve relative to
*/
@Override
public Source resolve(final String href, final String base)
throws TransformerException {
throws TransformerException {
if (s_log.isDebugEnabled()) {
s_log.debug("Resolve " + href + " (" + base + ")");
s_log.debug("Resolve " + href + " (found in " + base + ")");
}
URL baseURL = null;
@ -127,7 +131,10 @@ final class SimpleURIResolver implements URIResolver {
// are relative to 'thisURL'
return new StreamSource(is, thisURL.toString());
} catch (IOException ex) {
throw new TransformerException(String.format("cannot read stream for %s", thisURL.toString()), ex);
throw new TransformerException(
String.format("cannot read stream for %s",
thisURL.toString()),
ex);
}
}
}

View File

@ -34,6 +34,7 @@ public interface StylesheetResolver {
*
* @param sreq the <code>HttpServletRequest</code> for which to
* resolve a template
* @return URL where to try to find a stylesheet
*/
public URL resolve(HttpServletRequest sreq);
}

View File

@ -57,28 +57,34 @@ import org.apache.log4j.Logger;
*/
public class Templating {
/** Internal logger instance to faciliate debugging. Enable logging output
* by editing /WEB-INF/conf/log4j.properties int hte runtime environment
* and set com.arsdigita.templating.Templating=DEBUG by uncommenting it
* or adding the line. */
private static final Logger s_log = Logger.getLogger(Templating.class);
// just a tag to assure an implementation exists
// public static final Class DEFAULT_PRESENTATION_MANAGER
// = SimplePresentationManager.class;
/**
* This is the name of the attribute that is set in the request whose
/** This is the name of the attribute that is set in the request whose
* value, if present, is a collection of TransformerExceptions that
* can be used to produce a "pretty" error.
*/
* can be used to produce a "pretty" error. */
public static final String FANCY_ERROR_COLLECTION = "fancyErrorCollection";
// this was instantiated with hardcoded values, not anymore
/**
* The cache data storage for caching XSL templates.
*/
private static CacheTable s_templates = null;
private static final TemplatingConfig s_config = new TemplatingConfig();
/** Config object containing various parameter */
private static final TemplatingConfig s_config = TemplatingConfig
.getInstanceOf();
static {
s_log.debug("Static initalizer starting...");
s_config.load("ccm-core/templating.properties");
Exceptions.registerUnwrapper(
TransformerException.class,
new ExceptionUnwrapper() {
@Override
public Throwable unwrap(Throwable t) {
TransformerException ex = (TransformerException) t;
return ex.getCause();
@ -112,11 +118,12 @@ public class Templating {
/**
* Returns a new instance of the current presentation manager class. This is
* an object which has the {@link com.arsdigita.templating.PresentationManager
* PresentationManager} interface which can be used to transform an XML
* document into an output stream.
* an object which has the
* {@link com.arsdigita.templating.PresentationManager PresentationManager}
* interface which can be used to transform an XML document into an output
* stream.
*
* As of v ersion 6.6.0 the bebop framework is the only instance to provide
* As of version 6.6.0 the bebop framework is the only instance to provide
* an implementation. To avoid class hierachie kludge we directly return the
* bebop config here.
*
@ -156,12 +163,12 @@ public class Templating {
*
* @param source the <code>URL</code> to the top-level template resource
* @param fancyErrors Should this place any xsl errors in the request
* for use by another class. If this is true, the
* the errors are stored for later use.
* for use by another class. If this is true, the
* the errors are stored for later use.
* @param useCache Should the templates be pulled from cache, if available?
* True means they are pulled from cache. False means
* they are pulled from the disk. If this is false
* the pages are also not placed in the cache.
* True means they are pulled from cache. False means
* they are pulled from the disk. If this is false
* the pages are also not placed in the cache.
* @return an <code>XSLTemplate</code> instance representing
* <code>source</code>
*/
@ -235,7 +242,7 @@ public class Templating {
}
/**
* Resolves and retrieves the template for the given request.
* Resolves the template for the given request to an URL.
*
* @param sreq The current request object
* @param fancyErrors Should this place any xsl errors in the request
@ -250,10 +257,10 @@ public class Templating {
public static XSLTemplate getTemplate(final HttpServletRequest sreq,
boolean fancyErrors,
boolean useCache) {
Assert.exists(sreq, HttpServletRequest.class);
final URL sheet = getConfig().getStylesheetResolver().resolve(sreq);
Assert.exists(sheet, URL.class);
return Templating.getTemplate(sheet, fancyErrors, useCache);
@ -296,7 +303,7 @@ public class Templating {
* @return a virtual XSL file
*/
public static InputStream multiplexXSLFiles(Iterator paths) {
StringBuffer buf = new StringBuffer();
// StringBuilder buf = new StringBuilder();
Element root = new Element("xsl:stylesheet",
"http://www.w3.org/1999/XSL/Transform");
root.addAttribute("version", "1.0");
@ -328,33 +335,75 @@ public class Templating {
return new ByteArrayInputStream(doc.toString(true).getBytes());
}
// Transforms a URL, short-circuiting access to the resource
// servlet. This xfrms most http:// urls into file:// allowing
// XSLT invalidation to work for these resources. It has the
// added benefit of speeding up loading of XSL...
/**
* Transforms an URL, that refers to a local resource inside the running
* CCM web application. NON-local URLs remain unmodified.
*
* In case of a virtual path "/resource" it is short-circuiting access to
* the resource servlet. All other http:// URLs are transformed into file://
* for XSLT validation to work for these resources. It has the added benefit
* of speeding up loading of XSL...
*/
static URL transformURL(URL url) {
HttpHost self = Web.getConfig().getHost();
String path = url.getPath();
if (self.getName().equals(url.getHost()) && ((self.getPort() == url.
getPort()) || (url.getPort()
== -1
&& self.
getPort()
== 80))) {
/** Indicates whether url refers to a local resource inside the
* running CCM web application (inside it's webapp context) */
Boolean isLocal = false;
/** Contains the transformed "localized" path to url, i.e. without
* host part. */
String localPath = "";
if (path.startsWith("/resource")) {
// A virtual path to the servlet
path = path.substring("/resource".length());
URL newURL = Web.findResource(path);
// Check if the url refers to our own host
if (self.getName().equals(url.getHost())
&& ( (self.getPort() == url.getPort())
|| (url.getPort()== -1 && self.getPort()== 80)
)
) {
// host part denotes to a local resource, cut off host part.
localPath = url.getPath();
isLocal = true;
}
// java.net.URL is unaware of JavaEE webapplication. If CCM is not
// installed into the ROOT context, the path includes the webapp part
// which must be removed as well.
// It's a kind of HACK, unfortunately. If CCM is installed into the
// root context we don't detect whether the first part of the path
// refers to another web application inside the host and assume local
// and unrestricted access. The complete code should get refactored to
// use ServletContext#getResource(path)
String installContext = Web.getWebappContextPath();
if (s_log.isDebugEnabled()) {
s_log.debug("Installation context is >" + installContext + "<.");
}
if (!installContext.equals("")) {
// CCM is installed into a non-ROOT context
if (localPath.startsWith(installContext)) {
// remove webapp context part
localPath = localPath.substring(installContext.length());
if (s_log.isDebugEnabled()) {
s_log.debug("WebApp context removed: >>" +
localPath + "<<");
}
}
}
if (isLocal) {
// url specifies the running CCM host and port (or port isn't
// specified in url and default for running CCM host
if (localPath.startsWith("/resource")) {
// A virtual path to the ResourceServlet
localPath = localPath.substring("/resource".length()); //remove virtual part
URL newURL = Web.findResource(localPath); //without host part here!
if (s_log.isDebugEnabled()) {
s_log.debug("Transforming resource " + url + " to " + newURL);
}
return newURL;
} else {
// A real path to disk
final String filename =
Web.getServletContext().getRealPath(path);
final String filename = Web.getServletContext()
.getRealPath(localPath);
File file = new File(filename);
if (file.exists()) {
try {
@ -375,12 +424,14 @@ public class Templating {
}
}
} else {
// url is not the (local) running CCM host, no transformation
// is done
if (s_log.isDebugEnabled()) {
s_log.debug("URL " + url + " is not local");
}
}
return url;
return url; // returns the original, unmodified url here
}
}
@ -388,7 +439,7 @@ class LoggingErrorListener implements ErrorListener {
private static final Logger s_log =
Logger.getLogger(LoggingErrorListener.class);
private ArrayList m_errors;
private final ArrayList m_errors;
LoggingErrorListener() {
m_errors = new ArrayList();
@ -398,14 +449,17 @@ class LoggingErrorListener implements ErrorListener {
return m_errors;
}
@Override
public void warning(TransformerException e) throws TransformerException {
log(Level.WARN, e);
}
@Override
public void error(TransformerException e) throws TransformerException {
log(Level.ERROR, e);
}
@Override
public void fatalError(TransformerException e) throws TransformerException {
log(Level.FATAL, e);
}

View File

@ -31,9 +31,31 @@ import org.apache.log4j.Logger;
*/
public final class TemplatingConfig extends AbstractConfig {
/** Internal logger instance to faciliate debugging. Enable logging output
* by editing /WEB-INF/conf/log4j.properties int hte runtime environment
* and set com.arsdigita.templating.TemplatingConfig=DEBUG by uncommenting
* it */
private static final Logger s_log = Logger.getLogger
(TemplatingConfig.class);
/** Singelton config object. */
private static TemplatingConfig s_conf;
/**
* Gain a WorkspaceConfig object.
*
* Singelton pattern, don't instantiate a config object using the
* constructor directly!
* @return
*/
public static synchronized TemplatingConfig getInstanceOf() {
if (s_conf == null) {
s_conf = new TemplatingConfig();
s_conf.load();
}
return s_conf;
}
/** Fully qualified path string to file contain the pattern file for
{@link com.arsdigita.templating.PatternStylesheetResolver
PatternStylesheetResolver} */
@ -80,17 +102,20 @@ public final class TemplatingConfig extends AbstractConfig {
* Gets the stylesheet resolver. This value is set via the
* <code>com.arsdigita.templating.stylesheet_resolver</code>
* system property.
* @return
*/
public final StylesheetResolver getStylesheetResolver() {
return (StylesheetResolver) get(m_resolver);
}
/** Can be null. */
/** Can be null.
* @return */
public final Integer getCacheSize() {
return (Integer) get(m_cacheSize);
}
/** Can be null. */
/** Can be null.
* @return */
public final Integer getCacheAge() {
return (Integer) get(m_cacheAge);
}

View File

@ -131,7 +131,7 @@ public class URLPatternGenerator implements PatternGenerator {
private String getPath() {
String base = getBasePath();
String url = Web.getContext().getRequestURL().getPathInfo();
String url = Web.getWebContext().getRequestURL().getPathInfo();
if (s_log.isDebugEnabled()) {
s_log.debug("Base is " + base + " url is " + url);
@ -145,16 +145,16 @@ public class URLPatternGenerator implements PatternGenerator {
/**
* Provides the base URL of the application in the current Web request
* (i.e. application's PrimaryURL). If no application can be found or
* no PrimaryURL can be determined ROOT ("/") is returned.
*
* XXX fix me, why can't we get this from Web.getContext().getRequestURL
no PrimaryURL can be determined ROOT ("/") is returned.
XXX fix me, why can't we get this from Web.getWebContext().getRequestURL
*
* @return primary url of an application or ROOT
*/
private String getBasePath() {
// retrieve the application of the request
Application app = Web.getContext().getApplication();
Application app = Web.getWebContext().getApplication();
if (app == null) {
return "/";
} else {

View File

@ -33,44 +33,60 @@ import org.apache.log4j.Logger;
*/
public class WebAppPatternGenerator implements PatternGenerator {
/** Private Logger instance for debugging purpose. */
/** Internal logger instance to faciliate debugging. Enable logging output
* by editing /WEB-INF/conf/log4j.properties int hte runtime environment
* and set com.arsdigita.templating.WebAppPatternGenerator=DEBUG by
* uncommenting or adding the line. */
private static final Logger s_log =
Logger.getLogger(WebAppPatternGenerator.class);
/**
*
* @param key placeholder from the pattern string, without surrounding
* colons, constantly "webapp" here.
* @param req current HttpServletRequest
* @return List of webapps contextPath names in an Array of Strings.
*/
@Override
public String[] generateValues(String key,
HttpServletRequest req) {
Application app = Web.getContext().getApplication();
String ctx = app == null ? null : app.getContextPath();
if (s_log.isDebugEnabled()) {
s_log.debug("Generating Values key: " + key + " [" +
"Web.getContext(): " + Web.getContext() + "," +
"Application: " + Web.getContext().getApplication() + "," +
"ContextPath: " + ctx + "," + "]");
}
Application app = Web.getWebContext().getApplication();
String ctx = (app == null) ? null : app.getContextPath();
if (app == null || ctx == null || "".equals(ctx)) {
return new String[] { Web.ROOT_WEBAPP }; // Currently "ROOT"
ctx = Web.getWebappContextPath() ;
}
// JavaEE requires a leading "/" for web context part, but the pattern
// string already contains a "/", so we have to remove it here to
// too avoid a "//"
if (ctx.startsWith("/")) {
ctx = ctx.substring(1);
}
if (s_log.isDebugEnabled()) {
s_log.debug("Generating Values key: " + key + " [" +
"Web.getWebContext(): " + Web.getWebContext() + " ," +
"Application: " + Web.getWebContext().getApplication() + "," +
"ContextPath: >" + ctx + "<]");
}
/* "Older version: prior 6.6. Some modules used to be installed into
* its own web application context, but needed access to the main
* applications package files (e.g. bebop) which were installed into
* to ROOT web context. Therefore ROOT had to be added.
*/
// return new String[] { ctx + "," + Web.ROOT_WEBAPP };
/* As of version 6.6 all packages are installed in one web application
* context, therefore the ROOT entry is no longer valid.
* applications package files (e.g. bebop). Therefore the webapp context
* (ServletContext in API speech) of the main CCM application had to be
* added (which was ROOT by default)
*
* As of version 6.6 all packages are installed in one web application
* context, therefore no additional entry is required.
* This variation had first be introduced with the APLAWS integration
* package, which used to register an additional WebAppPatternGenerator,
* which simply cuts ","+ Web.ROOT_WEBAPP, under a different key
* "Webapp" (singular) */
// return new String[] { ctx + "," + Web.getRootWebappContextPath() };
return new String[] { ctx };
}
}

View File

@ -34,6 +34,8 @@ public interface XSLParameterGenerator {
* This returns the correct value for the parameter. This is the
* value that is added to the transformer and is available to all
* stylesheets
* @param request
* @return
*/
public String generateValue(HttpServletRequest request);
}

View File

@ -58,7 +58,14 @@ import org.w3c.dom.Document;
*/
public final class XSLTemplate {
/** Internal logger instance to faciliate debugging. Enable logging output
* by editing /WEB-INF/conf/log4j.properties int hte runtime environment
* and set com.arsdigita.templating.XSLTemplate=DEBUG by uncommenting
* or adding the line. */
private static final Logger s_log = Logger.getLogger(XSLTemplate.class);
/** Property containing the URL to the XSL source file or create this
* instance */
private final URL m_source;
private final Templates m_templates;
private final List m_dependents;
@ -102,6 +109,11 @@ public final class XSLTemplate {
throw new WrappedTransformerException(ex);
}
// List contains each include/import URL found in the style sheet
// recursively(!) (i.e. scanning each style sheet whose URL has been
// found in a style sheet, etc.
// In case of Mandalay (single entry stylesheet) about 250 URL's, all
// resolved when found Mandalay's start.xml in one go.
m_dependents = resolver.getStylesheetURIs();
m_created = new Date();
}

View File

@ -65,7 +65,7 @@ public class DebugPanel extends SimpleComponent {
UIConstants.UI_XML_NS);
exportAttributes(content);
URL here = Web.getContext().getRequestURL();
URL here = Web.getWebContext().getRequestURL();
URL xmlURL = selfURL(state, here, "output", "xml");
URL xslURL = selfURL(state, here, "output", "xsl");

View File

@ -104,7 +104,7 @@ public class UserAuthenticationListener implements RequestListener {
// first make sure we're not already looking at the login
// page -- if we are, don't redirect!
if (urlBase.equals(Web.getContext().getRequestURL().getRequestURI())) {
if (urlBase.equals(Web.getWebContext().getRequestURL().getRequestURI())) {
s_log.debug("preventing cyclic redirect to: " + urlBase);
// return without redirect
return;

View File

@ -28,6 +28,10 @@ import org.apache.log4j.Logger;
*/
public abstract class Record {
/** Internal logger instance to faciliate debugging. Enable logging output
* by editing /WEB-INF/conf/log4j.properties int the runtime environment
* and set com.arsdigita.util.Record=DEBUG
* by uncommenting or adding the line. */
private static final Logger s_log = Logger.getLogger(Record.class);
private Class m_class;

View File

@ -71,8 +71,8 @@ public class ResourceManager {
/**
* Returns a new InputStream object reading the URL argument.
* Behaves similarly to ServletContext.getResourceAsStream(),
* reading pathnames relative to the webapp root.
* Behaves similarly to ServletContext.getResourceAsStream(), reading
* pathnames relative to the webapp root.
*
* @param url a URL interpreted as a pathname relative to the webapp root
* @return a new input stream reading the named file, or null
@ -81,12 +81,14 @@ public class ResourceManager {
* not configured prior to use.
*/
public InputStream getResourceAsStream(String url) {
if (m_webappRoot == null && m_servletContext == null) {
throw new IllegalStateException(CONFIGURE_MESSAGE);
}
if (StringUtils.emptyString(url)) {
throw new IllegalArgumentException("URL is empty: " + url);
}
if (m_servletContext != null) {
// If we have a Servlet Context, use it.
InputStream is = m_servletContext.getResourceAsStream(url);
@ -212,6 +214,7 @@ public class ResourceManager {
/**
* Returns the last-modified time for the file on disk.
*
* @param path
* @return the last-modified time for the file on disk. Returns
* 0L if this isn't available (within a WAR file, for example),
* the file isn't found, or there's an I/O error. This is consistent

View File

@ -615,6 +615,10 @@ public class Application extends Resource {
return canonicalURL;
}
/**
*
* @return
*/
public String getContextPath() {
return "";
}
@ -663,7 +667,7 @@ public class Application extends Resource {
@Override
protected void beforeSave() {
if (isPropertyModified(PRIMARY_URL) || isNew()) {
BaseDispatcher.scheduleRefresh();
CCMDispatcherServlet.scheduleRefresh();
}
super.beforeSave();
@ -687,7 +691,7 @@ public class Application extends Resource {
*/
@Override
public void afterDelete() {
BaseDispatcher.scheduleRefresh();
CCMDispatcherServlet.scheduleRefresh();
}
/**

View File

@ -68,14 +68,14 @@ import org.apache.log4j.Logger;
* In the Application class it should define:
* </p>
* <pre>
* public String getContextPath() {
* return "ccm-mywebapp";
* }
*
* public String getServletPath() {
* return "/files";
* }
* </pre>
public String getWebContextPath() {
return "ccm-mywebapp";
}
public String getServletPath() {
return "/files";
}
</pre>
* <p>
* It can then put JSP files in a 'templates/ccm-mywebapp' directory at
* the root of its private webapp. Files in this directory can be scoped by

View File

@ -106,7 +106,7 @@ public abstract class BaseApplicationServlet extends BaseServlet {
throw new IllegalStateException("Application not found");
}
Web.getContext().setApplication(app);
Web.getWebContext().setApplication(app);
final RequestContext rc = makeLegacyContext
(sreq, app, Web.getUserContext());

View File

@ -35,39 +35,43 @@ import org.apache.log4j.Logger;
/**
* A base class for filters that require a persistence
* session to be present. This implements the doFilter
* method to open up a default persistence session, and
* then hand off to the doService method. Subclasses
* should override this doService method to provide the
* processing they require.
* A base class for filters that require a persistence session to be present.
* This implements the doFilter method to open up a default persistence session,
* and then hand off to the doService method. Subclasses should override this
* doService method to provide the processing they require.
*
* Assumes a initialized database connection and domain
* coupling machinery (provided by CCMApplicationListener
* during container startup).
* Assumes an initialized database connection and domain coupling machinery
* (provided by CCMApplicationListener during container startup).
*
* Actually, the class does nothing at all!
*/
public class BaseFilter implements Filter {
private static Logger s_log = Logger.getLogger(BaseFilter.class);
/** Internal logger instance to faciliate debugging. Enable logging output
* by editing /WEB-INF/conf/log4j.properties int the runtime environment
* and set com.arsdigita.web.BaseFilter=DEBUG
* by uncommenting or adding the line. */
private static final Logger s_log = Logger.getLogger(BaseFilter.class);
/**
*
* Initialization code, introduces an extension point for subclasses.
* @param sconfig
* @throws javax.servlet.ServletException
*/
@Override
public final void init(final FilterConfig sconfig) throws ServletException {
if (s_log.isInfoEnabled()) {
s_log.info("Initializing filter " + sconfig.getFilterName() +
" (class: " + getClass().getName() + ")");
}
// extension point for subclasses
doInit();
}
/**
*
* Initialization extension stub. Subclasses should overwrite this method
* to add functionality as required.
* @throws javax.servlet.ServletException
*/
protected void doInit() throws ServletException {
@ -75,8 +79,9 @@ public class BaseFilter implements Filter {
}
/**
*
* Shutdown code, introduces an extension point for subclasses.
*/
@Override
public final void destroy() {
if (s_log.isInfoEnabled()) {
s_log.info
@ -87,7 +92,8 @@ public class BaseFilter implements Filter {
}
/**
*
* Shutdown extension stub. Subclasses should overwrite this method
* to add functionality as required and properly stopp services.
*/
protected void doDestroy() {
// Empty
@ -101,6 +107,7 @@ public class BaseFilter implements Filter {
* @throws java.io.IOException
* @throws javax.servlet.ServletException
*/
@Override
public void doFilter(ServletRequest sreq,
ServletResponse sresp,
FilterChain chain)
@ -118,6 +125,11 @@ public class BaseFilter implements Filter {
/**
* This is the extension point for users of this class.
* @param sreq
* @param sresp
* @param chain
* @throws javax.servlet.ServletException
* @throws java.io.IOException
*/
protected void doService(final HttpServletRequest sreq,
final HttpServletResponse sresp,

View File

@ -34,7 +34,7 @@ import org.apache.log4j.Logger;
*
* <blockquote><pre>
* <%@page extends="com.arsdigita.web.BaseJSP" %>
* <b><%= Web.getContext().getUser().toString() %></b>
* <b><%= Web.getWebContext().getUser().toString() %></b>
* </pre></blockquote>
*
* @see com.arsdigita.web.BaseServlet
@ -43,13 +43,18 @@ import org.apache.log4j.Logger;
*/
public abstract class BaseJSP extends BaseServlet implements HttpJspPage {
/** A logger instance, primarily to assist debugging . */
private static Logger s_log = Logger.getLogger(BaseJSP.class);
/** Internal logger instance to faciliate debugging. Enable logging output
* by editing /WEB-INF/conf/log4j.properties int the runtime environment
* and set com.arsdigita.web.BaseJSP=DEBUG
* by uncommenting or adding the line. */
private static final Logger s_log = Logger.getLogger(BaseJSP.class);
/**
* <p>Invokes the <code>_jspService(sreq, sresp)</code> method in
* the environment prepared by <code>BaseServlet</code>.</p>
*
* @throws javax.servlet.ServletException
* @throws java.io.IOException
* @see #_jspService(HttpServletRequest,HttpServletResponse)
* @see com.arsdigita.web.BaseServlet
* @see com.arsdigita.web.BaseServlet#doService(HttpServletRequest,HttpServletResponse)
@ -86,16 +91,23 @@ public abstract class BaseJSP extends BaseServlet implements HttpJspPage {
* <p>The method that JSP compilers will override to produce the
* body of the page.</p>
*
* @param sreq
* @param sresp
* @throws javax.servlet.ServletException
* @throws java.io.IOException
* @see javax.servlet.jsp.HttpJspPage#_jspService(HttpServletRequest,HttpServletResponse)
*/
@Override
public abstract void _jspService(HttpServletRequest sreq,
HttpServletResponse sresp)
throws ServletException, IOException;
@Override
public void jspInit()
{
}
@Override
public void jspDestroy()
{
}

Some files were not shown because too many files have changed in this diff Show More