ccm-docrepo jetzt legacy free, kleinere Korrekturen an UI.
git-svn-id: https://svn.libreccm.org/ccm/trunk@1523 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
a1dd35d97d
commit
ea33e66880
|
|
@ -1,4 +1,11 @@
|
||||||
|
February 27, 2012
|
||||||
|
=================
|
||||||
|
|
||||||
|
Package ccm-docrepo is now initialized as a new style, legacy free application.
|
||||||
|
An update is not necessary because has not been part of distribution yet.
|
||||||
|
|
||||||
April 14, 2011
|
April 14, 2011
|
||||||
|
==============
|
||||||
|
|
||||||
Package ccm-docmgr from Byline repository copied and integrated in ccm/aplaws
|
Package ccm-docmgr from Byline repository copied and integrated in ccm/aplaws
|
||||||
as an test environment.
|
as an test environment.
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
<ccm:application xmlns:ccm="http://ccm.redhat.com/ccm-project"
|
<ccm:application xmlns:ccm="http://ccm.redhat.com/ccm-project"
|
||||||
name="ccm-docrepo"
|
name="ccm-docrepo"
|
||||||
prettyName="Red Hat Document Repository Application"
|
prettyName="Red Hat Document Repository Application"
|
||||||
version="6.6.0"
|
version="6.6.1"
|
||||||
release="1">
|
release="1">
|
||||||
|
|
||||||
<ccm:dependencies>
|
<ccm:dependencies>
|
||||||
|
|
@ -16,6 +16,9 @@
|
||||||
</ccm:contacts>
|
</ccm:contacts>
|
||||||
|
|
||||||
<ccm:description>
|
<ccm:description>
|
||||||
|
The document repository is an online file storage system for
|
||||||
|
collaborative file sharing within groups.
|
||||||
|
|
||||||
</ccm:description>
|
</ccm:description>
|
||||||
|
|
||||||
</ccm:application>
|
</ccm:application>
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
init com.arsdigita.docrepo.installer.Initializer { }
|
|
||||||
|
|
@ -26,7 +26,7 @@ query getRepositoriesView {
|
||||||
select distinct
|
select distinct
|
||||||
dr_repositories.repository_id,
|
dr_repositories.repository_id,
|
||||||
coalesce(dm.repository_id, null, 0, 1) as mounted,
|
coalesce(dm.repository_id, null, 0, 1) as mounted,
|
||||||
dr_repository_num_files(docs_repositories.root_id) as num_files
|
dr_repository_num_files(dr_repositories.root_id) as num_files
|
||||||
from dr_repositories
|
from dr_repositories
|
||||||
left join (select repository_id from docs_mounted
|
left join (select repository_id from docs_mounted
|
||||||
where party_id = :userID) dm
|
where party_id = :userID) dm
|
||||||
|
|
|
||||||
|
|
@ -86,16 +86,30 @@ public class Loader extends PackageLoader {
|
||||||
*/
|
*/
|
||||||
private void loadDocRepositoryApplicationType() {
|
private void loadDocRepositoryApplicationType() {
|
||||||
|
|
||||||
ApplicationType type = ApplicationType.createApplicationType(
|
/* Legacy compatible initialization */
|
||||||
"docrepo",
|
// ApplicationType type = ApplicationType.createApplicationType(
|
||||||
"Document Repository",
|
// "docrepo",
|
||||||
Repository.BASE_DATA_OBJECT_TYPE);
|
// "Document Repository",
|
||||||
type.setDescription
|
// Repository.BASE_DATA_OBJECT_TYPE);
|
||||||
("The document repository empowers users to share documents.");
|
|
||||||
// Current code requires an apps specific dispatcher class. Has to be
|
// Current code requires an apps specific dispatcher class. Has to be
|
||||||
// modified to be able to create a legacy free app type.
|
// modified to be able to create a legacy free app type.
|
||||||
type.setDispatcherClass
|
// type.setDispatcherClass
|
||||||
("com.arsdigita.docrepo.ui.DRDispatcher");
|
// ("com.arsdigita.docrepo.ui.DRDispatcher");
|
||||||
|
|
||||||
|
/* 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.
|
||||||
|
* 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.");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ public class Repository extends Application {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retreives a repository from the database usings its OID.
|
* Constructor retrieves a repository from the database usings its OID.
|
||||||
*
|
*
|
||||||
* @param oid the OID of the repository
|
* @param oid the OID of the repository
|
||||||
*/
|
*/
|
||||||
|
|
@ -324,4 +324,33 @@ public class Repository extends Application {
|
||||||
}
|
}
|
||||||
return null;
|
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>docrepo</servlet-name>
|
||||||
|
* <servlet-class>com.arsdigita.docrepo.RepositoryServlet</servlet-class>
|
||||||
|
* </servlet>
|
||||||
|
*
|
||||||
|
* <servlet-mapping>
|
||||||
|
* <servlet-name>docrepo</servlet-name>
|
||||||
|
* <url-pattern>/docrepo/*</url-pattern>
|
||||||
|
* </servlet-mapping>
|
||||||
|
*
|
||||||
|
* @return ServelPath of the applications servlet
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getServletPath() {
|
||||||
|
return "/docrepo/";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,87 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2011 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.docrepo;
|
|
||||||
|
|
||||||
import com.arsdigita.bebop.ActionLink;
|
|
||||||
import com.arsdigita.bebop.Label;
|
|
||||||
import com.arsdigita.bebop.Page;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
|
||||||
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.page.BebopApplicationServlet;
|
|
||||||
import com.arsdigita.bebop.page.BebopMapDispatcher;
|
|
||||||
import com.arsdigita.dispatcher.DispatcherHelper;
|
|
||||||
import com.arsdigita.dispatcher.ObjectNotFoundException;
|
|
||||||
import com.arsdigita.dispatcher.RequestContext;
|
|
||||||
import com.arsdigita.docrepo.File;
|
|
||||||
import com.arsdigita.kernel.permissions.PrivilegeDescriptor;
|
|
||||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
|
||||||
import com.arsdigita.web.Web;
|
|
||||||
import com.arsdigita.persistence.Session;
|
|
||||||
import com.arsdigita.persistence.SessionManager;
|
|
||||||
import com.arsdigita.persistence.DataQuery;
|
|
||||||
import com.arsdigita.util.UncheckedWrapperException;
|
|
||||||
import org.apache.log4j.Category;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author pb
|
|
||||||
*/
|
|
||||||
public class RepositoryServlet extends BebopApplicationServlet {
|
|
||||||
|
|
||||||
/** Private logger instance to faciliate debugging procedures */
|
|
||||||
private static final Logger s_log = Logger.getLogger(RepositoryServlet.class);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Servlet Initialisation, builds the UI elements (various panes)
|
|
||||||
* @throws ServletException
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void init() throws ServletException {
|
|
||||||
super.init();
|
|
||||||
s_log.debug("creating DocRepo page");
|
|
||||||
|
|
||||||
|
|
||||||
// Page index = buildIndexPage();
|
|
||||||
// Page admin = buildAdminIndexPage();
|
|
||||||
|
|
||||||
// put("/", index);
|
|
||||||
// put("/index.jsp", index);
|
|
||||||
// put("/one.jsp", index);
|
|
||||||
|
|
||||||
// put("admin", admin);
|
|
||||||
// put("admin/index.jsp", admin);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>com.arsdigita.docrepo</title>
|
<title>com.arsdigita.docrepo</title>
|
||||||
|
|
@ -65,7 +65,7 @@ import java.util.ArrayList;
|
||||||
* @author <mailto href="StefanDeusch@computer.org">Stefan Deusch</a>
|
* @author <mailto href="StefanDeusch@computer.org">Stefan Deusch</a>
|
||||||
*/
|
*/
|
||||||
class BrowsePane extends ModalContainer
|
class BrowsePane extends ModalContainer
|
||||||
implements DRConstants, ChangeListener, RequestListener {
|
implements DRConstants, ChangeListener, RequestListener {
|
||||||
|
|
||||||
private Component m_folderContent;
|
private Component m_folderContent;
|
||||||
private Component m_destinationFolderPanel;
|
private Component m_destinationFolderPanel;
|
||||||
|
|
@ -76,7 +76,7 @@ class BrowsePane extends ModalContainer
|
||||||
private ErrorMessageLabel m_errorMsgLabel;
|
private ErrorMessageLabel m_errorMsgLabel;
|
||||||
private Container m_mainBrowseContainer;
|
private Container m_mainBrowseContainer;
|
||||||
|
|
||||||
private TabbedPane m_mainTabPane;
|
// private TabbedPane m_mainTabPane;
|
||||||
|
|
||||||
private Tree m_tree;
|
private Tree m_tree;
|
||||||
|
|
||||||
|
|
@ -92,11 +92,11 @@ class BrowsePane extends ModalContainer
|
||||||
|
|
||||||
public BrowsePane() {
|
public BrowsePane() {
|
||||||
|
|
||||||
m_mainTabPane = new TabbedPane();
|
// m_mainTabPane = new TabbedPane();
|
||||||
|
|
||||||
m_mainBrowseContainer = new BoxPanel();
|
m_mainBrowseContainer = new BoxPanel();
|
||||||
m_mainTabPane.addTab(WS_BROWSE_TITLE,
|
// m_mainTabPane.addTab(WS_BROWSE_TITLE,
|
||||||
m_mainBrowseContainer);
|
// m_mainBrowseContainer);
|
||||||
|
|
||||||
m_mainBrowseContainer.setClassAttr("sidebarNavPanel");
|
m_mainBrowseContainer.setClassAttr("sidebarNavPanel");
|
||||||
//m_mainBrowseContainer.setAttribute("navbar-title", "Folders");
|
//m_mainBrowseContainer.setAttribute("navbar-title", "Folders");
|
||||||
|
|
@ -120,7 +120,8 @@ class BrowsePane extends ModalContainer
|
||||||
|
|
||||||
m_mainBrowseContainer.add(rightSide);
|
m_mainBrowseContainer.add(rightSide);
|
||||||
|
|
||||||
add(m_mainTabPane);
|
// add(m_mainTabPane);
|
||||||
|
add(m_mainBrowseContainer);
|
||||||
|
|
||||||
m_newFileForm = makeFileUploadForm();
|
m_newFileForm = makeFileUploadForm();
|
||||||
add(m_newFileForm);
|
add(m_newFileForm);
|
||||||
|
|
@ -344,7 +345,8 @@ class BrowsePane extends ModalContainer
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayFolderContentPanel(PageState state) {
|
public void displayFolderContentPanel(PageState state) {
|
||||||
setVisibleComponent(state, m_mainTabPane);
|
// setVisibleComponent(state, m_mainTabPane);
|
||||||
|
setVisibleComponent(state, m_mainBrowseContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayDestinationFolderPanel(PageState state,
|
public void displayDestinationFolderPanel(PageState state,
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
* @author <mailto href="StefanDeusch@computer.org">Stefan Deusch</a>
|
* @author <mailto href="StefanDeusch@computer.org">Stefan Deusch</a>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public interface DRConstants {
|
interface DRConstants {
|
||||||
|
|
||||||
// PDL vars
|
// PDL vars
|
||||||
String FOLDER_ID = "folderID";
|
String FOLDER_ID = "folderID";
|
||||||
|
|
|
||||||
|
|
@ -209,7 +209,7 @@ public class DRDispatcher extends BebopMapDispatcher implements DRConstants {
|
||||||
public void dispatch(javax.servlet.http.HttpServletRequest req,
|
public void dispatch(javax.servlet.http.HttpServletRequest req,
|
||||||
javax.servlet.http.HttpServletResponse resp,
|
javax.servlet.http.HttpServletResponse resp,
|
||||||
RequestContext ctx)
|
RequestContext ctx)
|
||||||
throws IOException, javax.servlet.ServletException {
|
throws IOException, javax.servlet.ServletException {
|
||||||
|
|
||||||
String url = req.getRequestURI();
|
String url = req.getRequestURI();
|
||||||
int index = url.lastIndexOf("/download/");
|
int index = url.lastIndexOf("/download/");
|
||||||
|
|
@ -0,0 +1,383 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2011 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.docrepo.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.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.dispatcher.DispatcherHelper;
|
||||||
|
import com.arsdigita.dispatcher.ObjectNotFoundException;
|
||||||
|
import com.arsdigita.docrepo.File;
|
||||||
|
// import com.arsdigita.docrepo.ui.BrowsePane;
|
||||||
|
// import com.arsdigita.docrepo.ui.DocrepoBasePage;
|
||||||
|
// import com.arsdigita.docrepo.ui.DRConstants;
|
||||||
|
// import com.arsdigita.docrepo.ui.DRUtils;
|
||||||
|
// import com.arsdigita.docrepo.ui.FileInfoHistoryPane;
|
||||||
|
// import com.arsdigita.docrepo.ui.FileInfoPropertiesPane;
|
||||||
|
// import com.arsdigita.docrepo.ui.RepositoryPane;
|
||||||
|
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||||
|
import com.arsdigita.kernel.permissions.PrivilegeDescriptor;
|
||||||
|
import com.arsdigita.persistence.DataQuery;
|
||||||
|
import com.arsdigita.persistence.Session;
|
||||||
|
import com.arsdigita.persistence.SessionManager;
|
||||||
|
import com.arsdigita.templating.PresentationManager;
|
||||||
|
import com.arsdigita.templating.Templating;
|
||||||
|
import com.arsdigita.util.Assert;
|
||||||
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
|
import com.arsdigita.web.Application;
|
||||||
|
import com.arsdigita.web.BaseApplicationServlet;
|
||||||
|
import com.arsdigita.xml.Document;
|
||||||
|
|
||||||
|
import com.arsdigita.web.Web;
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
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 the ccm-docrepo application, serves all request made
|
||||||
|
* for the application's UI.
|
||||||
|
*
|
||||||
|
* 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 <tt>Page</tt> has been registered to
|
||||||
|
* the URL and if so passes the request to that page.
|
||||||
|
*
|
||||||
|
* If no <tt>Page</tt> is registered to the URL, then the CMS Service 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: DRServlet.java 2161 2012-02-26 00:16:13Z pboy $
|
||||||
|
*/
|
||||||
|
public class DRServlet extends BaseApplicationServlet
|
||||||
|
implements DRConstants {
|
||||||
|
|
||||||
|
/** Private logger instance to faciliate debugging procedures */
|
||||||
|
private static final Logger s_log = Logger.getLogger(DRServlet.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() {
|
||||||
|
if (s_log.isDebugEnabled()) {
|
||||||
|
s_log.info("starting RepositoryServlet doInit method ...");
|
||||||
|
}
|
||||||
|
|
||||||
|
addPage("/", buildDMIndexPage());
|
||||||
|
addPage("/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 */
|
||||||
|
s_log.debug("Downloading");
|
||||||
|
String str = sreq.getParameter(FILE_ID_PARAM.getName());
|
||||||
|
if (str != null) {
|
||||||
|
BigDecimal id = new BigDecimal(str);
|
||||||
|
|
||||||
|
File file = null;
|
||||||
|
try {
|
||||||
|
file = new File(id);
|
||||||
|
} catch(DataObjectNotFoundException nfe) {
|
||||||
|
throw new ObjectNotFoundException(
|
||||||
|
"The requested file no longer exists.");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Check to see if current user is allowed to read this file
|
||||||
|
file.assertPrivilege(PrivilegeDescriptor.READ);
|
||||||
|
|
||||||
|
String mimetype = file.getContentType();
|
||||||
|
if (mimetype == null) {
|
||||||
|
mimetype = File.DEFAULT_MIME_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sresp.setContentType(mimetype);
|
||||||
|
|
||||||
|
InputStream is;
|
||||||
|
final String transaction = sreq.getParameter("trans_id");
|
||||||
|
if (transaction == null || transaction.equals("current")) {
|
||||||
|
is = file.getInputStream();
|
||||||
|
} else {
|
||||||
|
is = getFileRevision(transaction);
|
||||||
|
}
|
||||||
|
|
||||||
|
sendToOutput(is, sresp.getOutputStream());
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* Show the repository page */
|
||||||
|
s_log.debug("show repository page");
|
||||||
|
// super.dispatch(req, resp, ctx);
|
||||||
|
|
||||||
|
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 Document doc = page.buildDocument(sreq, sresp);
|
||||||
|
|
||||||
|
PresentationManager pm = Templating.getPresentationManager();
|
||||||
|
pm.servePage(doc, sreq, sresp);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
sresp.sendError(404, "No such page for path " + pathInfo);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
private 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 repository,
|
||||||
|
*/
|
||||||
|
|
||||||
|
private Page buildDMIndexPage() {
|
||||||
|
|
||||||
|
Page page = new DocrepoBasePage();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create main administration tab.
|
||||||
|
*/
|
||||||
|
TabbedPane tabbedPane = new TabbedPane();
|
||||||
|
tabbedPane.setIdAttr("page-body");
|
||||||
|
tabbedPane.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.*/
|
||||||
|
// tabbedPane.addTab(WS_REPOSITORIES_TITLE, new RepositoryPane());
|
||||||
|
|
||||||
|
//p.add(new BrowsePane());
|
||||||
|
page.add(tabbedPane);
|
||||||
|
page.lock();
|
||||||
|
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build page for the administration of one file.
|
||||||
|
* (Implementation according to wireframes at)
|
||||||
|
*/
|
||||||
|
private Page buildFileInfoPage() {
|
||||||
|
|
||||||
|
DocrepoBasePage p = new DocrepoBasePage() {
|
||||||
|
// 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(FILE_ID_PARAM);
|
||||||
|
if (fid!=null) {
|
||||||
|
t.setLabel
|
||||||
|
(DRUtils.getFile(fid).getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
setTitle(title);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/* 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 = GO_BACK_LABEL;
|
||||||
|
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(FILE_ID_PARAM);
|
||||||
|
|
||||||
|
if (fid != null) {
|
||||||
|
url = url + "?d_id="+fid;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
BigDecimal pid = null;
|
||||||
|
BigDecimal fid = (BigDecimal) state.getValue(FILE_ID_PARAM);
|
||||||
|
if (fid!=null) {
|
||||||
|
pid = DRUtils.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));
|
||||||
|
tb.addTab(FILE_INFO_HISTORY_TITLE, new FileInfoHistoryPane());
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param is
|
||||||
|
* @param os
|
||||||
|
*/
|
||||||
|
private static void sendToOutput(InputStream is, OutputStream os) {
|
||||||
|
byte[] buf = new byte[8192]; // 8k buffer
|
||||||
|
|
||||||
|
try {
|
||||||
|
int sz = 0;
|
||||||
|
while ((sz = is.read(buf, 0 , 8192)) != -1) {
|
||||||
|
os.write(buf, 0, sz);
|
||||||
|
}
|
||||||
|
} catch (IOException iox) {
|
||||||
|
iox.printStackTrace();
|
||||||
|
throw new UncheckedWrapperException("IO Error streaming file", iox);
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
is.close();
|
||||||
|
os.close();
|
||||||
|
} catch(IOException iox2) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param transaction
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private static InputStream getFileRevision(String transaction) {
|
||||||
|
BigDecimal transactionID = new BigDecimal(transaction);
|
||||||
|
|
||||||
|
Session session = SessionManager.getSession();
|
||||||
|
DataQuery query = session.retrieveQuery
|
||||||
|
("com.arsdigita.docrepo.getFileRevisionBlob");
|
||||||
|
query.setParameter("transactionID", transactionID);
|
||||||
|
InputStream is = null;
|
||||||
|
if (query.next()) {
|
||||||
|
Object blob = query.get("content");
|
||||||
|
is = new ByteArrayInputStream((byte[]) blob);
|
||||||
|
}
|
||||||
|
|
||||||
|
return is;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -48,7 +48,7 @@ import java.util.Locale;
|
||||||
* @author <mailto href="StefanDeusch@computer.org">Stefan Deusch</a>
|
* @author <mailto href="StefanDeusch@computer.org">Stefan Deusch</a>
|
||||||
* @version $Id: DRUtils.java pboy $
|
* @version $Id: DRUtils.java pboy $
|
||||||
*/
|
*/
|
||||||
public class DRUtils implements DRConstants {
|
class DRUtils implements DRConstants {
|
||||||
|
|
||||||
private static final Logger s_log = Logger.getLogger(DRUtils.class);
|
private static final Logger s_log = Logger.getLogger(DRUtils.class);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ import org.apache.log4j.Logger;
|
||||||
* @author <a href="mailto:jparsons@arsdigita.com">Jim Parsons</a>
|
* @author <a href="mailto:jparsons@arsdigita.com">Jim Parsons</a>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class DocrepoBasePage extends Page {
|
class DocrepoBasePage extends Page {
|
||||||
|
|
||||||
private final Container m_global;
|
private final Container m_global;
|
||||||
private final Container m_header;
|
private final Container m_header;
|
||||||
|
|
@ -131,7 +131,11 @@ public class DocrepoBasePage extends Page {
|
||||||
// <em>override</em> this method.
|
// <em>override</em> this method.
|
||||||
protected final void buildPage() {
|
protected final void buildPage() {
|
||||||
buildTitle();
|
buildTitle();
|
||||||
buildContextBar();
|
// Context Byr temporarily deactivated until the functionality to
|
||||||
|
// to create multiple repositories (table docs_mounted) is restored.
|
||||||
|
// Because currently there is only one repository mounted there is
|
||||||
|
// no relevant context
|
||||||
|
/* buildContextBar(); */
|
||||||
buildGlobal(getGlobal());
|
buildGlobal(getGlobal());
|
||||||
buildHeader(getHeader());
|
buildHeader(getHeader());
|
||||||
buildBody(getBody());
|
buildBody(getBody());
|
||||||
|
|
|
||||||
|
|
@ -56,10 +56,9 @@ import java.util.Vector;
|
||||||
|
|
||||||
class RepositoriesTable implements DRConstants {
|
class RepositoriesTable implements DRConstants {
|
||||||
|
|
||||||
private static String REPOSITORIES_IDS
|
private static String REPOSITORIES_IDS = "repositories-ids";
|
||||||
= "repositories-ids";
|
|
||||||
private static String REPOSITORIES_SUBSCRIBED_IDS =
|
private static String REPOSITORIES_SUBSCRIBED_IDS =
|
||||||
"repositories-subscribed-ids";
|
"repositories-subscribed-ids";
|
||||||
|
|
||||||
static String[] s_tableHeaders = {
|
static String[] s_tableHeaders = {
|
||||||
"",
|
"",
|
||||||
|
|
@ -87,6 +86,7 @@ class RepositoriesTable implements DRConstants {
|
||||||
|
|
||||||
// store query result once
|
// store query result once
|
||||||
m_query = new RequestLocal() {
|
m_query = new RequestLocal() {
|
||||||
|
@Override
|
||||||
protected Object initialValue(PageState s) {
|
protected Object initialValue(PageState s) {
|
||||||
User viewer = DRUtils.getUser(s);
|
User viewer = DRUtils.getUser(s);
|
||||||
Session session = SessionManager.getSession();
|
Session session = SessionManager.getSession();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?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 docrepo applications -->
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>docrepo</servlet-name>
|
||||||
|
<servlet-class>com.arsdigita.docrepo.ui.DRServlet</servlet-class>
|
||||||
|
</servlet>
|
||||||
|
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>docrepo</servlet-name>
|
||||||
|
<url-pattern>/docrepo/*</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
|
||||||
|
</web-app>
|
||||||
Loading…
Reference in New Issue