DocMgr auf legacy free umgestellt. Die UI wird aufgebaut, wobei Formatierung noch sehr rudimentär. Weitere Probleme nicht weiter angegangen.

git-svn-id: https://svn.libreccm.org/ccm/trunk@1559 8810af33-2d31-482b-a856-94f89814c4df
master
pb 2012-03-28 20:06:07 +00:00
parent b6c7d1587f
commit 35db4b6f03
18 changed files with 687 additions and 139 deletions

View File

@ -6,15 +6,15 @@
<initializer class="com.arsdigita.core.Initializer"/>
</requires>
<provides>
<initializer class="com.arsdigita.cms.docmgr.installer.Initializer"/>
<initializer class="com.arsdigita.cms.docmgr.installer.DocumentInitializer"/>
<initializer class="com.arsdigita.cms.docmgr.installer.DocLinkInitializer"/>
<initializer class="com.arsdigita.cms.docmgr.Initializer"/>
<initializer class="com.arsdigita.cms.docmgr.DocumentInitializer"/>
<initializer class="com.arsdigita.cms.docmgr.DocLinkInitializer"/>
</provides>
<scripts>
<schema directory="ccm-docmgr"/>
<data class="com.arsdigita.cms.docmgr.DocumentLoader"/>
<data class="com.arsdigita.cms.docmgr.DocLinkLoader"/>
<data class="com.arsdigita.cms.docmgr.DocFolderLoader"/>
<data class="com.arsdigita.cms.docmgr.Loader"/>
<data class="com.arsdigita.cms.docmgr.RepositoryLoader"/>
</scripts>
</load>

View File

@ -1,4 +1,4 @@
package com.arsdigita.cms.docmgr.installer;
package com.arsdigita.cms.docmgr;
import com.arsdigita.cms.ContentType;
import com.arsdigita.cms.docmgr.DocFolder;

View File

@ -1,4 +1,4 @@
package com.arsdigita.cms.docmgr.installer;
package com.arsdigita.cms.docmgr;
import org.apache.log4j.Category;

View File

@ -33,16 +33,18 @@ import com.arsdigita.web.Application;
*/
public class DocumentCategoryBrowserApplication extends Application {
public static final String BASE_DATA_OBJECT_TYPE =
"com.arsdigita.cms.docmgr.DocumentCategoryBrowserApplication";
protected String getBaseDataObjectType() {
return BASE_DATA_OBJECT_TYPE;
}
private static Logger s_log =
Logger.getLogger(DocumentCategoryBrowserApplication.class);
public static final String BASE_DATA_OBJECT_TYPE =
"com.arsdigita.cms.docmgr.DocumentCategoryBrowserApplication";
@Override
protected String getBaseDataObjectType() {
return BASE_DATA_OBJECT_TYPE;
}
// pdl constants
private static final String OWNER = "ownerID";
private static final String ROOT = "rootID";
@ -101,5 +103,34 @@ public class DocumentCategoryBrowserApplication extends Application {
// set("name", name);
//}
/**
* Returns the servletPath part of the URL to the application servlet.
* (see Servlet API specification or web.URL for more information)
*
* The method overwrites the super class to provide an application specific
* location for servlets/JSP. This is necessary if you whish to install the
* module (application) along with others in one context. If you install the
* module into its own context (no longer recommended for versions newer
* than 1.0.4) you may use a standard location.
*
* Usually it is a symbolic name/path, which will be mapped in the web.xml
* to the real location in the file system. Example:
* <servlet>
* <servlet-name>docmgr-categorybrowser</servlet-name>
* <servlet-class>com.arsdigita.cms.docmgr.ui.CategoryBrowserServlet</servlet-class>
* </servlet>
*
* <servlet-mapping>
* <servlet-name>docmgr-categorybrowser</servlet-name>
* <url-pattern>/docmgr-cat/*</url-pattern>
* </servlet-mapping>
*
* @return ServelPath of the applications servlet
*/
@Override
public String getServletPath() {
return "/docmgr-cat";
}
}

View File

@ -1,4 +1,4 @@
package com.arsdigita.cms.docmgr.installer;
package com.arsdigita.cms.docmgr;
import org.apache.log4j.Category;

View File

@ -13,7 +13,7 @@
*
*/
package com.arsdigita.cms.docmgr.installer;
package com.arsdigita.cms.docmgr;
import org.apache.log4j.Logger;

View File

@ -31,6 +31,10 @@ import com.arsdigita.web.Application;
*/
public class LegacyCategoryBrowserApplication extends Application {
private static Logger s_log =
Logger.getLogger(LegacyCategoryBrowserApplication.class);
public static final String BASE_DATA_OBJECT_TYPE =
"com.arsdigita.cms.docmgr.LegacyCategoryBrowserApplication";
@ -38,9 +42,6 @@ public class LegacyCategoryBrowserApplication extends Application {
return BASE_DATA_OBJECT_TYPE;
}
private static Logger s_log =
Logger.getLogger(LegacyCategoryBrowserApplication.class);
// pdl constants
private static final String OWNER = "ownerID";
private static final String ROOT = "rootID";
@ -99,5 +100,33 @@ public class LegacyCategoryBrowserApplication extends Application {
// set("name", name);
//}
/**
* Returns the servletPath part of the URL to the application servlet.
* (see Servlet API specification or web.URL for more information)
*
* The method overwrites the super class to provide an application specific
* location for servlets/JSP. This is necessary if you whish to install the
* module (application) along with others in one context. If you install the
* module into its own context (no longer recommended for versions newer
* than 1.0.4) you may use a standard location.
*
* Usually it is a symbolic name/path, which will be mapped in the web.xml
* to the real location in the file system. Example:
* <servlet>
* <servlet-name>docmgr-categorybrowser</servlet-name>
* <servlet-class>com.arsdigita.cms.docmgr.ui.CategoryBrowserServlet</servlet-class>
* </servlet>
*
* <servlet-mapping>
* <servlet-name>docmgr-categorybrowser</servlet-name>
* <url-pattern>/docmgr-cat/*</url-pattern>
* </servlet-mapping>
*
* @return ServelPath of the applications servlet
*/
@Override
public String getServletPath() {
return "/docmgr-cat";
}
}

View File

@ -13,7 +13,7 @@
*
*/
package com.arsdigita.cms.docmgr.installer;
package com.arsdigita.cms.docmgr;
import java.util.HashMap;
import java.util.Iterator;

View File

@ -346,4 +346,34 @@ public class Repository extends Application {
}
return null;
}
/**
* Returns the servletPath part of the URL to the application servlet.
* (see Servlet API specification or web.URL for more information)
*
* The method overwrites the super class to provide an application specific
* location for servlets/JSP. This is necessary if you whish to install the
* module (application) along with others in one context. If you install the
* module into its own context (no longer recommended for versions newer
* than 1.0.4) you may use a standard location.
*
* Usually it is a symbolic name/path, which will be mapped in the web.xml
* to the real location in the file system. Example:
* <servlet>
* <servlet-name>docmgr-repository</servlet-name>
* <servlet-class>com.arsdigita.cms.docmgr.ui.RepositoryServlet</servlet-class>
* </servlet>
*
* <servlet-mapping>
* <servlet-name>docmgr-repository</servlet-name>
* <url-pattern>/docmgr-repo/*</url-pattern>
* </servlet-mapping>
*
* @return ServelPath of the applications servlet
*/
@Override
public String getServletPath() {
return "/docmgr-repo";
}
}

View File

@ -26,13 +26,11 @@ import com.arsdigita.kernel.ACSObjectInstantiator;
import com.arsdigita.kernel.Kernel;
import com.arsdigita.kernel.KernelExcursion;
import com.arsdigita.loader.PackageLoader;
// import com.arsdigita.mimetypes.*;
import com.arsdigita.persistence.DataObject;
import com.arsdigita.portal.PortletType;
import com.arsdigita.portal.apportlet.AppPortletSetup;
import com.arsdigita.portal.apportlet.AppPortletType;
import com.arsdigita.runtime.ScriptContext;
import com.arsdigita.web.ApplicationSetup;
import com.arsdigita.web.ApplicationType;
import org.apache.log4j.Logger;
@ -41,22 +39,23 @@ import org.apache.log4j.Logger;
// ///////////////////////////////////////////////////////////////////////////
// Project: Migrate to new style legacy free type of application.
//
// Step 1: Copy from Initializer all data base / applicationtype
// related code to LOADER and use Loader for data loading.
// Step 1: Copy from Initializer all data base / applicationtype *DONE*
// related code to LOADER and use RepositoryLoader for
// data loading.
//
// Step 2: Remove usage of ApplicationSetup and switch to legacy
// Step 2: Remove usage of ApplicationSetup and switch to legacy *DONE*
// compativle AppType xxx = new AppType.create(......)
// Move setInstantiator back to Initializer as required.
//
// Step 3: Move to legacy free app type
// (a) modify new App.Tpye.....
// (b) create AppServlet from Dispatcher
// (a) modify new App.Tpye..... *DONE*
// (b) create AppServlet from Dispatcher *DONE*
//
//
// TESTS:
// (a) Try to instantiate an instance of each type and check the UI
// produced by the dispatcher / servlet
// (b) Instantiate the porlets and try to reproduce the behaviour
// (a) Try to instantiate an instance of each type and check *MOSTLY
// the UI produced by the dispatcher / servlet DONE
// (b) Instantiate the portlets and try to reproduce the behaviour
// (probably reproduce the error showing up originally)
//
//
@ -65,17 +64,17 @@ import org.apache.log4j.Logger;
/**
* CMS Document Manager (DocMgr) Loader
* CMS Document Manager (DocMgr) RepositoryLoader
*
* @author pboy &lt;pboy@barkhof.uni-bremen.de&gt;
* @version $Id: Loader.java $
* @version $Id: RepositoryLoader.java $
**/
public class Loader extends PackageLoader {
public class RepositoryLoader extends PackageLoader {
/** Logger instance for debugging */
private static final Logger s_log = Logger.getLogger(Loader.class);
private static final Logger s_log = Logger.getLogger(RepositoryLoader.class);
/**
* Run script invoked by com.arsdigita.packing loader script.
@ -88,14 +87,14 @@ public class Loader extends PackageLoader {
public void excurse() {
setEffectiveParty(Kernel.getSystemParty());
loadDocRepositoryApplicationType(); //former setupDocs
setupDocRepositoryPortlet(null); //former setupDocManagerPortlet
loadRepositoryApplicationType(); //former setupDocs
loadRepositoryPortletType(null); //former setupDocManagerPortlet
ApplicationType categoryBrowseDocsAppType = setupCategoryBrowsing();
ApplicationType categoryBrowseDocsAppType = loadCategoryBrowserType();
setupCategoryDocsPortlet(categoryBrowseDocsAppType);
ApplicationType legacyCategoryBrowseDocsAppType =
setupLegacyCategoryBrowsing();
loadLegacyCategoryBrowserType();
setupLegacyCategoryDocsPortlet(legacyCategoryBrowseDocsAppType);
// de-activate search for now
@ -127,107 +126,47 @@ public class Loader extends PackageLoader {
*
* TODO: migrate to a new style, legacy free application type.
*/
// formerly setupDocs()
private ApplicationType loadDocRepositoryApplicationType() {
/* ApplicationSetup setup = new ApplicationSetup(s_log);
setup.setApplicationObjectType(Repository.BASE_DATA_OBJECT_TYPE);
setup.setKey("cmsdocs");
setup.setTitle("Document Manager (CMS) Application");
setup.setSingleton(false);
setup.setDescription
("The document manager empowers users to share documents.");
setup.setDispatcherClass("com.arsdigita.cms.docmgr.ui.DMDispatcher");
setup.setInstantiator(new ACSObjectInstantiator() {
@Override
public DomainObject doNewInstance(DataObject dataObject) {
return new Repository(dataObject);
}
});
return setup.run();
*/
/* Create new type legacy compatible application type */
ApplicationType type = ApplicationType
.createApplicationType("cmsdocs",
"DocRepo",
Repository.BASE_DATA_OBJECT_TYPE);
type.setDispatcherClass("com.arsdigita.cms.docmgr.ui.DMDispatcher");
type.setDescription("The document manager empowers users to share documents.");
private ApplicationType loadRepositoryApplicationType() {
/* Legacy free initialization
* 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.
* 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.
* Example: "DocRepo" will become "docrepo".
*/
// ApplicationType type = new
// ApplicationType("DocRepo",
// Repository.BASE_DATA_OBJECT_TYPE );
// type.setDescription
// ("The document repository empowers users to share documents.");
ApplicationType type = new ApplicationType(
"CMSDocs",
Repository.BASE_DATA_OBJECT_TYPE );
type.setDescription
("The document repository empowers users to share documents.");
return type;
}
private ApplicationType setupCategoryBrowsing() {
/* ApplicationSetup setup = new ApplicationSetup(s_log);
setup.setApplicationObjectType(DocumentCategoryBrowserApplication
private ApplicationType loadCategoryBrowserType() {
ApplicationType type = new ApplicationType(
"cmsdocs-categories",
DocumentCategoryBrowserApplication
.BASE_DATA_OBJECT_TYPE );
setup.setKey("cmsdocs-categories");
setup.setTitle("Browse Documents Application");
setup.setSingleton(true);
setup.setDescription
("Browse documents by category.");
setup.setDispatcherClass("com.arsdigita.cms.docmgr.ui.DCNDispatcher");
setup.setInstantiator(new ACSObjectInstantiator() {
@Override
public DomainObject doNewInstance(DataObject dataObject) {
return new DocumentCategoryBrowserApplication(dataObject);
}
});
return setup.run();
*/
/* Create new type legacy compatible application type */
ApplicationType type = ApplicationType
.createApplicationType("cmsdocs-categories",
"Browse Documents Application",
DocumentCategoryBrowserApplication.BASE_DATA_OBJECT_TYPE);
type.setDispatcherClass("com.arsdigita.cms.docmgr.ui.DCNDispatcher");
type.setDescription("Browse documents by category.");
return type;
}
private ApplicationType setupLegacyCategoryBrowsing() {
/* ApplicationSetup setup = new ApplicationSetup(s_log);
setup.setApplicationObjectType(LegacyCategoryBrowserApplication
.BASE_DATA_OBJECT_TYPE);
setup.setKey("cmsdocs-categories-legacy");
setup.setTitle("Taxonomy Browser");
setup.setSingleton(true);
setup.setDescription
("Browse documents by category.");
setup.setDispatcherClass("com.arsdigita.cms.docmgr.ui.DCNDispatcher");
setup.setInstantiator(new ACSObjectInstantiator() {
@Override
public DomainObject doNewInstance(DataObject dataObject) {
return new LegacyCategoryBrowserApplication(dataObject);
}
});
return setup.run();
/**
*
* @return
*/
/* Create new type legacy compatible application type */
ApplicationType type = ApplicationType
.createApplicationType("cmsdocs-categories-legacy",
"Taxonomy Browser",
LegacyCategoryBrowserApplication.BASE_DATA_OBJECT_TYPE);
type.setDispatcherClass("com.arsdigita.cms.docmgr.ui.DCNDispatcher");
type.setDescription("Browse documents by category.");
private ApplicationType loadLegacyCategoryBrowserType() {
ApplicationType type = new ApplicationType("cmsdocs-categories-legacy",
LegacyCategoryBrowserApplication
.BASE_DATA_OBJECT_TYPE );
type.setDescription("Browse documents by legacy category (Taxonomie Browser).");
return type;
@ -246,7 +185,7 @@ public class Loader extends PackageLoader {
// SiteNode sn = SiteNode.getSiteNode("/administration", false);
// if (!"administration".equals(sn.getName())) {
Repository repo = Repository
.create( "docrepo",
.create( "cmsdocs-repo",
"Default DocumentMgr Repository",
null);
repo.save();
@ -273,7 +212,7 @@ public class Loader extends PackageLoader {
* by configuration.
*/
//former setupDocManagerPortlet
private void setupDocRepositoryPortlet(ApplicationType provider) {
private void loadRepositoryPortletType(ApplicationType provider) {
// Create the document repository portlet
/* AppPortletSetup setup = new AppPortletSetup(s_log);
@ -350,5 +289,4 @@ public class Loader extends PackageLoader {
}
}

View File

@ -0,0 +1,89 @@
/*
* Copyright (C) 2012 Peter boy (pboy@barkhof.uni-bremen.de
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.docmgr.ui;
import com.arsdigita.bebop.Page;
import com.arsdigita.bebop.TabbedPane;
import org.apache.log4j.Logger;
/**
* Application servlet for ccm-docmgr's DocumentCategoryBrowser and
* LegacyCategoryBrowser application which serves all request made for
* the application's UI.
*
* CagtegoryBrowserServlet is called by BaseApplicationServlet which has
* determined that it is associated with a request URL.
*
* The servlet has to be included in servlet container's deployment descriptor,
* see teh domain classes' getServletPath() method for details
* about web.xml record. It is NOT directly referenced by any other class.
*
* It determines whether a <tt>Page</tt> has been registered to the URL and
* if so passes the request to that page. Otherwise it hands the request
* to the TemplateResolver to find an appropriate JSP file.
*
* @author <mailto href="StefanDeusch@computer.org">Stefan Deusch</a>
* @author Peter Boy <pboy@barkhof.uni-bremen.de>
* @version $Id: RepositoryServlet.java 2161 2012-02-26 00:16:13Z pboy $
*/
public class CategoryBrowserServlet extends RepositoryServlet
implements DMConstants {
/** Private logger instance to faciliate debugging procedures */
private static final Logger s_log = Logger.getLogger(
CategoryBrowserServlet.class);
/**
* Use parent's class initialization extension point to perform additional
* initialisation tasks. Here: build the UI pages.
*/
@Override
public void doInit() {
addPage( "/", buildCategoryBrowserIndexPage() );
addPage( "/file", buildFileInfoPage());
// search is a tab, for now.
//addPage("/search", buildSearchPage());
//addPage("/search/file", buildFileInfoPage());
}
/**
* Build index page to browse documents by category
*/
private Page buildCategoryBrowserIndexPage() {
Page p = new DocmgrBasePage();
/* Create main administration tab. */
TabbedPane tb = new TabbedPane();
tb.setIdAttr("page-body");
p.add(new BrowseCatDocsPane());
p.lock();
return p;
}
}

View File

@ -61,7 +61,7 @@ import com.arsdigita.cms.ContentSectionCollection;
import com.arsdigita.cms.docmgr.DocFolder;
import com.arsdigita.cms.docmgr.DocMgr;
import com.arsdigita.cms.docmgr.DocLink;
import com.arsdigita.cms.docmgr.installer.Initializer;
import com.arsdigita.cms.docmgr.Initializer;
import com.arsdigita.cms.docmgr.search.SearchResults;
import com.arsdigita.cms.docmgr.search.SearchUtils;
import com.arsdigita.dispatcher.ObjectNotFoundException;

View File

@ -15,14 +15,6 @@
package com.arsdigita.cms.docmgr.ui;
import java.io.IOException;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.URLDecoder;
import org.apache.log4j.Category;
import com.arsdigita.bebop.ActionLink;
import com.arsdigita.bebop.page.BebopMapDispatcher;
import com.arsdigita.bebop.Label;
@ -50,6 +42,14 @@ import com.arsdigita.util.Assert;
import com.arsdigita.versioning.Versions;
import com.arsdigita.web.Web;
import java.io.IOException;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.URLDecoder;
import org.apache.log4j.Category;
/**
* Dispatcher for document manager application.
*

View File

@ -47,7 +47,7 @@ import com.arsdigita.cms.ContentBundle;
import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.ContentSectionCollection;
import com.arsdigita.cms.FileAsset;
import com.arsdigita.cms.docmgr.installer.Initializer;
import com.arsdigita.cms.docmgr.Initializer;
import com.arsdigita.cms.docmgr.DocFolder;
import com.arsdigita.cms.docmgr.DocMgr;
import com.arsdigita.cms.docmgr.Document;

View File

@ -0,0 +1,403 @@
/*
* Copyright (C) 2012 Peter boy (pboy@barkhof.uni-bremen.de
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.docmgr.ui;
import com.arsdigita.bebop.ActionLink;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.Page;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.RequestLocal;
import com.arsdigita.bebop.TabbedPane;
import com.arsdigita.bebop.event.ActionEvent;
import com.arsdigita.bebop.event.ActionListener;
import com.arsdigita.bebop.event.PrintEvent;
import com.arsdigita.bebop.event.PrintListener;
import com.arsdigita.bebop.parameters.BigDecimalParameter;
import com.arsdigita.cms.FileAsset;
import com.arsdigita.cms.docmgr.Document;
import com.arsdigita.dispatcher.DispatcherHelper;
import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.kernel.Kernel;
import com.arsdigita.kernel.permissions.PrivilegeDescriptor;
import com.arsdigita.persistence.AbstractTransactionListener;
import com.arsdigita.persistence.Session;
import com.arsdigita.persistence.SessionManager;
import com.arsdigita.persistence.TransactionContext;
import com.arsdigita.templating.PresentationManager;
import com.arsdigita.templating.Templating;
import com.arsdigita.util.Assert;
import com.arsdigita.versioning.Versions;
import com.arsdigita.web.Application;
import com.arsdigita.web.BaseApplicationServlet;
import com.arsdigita.web.Web;
import java.io.IOException;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.URLDecoder;
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;
/**
* Application servlet for ccm-docmgr's Repository application, the main
* package application, serves all request made for the application's UI.
*
* RepositporyServlet is called by BaseApplicationServlet which has determined
* that RepositoryServlet is associated with a request URL.
*
* The servlet has to be included in servlet container's deployment descriptor,
* see {@see com.arsdigita.cms.docmgr.Repository#getServletPath()} for details
* about web.xml record. It is NOT directly referenced by any other class.
*
* It determines whether a <tt>Page</tt> has been registered to the URL and
* if so passes the request to that page. Otherwise it hands the request
* to the TemplateResolver to find an appropriate JSP file.
*
* @author <mailto href="StefanDeusch@computer.org">Stefan Deusch</a>
* @author Peter Boy <pboy@barkhof.uni-bremen.de>
* @version $Id: RepositoryServlet.java 2161 2012-02-26 00:16:13Z pboy $
*/
public class RepositoryServlet extends BaseApplicationServlet
implements DMConstants {
/** Private logger instance to faciliate debugging procedures */
private static final Logger s_log = Logger.getLogger(RepositoryServlet.class);
/** URL (pathinfo) -> Page object mapping. Based on it (and the http
* request url) the doService method selects a page to display */
private final Map m_pages = new HashMap();
/**
* Use parent's class initialization extension point to perform additional
* initialisation tasks. Here: build the UI pages.
*/
@Override
public void doInit() {
addPage( "/", buildRepositoryIndexPage() );
addPage( "/file", buildFileInfoPage());
// search is a tab, for now.
//addPage("/search", buildSearchPage());
//addPage("/search/file", buildFileInfoPage());
}
/**
* Implements the (abstract) doService method of BaseApplicationServlet to
* perform the services.
* @see com.arsdigita.web.BaseApplicationServlet#doService
* (HttpServletRequest, HttpServletResponse, Application)
*/
protected void doService( HttpServletRequest sreq,
HttpServletResponse sresp,
Application app)
throws ServletException, IOException {
if (s_log.isDebugEnabled()) {
s_log.info("starting doService method");
}
String url = sreq.getRequestURI();
int index = url.lastIndexOf("/download/");
if (index > 0) {
/* Download requested, handle the download */
String str = sreq.getParameter(FILE_ID_PARAM_NAME);
s_log.debug("Downloading");
if (str != null) {
BigDecimal id = new BigDecimal(str);
s_log.debug("requesting file for id: "+str);
Document doc = new Document(id);
sresp.setHeader("Content-Disposition", "attachment; filename=" +
URLDecoder.decode(doc.getName()));
doc.assertPrivilege(PrivilegeDescriptor.READ);
// if the user has requested an earlier revision, get
// that revision and serve it
String param = sreq.getParameter("transID");
if (param != null) {
Session ssn = SessionManager.getSession();
TransactionContext txn = ssn.getTransactionContext();
txn.addTransactionListener(new AbstractTransactionListener() {
@Override
public void beforeCommit(TransactionContext txn) {
Assert.fail("uncommittable transaction");
}
});
Kernel.getContext().getTransaction().setCommitRequested(false);
BigInteger transID = new BigInteger(param);
Versions.rollback(doc.getOID(), transID);
}
FileAsset file = doc.getFile();
sresp.setContentType( null != file.getMimeType() ?
file.getMimeType().getMimeType() : "text/plain" );
OutputStream os = null;
try {
os = sresp.getOutputStream();
file.writeBytes(os);
} catch (IOException iox) {
iox.printStackTrace();
throw new RuntimeException(iox.getMessage());
} finally {
try {
//is.close();
os.close();
} catch(IOException iox2) { }
}
}
} else {
/* No download, show the repository index page */
s_log.debug("show repository page");
String pathInfo = sreq.getPathInfo();
Assert.exists(pathInfo, "String pathInfo");
if (pathInfo.length() > 1 && pathInfo.endsWith("/")) {
/* NOTE: ServletAPI specifies, pathInfo may be empty or will
* start with a '/' character. It currently carries a
* trailing '/' if a "virtual" page, i.e. not a real jsp, but
* result of a servlet mapping. But Application requires url
* NOT to end with a trailing '/' for legacy free applications.*/
pathInfo = pathInfo.substring(0, pathInfo.length()-1);
}
final Page page = (Page) m_pages.get(pathInfo);
if (page != null) {
final com.arsdigita.xml.Document doc = page.buildDocument(sreq,
sresp);
PresentationManager pm = Templating.getPresentationManager();
pm.servePage(doc, sreq, sresp);
} else {
// TODO: Check JSP's first (cf. cms content-section servlet)
sresp.sendError(404, "No such page for path " + pathInfo);
}
}
if (s_log.isDebugEnabled()) s_log.info("completed doService method");
}
/**
* Adds one Url-Page mapping to the internal mapping table.
*
* @param pathInfo url stub for a page to display
* @param page Page object to display
*/
protected void addPage(final String pathInfo, final Page page) {
Assert.exists(pathInfo, String.class);
Assert.exists(page, Page.class);
// Current Implementation requires pathInfo to start with a leading '/'
// SUN Servlet API specifies: "PathInfo *may be empty* or will start
// with a '/' character."
Assert.isTrue(pathInfo.startsWith("/"), "path starts not with '/'");
m_pages.put(pathInfo, page);
}
/**
* Build index page for the document manager,
*/
private Page buildRepositoryIndexPage() {
Page p = new DocmgrBasePage();
/* Create main administration tab. */
TabbedPane tb = new TabbedPane();
tb.setIdAttr("page-body");
//tb.addTab(WS_BROWSE_TITLE, new BrowsePane());
/*
* Disable Repositories tab because
* Still need to decide what to do with mounting
* repository, since repository are now application.
*
tb.addTab(WS_REPOSITORIES_TITLE, new RepositoryPane());
*/
p.add(new BrowsePane());
p.lock();
return p;
}
/**
* Build page for the administration of one file.
*/
protected Page buildFileInfoPage() {
final BigDecimalParameter fileIDParam = new
BigDecimalParameter(FILE_ID_PARAM_NAME);
DocmgrBasePage p = new DocmgrBasePage(fileIDParam) {
// need to override this to show the File name
@Override
protected void buildTitle() {
Label title = new Label();
title.addPrintListener(new
com.arsdigita.bebop.event.PrintListener() {
public void prepare(PrintEvent e) {
PageState state = e.getPageState();
Label t = (Label) e.getTarget();
BigDecimal fid =
(BigDecimal) state.getValue(fileIDParam);
if (fid!=null) {
t.setLabel(DMUtils.getFile(fid).getTitle());
}
}
});
setTitle(title);
}
@Override
protected void buildContextBar() {
FileDimensionalNavbar navbar = new FileDimensionalNavbar(
new RequestLocal() {
@Override
protected Object initialValue(PageState state) {
BigDecimal id = (BigDecimal) state.getValue(fileIDParam);
return new Document(id);
}
});
navbar.setClassAttr("portalNavbar");
getHeader().add(navbar);
}
};
// need to add the file parameter to the page
//BigDecimalParameter FILE_ID_PARAM = new BigDecimalParameter(FILE_ID_PARAM_NAME);
//p.addGlobalStateParam(fileIDParam);
/* Temporary fix to sdm #204233, NavBar of Application allows only
one URL per application, so here we add a Link back to the parent folder
*/
Label backLinkLabel = new Label
(new GlobalizedMessage("ui.fileinfo.goback.label", BUNDLE_NAME));
backLinkLabel.addPrintListener(new PrintListener() {
public void prepare(PrintEvent e) {
PageState state = e.getPageState();
Label t= (Label) e.getTarget();
String fixed = t.getLabel(e.getPageState());
String url = Web.getContext().getApplication().getTitle();
t.setLabel(fixed + " " + url);
}});
ActionLink backLink = new ActionLink(backLinkLabel);
backLink.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
PageState state = e.getPageState();
String url = Web.getContext().getApplication().getPath();
BigDecimal fid = (BigDecimal) state.getValue(fileIDParam);
if (fid != null) {
url = url + "?d_id="+fid;
}
/*
BigDecimal pid = null;
BigDecimal fid = (BigDecimal) state.getValue(FILE_ID_PARAM);
if (fid!=null) {
pid = DMUtils.getFile(fid).getParentResource().getID();
}
*/
try {
DispatcherHelper.sendRedirect(state.getRequest(),
state.getResponse(),
url);
} catch (IOException iox) {
throw new RuntimeException("Redirect to Application failed"
+iox);
}
}});
backLink.setClassAttr("actionLink");
p.add(backLink);
// create main File-Info tabs
TabbedPane tb = new TabbedPane();
tb.setIdAttr("page-body");
tb.addTab(FILE_INFO_PROPERTIES_TITLE, new FileInfoPropertiesPane(p));
// TODO - comment in
tb.addTab(FILE_INFO_HISTORY_TITLE, new FileInfoHistoryPane(p));
/*
* Disable Links tab because we have not
* decided how to link other KnItems to a document.
* 01/04/02 Stefan Deusch
*
tb.addTab(FILE_INFO_LINKS_TITLE, new FileInfoLinksPane());
*/
p.add(tb);
p.lock();
return p;
}
/**
* Build search page for the document manager,
*/
protected Page buildSearchPage() {
Page p = new DocmgrBasePage();
/**
* Create main administration tab.
*/
TabbedPane tb = new TabbedPane();
tb.setIdAttr("page-body");
//tb.addTab(WS_BROWSE_TITLE, new BrowsePane());
/*
* Disable Repositories tab because
* Still need to decide what to do with mounting
* repository, since repository are now application.
*
tb.addTab(WS_REPOSITORIES_TITLE, new RepositoryPane());
*/
p.add(new SearchPane());
p.lock();
return p;
}
}

View File

@ -0,0 +1,28 @@
<?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">
<!-- Servlets for the ccm-docmgr applications -->
<servlet>
<servlet-name>docmgr-repository</servlet-name>
<servlet-class>com.arsdigita.cms.docmgr.ui.RepositoryServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>docmgr-categorybrowser</servlet-name>
<servlet-class>com.arsdigita.cms.docmgr.ui.CategoryBrowserServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>docmgr-repository</servlet-name>
<url-pattern>/docmgr-repo/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>docmgr-categorybrowser</servlet-name>
<url-pattern>/docmgr-cat/*</url-pattern>
</servlet-mapping>
</web-app>

View File

@ -9,7 +9,7 @@
<xsl:import href="../../content-section/xsl/cms.xsl"/>
<xsl:import href="../../acs-admin/xsl/admin_en.xsl"/>
<xsl:import href="../../admin/xsl/admin_en.xsl"/>
<xsl:import href="../../categorization/xsl/categorization.xsl"/>
<xsl:import href="../../bebop/xsl/DimensionalNavbar.xsl"/>
<xsl:import href="../../toolbox/xsl/ControlBar.xsl"/>