CCM NG: More classes for the content section application
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4196 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
2948e65c3a
commit
1716a17093
|
|
@ -28,6 +28,9 @@ public class CmsConstants {
|
||||||
|
|
||||||
public static final String DB_SCHEMA = "CCM_CMS";
|
public static final String DB_SCHEMA = "CCM_CMS";
|
||||||
|
|
||||||
|
public static final String CONTENT_SECTION_APP_TYPE = "org.librecms.contentsection.ContentSection";
|
||||||
|
public static final String CONTENT_SECTION_SERVLET_PATH = "/templates/servlet/content-section/*";
|
||||||
|
|
||||||
public static final String PRIVILEGE_ADMINISTER_CATEGORIES = "administer_categories";
|
public static final String PRIVILEGE_ADMINISTER_CATEGORIES = "administer_categories";
|
||||||
public static final String PRIVILEGE_ADMINISTER_CONTENT_TYPES = "administer_content_types";
|
public static final String PRIVILEGE_ADMINISTER_CONTENT_TYPES = "administer_content_types";
|
||||||
public static final String PRIVILEGE_ADMINISTER_LIFECYLES = "administer_lifecyles";
|
public static final String PRIVILEGE_ADMINISTER_LIFECYLES = "administer_lifecyles";
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ import javax.persistence.JoinTable;
|
||||||
import javax.persistence.ManyToMany;
|
import javax.persistence.ManyToMany;
|
||||||
import javax.persistence.OneToOne;
|
import javax.persistence.OneToOne;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
import org.libreccm.web.ApplicationType;
|
||||||
|
|
||||||
import static org.librecms.CmsConstants.*;
|
import static org.librecms.CmsConstants.*;
|
||||||
|
|
||||||
|
|
@ -44,6 +45,12 @@ import static org.librecms.CmsConstants.*;
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "CONTENT_SECTIONS", schema = DB_SCHEMA)
|
@Table(name = "CONTENT_SECTIONS", schema = DB_SCHEMA)
|
||||||
|
@ApplicationType(
|
||||||
|
name = CONTENT_SECTION_APP_TYPE,
|
||||||
|
descBundle = "org.librecms.contentsection.ContentSectionResources",
|
||||||
|
singleton = false,
|
||||||
|
creator = ContentSectionCreator.class,
|
||||||
|
servlet = ContentSectionServlet.class)
|
||||||
public class ContentSection extends CcmApplication implements Serializable {
|
public class ContentSection extends CcmApplication implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = -671718122153931727L;
|
private static final long serialVersionUID = -671718122153931727L;
|
||||||
|
|
@ -57,7 +64,6 @@ public class ContentSection extends CcmApplication implements Serializable {
|
||||||
protected static final String PUBLISHER = "publisher";
|
protected static final String PUBLISHER = "publisher";
|
||||||
protected static final String CONTENT_READER = "content_reader";
|
protected static final String CONTENT_READER = "content_reader";
|
||||||
|
|
||||||
|
|
||||||
@Column(name = "LABEL", length = 512)
|
@Column(name = "LABEL", length = 512)
|
||||||
private String label;
|
private String label;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 LibreCCM Foundation.
|
||||||
|
*
|
||||||
|
* 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., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package org.librecms.contentsection;
|
||||||
|
|
||||||
|
import org.libreccm.configuration.Configuration;
|
||||||
|
import org.libreccm.configuration.Setting;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Global settings for content sections. Some of these settings control
|
||||||
|
* the initial values for new content sections.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class ContentSectionConfig {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 LibreCCM Foundation.
|
||||||
|
*
|
||||||
|
* 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., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package org.librecms.contentsection;
|
||||||
|
|
||||||
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import org.libreccm.web.ApplicationCreator;
|
||||||
|
import org.libreccm.web.ApplicationRepository;
|
||||||
|
import org.libreccm.web.ApplicationType;
|
||||||
|
import org.libreccm.web.CcmApplication;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@RequestScoped
|
||||||
|
public class ContentSectionCreator
|
||||||
|
implements ApplicationCreator<CcmApplication>{
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ApplicationRepository appRepo;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CcmApplication createInstance(final String primaryUrl,
|
||||||
|
final ApplicationType type) {
|
||||||
|
return appRepo.retrieveApplicationForPath(primaryUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,210 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 LibreCCM Foundation.
|
||||||
|
*
|
||||||
|
* 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., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package org.librecms.contentsection;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.Page;
|
||||||
|
import com.arsdigita.web.ApplicationFileResolver;
|
||||||
|
import com.arsdigita.web.BaseApplicationServlet;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import javax.servlet.ServletConfig;
|
||||||
|
import javax.servlet.ServletException;
|
||||||
|
import javax.servlet.annotation.WebServlet;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
import org.libreccm.web.CcmApplication;
|
||||||
|
import org.librecms.CmsConstants;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This servlet will maybe removed. Our current plan is to integrate the navigation
|
||||||
|
* application into ccm-cms, and to deliver all content using that app. Then
|
||||||
|
* this servlet becomes useless.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NOTE:
|
||||||
|
* Repaired ItemURLCache to save multilingual items with automatic
|
||||||
|
* language negotiation. The cache now uses the remaining url part
|
||||||
|
* and the language concatinated as a hash table key. The delimiter
|
||||||
|
* is CACHE_KEY_DELIMITER.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NOTE 2:
|
||||||
|
* In a process of refactoring from legacy compatible to legacy free applications.
|
||||||
|
* TODO:
|
||||||
|
* - replace url check using RequestContext which resolves to SiteNodeRequest
|
||||||
|
* implementation (due to SiteNodeRequest used in BaseApplicationServlet).
|
||||||
|
* - Refactor content item UI bebop ApplicationPage or PageFactory instead of
|
||||||
|
* legacy infected sitenode / package dispatchers.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Content Section's Application Servlet according CCM core web application
|
||||||
|
* structure {
|
||||||
|
*
|
||||||
|
* @see com.arsdigita.web.Application} implements the content section UI.
|
||||||
|
*
|
||||||
|
* It handles the UI for content items and delegates the UI for sections and
|
||||||
|
* folders to jsp templates.
|
||||||
|
*
|
||||||
|
* @author unknown
|
||||||
|
* @author <a href="mailto:pboy@barkhof.uni-bremen.de">Peter Boy</a>
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
@WebServlet(urlPatterns = {CmsConstants.CONTENT_SECTION_SERVLET_PATH})
|
||||||
|
public class ContentSectionServlet extends BaseApplicationServlet {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 8061725145564728637L;
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LogManager.getLogger(
|
||||||
|
ContentSectionServlet.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Literal for the prefix (in url) for previewing items
|
||||||
|
*/
|
||||||
|
public static final String PREVIEW = "/preview";
|
||||||
|
/**
|
||||||
|
* Literal Template files suffix
|
||||||
|
*/
|
||||||
|
public static final String FILE_SUFFIX = ".jsp";
|
||||||
|
/**
|
||||||
|
* Literal of URL Stub for index file name (includes leading slash)
|
||||||
|
*/
|
||||||
|
public static final String INDEX_FILE = "/index";
|
||||||
|
public static final String XML_SUFFIX = ".xml";
|
||||||
|
public static final String XML_MODE = "xmlMode";
|
||||||
|
public static final String MEDIA_TYPE = "templateContext";
|
||||||
|
private static final String CACHE_KEY_DELIMITER = "%";
|
||||||
|
|
||||||
|
public static final String CONTENT_ITEM
|
||||||
|
= "com.arsdigita.cms.dispatcher.item";
|
||||||
|
public static final String CONTENT_SECTION
|
||||||
|
= "com.arsdigita.cms.dispatcher.section";
|
||||||
|
|
||||||
|
//ToDo: private final ContentItemDispatcher m_disp = new ContentItemDispatcher();
|
||||||
|
public static Map s_itemResolverCache = Collections
|
||||||
|
.synchronizedMap(new HashMap());
|
||||||
|
private static Map s_itemURLCacheMap = null;
|
||||||
|
/**
|
||||||
|
* Whether to cache the content items
|
||||||
|
*/
|
||||||
|
private static final boolean s_cacheItems = true;
|
||||||
|
// NEW STUFF here used to process the pages in this servlet
|
||||||
|
/**
|
||||||
|
* 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();
|
||||||
|
/**
|
||||||
|
* Path to directory containg ccm-cms template (jsp) files
|
||||||
|
*/
|
||||||
|
private String m_templatePath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolver to actually use to find templates (JSP). JSP may be stored in
|
||||||
|
* file system or otherwise, depends on resolver. Resolver is retrieved from
|
||||||
|
* configuration. (probably used for other stuff as JSP's as well)
|
||||||
|
*/
|
||||||
|
private ApplicationFileResolver m_resolver;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init method overwrites parents init to pass in optional parameters
|
||||||
|
* {@link com.arsdigita.web.BaseServlet}. If not specified system wide
|
||||||
|
* defaults are used.
|
||||||
|
*
|
||||||
|
* @param config
|
||||||
|
* @throws javax.servlet.ServletException
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void init(ServletConfig config) throws ServletException {
|
||||||
|
|
||||||
|
super.init(config);
|
||||||
|
|
||||||
|
// optional init-param named template-path from ~/WEB-INF/web.xml
|
||||||
|
// may overwrite configuration parameters
|
||||||
|
String templatePath = config.getInitParameter("template-path");
|
||||||
|
//ToDo
|
||||||
|
/*if (templatePath == null) {
|
||||||
|
m_templatePath = ContentSection.getConfig().getTemplateRoot();
|
||||||
|
} else {
|
||||||
|
m_templatePath = config.getInitParameter("template-path");
|
||||||
|
}*/
|
||||||
|
|
||||||
|
// optional init-param named file-resolver from ~/WEB-INF/web.xml
|
||||||
|
String resolverName = config.getInitParameter("file-resolver");
|
||||||
|
|
||||||
|
//ToDo
|
||||||
|
// if (resolverName == null) {
|
||||||
|
// m_resolver = Web.getConfig().getApplicationFileResolver();
|
||||||
|
// } else {
|
||||||
|
// m_resolver = (ApplicationFileResolver) Classes.newInstance(
|
||||||
|
// resolverName);
|
||||||
|
// }
|
||||||
|
LOGGER.debug("Template path is {} with resolver {}",
|
||||||
|
m_templatePath,
|
||||||
|
m_resolver.getClass().getName());
|
||||||
|
|
||||||
|
// NEW STUFF here will be used to process the pages in this servlet
|
||||||
|
// Currently NOT working
|
||||||
|
// addPage("/admin", new MainPage()); // index page at address ~/cs
|
||||||
|
// addPage("/admin/index.jsp", new MainPage());
|
||||||
|
// addPage("/admin/item.jsp", new MainPage());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal service method, adds one pair of Url - Page to the internal hash
|
||||||
|
* map, used as a cache.
|
||||||
|
*
|
||||||
|
* @param pathInfo url stub for a page to display
|
||||||
|
* @param page Page object to display
|
||||||
|
*/
|
||||||
|
private void addPage(final String pathInfo, final Page page) {
|
||||||
|
m_pages.put(pathInfo, page);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of parent's (abstract) doService method checks HTTP
|
||||||
|
* request to determine whether to handle a content item or other stuff
|
||||||
|
* which is delegated to jsp templates.
|
||||||
|
* {
|
||||||
|
*
|
||||||
|
* @see com.arsdigita.web.BaseApplicationServlet#doService
|
||||||
|
* (HttpServletRequest, HttpServletResponse, Application)}
|
||||||
|
*
|
||||||
|
* @param request
|
||||||
|
* @param response
|
||||||
|
* @param app
|
||||||
|
* @throws javax.servlet.ServletException
|
||||||
|
* @throws java.io.IOException
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void doService(final HttpServletRequest request,
|
||||||
|
final HttpServletResponse response,
|
||||||
|
final CcmApplication app)
|
||||||
|
throws ServletException, IOException {
|
||||||
|
|
||||||
|
//ToDo
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
# Copyright (C) 2016 LibreCCM Foundation.
|
||||||
|
#
|
||||||
|
# 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., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
# MA 02110-1301 USA
|
||||||
|
|
||||||
|
application_title=Content Section
|
||||||
|
application_desc=A content section is used to group similar content.
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
# Copyright (C) 2016 LibreCCM Foundation.
|
||||||
|
#
|
||||||
|
# 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., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
# MA 02110-1301 USA
|
||||||
|
|
||||||
|
application_title=Inhaltssektion
|
||||||
|
application_desc=A content section is used to group similar content.
|
||||||
|
|
@ -32,8 +32,8 @@ import static com.arsdigita.ui.login.LoginConstants.*;
|
||||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
*/
|
*/
|
||||||
@RequestScoped
|
@RequestScoped
|
||||||
public class LoginApplicationCreator implements
|
public class LoginApplicationCreator
|
||||||
ApplicationCreator<CcmApplication> {
|
implements ApplicationCreator<CcmApplication> {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ApplicationRepository appRepository;
|
private ApplicationRepository appRepository;
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,8 @@ import static com.arsdigita.ui.login.LoginConstants.*;
|
||||||
* expose various properties, especially the URL_MSG's of public subpages (e.g.
|
* expose various properties, especially the URL_MSG's of public subpages (e.g.
|
||||||
* logout) and initializes the creation of the UI.
|
* logout) and initializes the creation of the UI.
|
||||||
*
|
*
|
||||||
* @author Peter Boy <pboy@barkhof.uni-bremen.de>
|
* @author <a href="mailto:pboy@barkhof.uni-bremen.de">Peter Boy</a>
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
*/
|
*/
|
||||||
@WebServlet(urlPatterns = {LOGIN_SERVLET_PATH})
|
@WebServlet(urlPatterns = {LOGIN_SERVLET_PATH})
|
||||||
public class LoginServlet extends BebopApplicationServlet {
|
public class LoginServlet extends BebopApplicationServlet {
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ public abstract class BaseServlet extends HttpServlet {
|
||||||
* @throws javax.servlet.ServletException
|
* @throws javax.servlet.ServletException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final void init(final ServletConfig config) throws ServletException {
|
public void init(final ServletConfig config) throws ServletException {
|
||||||
LOGGER.info("Initialising servlet %s (class: %s)...",
|
LOGGER.info("Initialising servlet %s (class: %s)...",
|
||||||
config.getServletName(),
|
config.getServletName(),
|
||||||
getClass().getName());
|
getClass().getName());
|
||||||
|
|
|
||||||
|
|
@ -30,10 +30,8 @@ import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.xml.bind.JAXB;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.libreccm.categorization.Domain;
|
|
||||||
|
|
||||||
import org.libreccm.modules.CcmModule;
|
import org.libreccm.modules.CcmModule;
|
||||||
import org.libreccm.modules.InitEvent;
|
import org.libreccm.modules.InitEvent;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue