diff --git a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentModelBuilder.java b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentModelBuilder.java index c6b85b957..0aa17a481 100755 --- a/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentModelBuilder.java +++ b/ccm-cms-assets-fileattachment/src/com/arsdigita/cms/contentassets/ui/FileAttachmentModelBuilder.java @@ -20,9 +20,10 @@ import com.arsdigita.bebop.table.AbstractTableModelBuilder; import com.arsdigita.bebop.table.TableModel; import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.Service; import com.arsdigita.cms.contentassets.FileAttachment; import com.arsdigita.cms.dispatcher.StreamAsset; -import com.arsdigita.cms.dispatcher.Utilities; +// import com.arsdigita.cms.dispatcher.Utilities; import com.arsdigita.persistence.DataCollection; import com.arsdigita.persistence.DataObject; import com.arsdigita.web.ParameterMap; @@ -120,8 +121,11 @@ public class FileAttachmentModelBuilder extends AbstractTableModelBuilder { // TODO provide API for asset URL ParameterMap params = new ParameterMap(); params.setParameter(StreamAsset.ASSET_ID, _file.getID()); - return URL.there( Utilities.getServiceURL()+"download/asset", - params ).getURL(); + // return URL.there( Utilities.getServiceURL()+"download/asset", + // params ).getURL(); + return URL + .there(Service.getURL()+"/download/asset", params ) + .getURL(); }else{ return _file.getDescription(); } diff --git a/ccm-cms-assets-imagestep/src/com/arsdigita/cms/contentassets/ui/ImageStepDisplay.java b/ccm-cms-assets-imagestep/src/com/arsdigita/cms/contentassets/ui/ImageStepDisplay.java index 96c49ceb1..fbf4dc0e9 100755 --- a/ccm-cms-assets-imagestep/src/com/arsdigita/cms/contentassets/ui/ImageStepDisplay.java +++ b/ccm-cms-assets-imagestep/src/com/arsdigita/cms/contentassets/ui/ImageStepDisplay.java @@ -140,6 +140,7 @@ public class ImageStepDisplay extends SimpleContainer { container.setBorder( 1 ); container.add( new ImageDisplay(null) { + @Override protected void generateImagePropertiesXML( ImageAsset image, PageState state, Element element ) { diff --git a/ccm-cms-types-organization/src/com/arsdigita/cms/contenttypes/ui/OrganizationImageStep.java b/ccm-cms-types-organization/src/com/arsdigita/cms/contenttypes/ui/OrganizationImageStep.java index c9ebf49b7..381934437 100755 --- a/ccm-cms-types-organization/src/com/arsdigita/cms/contenttypes/ui/OrganizationImageStep.java +++ b/ccm-cms-types-organization/src/com/arsdigita/cms/contenttypes/ui/OrganizationImageStep.java @@ -23,7 +23,7 @@ import com.arsdigita.cms.contenttypes.util.OrganizationGlobalizationUtil; import com.arsdigita.bebop.PageState; import com.arsdigita.cms.ContentItem; -import com.arsdigita.cms.dispatcher.Utilities; +// import com.arsdigita.cms.dispatcher.Utilities; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; import com.arsdigita.cms.ui.authoring.SimpleEditStep; @@ -33,6 +33,7 @@ import com.arsdigita.toolbox.ui.DomainObjectPropertySheet; import com.arsdigita.cms.ui.authoring.WorkflowLockedComponentAccess; import com.arsdigita.cms.ImageAsset; +import com.arsdigita.cms.Service; import java.math.BigDecimal; @@ -110,9 +111,13 @@ public class OrganizationImageStep heightStr = " height=\"" + height.toString() + "\" "; } + // String labelStr = ""; String labelStr = ""; + Service.getImageURL(image) + + "\" " + widthStr + heightStr + "/>"; + return labelStr; } } diff --git a/ccm-cms/src/com/arsdigita/cms/CMS.java b/ccm-cms/src/com/arsdigita/cms/CMS.java index 666e7b652..23a000be1 100755 --- a/ccm-cms/src/com/arsdigita/cms/CMS.java +++ b/ccm-cms/src/com/arsdigita/cms/CMS.java @@ -18,6 +18,7 @@ */ package com.arsdigita.cms; +import com.arsdigita.bebop.PageState; import org.apache.log4j.Logger; /** @@ -87,4 +88,16 @@ public abstract class CMS { static final void setContext(CMSContext context) { s_context.set(context); } + + /** + * Fetch the security manager. + * + * @param state The page state + * @return The SecurityManager for the content section + */ + public static SecurityManager getSecurityManager(PageState state) { + ContentSection section = CMS.getContext().getContentSection(); + return new SecurityManager(section); + } + } diff --git a/ccm-cms/src/com/arsdigita/cms/ContentSection.java b/ccm-cms/src/com/arsdigita/cms/ContentSection.java index 771a8d509..1dd04b5d3 100755 --- a/ccm-cms/src/com/arsdigita/cms/ContentSection.java +++ b/ccm-cms/src/com/arsdigita/cms/ContentSection.java @@ -33,7 +33,6 @@ import com.arsdigita.cms.util.GlobalizationUtil; import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.globalization.Locale; import com.arsdigita.kernel.Group; -import com.arsdigita.kernel.SiteNode; import com.arsdigita.kernel.permissions.PermissionService; import com.arsdigita.persistence.CompoundFilter; import com.arsdigita.persistence.DataAssociation; @@ -51,12 +50,13 @@ import com.arsdigita.web.URL; import com.arsdigita.web.Web; import com.arsdigita.workflow.simple.TaskCollection; import com.arsdigita.workflow.simple.WorkflowTemplate; -import org.apache.log4j.Logger; import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; import java.util.StringTokenizer; + import org.apache.log4j.Level; +import org.apache.log4j.Logger; /** *

A content section represents a collection of content that is @@ -919,68 +919,30 @@ public class ContentSection extends Application { // // Finding a content section. // + /** * Looks up the section given the SiteNode. * - * @param node The site node + * @param path * @return The content section - * @pre ( node != null ) + * @pre ( path != null ) * @post ( return != null ) */ - public static ContentSection getSectionFromNode(SiteNode node) + public static ContentSection getSectionForPath(String path) throws DataObjectNotFoundException { - return (ContentSection) retrieveApplicationForSiteNode(node); - -// BigDecimal sectionId = null; -// -// PackageInstance pkg = node.getPackageInstance(); -// if ( pkg == null ) { -// throw new DataObjectNotFoundException( -// "No package instance for node_id=" + node.getID().toString()); -// } -// -// return getSectionFromPackage(pkg); + return (ContentSection) retrieveApplicationForPath(path); } -// /** -// * Looks up the section given the PackageInstance. -// * -// * @param pkg The package instance -// * @return The content section ID -// * @pre ( pkg != null ) -// * @post ( return != null ) -// */ -// public static ContentSection getSectionFromPackage(PackageInstance pkg) -// throws DataObjectNotFoundException { -// -// ContentSection section = null; -// -// final String query = "com.arsdigita.cms.getSectionFromPackage"; -// DataQuery dq = SessionManager.getSession().retrieveQuery(query); -// dq.setParameter("packageId", pkg.getID()); -// if ( dq.next() ) { -// DataObject dobj = (DataObject) dq.get("section"); -// if ( dobj != null ) { -// section = (ContentSection) DomainObjectFactory.newInstance(dobj); -// } -// dq.close(); -// } else { -// throw new DataObjectNotFoundException( -// "Failed to fetch a content section for the current package " + -// "instance. [package_id =" + pkg.getID().toString() + "]"); -// } -// return section; -// } /** * Get the content section for an item. * - * @deprecated use {@link ContentItem#getContentSection} instead - * * @pre item != null * @post return != null * @param item A content item * @return The content section of an item + * + * @deprecated use {@link ContentItem#getContentSection} instead */ public static ContentSection getContentSection(ContentItem item) throws DataObjectNotFoundException { @@ -991,11 +953,11 @@ public class ContentSection extends Application { /** * Get the content section for a folder. * - * @deprecated use {@link ContentItem#getContentSection} instead * @pre item != null * @post return != null * @param folder A content folder * @return The content section of the folder + * @deprecated use {@link ContentItem#getContentSection} instead */ public static ContentSection getContentSection(Folder folder) throws DataObjectNotFoundException { diff --git a/ccm-cms/src/com/arsdigita/cms/Loader.java b/ccm-cms/src/com/arsdigita/cms/Loader.java index 0110b68ff..e200136f0 100755 --- a/ccm-cms/src/com/arsdigita/cms/Loader.java +++ b/ccm-cms/src/com/arsdigita/cms/Loader.java @@ -138,38 +138,22 @@ public class Loader extends PackageLoader { public void excurse() { setEffectiveParty(Kernel.getSystemParty()); - // 2 - step 1b) Setup the Workspace package. - // loadWorkspacePackage(); // using old stype - // new style: + // Step 1) Setup the CMS Workspace ApplicationType appType = loadWorkspaceApplicationType(); setupDefaultWorkspaceApplicationInstance(appType); - // 3 - step 1c) Setup the CMS global services package. - // loadServicePackage(); // using olde style - // new style: + // Step 2) Setup the CMS global services appType = loadServiceApplicationType(); setupDefaultServiceApplicationInstance(appType); - // 4 - step 1d) Load the content-center page mappings - // Wrong! Is Initializer task, must be done each startup, in - // any way not a Loader task. It is here for reference - // purpose during migration of the whole CMS to new style. - // loadContentCenterMapping(s_conf.getContentCenterMap() ); - - // 5) load (cms internal) content type definition(s) - // Used to be step 2 in former enterprise.init file + // Step 3) load (cms internal) content type definition(s) loadContentTypeDefinitions(s_conf.getCTDefFiles()); - // 6) Load CMS (content section) package application instance - // Used to be step 4 in former enterprise.init file - // (step 3 being initialize publishToFile, not to handle in Loader) - // Implemented by - // com.arsdigita.cms.installer.SectionInitializer + // Step 4) Load CMS content section // Loads content section application type and instance in one step loadContentSection( (String[]) get(m_contentSectionNames) ); - // Loading CMS portlets - // Used to be step 7 (last step) in former enterprise.init + // Step 5) Loading CMS portlets s_log.debug("CMS.loader going to load portlets"); ContentDirectoryPortlet.loadPortletType(); ContentItemPortlet.loadPortletType(); @@ -277,16 +261,28 @@ public class Loader extends PackageLoader { // ApplicationType serviceType = appsetup.run(); // serviceType.save(); // ////////////// Current style to create app type /////////////// - /* Create new stype legacy compatible application type */ - ApplicationType serviceType = ApplicationType - .createApplicationType(Service.PACKAGE_KEY, - Service.INSTANCE_NAME, - Service.BASE_DATA_OBJECT_TYPE); - serviceType.setDescription("Services to store global resources and assets."); - serviceType.setDispatcherClass(Service.DISPATCHER_CLASS); - serviceType.save(); + /* Create new type legacy compatible application type */ + // ApplicationType type = ApplicationType + // .createApplicationType(Service.PACKAGE_KEY, + // Service.INSTANCE_NAME, + // Service.BASE_DATA_OBJECT_TYPE); + // type.setDispatcherClass(Service.DISPATCHER_CLASS); - return serviceType; + /* Create new type legacy free application type + * NOTE: The wording in the title parameter of ApplicationType + * determines the name of the subdirectory for the XSL stylesheets. + * It gets "urlized", i.e. trimming leading and trailing blanks and + * replacing blanks between words and illegal characters with an + * hyphen and converted to lower case. + * "Content Section" will become "content-section". */ + ApplicationType type = new ApplicationType( + Service.INSTANCE_NAME, + Service.BASE_DATA_OBJECT_TYPE ); + + type.setDescription("Services to store global resources and assets."); + type.save(); + + return type; } @@ -299,10 +295,10 @@ public class Loader extends PackageLoader { // create legacy compatible application instance, // old-style package key used as url fragment where to install the instance Service app = (Service) Application.createApplication( - serviceType, // type - Service.PACKAGE_KEY, // url fragment - Service.INSTANCE_NAME,// title - null); // parent + serviceType, // type + Service.PACKAGE_KEY, // url fragment + "CMS Service Instance", // title + null); // parent app.setDescription("The default CMS service instance."); app.save(); diff --git a/ccm-cms/src/com/arsdigita/cms/Service.java b/ccm-cms/src/com/arsdigita/cms/Service.java index 4ec542966..eeaa64855 100644 --- a/ccm-cms/src/com/arsdigita/cms/Service.java +++ b/ccm-cms/src/com/arsdigita/cms/Service.java @@ -18,12 +18,15 @@ */ package com.arsdigita.cms; +import com.arsdigita.cms.dispatcher.StreamAsset; +import com.arsdigita.cms.dispatcher.StreamImage; import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.persistence.DataObject; import com.arsdigita.persistence.OID; // import com.arsdigita.persistence.DataAssociation; // import com.arsdigita.persistence.PersistenceException; import com.arsdigita.web.Application; +import com.arsdigita.web.URL; import java.math.BigDecimal; @@ -97,12 +100,66 @@ public class Service extends Application { return BASE_DATA_OBJECT_TYPE; } + + public static String getURL() { + return "/" + PACKAGE_KEY + "/"; + } + + + /** + * Constuct a URL which serves a binary asset. + * + * @param asset The binary asset + * @return the URL which will serve the specified binary asset + */ + public static String getAssetURL(BinaryAsset asset) { + return getAssetURL(asset.getID()); + } + + /** + * Constuct a URL which serves a binary asset. + * + * @param assetId The asset ID + * @return the URL which will serve the specified binary asset + */ + public static String getAssetURL(BigDecimal assetId) { + StringBuilder buf = new StringBuilder(Service.getURL() ); + buf.append("stream/asset?"); + buf.append(StreamAsset.ASSET_ID).append("=").append(assetId); + return buf.toString(); + } + + + + /** + * Constuct a URL which serves an image. + * + * @param asset The image asset whose image is to be served + * @return the URL which will serve the specified image asset + */ + public static String getImageURL(ImageAsset asset) { + StringBuilder buf = new StringBuilder(Service.getURL() ); + buf.append("stream/image/?"); + buf.append(StreamImage.IMAGE_ID).append("=").append(asset.getID()); + return buf.toString(); + } + + /** + * The URL to log out. + * @return The logout URL + */ + public static String getLogoutURL() { + StringBuilder buf = new StringBuilder(Service.getURL() ); + buf.append("logout"); + return buf.toString(); + } + /** * This is called when the application is created. */ public static Service create(String urlName, - String title, - Application parent) { + String title, + Application parent) { Service app = (Service) Application.createApplication (BASE_DATA_OBJECT_TYPE, urlName, title, parent); @@ -112,5 +169,11 @@ public class Service extends Application { return app; } + @Override + public String getServletPath() { + //return URL.SERVLET_DIR + "/cms-service"; + return "/templates/servlet/cms-service"; + } + } diff --git a/ccm-cms/src/com/arsdigita/cms/ServiceServlet.java b/ccm-cms/src/com/arsdigita/cms/ServiceServlet.java index 16e5f84b0..2037c5c30 100644 --- a/ccm-cms/src/com/arsdigita/cms/ServiceServlet.java +++ b/ccm-cms/src/com/arsdigita/cms/ServiceServlet.java @@ -51,6 +51,15 @@ import org.xml.sax.helpers.DefaultHandler; * URLs of the available services are stored in a XML file which is processed * into a cache of services on a request by request basis (lazy loading). * + * ServiceServlet is called by BaseApplicationServlet which has determined that + * ServiceServlet is associated with a request URL. + * + * The CMS Service determines whether a Page has been registered to + * the URL and if so passes the request to that page. + * + * If no Page is registered to the URL, then the CMS Service hands + * the request to the TemplateResolver to find an appropriate JSP file. + * * @author Peter Boy * @version $Id: ServiceServlet.java 2161 2011-02-02 00:16:13Z pboy $ */ @@ -68,9 +77,7 @@ public class ServiceServlet extends BaseApplicationServlet { /** Mapping between a relative URL and the class name of a ResourceHandler.*/ private static HashMap s_pageClasses = new HashMap(); - /** - * Instantiated ResourceHandler cache. This allows for lazy loading. - */ + /** Instantiated ResourceHandler cache. This allows for lazy loading. */ private static SimpleCache s_pages = new SimpleCache(); /** List of URLs which require a trailing slash. These are required for @@ -80,6 +87,7 @@ public class ServiceServlet extends BaseApplicationServlet { /** Path to directory containg ccm-cms template files */ private String m_templatePath; + /** Resolvers to find templages (JSP) and other stuff stored in file system.*/ private ApplicationFileResolver m_resolver; @@ -101,20 +109,21 @@ public class ServiceServlet extends BaseApplicationServlet { /* Process mapping file. */ readFromFile(MAP_FILE); + /** Set Template base path for JSP's */ m_templatePath = ContentSection.getConfig().getTemplateRoot(); Assert.exists(m_templatePath, String.class); Assert.isTrue(m_templatePath.startsWith("/"), "template-path must start with '/'"); Assert.isTrue(!m_templatePath.endsWith("/"), "template-path must not end with '/'"); + /** Set TemplateResolver class */ m_resolver = Web.getConfig().getApplicationFileResolver(); } /** * Implements the (abstract) doService method of BaseApplicationServlet to - * create the perform the services. - * + * perform the services. * @see com.arsdigita.web.BaseApplicationServlet#doService * (HttpServletRequest, HttpServletResponse, Application) */ @@ -152,15 +161,10 @@ public class ServiceServlet extends BaseApplicationServlet { page.dispatch(sreq, sresp, ctx); } else { // Fall back on the JSP application dispatcher. - // m_notFoundHandler.dispatch(request, response, actx); if (s_log.isInfoEnabled()) { - s_log.info("NOT serving content item"); + s_log.info("NO page registered to serve the requst url."); } - /* Store content section in http request to make it available - * or admin index,jsp */ - // sreq.setAttribute(CONTENT_SECTION, section); - RequestDispatcher rd = m_resolver.resolve(m_templatePath, sreq, sresp, app); if (rd != null) { @@ -170,7 +174,6 @@ public class ServiceServlet extends BaseApplicationServlet { sreq = DispatcherHelper.restoreOriginalRequest(sreq); rd.forward(sreq,sresp); } else { - // sresp.sendError(404, packageURL + " not found on this server."); sresp.sendError(404, requestUri + " not found on this server."); } diff --git a/ccm-cms/src/com/arsdigita/cms/Workspace.java b/ccm-cms/src/com/arsdigita/cms/Workspace.java index 0b4e42577..fa9093760 100644 --- a/ccm-cms/src/com/arsdigita/cms/Workspace.java +++ b/ccm-cms/src/com/arsdigita/cms/Workspace.java @@ -25,6 +25,8 @@ import com.arsdigita.persistence.OID; // import com.arsdigita.persistence.PersistenceException; import com.arsdigita.web.Application; +import com.arsdigita.web.ApplicationCollection; +import com.arsdigita.web.ApplicationType; import java.math.BigDecimal; import org.apache.log4j.Logger; @@ -107,4 +109,39 @@ public class Workspace extends Application { return app; } + /** + * Returns an instance of the Workspace application. There must not more + * than one instance exist. May return null. + */ + public static Application getInstance() { + ApplicationType workspaceType = ApplicationType. + retrieveApplicationTypeForApplication(BASE_DATA_OBJECT_TYPE); + if ( workspaceType == null ) { return null; } + + ApplicationCollection apps = Application.retrieveAllApplications(); + apps.addEqualsFilter("resourceType.id", workspaceType.getID()); + if ( !apps.next() ) { return null; } + + Application result = apps.getApplication(); + apps.close(); + return result; + } + + /** + * Fetch the location (URL) of the CMS Workspace. There must not more than + * one instance exist. + * + * @return The URL of the CMS Workspace (currently including trailing slash) + */ + public static String getURL() { + + Application app = Workspace.getInstance(); + if (app == null) { + return null; + } else { + String url = (String) app.getPrimaryURL(); + return url; + } + } + } diff --git a/ccm-cms/src/com/arsdigita/cms/dispatcher/CMSDispatcher.java b/ccm-cms/src/com/arsdigita/cms/dispatcher/CMSDispatcher.java index 0cbc30610..9717034cd 100755 --- a/ccm-cms/src/com/arsdigita/cms/dispatcher/CMSDispatcher.java +++ b/ccm-cms/src/com/arsdigita/cms/dispatcher/CMSDispatcher.java @@ -32,7 +32,6 @@ import com.arsdigita.dispatcher.RequestContext; import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.kernel.ACSObjectCache; import com.arsdigita.kernel.KernelHelper; -import com.arsdigita.kernel.SiteNode; import com.arsdigita.kernel.User; import com.arsdigita.web.LoginSignal; import com.arsdigita.web.URL; @@ -451,8 +450,7 @@ public class CMSDispatcher implements Dispatcher, ChainedDispatcher { } // Fetch the current site node from the URL. - SiteNode sn = SiteNode.getSiteNode(url); - ContentSection section = ContentSection.getSectionFromNode(sn); + ContentSection section = ContentSection.getSectionForPath(url); return section; } diff --git a/ccm-cms/src/com/arsdigita/cms/dispatcher/CMSPage.java b/ccm-cms/src/com/arsdigita/cms/dispatcher/CMSPage.java index 355bd8779..2fb8d4a84 100755 --- a/ccm-cms/src/com/arsdigita/cms/dispatcher/CMSPage.java +++ b/ccm-cms/src/com/arsdigita/cms/dispatcher/CMSPage.java @@ -27,6 +27,7 @@ import com.arsdigita.bebop.page.PageTransformer; import com.arsdigita.cms.CMSExcursion; import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentSection; +import com.arsdigita.cms.ContentSectionServlet; import com.arsdigita.cms.SecurityManager; import com.arsdigita.developersupport.DeveloperSupport; import com.arsdigita.dispatcher.RequestContext; @@ -194,7 +195,8 @@ public class CMSPage extends Page implements ResourceHandler { */ public ContentSection getContentSection(HttpServletRequest request) { // Resets all content sections associations. - return ContentSectionDispatcher.getContentSection(request); + // return ContentSectionDispatcher.getContentSection(request); + return ContentSectionServlet.getContentSection(request); } /** diff --git a/ccm-cms/src/com/arsdigita/cms/dispatcher/ContentSectionDispatcher.java b/ccm-cms/src/com/arsdigita/cms/dispatcher/ContentSectionDispatcher.java index 49238a6e2..5cd8efbb0 100755 --- a/ccm-cms/src/com/arsdigita/cms/dispatcher/ContentSectionDispatcher.java +++ b/ccm-cms/src/com/arsdigita/cms/dispatcher/ContentSectionDispatcher.java @@ -27,7 +27,6 @@ import com.arsdigita.dispatcher.RequestContext; import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.kernel.Kernel; import com.arsdigita.kernel.KernelContext; -import com.arsdigita.kernel.SiteNode; import com.arsdigita.kernel.User; import com.arsdigita.sitenode.SiteNodeRequestContext; import com.arsdigita.util.Assert; @@ -104,9 +103,8 @@ public class ContentSectionDispatcher implements Dispatcher { try { - // Fetch the current site node from the request context; - SiteNode sn = actx.getSiteNode(); - ContentSection section = ContentSection.getSectionFromNode(sn); + ContentSection section = (ContentSection) ContentSection + .getCurrentApplication(request); Assert.exists(section); request.setAttribute(CONTENT_SECTION, section); diff --git a/ccm-cms/src/com/arsdigita/cms/dispatcher/ItemDispatcher.java b/ccm-cms/src/com/arsdigita/cms/dispatcher/ItemDispatcher.java index 041e98605..2baa0b52a 100755 --- a/ccm-cms/src/com/arsdigita/cms/dispatcher/ItemDispatcher.java +++ b/ccm-cms/src/com/arsdigita/cms/dispatcher/ItemDispatcher.java @@ -21,6 +21,7 @@ package com.arsdigita.cms.dispatcher; import com.arsdigita.cms.CMSExcursion; import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentSection; +import com.arsdigita.cms.ContentSectionServlet; import com.arsdigita.cms.SecurityManager; import com.arsdigita.cms.lifecycle.Lifecycle; import com.arsdigita.dispatcher.ChainedDispatcher; @@ -32,14 +33,17 @@ import com.arsdigita.kernel.Party; import com.arsdigita.kernel.User; import com.arsdigita.versioning.Transaction; import com.arsdigita.web.LoginSignal; + import java.io.IOException; import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.Map; + import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; + import org.apache.log4j.Logger; /** @@ -129,7 +133,8 @@ public class ItemDispatcher implements ChainedDispatcher { } final ContentSection section = - ContentSectionDispatcher.getContentSection(request); + ContentSectionServlet.getContentSection(request); + // ContentSectionDispatcher.getContentSection(request); final ContentItem item = getItem(section, url); if (item == null) { diff --git a/ccm-cms/src/com/arsdigita/cms/dispatcher/MultilingualItemResolver.java b/ccm-cms/src/com/arsdigita/cms/dispatcher/MultilingualItemResolver.java index 64c0d26ad..31fdc99a9 100755 --- a/ccm-cms/src/com/arsdigita/cms/dispatcher/MultilingualItemResolver.java +++ b/ccm-cms/src/com/arsdigita/cms/dispatcher/MultilingualItemResolver.java @@ -24,6 +24,7 @@ import com.arsdigita.cms.ContentBundle; import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.Folder; +import com.arsdigita.cms.Workspace; import com.arsdigita.cms.ui.ContentItemPage; import com.arsdigita.cms.util.LanguageUtil; import com.arsdigita.domain.DomainObjectFactory; @@ -245,7 +246,7 @@ public class MultilingualItemResolver extends AbstractItemResolver implements It // Determine if we are under the admin UI. - if (url.startsWith(ADMIN_PREFIX) || url.startsWith(Utilities.getWorkspaceURL())) { + if (url.startsWith(ADMIN_PREFIX) || url.startsWith(Workspace.getURL())) { return ContentItem.DRAFT; } else { return ContentItem.LIVE; diff --git a/ccm-cms/src/com/arsdigita/cms/dispatcher/SimpleItemResolver.java b/ccm-cms/src/com/arsdigita/cms/dispatcher/SimpleItemResolver.java index e62747145..f27b4a8f3 100755 --- a/ccm-cms/src/com/arsdigita/cms/dispatcher/SimpleItemResolver.java +++ b/ccm-cms/src/com/arsdigita/cms/dispatcher/SimpleItemResolver.java @@ -24,6 +24,7 @@ import com.arsdigita.cms.CMS; import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.Folder; +import com.arsdigita.cms.Workspace; import com.arsdigita.cms.ui.ContentItemPage; import com.arsdigita.cms.util.GlobalizationUtil; import com.arsdigita.dispatcher.DispatcherHelper; @@ -63,7 +64,7 @@ public class SimpleItemResolver extends AbstractItemResolver implements ItemReso Logger.getLogger(SimpleItemResolver.class.getName()); private static final String ADMIN_PREFIX = "admin"; - private static final String WORKSPACE_PREFIX = Utilities.getWorkspaceURL(); + private static final String WORKSPACE_PREFIX = Workspace.getURL(); private static MasterPage s_masterP = null; diff --git a/ccm-cms/src/com/arsdigita/cms/dispatcher/Utilities.java b/ccm-cms/src/com/arsdigita/cms/dispatcher/Utilities.java index dceef6cff..6e8414853 100755 --- a/ccm-cms/src/com/arsdigita/cms/dispatcher/Utilities.java +++ b/ccm-cms/src/com/arsdigita/cms/dispatcher/Utilities.java @@ -24,16 +24,12 @@ import com.arsdigita.cms.CMS; import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.ImageAsset; import com.arsdigita.cms.SecurityManager; +import com.arsdigita.cms.Service; +import com.arsdigita.cms.Workspace; import com.arsdigita.dispatcher.DispatcherHelper; import com.arsdigita.kernel.Kernel; import com.arsdigita.kernel.KernelContext; -import com.arsdigita.kernel.PackageInstance; -import com.arsdigita.kernel.PackageInstanceCollection; -import com.arsdigita.kernel.PackageType; -import com.arsdigita.kernel.SiteNode; -import com.arsdigita.kernel.SiteNodeCollection; import com.arsdigita.kernel.User; -import org.apache.log4j.Logger; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -43,6 +39,8 @@ import java.util.Date; import java.util.HashMap; import java.util.Map; +import org.apache.log4j.Logger; + /** *

This class provides many utility functions for the Content Management * System.

@@ -63,23 +61,20 @@ public class Utilities { public static final Logger LOG = Logger.getLogger(Utilities.class); /** - * Fetch the location of the CMS Workspace package. Caches the result. + * Fetch the location of the CMS Workspace package. * @return The URL of the CMS Workspace package - * @deprecated without direct replacement yet, refactor code to use - * legacy free code in com.arsdigita.web + * @deprecated use Workspace.getURL() instead */ public static String getWorkspaceURL() { - String url = (String) m_cache.get(CMS.WORKSPACE_PACKAGE_KEY); - if ( url == null ) { - url = getSingletonPackageURL(CMS.WORKSPACE_PACKAGE_KEY); - m_cache.put(CMS.WORKSPACE_PACKAGE_KEY, url); - } - return url; + + return Workspace.getURL(); + } /** - * Fetch the location of the CMS Services package. Caches the result. + * Fetch the location (URL) of the CMS Services package. Caches the result. * @return The URL of the CMS Services package + * @deprecated Use Service.getURL( instead */ public static String getServiceURL() { String url = (String) m_cache.get(CMS.SERVICE_PACKAGE_KEY); @@ -90,7 +85,8 @@ public class Utilities { // file that is maintained by a non cms application eg // forum, then I can end up with a url that doesn't work // and so breaks file links everywhere - url = getSingletonPackageURLSansContext(CMS.SERVICE_PACKAGE_KEY); + // url = getSingletonPackageURLSansContext(CMS.SERVICE_PACKAGE_KEY); + url = Service.getURL(); m_cache.put(CMS.SERVICE_PACKAGE_KEY, url); } @@ -102,7 +98,8 @@ public class Utilities { * @return The logout URL */ public static String getLogoutURL() { - StringBuffer buf = new StringBuffer(getServiceURL()); + //StringBuffer buf = new StringBuffer(getServiceURL()); + StringBuilder buf = new StringBuilder(Service.getURL() ); buf.append("logout"); return buf.toString(); } @@ -112,6 +109,7 @@ public class Utilities { * * @param asset The binary asset * @return the URL which will serve the specified binary asset + * @deprecated Use Service.getAssetURL(BinaryAsset asset) instead */ public static String getAssetURL(BinaryAsset asset) { return getAssetURL(asset.getID()); @@ -122,9 +120,11 @@ public class Utilities { * * @param assetId The asset ID * @return the URL which will serve the specified binary asset + * @deprecated Use Service.getAssetURL(BigDecimal assetId) instead */ public static String getAssetURL(BigDecimal assetId) { - StringBuffer buf = new StringBuffer(getServiceURL()); + // StringBuffer buf = new StringBuffer(getServiceURL()); + StringBuilder buf = new StringBuilder(Service.getURL() ); buf.append("stream/asset?"); buf.append(StreamAsset.ASSET_ID).append("=").append(assetId); return buf.toString(); @@ -137,9 +137,11 @@ public class Utilities { * * @param asset The image asset whose image is to be served * @return the URL which will serve the specified image asset + * @deprecated Use Service.getImageURL(ImageAsset) instead! */ public static String getImageURL(ImageAsset asset) { - StringBuffer buf = new StringBuffer(getServiceURL()); + // StringBuffer buf = new StringBuffer(getServiceURL()); + StringBuilder buf = new StringBuilder(Service.getURL() ); buf.append("stream/image/?"); buf.append(StreamImage.IMAGE_ID).append("=").append(asset.getID()); return buf.toString(); @@ -165,59 +167,14 @@ public class Utilities { } - /** - * Fetches the URL of a mounted instance of a package. - * @param key The package key - * @return The URL where the package is mounted - * @deprecated without direct replacement yet - */ - private static String getSingletonPackageURL(String key) { - PackageType type = null; - type = PackageType.findByKey(key); - - PackageInstanceCollection instances = type.getInstances(); - PackageInstance instance = null; - if ( !instances.next() ) { - instances.close(); - throw new RuntimeException( - "Failed to locate an instance of the singleton package: " + key); - } else { - instance = instances.getPackageInstance(); - instances.close(); - } - - SiteNodeCollection nodes = instance.getMountPoints(); - SiteNode node = null; - if ( !nodes.next() ) { - nodes.close(); - throw new RuntimeException( - "Failed to locate a mountpoint for the singleton package: " + key); - } else { - node = nodes.getSiteNode(); - nodes.close(); - } - - StringBuffer url = new StringBuffer(); - String context = getWebappContext(); - if (context != null) { - url.append(context); - } - url.append(SiteNode.getRootSiteNode().getURL()) - .append(node.getURL().substring(1)); - - LOG.debug("Single package url for " + key + " is " + url); - - return url.toString(); - } - /** * * @param key * @return - * @deprecated without replacement (singleton package is not a supported + * // @deprecated without replacement (singleton package is not a supported * property for legacy free applications.) */ - private static String getSingletonPackageURLSansContext(String key) { +/* private static String getSingletonPackageURLSansContext(String key) { PackageType type = null; type = PackageType.findByKey(key); PackageInstanceCollection instances = type.getInstances(); @@ -251,7 +208,7 @@ public class Utilities { return url.toString(); } - +*/ /** * Fetch the context path of the request. This is typically "/". @@ -377,6 +334,7 @@ public class Utilities { * * @param state The page state * @return The SecurityManager for the content section + * @deprecated Use CMS.getSecurityManager(PageState state) instead. */ public static SecurityManager getSecurityManager(PageState state) { ContentSection section = CMS.getContext().getContentSection(); diff --git a/ccm-cms/src/com/arsdigita/cms/ui/CMSApplicationPage.java b/ccm-cms/src/com/arsdigita/cms/ui/CMSApplicationPage.java index 7d0c6d870..56b8e1f11 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/CMSApplicationPage.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/CMSApplicationPage.java @@ -28,6 +28,7 @@ import com.arsdigita.bebop.page.PageTransformer; import com.arsdigita.cms.CMSExcursion; import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentSection; +import com.arsdigita.cms.ContentSectionServlet; import com.arsdigita.cms.SecurityManager; import com.arsdigita.developersupport.DeveloperSupport; import com.arsdigita.dispatcher.RequestContext; @@ -195,7 +196,8 @@ public class CMSApplicationPage extends Page { */ public ContentSection getContentSection(HttpServletRequest request) { // Resets all content sections associations. - return ContentSectionDispatcher.getContentSection(request); + // return ContentSectionDispatcher.getContentSection(request); + return ContentSectionServlet.getContentSection(request); } /** diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ContentItemNavbar.java b/ccm-cms/src/com/arsdigita/cms/ui/ContentItemNavbar.java index 31ae42d07..a598483bb 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/ContentItemNavbar.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/ContentItemNavbar.java @@ -25,7 +25,7 @@ import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.ContentType; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.PageLocations; -import com.arsdigita.cms.dispatcher.Utilities; +import com.arsdigita.cms.Workspace; import com.arsdigita.web.URL; import com.arsdigita.xml.Element; @@ -49,6 +49,12 @@ public class ContentItemNavbar extends CMSContainer { setClassAttr("item"); } + /** + * + * @param state + * @param parent + */ + @Override public void generateXML(PageState state, Element parent) { Element element = new Element("cms:breadCrumbTrail", CMS.CMS_XML_NS); @@ -57,7 +63,7 @@ public class ContentItemNavbar extends CMSContainer { ContentType type = item.getContentType(); final String url = URL.there(state.getRequest(), - Utilities.getWorkspaceURL()).toString(); + Workspace.getURL()).toString(); element.addAttribute("workspaceURL", url); element.addAttribute("sectionName", section.getName()); diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ContentItemRenderer.java b/ccm-cms/src/com/arsdigita/cms/ui/ContentItemRenderer.java index 28d84d262..c8c5d2c02 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/ContentItemRenderer.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/ContentItemRenderer.java @@ -53,6 +53,7 @@ public class ContentItemRenderer extends DomainObjectRenderer { * Generate XML for the domain object supplied by the * selection model. */ + @Override public void generateXML(PageState state, Element parent) { ContentItem item = ContentSectionDispatcher.getContentItem(state.getRequest()); Element e = generateXMLElement(item); diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ContentSectionNavbar.java b/ccm-cms/src/com/arsdigita/cms/ui/ContentSectionNavbar.java index 57430a5cc..8556ca497 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/ContentSectionNavbar.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/ContentSectionNavbar.java @@ -24,7 +24,7 @@ import com.arsdigita.bebop.Link; import com.arsdigita.bebop.PageState; import com.arsdigita.cms.CMS; import com.arsdigita.cms.ContentSection; -import com.arsdigita.cms.dispatcher.Utilities; +import com.arsdigita.cms.Workspace; import com.arsdigita.cms.util.GlobalizationUtil; import com.arsdigita.ui.UI; import com.arsdigita.xml.Element; @@ -45,7 +45,7 @@ public class ContentSectionNavbar extends CMSContainer { setClassAttr("section"); String wsUrl = UI.getWorkspaceURL(); - String csUrl = Utilities.getWorkspaceURL(); + String csUrl = Workspace.getURL(); m_navbar = new DimensionalNavbar(); m_navbar.setAlign(DimensionalNavbar.LEFT); diff --git a/ccm-cms/src/com/arsdigita/cms/ui/GlobalNavigation.java b/ccm-cms/src/com/arsdigita/cms/ui/GlobalNavigation.java index a56f86a82..614ea1a6d 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/GlobalNavigation.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/GlobalNavigation.java @@ -21,7 +21,7 @@ package com.arsdigita.cms.ui; import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.SimpleComponent; import com.arsdigita.cms.CMS; -import com.arsdigita.cms.dispatcher.Utilities; +import com.arsdigita.cms.Workspace; import com.arsdigita.ui.UI; import com.arsdigita.web.URL; import com.arsdigita.xml.Element; @@ -46,7 +46,7 @@ class GlobalNavigation extends SimpleComponent { private final String m_helpPath; GlobalNavigation() { - m_centerPath = Utilities.getWorkspaceURL(); + m_centerPath = Workspace.getURL(); m_wspcPath = UI.getWorkspaceURL(); m_signOutPath = UI.getLogoutPageURL(); m_helpPath = "/nowhere"; // We don't have this yet XXX. diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ImageBrowser.java b/ccm-cms/src/com/arsdigita/cms/ui/ImageBrowser.java index 835f73cb1..466a91c82 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/ImageBrowser.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/ImageBrowser.java @@ -30,9 +30,11 @@ import com.arsdigita.bebop.table.DefaultTableCellRenderer; import com.arsdigita.bebop.table.TableCellRenderer; import com.arsdigita.bebop.table.TableModel; import com.arsdigita.bebop.table.TableModelBuilder; +import com.arsdigita.cms.CMS; import com.arsdigita.cms.ImageAsset; import com.arsdigita.cms.SecurityManager; -import com.arsdigita.cms.dispatcher.Utilities; +import com.arsdigita.cms.Service; +// import com.arsdigita.cms.dispatcher.Utilities; import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.mimetypes.MimeType; @@ -163,7 +165,8 @@ public class ImageBrowser extends Table { boolean isSelected, Object key, int row, int column) { ImageAsset a = (ImageAsset) value; - String url = Utilities.getImageURL(a); + // String url = Utilities.getImageURL(a); + String url = Service.getImageURL(a); Image img = new Image(URL.getDispatcherPath() + url); img.setBorder("0"); @@ -202,7 +205,8 @@ public class ImageBrowser extends Table { boolean isSelected, Object key, int row, int column) { boolean canDelete = false; - SecurityManager sm = Utilities.getSecurityManager(state); + // SecurityManager sm = Utilities.getSecurityManager(state); + SecurityManager sm = CMS.getSecurityManager(state); if (sm.canAccess(state.getRequest(), SecurityManager.DELETE_IMAGES)) { try { ImageAsset asset = (ImageAsset) DomainObjectFactory.newInstance(new OID(ImageAsset.BASE_DATA_OBJECT_TYPE, (BigDecimal) key)); diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ImageDisplay.java b/ccm-cms/src/com/arsdigita/cms/ui/ImageDisplay.java index 1c89d0f35..fb97a4eba 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/ImageDisplay.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/ImageDisplay.java @@ -23,7 +23,8 @@ import com.arsdigita.bebop.SimpleComponent; import com.arsdigita.cms.CMS; import com.arsdigita.cms.ImageAsset; import com.arsdigita.cms.ItemSelectionModel; -import com.arsdigita.cms.dispatcher.Utilities; +import com.arsdigita.cms.Service; +// import com.arsdigita.cms.dispatcher.Utilities; import com.arsdigita.mimetypes.MimeType; import com.arsdigita.util.Assert; import com.arsdigita.web.URL; @@ -64,6 +65,7 @@ public class ImageDisplay extends SimpleComponent { return m_item; } + @Override public void generateXML(PageState state, Element parent) { if ( isVisible(state) ) { @@ -89,7 +91,8 @@ public class ImageDisplay extends SimpleComponent { Element element) { element.addAttribute("name", image.getName()); element.addAttribute("src", URL.getDispatcherPath() + - Utilities.getImageURL(image)); + Service.getImageURL(image)); + // Utilities.getImageURL(image)); BigDecimal width = image.getWidth(); if ( width != null ) { diff --git a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchWidget.java b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchWidget.java index e100fc74f..4724b9e46 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchWidget.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchWidget.java @@ -38,6 +38,7 @@ import com.arsdigita.bebop.util.BebopConstants; import com.arsdigita.cms.CMS; import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentType; +import com.arsdigita.cms.Workspace; import com.arsdigita.cms.dispatcher.ContentCenterDispatcher; import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.web.ParameterMap; @@ -225,9 +226,7 @@ public class ItemSearchWidget extends FormSection ItemSearchPage.class.getName()); s_log.debug("Search URL stub is: " + searchURL); - searchURL = com.arsdigita.cms.dispatcher.Utilities. - getWorkspaceURL() - + searchURL; + searchURL = Workspace.getURL() + searchURL; // TODO Not sure what to do when you get a null here diff --git a/ccm-cms/src/com/arsdigita/cms/ui/SectionConfigurationPage.java b/ccm-cms/src/com/arsdigita/cms/ui/SectionConfigurationPage.java index ae245fe7f..3562b3f9a 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/SectionConfigurationPage.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/SectionConfigurationPage.java @@ -48,6 +48,7 @@ import com.arsdigita.bebop.parameters.NotNullValidationListener; import com.arsdigita.cms.CMS; import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.SectionLocaleCollection; +import com.arsdigita.cms.Workspace; import com.arsdigita.cms.dispatcher.CMSPage; import com.arsdigita.cms.dispatcher.Utilities; import com.arsdigita.cms.util.GlobalizationUtil; @@ -181,7 +182,7 @@ public class SectionConfigurationPage extends CMSPage implements Resettable { DimensionalNavbar dn = new DimensionalNavbar(); dn.setDelimiter(" - "); - dn.add(new Link( new Label(GlobalizationUtil.globalize("cms.ui.my_workspace")), Utilities.getWorkspaceURL())); + dn.add(new Link( new Label(GlobalizationUtil.globalize("cms.ui.my_workspace")), Workspace.getURL())); dn.add(new Link( new Label(GlobalizationUtil.globalize("cms.ui.sign_out")), Utilities.getLogoutURL())); // FIXME: Write online help, for the time being, do not offer a link // dn.add(new Link( new Label(GlobalizationUtil.globalize("cms.ui.help")), "help")); diff --git a/ccm-cms/src/com/arsdigita/cms/ui/WorkspaceContextBar.java b/ccm-cms/src/com/arsdigita/cms/ui/WorkspaceContextBar.java index 3d20b9fea..1a1ee926e 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/WorkspaceContextBar.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/WorkspaceContextBar.java @@ -19,7 +19,7 @@ package com.arsdigita.cms.ui; import com.arsdigita.bebop.PageState; -import com.arsdigita.cms.dispatcher.Utilities; +import com.arsdigita.cms.Workspace; import com.arsdigita.toolbox.ui.ContextBar; import com.arsdigita.web.URL; import org.apache.log4j.Logger; @@ -37,11 +37,12 @@ class WorkspaceContextBar extends ContextBar { private static final Logger s_log = Logger.getLogger (WorkspaceContextBar.class); + @Override protected List entries(final PageState state) { final List entries = super.entries(state); final String centerTitle = lz("cms.ui.content_center"); - final String centerPath = Utilities.getWorkspaceURL(); + final String centerPath = Workspace.getURL(); final URL url = URL.there(state.getRequest(), centerPath); entries.add(new Entry(centerTitle, url)); diff --git a/ccm-cms/src/com/arsdigita/cms/ui/lifecycle/ItemLifecycleItemPane.java b/ccm-cms/src/com/arsdigita/cms/ui/lifecycle/ItemLifecycleItemPane.java index 669eed592..cd80d2dc6 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/lifecycle/ItemLifecycleItemPane.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/lifecycle/ItemLifecycleItemPane.java @@ -46,6 +46,7 @@ import com.arsdigita.cms.CMSConfig; import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.SecurityManager; +import com.arsdigita.cms.Workspace; import com.arsdigita.cms.dispatcher.Utilities; import com.arsdigita.cms.lifecycle.Lifecycle; import com.arsdigita.cms.ui.BaseItemPane; @@ -274,7 +275,7 @@ class ItemLifecycleItemPane extends BaseItemPane { if (ContentSection.getConfig().getUseStreamlinedCreation()) { throw new RedirectSignal( URL.there(state.getRequest(), - Utilities.getWorkspaceURL()), true); + Workspace.getURL()), true); } } } @@ -361,7 +362,7 @@ class ItemLifecycleItemPane extends BaseItemPane { if (ContentSection.getConfig().getUseStreamlinedCreation()) { throw new RedirectSignal( URL.there(state.getRequest(), - Utilities.getWorkspaceURL()), true); + Workspace.getURL()), true); } } } @@ -529,7 +530,7 @@ class ItemLifecycleItemPane extends BaseItemPane { if (ContentSection.getConfig().getUseStreamlinedCreation()) { throw new RedirectSignal( URL.there(state.getRequest(), - Utilities.getWorkspaceURL()), true); + Workspace.getURL()), true); } } } else if (REPUBLISH_AND_RESET.equals(selected)) { @@ -564,7 +565,7 @@ class ItemLifecycleItemPane extends BaseItemPane { if (ContentSection.getConfig().getUseStreamlinedCreation()) { throw new RedirectSignal( URL.there(state.getRequest(), - Utilities.getWorkspaceURL()), true); + Workspace.getURL()), true); } } } else if (UNPUBLISH.equals(selected)) { diff --git a/ccm-cms/src/com/arsdigita/cms/ui/lifecycle/ItemLifecycleSelectForm.java b/ccm-cms/src/com/arsdigita/cms/ui/lifecycle/ItemLifecycleSelectForm.java index e9b69c627..10e394c7f 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/lifecycle/ItemLifecycleSelectForm.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/lifecycle/ItemLifecycleSelectForm.java @@ -54,7 +54,7 @@ import com.arsdigita.cms.CMSConfig; import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.ContentTypeLifecycleDefinition; -import com.arsdigita.cms.dispatcher.Utilities; +import com.arsdigita.cms.Workspace; import com.arsdigita.cms.lifecycle.Lifecycle; import com.arsdigita.cms.lifecycle.LifecycleDefinition; import com.arsdigita.cms.lifecycle.LifecycleDefinitionCollection; @@ -417,7 +417,7 @@ class ItemLifecycleSelectForm extends BaseForm { if (ContentSection.getConfig().getUseStreamlinedCreation()) { throw new RedirectSignal( URL.there(state.getRequest(), - Utilities.getWorkspaceURL()), + Workspace.getURL()), true); } } diff --git a/ccm-cms/src/com/arsdigita/cms/ui/portlet/TaskPortletRenderer.java b/ccm-cms/src/com/arsdigita/cms/ui/portlet/TaskPortletRenderer.java index c85e2bc2b..3c86d24a4 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/portlet/TaskPortletRenderer.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/portlet/TaskPortletRenderer.java @@ -23,7 +23,7 @@ import com.arsdigita.bebop.SimpleContainer; import com.arsdigita.bebop.portal.AbstractPortletRenderer; import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentSection; -import com.arsdigita.cms.dispatcher.Utilities; +import com.arsdigita.cms.Workspace; import com.arsdigita.cms.portlet.TaskPortlet; import com.arsdigita.cms.ui.ContentItemPage; import com.arsdigita.cms.util.GlobalizationUtil; @@ -63,7 +63,7 @@ public class TaskPortletRenderer extends AbstractPortletRenderer { protected void generateBodyXML(PageState pageState, Element parentElement) { - final String contentCenter = Utilities.getWorkspaceURL(); + final String contentCenter = Workspace.getURL(); Link link = new Link("Content Center", contentCenter); diff --git a/ccm-cms/src/com/arsdigita/cms/ui/templates/CategoryTemplates.java b/ccm-cms/src/com/arsdigita/cms/ui/templates/CategoryTemplates.java index cee481410..c888974aa 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/templates/CategoryTemplates.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/templates/CategoryTemplates.java @@ -51,6 +51,7 @@ import com.arsdigita.categorization.Category; import com.arsdigita.cms.CMS; import com.arsdigita.cms.CategoryTemplateMapping; import com.arsdigita.cms.ContentSection; +import com.arsdigita.cms.ContentSectionServlet; import com.arsdigita.cms.ContentType; import com.arsdigita.cms.ContentTypeCollection; import com.arsdigita.cms.SectionTemplateMapping; @@ -59,7 +60,6 @@ import com.arsdigita.cms.Template; import com.arsdigita.cms.TemplateCollection; import com.arsdigita.cms.TemplateManager; import com.arsdigita.cms.TemplateManagerFactory; -import com.arsdigita.cms.dispatcher.ContentSectionDispatcher; import com.arsdigita.cms.ui.CMSContainer; import com.arsdigita.cms.ui.FormSecurityListener; import com.arsdigita.cms.ui.category.CategoryComponentAccess; @@ -157,6 +157,7 @@ public class CategoryTemplates extends CMSContainer { add(m_assign); } + @Override public void register(Page p) { super.register(p); @@ -183,6 +184,7 @@ public class CategoryTemplates extends CMSContainer { String useContext) { } + @Override public void register(Page p) { super.register(p); @@ -232,6 +234,7 @@ public class CategoryTemplates extends CMSContainer { new AssignCellRenderer()); addTableActionListener(new TableActionAdapter() { + @Override public void cellSelected(TableActionEvent e) { PageState s = e.getPageState(); TemplatesListing l = (TemplatesListing)e.getSource(); @@ -242,7 +245,8 @@ public class CategoryTemplates extends CMSContainer { // created statically if(c == m_assignCol) { SectionTemplateMapping m = - (SectionTemplateMapping)getMappingModel().getSelectedObject(s); + (SectionTemplateMapping)getMappingModel() + .getSelectedObject(s); assignTemplate(s, m.getTemplate()); } } @@ -253,7 +257,7 @@ public class CategoryTemplates extends CMSContainer { * Get all the templates for the given type in the current section */ protected TemplateCollection getTemplateCollection(PageState s) { - ContentSection sec = ContentSectionDispatcher.getContentSection(s.getRequest()); + ContentSection sec = ContentSectionServlet.getContentSection(s.getRequest()); Assert.exists(sec, "content section"); /* @@ -298,7 +302,8 @@ public class CategoryTemplates extends CMSContainer { map.setUseContext(useContext); map.setTemplate(t); } - map.setContentSection(ContentSectionDispatcher.getContentSection(s.getRequest())); + map.setContentSection(ContentSectionServlet + .getContentSection(s.getRequest())); map.save(); m_display.setVisible(s, true); @@ -317,7 +322,8 @@ public class CategoryTemplates extends CMSContainer { m_link.setClassAttr("assignTemplateLink"); } - public Component getComponent(Table table, PageState state, Object value, + public Component getComponent(Table table, PageState state, + Object value, boolean isSelected, Object key, int row, int column) { return m_link; @@ -326,6 +332,9 @@ public class CategoryTemplates extends CMSContainer { } + /** + * + */ private class AssignForm extends Form { SingleSelect m_type; @@ -345,22 +354,24 @@ public class CategoryTemplates extends CMSContainer { m_type = new SingleSelect(type.getStateParameter()); try { m_type.addPrintListener(new PrintListener() { - public void prepare(PrintEvent e) { - PageState state = e.getPageState(); - ContentSection section = ContentSectionDispatcher.getContentSection(state.getRequest()); + public void prepare(PrintEvent e) { + PageState state = e.getPageState(); + ContentSection section = ContentSectionServlet + .getContentSection(state + .getRequest()); - SingleSelect target = (SingleSelect)e.getTarget(); + SingleSelect target = (SingleSelect)e.getTarget(); - ContentTypeCollection types = section.getContentTypes(); - types.addOrder(ContentType.LABEL); + ContentTypeCollection types = section.getContentTypes(); + types.addOrder(ContentType.LABEL); - while (types.next()) { - ContentType type = types.getContentType(); - target.addOption(new Option(type.getID().toString(), - type.getLabel())); - } + while (types.next()) { + ContentType type = types.getContentType(); + target.addOption(new Option(type.getID().toString(), + type.getLabel())); } - }); + } + }); } catch (TooManyListenersException ex) { throw new UncheckedWrapperException("This can never happen", ex); } @@ -369,30 +380,7 @@ public class CategoryTemplates extends CMSContainer { // XXX no need for selecting template contexts currently m_context = new Hidden(context.getStateParameter()); m_context.setDefaultValue(TemplateManager.PUBLIC_CONTEXT); - /* - m_context = new SingleSelect(context.getStateParameter()); - try { - m_context.addPrintListener(new PrintListener() { - public void prepare(PrintEvent e) { - PageState state = e.getPageState(); - SingleSelect target = (SingleSelect)e.getTarget(); - - TemplateContextCollection contexts = TemplateContext.retrieveAll(); - contexts.addOrder(TemplateContext.LABEL); - - while (contexts.next()) { - TemplateContext type = contexts.getTemplateContext(); - target.addOption(new Option(type.getContext(), - type.getLabel())); - } - context.setSelectedKey(state, TemplateManager.PUBLIC_CONTEXT); - } - }); - } catch (TooManyListenersException ex) { - throw new UncheckedWrapperException("This can never happen", ex); - } - */ add(m_context); add(new Submit("Assign template")); diff --git a/ccm-cms/src/com/arsdigita/cms/ui/workflow/TaskFinishForm.java b/ccm-cms/src/com/arsdigita/cms/ui/workflow/TaskFinishForm.java index 7bdd29a19..1787b02ec 100755 --- a/ccm-cms/src/com/arsdigita/cms/ui/workflow/TaskFinishForm.java +++ b/ccm-cms/src/com/arsdigita/cms/ui/workflow/TaskFinishForm.java @@ -30,7 +30,7 @@ import com.arsdigita.bebop.form.Option; import com.arsdigita.bebop.form.RadioGroup; import com.arsdigita.bebop.parameters.BooleanParameter; import com.arsdigita.cms.ContentSection; -import com.arsdigita.cms.dispatcher.Utilities; +import com.arsdigita.cms.Workspace; import com.arsdigita.cms.ui.ContentItemPage; import com.arsdigita.cms.workflow.CMSEngine; import com.arsdigita.cms.workflow.CMSTask; @@ -39,7 +39,6 @@ import com.arsdigita.kernel.Kernel; import com.arsdigita.kernel.Party; import com.arsdigita.kernel.permissions.PermissionDescriptor; import com.arsdigita.kernel.permissions.PermissionService; -import com.arsdigita.util.UncheckedWrapperException; import com.arsdigita.web.RedirectSignal; import com.arsdigita.web.URL; import com.arsdigita.web.Web; @@ -206,7 +205,7 @@ public final class TaskFinishForm extends CommentAddForm { if (ContentSection.getConfig().getUseStreamlinedCreation()) { throw new RedirectSignal (URL.there(state.getRequest(), - Utilities.getWorkspaceURL()), + Workspace.getURL()), true); } diff --git a/ccm-core/src/com/arsdigita/categorization/Categorization.java b/ccm-core/src/com/arsdigita/categorization/Categorization.java index 43256039f..bc56e10b8 100755 --- a/ccm-core/src/com/arsdigita/categorization/Categorization.java +++ b/ccm-core/src/com/arsdigita/categorization/Categorization.java @@ -19,7 +19,7 @@ package com.arsdigita.categorization; import com.arsdigita.kernel.ACSObject; -import com.arsdigita.kernel.SiteNode; +// import com.arsdigita.kernel.SiteNode; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -34,21 +34,25 @@ public class Categorization { private static List s_categoryListeners = new ArrayList(); +/* No longer used. Client methods are removed. public static final String CONTEXT_NAVIGATION = "navigation"; - +*/ /** * A wrapper for {@link Categorization#getGlobalRootCategory(String) * getGlobalRootCategory(Categorization.CONTEXT_NAVIGATION)}. * @see #getGlobalRootCategory() **/ - public static Category getGlobalRootCategory() { +/* No longer used. Removed because we no longer support old type applications + and SiteNode + public static Category getGlobalRootCategory() { return getGlobalRootCategory(CONTEXT_NAVIGATION); } - +*/ /** * @see Category#getRootForObject(com.arsdigita.kernel.ACSObject) **/ - public static Category getGlobalRootCategory(String context) { +/* Not use anymore. We no longer support old type applications and SiteNode + private static Category getGlobalRootCategory(String context) { // XXX change this impl. // XXX support context Category root = Category.getRootForObject( @@ -56,7 +60,7 @@ public class Categorization { ); return root; } - +*/ public static void addCategoryListener(CategoryListener cl) { s_categoryListeners.add(cl); } diff --git a/ccm-core/src/com/arsdigita/templating/ApplicationPatternGenerator.java b/ccm-core/src/com/arsdigita/templating/ApplicationPatternGenerator.java index fa9d7a85a..92da3d3ac 100755 --- a/ccm-core/src/com/arsdigita/templating/ApplicationPatternGenerator.java +++ b/ccm-core/src/com/arsdigita/templating/ApplicationPatternGenerator.java @@ -67,7 +67,11 @@ public class ApplicationPatternGenerator implements PatternGenerator { // 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. - s_log.warn("ApplicationType for >>" +key + + // 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."); diff --git a/ccm-core/src/com/arsdigita/templating/URLPatternGenerator.java b/ccm-core/src/com/arsdigita/templating/URLPatternGenerator.java index bfde13290..fe9479812 100755 --- a/ccm-core/src/com/arsdigita/templating/URLPatternGenerator.java +++ b/ccm-core/src/com/arsdigita/templating/URLPatternGenerator.java @@ -23,10 +23,9 @@ import com.arsdigita.web.Web; import com.arsdigita.util.StringUtils; import com.arsdigita.dispatcher.DispatcherHelper; -import com.arsdigita.sitenode.SiteNodeRequestContext; -import com.arsdigita.kernel.SiteNode; import com.arsdigita.util.Assert; +import com.arsdigita.web.Application; import javax.servlet.http.HttpServletRequest; import org.apache.log4j.Logger; @@ -140,14 +139,27 @@ public class URLPatternGenerator implements PatternGenerator { return url.substring(base.length()-1); } - // XXX fix me, why can't we get this from Web.getConfig.getRequestURL + /** + * Provides the base URL of the application in the current Web request + * (i.e. application's PrimaryURL) + * + * XXX fix me, why can't we get this from Web.getConfig.getRequestURL + * + * @return primary url of an application + */ private String getBasePath() { - SiteNodeRequestContext ctx = (SiteNodeRequestContext) - DispatcherHelper.getRequestContext(Web.getRequest()); + +// OLD code using kernel.SiteNode etc which is deprecatged and no longer +// available +// SiteNodeRequestContext ctx = (SiteNodeRequestContext) +// DispatcherHelper.getRequestContext(Web.getRequest()); +// SiteNode node = ctx.getSiteNode(); +// Assert.exists(node, SiteNode.class); +// return node.getURL(); - SiteNode node = ctx.getSiteNode(); - Assert.exists(node, SiteNode.class); - return node.getURL(); + // retrieve the application of the request + Application app = Web.getContext().getApplication(); + return app.getPrimaryURL(); } } diff --git a/ccm-core/src/com/arsdigita/ui/login/UserInfo.java b/ccm-core/src/com/arsdigita/ui/login/UserInfo.java index 318ebcded..bb44af1d3 100755 --- a/ccm-core/src/com/arsdigita/ui/login/UserInfo.java +++ b/ccm-core/src/com/arsdigita/ui/login/UserInfo.java @@ -24,24 +24,20 @@ import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.SimpleComponent; import com.arsdigita.bebop.SimpleContainer; import com.arsdigita.kernel.User; -import com.arsdigita.kernel.PackageInstanceCollection; -import com.arsdigita.kernel.PackageInstance; -import com.arsdigita.kernel.SiteNode; -import com.arsdigita.kernel.SiteNodeCollection; -import com.arsdigita.kernel.PackageType; -import com.arsdigita.persistence.DataCollection; -import com.arsdigita.persistence.SessionManager; import com.arsdigita.ui.UI; +import com.arsdigita.web.Application; +import com.arsdigita.web.ApplicationCollection; +import com.arsdigita.web.ApplicationType; +import com.arsdigita.web.ApplicationTypeCollection; import com.arsdigita.web.URL; import com.arsdigita.xml.Element; import java.util.ArrayList; import java.util.List; -import java.util.HashMap; import java.util.Iterator; - import org.apache.log4j.Logger; + /** * A reusable Bebop component to display the primary attributes of the * currently logged in user. Users can extend this class to provide @@ -49,29 +45,27 @@ import org.apache.log4j.Logger; * UserInfo#register(Page)} and {@link UserInfo#getUser(PageState)} * methods. * - * * @author Michael Bryzek * @author Roger Hsueh * @author Sameer Ajmani + * @author Peter Boy (refactored to eliminate old type kernel.Package* / SiteNode) * @since 2001-06-01 * @version 1.0 * @version $Id: UserInfo.java 287 2005-02-22 00:29:02Z sskracic $ - * - **/ + */ public class UserInfo extends SimpleContainer { + /** Logger instance for debugging support */ private static final Logger s_log = - Logger.getLogger(UserInfo.class.getName()); + Logger.getLogger(UserInfo.class.getName()); - /** m_contentCenters holds a list of content centers that exist - on this installation */ + /** Holds a list of content centers (Application instances) that exist + * on this installation. Usually there is only ONE installed, but obviously + * care is taken that one content-center may be installed per subsite. */ private List m_contentCenters; - /** m_centerSiteNodes contains a mapping of content centers to the - site nodes where they are mounted. */ - private HashMap m_centerSiteNodes; private UserAuthenticationListener m_listener = - new UserAuthenticationListener(); + new UserAuthenticationListener(); /** * Constructor. @@ -86,101 +80,107 @@ public class UserInfo extends SimpleContainer { list.add(new DynamicLink("login.userInfo.changePasswordLink", UI.getRecoverPasswordPageURL())); add(list); + // add user info text add(new SimpleComponent() { @Override - public void generateXML(PageState state, Element parent) { - if (!isLoggedIn(state)) { - s_log.debug("user is not logged in, so no XML generated"); - return; + public void generateXML(PageState state, Element parent) { + if (!isLoggedIn(state)) { + s_log.debug("user is not logged in, so no XML generated"); + return; + } + User user = getUser(state); + + Element userElement = new Element("subsite:userInfo", + SubsiteDispatcher.SUBSITE_NS_URI); + + // check if Content-Center (CMS Workspace) is installed and + // instantiated, if so collect all instantiated workspace apps. + if (m_contentCenters == null) { + + m_contentCenters = new ArrayList(); + + ApplicationTypeCollection + appTypes = ApplicationType + .retrieveAllApplicationTypes(); + appTypes.addEqualsFilter("title", "Content Center"); + String objectType; + if (appTypes.next()) { + objectType = appTypes.getApplicationObjectType(); + } else { + objectType = null; } - User user = getUser(state); - Element userElement = new Element - ("subsite:userInfo", SubsiteDispatcher.SUBSITE_NS_URI); - - if (m_contentCenters == null) { - m_contentCenters = new ArrayList(); - m_centerSiteNodes = new HashMap(); - - // XXX has to refactored! - // used old style packageType to retrieve a list of installed - // content-centers. Odd, there may exist only one content-center per - // installation! - // Currently (version 6.6.0 2011-02-06) content-center = workspace - // exists as legacy application only, not as legacy compatible application! + // If application type CMS Workspace is installed: + if (objectType != null) { // retrieve all packages of type content-center // works because there may be only one. - DataCollection dc = SessionManager.getSession().retrieve - (PackageType.BASE_DATA_OBJECT_TYPE); - dc.addEqualsFilter("packageKey", "content-center"); + ApplicationCollection workspaceInstances = Application + .retrieveAllApplications(objectType); - if (dc.next()) { - // works because there may be only one entry of - // package type content-center - PackageType pt = new PackageType(dc.getDataObject()); - dc.close(); - - PackageInstanceCollection collection = pt.getInstances(); - while (collection.next()) { - PackageInstance instance = collection.getPackageInstance(); - instance.disconnect(); - m_contentCenters.add(instance); - SiteNodeCollection nodes = instance.getMountPoints(); - ArrayList list = new ArrayList(); - while (nodes.next()) { - SiteNode sn = nodes.getSiteNode(); - sn.disconnect(); - list.add(sn); - } - m_centerSiteNodes.put(instance, list); - } + // step through collection of instances of type Workspace + // generally there is only a single instance, but obviously + // code takes care provided therfe is an instance for + // each subsite. + while (workspaceInstances.next()) { + // retrieve one Workspace instance of collection + Application workspaceInstance = (Application) + workspaceInstances.getApplication(); + // Add Workspace instance to internal map + m_contentCenters.add(workspaceInstance); } } - - if (m_contentCenters.size() > 0) { - Element center; - Element nodeURL; - List nodes; - Iterator nodesIterator; - Element contentCenters = userElement.newChildElement - ("subsite:contentCenters", SubsiteDispatcher.SUBSITE_NS_URI); - Iterator centers = m_contentCenters.iterator(); - while (centers.hasNext()) { - PackageInstance instance = (PackageInstance) centers.next(); - center = contentCenters.newChildElement - ("subsite:center", SubsiteDispatcher.SUBSITE_NS_URI); - center.addAttribute("name", instance.getName()); - nodes = (List)m_centerSiteNodes.get(instance); - if (nodes != null) { - nodesIterator = nodes.iterator(); - while (nodesIterator.hasNext()) { - SiteNode node = (SiteNode) nodesIterator.next(); - nodeURL = center.newChildElement - ("subsite:url", SubsiteDispatcher.SUBSITE_NS_URI); - - final URL url = URL.there - (state.getRequest(), node.getURL()); - - nodeURL.setText(url.toString()); - } - } - } - } - - userElement.addAttribute("id", - user.getID().toString()); - userElement.addAttribute - ("email", - user.getPrimaryEmail().getEmailAddress()); - userElement.addAttribute("name", user.getName()); - userElement.addAttribute("screenName", - user.getScreenName()); - userElement.addAttribute("URI", user.getURI()); - - parent.addContent(userElement); } - }); + + // work on the list of installed (instantiated) + // workspaces (content-centers) if any and add some attributes + // to XML generator + if (m_contentCenters.size() > 0) { + + Element center; + Element workspaceURL; + Element contentCenters = userElement.newChildElement + ("subsite:contentCenters", + SubsiteDispatcher.SUBSITE_NS_URI); + + // step through instantiated workspaces (content-centers) + Iterator centers = m_contentCenters.iterator(); + while (centers.hasNext()) { + + Application workspaceInstance = (Application)centers.next(); + + // for each instance of Workspace = for each installed + // (instantiated) Workspace application: + // Add an Element + center = contentCenters.newChildElement + ("subsite:center", + SubsiteDispatcher.SUBSITE_NS_URI); + + // Add attribute name = URL without trailing/leading "/" + center.addAttribute("name", workspaceInstance.getTitle()); + + workspaceURL = center.newChildElement( + "subsite:url", + SubsiteDispatcher.SUBSITE_NS_URI); + + // get URL of Workspace application (instance) + final URL url = URL.there(state.getRequest(), + workspaceInstance.getPath()); + workspaceURL.setText(url.toString()); + } + } + + // in any case: add basic user attributes + userElement.addAttribute("id", user.getID().toString()); + userElement.addAttribute("email",user.getPrimaryEmail() + .getEmailAddress()); + userElement.addAttribute("name", user.getName()); + userElement.addAttribute("screenName",user.getScreenName()); + userElement.addAttribute("URI", user.getURI()); + + parent.addContent(userElement); + } + }); } /** @@ -191,6 +191,7 @@ public class UserInfo extends SimpleContainer { * * @pre p != null **/ + @Override public void register(Page p) { super.register(p); p.addRequestListener(m_listener); diff --git a/ccm-docmgr/src/com/arsdigita/cms/docmgr/Repository.java b/ccm-docmgr/src/com/arsdigita/cms/docmgr/Repository.java index d8ff77963..c15677c72 100755 --- a/ccm-docmgr/src/com/arsdigita/cms/docmgr/Repository.java +++ b/ccm-docmgr/src/com/arsdigita/cms/docmgr/Repository.java @@ -15,8 +15,6 @@ package com.arsdigita.cms.docmgr; -import com.arsdigita.cms.docmgr.installer.Initializer; -import com.arsdigita.cms.docmgr.util.GlobalizationUtil; import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.ContentSectionCollection; import com.arsdigita.domain.DataObjectNotFoundException; @@ -24,22 +22,18 @@ import com.arsdigita.kernel.Group; import com.arsdigita.kernel.Kernel; import com.arsdigita.kernel.KernelExcursion; import com.arsdigita.kernel.Party; -import com.arsdigita.kernel.SiteNode; import com.arsdigita.kernel.User; -import com.arsdigita.kernel.permissions.PermissionDescriptor; +// import com.arsdigita.kernel.permissions.PermissionDescriptor; import com.arsdigita.kernel.permissions.PermissionService; -import com.arsdigita.kernel.permissions.PrivilegeDescriptor; -import com.arsdigita.persistence.DataObject; +// import com.arsdigita.kernel.permissions.PrivilegeDescriptor; import com.arsdigita.persistence.OID; import com.arsdigita.persistence.SessionManager; -import com.arsdigita.persistence.Session; import com.arsdigita.persistence.DataCollection; import com.arsdigita.persistence.DataObject; import com.arsdigita.util.UncheckedWrapperException; import com.arsdigita.web.Application; import com.arsdigita.web.Web; -import com.arsdigita.web.ApplicationCollection; import com.arsdigita.util.Assert; import java.math.BigDecimal; diff --git a/ccm-docmgr/src/com/arsdigita/cms/docmgr/dispatcher/MultilingualDocumentResolver.java b/ccm-docmgr/src/com/arsdigita/cms/docmgr/dispatcher/MultilingualDocumentResolver.java index ea74f0fd8..00fce509e 100755 --- a/ccm-docmgr/src/com/arsdigita/cms/docmgr/dispatcher/MultilingualDocumentResolver.java +++ b/ccm-docmgr/src/com/arsdigita/cms/docmgr/dispatcher/MultilingualDocumentResolver.java @@ -32,12 +32,12 @@ import com.arsdigita.cms.ContentBundle; import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.Folder; +import com.arsdigita.cms.Workspace; import com.arsdigita.cms.dispatcher.AbstractItemResolver; import com.arsdigita.cms.dispatcher.CMSDispatcher; import com.arsdigita.cms.dispatcher.CMSPage; import com.arsdigita.cms.dispatcher.ItemResolver; import com.arsdigita.cms.dispatcher.MasterPage; -import com.arsdigita.cms.dispatcher.Utilities; import com.arsdigita.cms.ui.ContentItemPage; import com.arsdigita.cms.util.LanguageUtil; import com.arsdigita.domain.DomainObjectFactory; @@ -58,16 +58,17 @@ import com.arsdigita.web.Web; * Created Mon Jan 20 14:30:03 2003. * * @author Michael Hanisch - * @version $Id: //apps/docmgr-cms/dev/src/com/arsdigita/cms/docmgr/dispatcher/MultilingualDocumentResolver.java#1 $ + * @version $Id: MultilingualDocumentResolver.java#1 $ */ -public class MultilingualDocumentResolver extends AbstractItemResolver implements ItemResolver { +public class MultilingualDocumentResolver extends AbstractItemResolver + implements ItemResolver { private static final Logger s_log = Logger.getLogger (MultilingualDocumentResolver.class); private static MasterPage s_masterP = null; private static final String ADMIN_PREFIX = "admin"; - private static final String WORKSPACE_PREFIX = Utilities.getWorkspaceURL(); + private static final String WORKSPACE_PREFIX = Workspace.getURL(); /** * The string identifying an item's ID in the query string of a @@ -727,7 +728,8 @@ public class MultilingualDocumentResolver extends AbstractItemResolver implement // will have deal with 'foo' folder. String name = index > 0 ? url.substring(0, index) : ""; - parentFolder = name != "" ? (Folder) parentFolder.getItem(name, true) : parentFolder; + parentFolder = name != "" ? (Folder) parentFolder.getItem(name, true) + : parentFolder; url = index + 1 < len ? url.substring(index + 1) : ""; return getItemFromLiveURL(url, parentFolder); diff --git a/ccm-ldn-terms/src/com/arsdigita/london/terms/importer/TermItemBuilder.java b/ccm-ldn-terms/src/com/arsdigita/london/terms/importer/TermItemBuilder.java index 46dd3738a..b82d85eed 100755 --- a/ccm-ldn-terms/src/com/arsdigita/london/terms/importer/TermItemBuilder.java +++ b/ccm-ldn-terms/src/com/arsdigita/london/terms/importer/TermItemBuilder.java @@ -25,8 +25,6 @@ import org.apache.log4j.Logger; import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentSection; import com.arsdigita.cms.Folder; -import com.arsdigita.domain.DataObjectNotFoundException; -import com.arsdigita.kernel.SiteNode; import com.arsdigita.london.terms.Domain; import com.arsdigita.london.terms.Term; import com.arsdigita.util.Assert; @@ -53,22 +51,12 @@ public class TermItemBuilder { Assert.exists(path, String.class); Term term = m_domain.getTerm(id); - - SiteNode node = null; - try { - s_log.debug(String.format("Trying to get SiteNode for path '%s", - path)); - node = SiteNode.getSiteNode(path); - } catch (DataObjectNotFoundException ex) { - s_log.error("Couldn't fetch sitenode for " + path); - return; - } ContentSection section = null; - section = ContentSection.getSectionFromNode(node); + section = ContentSection.getSectionForPath(path); String[] bits = StringUtils.split( - path.substring(node.getURL().length(), + path.substring(section.getURL().length(), path.length()), '/'); diff --git a/ccm-sci-bundle/bundles/devel/cfg/web-sci.xml b/ccm-sci-bundle/bundles/devel/cfg/web-sci.xml index a27f152ea..f036018a8 100644 --- a/ccm-sci-bundle/bundles/devel/cfg/web-sci.xml +++ b/ccm-sci-bundle/bundles/devel/cfg/web-sci.xml @@ -163,6 +163,11 @@ com.arsdigita.cms.ContentSectionServlet + + cms-service + com.arsdigita.cms.ServiceServlet + + content-type-xsl com.arsdigita.cms.dispatcher.ContentTypeXSLServlet @@ -178,7 +183,6 @@ com.arsdigita.cms.dispatcher.TemplateXSLServlet - TextOnlyServlet Text Only Servlet @@ -501,6 +505,11 @@ /themes/servlet/content-section/* + + cms-service + /templates/servlet/cms-service/* + + content-item-xsl /templates/servlet/content-item/* diff --git a/ccm-simplesurvey/src/com/arsdigita/simplesurvey/Survey.java b/ccm-simplesurvey/src/com/arsdigita/simplesurvey/Survey.java index 3a6aa359f..57603a569 100755 --- a/ccm-simplesurvey/src/com/arsdigita/simplesurvey/Survey.java +++ b/ccm-simplesurvey/src/com/arsdigita/simplesurvey/Survey.java @@ -101,21 +101,31 @@ public class Survey extends ACSObject { return survey; } - public static SurveyCollection retrieveByPackage(PackageInstance pack) { - DataCollection surveys = - SessionManager.getSession().retrieve(BASE_DATA_OBJECT_TYPE); + /** + * Retrieves a SurveyCollection of all Surveys ever created, sorted by + * its start date. + * + * @return + */ + public static SurveyCollection retrieveAll() { + + DataCollection surveys = SessionManager.getSession() + .retrieve(BASE_DATA_OBJECT_TYPE); - /* + /* surveys.addEqualsFilter(PACKAGE_INSTANCE + "." + ACSObject.ID, - pack.getID()); + pack.getID()); */ surveys.addOrder(START_DATE); - - return new SurveyCollection(surveys); + return new SurveyCollection(surveys); } + /** + * + * @return + */ public ResponseCollection getResponses() { - return Response.retrieveBySurvey(this); + return Response.retrieveBySurvey(this); } public ResponseCollection getUserResponses(User user) { diff --git a/ccm-simplesurvey/src/com/arsdigita/simplesurvey/ui/SimpleSurveyPanel.java b/ccm-simplesurvey/src/com/arsdigita/simplesurvey/ui/SimpleSurveyPanel.java index 43cf56647..d7d1a7500 100755 --- a/ccm-simplesurvey/src/com/arsdigita/simplesurvey/ui/SimpleSurveyPanel.java +++ b/ccm-simplesurvey/src/com/arsdigita/simplesurvey/ui/SimpleSurveyPanel.java @@ -29,10 +29,12 @@ import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.SimpleContainer; import com.arsdigita.bebop.event.PrintListener; import com.arsdigita.bebop.event.PrintEvent; -import com.arsdigita.kernel.SiteNode; +// import com.arsdigita.kernel.SiteNode; import com.arsdigita.ui.UI; import com.arsdigita.ui.login.UserAuthenticationListener; +import com.arsdigita.web.Application; +import com.arsdigita.web.Web; import javax.servlet.http.HttpServletRequest; @@ -109,16 +111,24 @@ public abstract class SimpleSurveyPanel extends SimpleContainer { public abstract String getRelativeURL(); + /** + * + * @param request + * @return + */ public static String getSubsiteURL(HttpServletRequest request) { - // Get the SiteNode from the request URI - SiteNode siteNode; - try { - siteNode = SiteNode.getSiteNode(request.getRequestURI(), true); - } catch (com.arsdigita.domain.DataObjectNotFoundException e) { - throw new com.arsdigita.util.UncheckedWrapperException(e); - } + // Get the SiteNode from the request URI + // SiteNode siteNode; + // try { + // siteNode = SiteNode.getSiteNode(request.getRequestURI(), true); + // } catch (com.arsdigita.domain.DataObjectNotFoundException e) { + // throw new com.arsdigita.util.UncheckedWrapperException(e); + // } + // return siteNode.getURL(); - return siteNode.getURL(); + // Application app = Web.getContext().getApplication(); + Application thisApp = Application.getCurrentApplication(request); + return thisApp.getPrimaryURL(); } } diff --git a/ccm-simplesurvey/src/com/arsdigita/simplesurvey/ui/SurveyTable.java b/ccm-simplesurvey/src/com/arsdigita/simplesurvey/ui/SurveyTable.java index 3302e69ad..be0c60268 100755 --- a/ccm-simplesurvey/src/com/arsdigita/simplesurvey/ui/SurveyTable.java +++ b/ccm-simplesurvey/src/com/arsdigita/simplesurvey/ui/SurveyTable.java @@ -28,7 +28,6 @@ import java.util.Date; import com.arsdigita.persistence.Filter; import com.arsdigita.kernel.ACSObject; -import com.arsdigita.kernel.PackageInstance; import com.arsdigita.bebop.Table; import com.arsdigita.bebop.table.TableModelBuilder; import com.arsdigita.bebop.table.TableModel; @@ -37,8 +36,6 @@ import com.arsdigita.bebop.table.TableCellRenderer; import com.arsdigita.util.LockableImpl; import com.arsdigita.formbuilder.PersistentForm; -import com.arsdigita.simplesurvey.SimpleSurveyUtil; - import com.arsdigita.bebop.Component; import com.arsdigita.simplesurvey.Survey; @@ -74,28 +71,27 @@ public class SurveyTable extends Table { private static class SurveyTableModelBuilder extends LockableImpl implements TableModelBuilder { - private Class m_surveyClass; + private Class m_surveyClass; - public SurveyTableModelBuilder(Class surveyClass) { - m_surveyClass = surveyClass; - } + public SurveyTableModelBuilder(Class surveyClass) { + m_surveyClass = surveyClass; + } - public TableModel makeModel(Table l, PageState pageState) { - PackageInstance pack = SimpleSurveyUtil.getPackageInstance(pageState); - SurveyCollection surveys = - Survey.retrieveByPackage(pack); - - surveys.addEqualsFilter(ACSObject.DEFAULT_DOMAIN_CLASS, - m_surveyClass.getName()); - - Date currentDate = new Date(); - Filter startFilter = surveys.addFilter("startDate < :startDate"); - startFilter.set("startDate", currentDate); - Filter endFilter = surveys.addFilter("endDate > :endDate"); - endFilter.set("endDate", currentDate); - - return new AdminSurveyTableModel(surveys); - } + public TableModel makeModel(Table l, PageState pageState) { + + SurveyCollection surveys = Survey.retrieveAll(); + + surveys.addEqualsFilter(ACSObject.DEFAULT_DOMAIN_CLASS, + m_surveyClass.getName()); + + Date currentDate = new Date(); + Filter startFilter = surveys.addFilter("startDate < :startDate"); + startFilter.set("startDate", currentDate); + Filter endFilter = surveys.addFilter("endDate > :endDate"); + endFilter.set("endDate", currentDate); + + return new AdminSurveyTableModel(surveys); + } } private class SurveyCellRenderer implements TableCellRenderer { diff --git a/ccm-simplesurvey/src/com/arsdigita/simplesurvey/ui/admin/AdminSurveyTable.java b/ccm-simplesurvey/src/com/arsdigita/simplesurvey/ui/admin/AdminSurveyTable.java index 7560d01ac..edb29e379 100755 --- a/ccm-simplesurvey/src/com/arsdigita/simplesurvey/ui/admin/AdminSurveyTable.java +++ b/ccm-simplesurvey/src/com/arsdigita/simplesurvey/ui/admin/AdminSurveyTable.java @@ -92,7 +92,7 @@ public class AdminSurveyTable extends Table { public TableModel makeModel(Table l, PageState pageState) { PackageInstance pack = SimpleSurveyUtil.getPackageInstance(pageState); SurveyCollection surveys = - Survey.retrieveByPackage(pack); + Survey.retrieveAll(); surveys.addEqualsFilter(ACSObject.DEFAULT_DOMAIN_CLASS, m_surveyClass.getName()); diff --git a/ccm-webpage/src/com/arsdigita/cms/webpage/ui/WebpageCMSEditorPage.java b/ccm-webpage/src/com/arsdigita/cms/webpage/ui/WebpageCMSEditorPage.java index d2d3d831f..d81987c53 100755 --- a/ccm-webpage/src/com/arsdigita/cms/webpage/ui/WebpageCMSEditorPage.java +++ b/ccm-webpage/src/com/arsdigita/cms/webpage/ui/WebpageCMSEditorPage.java @@ -37,9 +37,9 @@ import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.categorization.CategoryCollection; import com.arsdigita.cms.ContentBundle; import com.arsdigita.cms.ContentSection; +import com.arsdigita.cms.ContentSectionServlet; import com.arsdigita.cms.SecurityManager; import com.arsdigita.cms.dispatcher.CMSPage; -import com.arsdigita.cms.dispatcher.ContentSectionDispatcher; import com.arsdigita.cms.lifecycle.Lifecycle; import com.arsdigita.cms.lifecycle.LifecycleDefinition; import com.arsdigita.cms.lifecycle.LifecycleDefinitionCollection; @@ -233,7 +233,8 @@ public class WebpageCMSEditorPage extends CMSPage implements WebpageConstants { s_log.debug("init"); PageState state = e.getPageState(); HttpServletRequest request = state.getRequest(); - ContentSection section = ContentSectionDispatcher.getContentSection(request); + // ContentSection section = ContentSectionDispatcher.getContentSection(request); + ContentSection section = ContentSectionServlet.getContentSection(request); Webpage webpage = null; try { @@ -344,7 +345,8 @@ public class WebpageCMSEditorPage extends CMSPage implements WebpageConstants { s_log.debug("process"); PageState state = e.getPageState(); HttpServletRequest request = state.getRequest(); - ContentSection section = ContentSectionDispatcher.getContentSection(request); + // ContentSection section = ContentSectionDispatcher.getContentSection(request); + ContentSection section = ContentSectionServlet.getContentSection(request); if (m_save.isSelected(state)) { Webpage webpage = null; diff --git a/ccm-webpage/src/com/arsdigita/cms/webpage/ui/WebpagePreviewPage.java b/ccm-webpage/src/com/arsdigita/cms/webpage/ui/WebpagePreviewPage.java index 5a404efb7..ec16c055e 100755 --- a/ccm-webpage/src/com/arsdigita/cms/webpage/ui/WebpagePreviewPage.java +++ b/ccm-webpage/src/com/arsdigita/cms/webpage/ui/WebpagePreviewPage.java @@ -9,9 +9,9 @@ import com.arsdigita.bebop.SimpleContainer; import com.arsdigita.cms.CMS; import com.arsdigita.cms.ContentItem; import com.arsdigita.cms.ContentSection; +import com.arsdigita.cms.ContentSectionServlet; import com.arsdigita.cms.dispatcher.CMSPage; import com.arsdigita.cms.dispatcher.ContentItemDispatcher; -import com.arsdigita.cms.dispatcher.ContentSectionDispatcher; import com.arsdigita.cms.dispatcher.XMLGenerator; //import com.arsdigita.cms.ui.ContentSectionComponent; import com.arsdigita.cms.webpage.Webpage; @@ -49,13 +49,14 @@ public class WebpagePreviewPage extends CMSPage { protected XMLGenerator getXMLGenerator(PageState ps) { HttpServletRequest request = ps.getRequest(); - ContentSection section = ContentSectionDispatcher.getContentSection(request); + // ContentSection section = ContentSectionDispatcher.getContentSection(request); + ContentSection section = ContentSectionServlet.getContentSection(request); Assert.exists(section, ContentSection.class); return section.getXMLGenerator(); } public ContentItem getContentItem(HttpServletRequest request) { - ContentSection section = ContentSectionDispatcher.getContentSection(request); + ContentSection section = ContentSectionServlet.getContentSection(request); Webpage webpage = null; ContentItem item = ContentItemDispatcher.getContentItem(request);