From 7ce68f3cd7600bb2b3b8087ebe670740f6e0f716 Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Tue, 15 Mar 2022 20:21:30 +0100 Subject: [PATCH] Removed several old classes --- .../java/com/arsdigita/cms/ContentCenter.java | 33 -- .../arsdigita/cms/ContentCenterServlet.java | 307 ------------ .../cms/ContentItemXMLRenderer.java.off | 155 ------ .../dispatcher/ContentSectionDispatcher.java | 8 +- .../DefaultTemplateResolver.java.off | 246 ---------- .../cms/dispatcher/FileDispatcher.java | 99 ---- .../dispatcher/SimpleXMLGenerator.java.off | 445 ------------------ .../cms/dispatcher/TemplateResolver.java.off | 97 ---- .../java/com/arsdigita/cms/ui/BaseTree.java | 63 --- .../cms/ui/ContentItemContextBar.java | 120 ----- .../com/arsdigita/cms/ui/ContentItemPage.java | 7 +- .../cms/ui/ContentSectionContextBar.java | 154 ------ .../arsdigita/cms/ui/ContentSectionPage.java | 10 +- .../com/arsdigita/cms/ui/ImagesPane.java.todo | 265 ----------- .../java/com/arsdigita/cms/ui/ReportPane.java | 171 ------- .../assets/forms/AbstractBinaryAssetForm.java | 198 -------- .../AbstractBinaryAssetFormController.java | 98 ---- .../ui/assets/forms/AbstractBookmarkForm.java | 141 ------ .../forms/AbstractBookmarkFormController.java | 77 --- .../forms/AbstractContactableEntityForm.java | 434 ----------------- ...stractContactableEntityFormController.java | 210 --------- .../cms/ui/assets/forms/AudioForm.java | 128 ----- .../ui/assets/forms/AudioFormController.java | 82 ---- .../cms/ui/assets/forms/BookmarkForm.java | 182 ------- .../assets/forms/BookmarkFormController.java | 36 -- .../assets/forms/ExternalAudioAssetForm.java | 104 ---- .../ExternalAudioAssetFormController.java | 81 ---- .../assets/forms/ExternalVideoAssetForm.java | 100 ---- .../ExternalVideoAssetFormController.java | 83 ---- .../cms/ui/assets/forms/FileAssetForm.java | 40 -- .../assets/forms/FileAssetFormController.java | 35 -- .../cms/ui/assets/forms/ImageForm.java | 133 ------ .../ui/assets/forms/ImageFormController.java | 95 ---- .../ui/assets/forms/LegalMetadataForm.java | 143 ------ .../forms/LegalMetadataFormController.java | 93 ---- .../cms/ui/assets/forms/OrganizationForm.java | 95 ---- .../forms/OrganizationFormController.java | 65 --- .../cms/ui/assets/forms/PersonForm.java | 323 ------------- .../ui/assets/forms/PersonFormController.java | 183 ------- .../ui/assets/forms/PostalAddressForm.java | 111 ----- .../forms/PostalAddressFormController.java | 82 ---- .../cms/ui/assets/forms/RelatedLinkForm.java | 58 --- .../cms/ui/assets/forms/SideNoteForm.java | 102 ---- .../assets/forms/SideNoteFormController.java | 67 --- .../cms/ui/assets/forms/VideoForm.java | 130 ----- .../ui/assets/forms/VideoFormController.java | 98 ---- .../ui/assets/searchpage/AssetSearchPage.java | 185 -------- .../searchpage/AssetSearchPageController.java | 85 ---- .../assets/searchpage/ResultsTableModel.java | 76 --- .../ui/assets/searchpage/ResultsTableRow.java | 64 --- .../AbstractContentItemComponentForm.java | 97 ---- .../CategorizedItemComponentForm.java | 50 -- .../pagemodel/CategoryTreeComponentForm.java | 111 ----- .../FixedContentItemComponentForm.java | 123 ----- .../pagemodel/GreetingItemComponentForm.java | 50 -- .../ui/pagemodel/ItemListComponentForm.java | 207 -------- .../london/terms/ui/CategorySubtree.java | 161 ------- .../terms/ui/CategorySubtreeController.java | 50 -- ccm-cms/src/main/java/org/librecms/Cms.java | 61 +-- .../java/org/librecms/assets/AssetType.java | 11 +- .../librecms/assets/AssetTypesManager.java | 2 - .../java/org/librecms/assets/AudioAsset.java | 6 +- .../java/org/librecms/assets/Bookmark.java | 12 +- .../librecms/assets/ExternalAudioAsset.java | 12 +- .../librecms/assets/ExternalVideoAsset.java | 14 +- .../java/org/librecms/assets/FileAsset.java | 21 +- .../main/java/org/librecms/assets/Image.java | 15 +- .../org/librecms/assets/LegalMetadata.java | 2 - .../org/librecms/assets/Organization.java | 12 +- .../main/java/org/librecms/assets/Person.java | 10 +- .../org/librecms/assets/PostalAddress.java | 11 +- .../java/org/librecms/assets/RelatedLink.java | 2 - .../java/org/librecms/assets/SideNote.java | 2 - .../java/org/librecms/assets/VideoAsset.java | 6 +- .../java/org/libreccm/modules/Module.java | 1 + .../org/libreccm/web/ApplicationType.java | 2 + 76 files changed, 68 insertions(+), 7380 deletions(-) delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ContentCenter.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ContentCenterServlet.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ContentItemXMLRenderer.java.off delete mode 100755 ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/DefaultTemplateResolver.java.off delete mode 100755 ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/FileDispatcher.java delete mode 100755 ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/SimpleXMLGenerator.java.off delete mode 100755 ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/TemplateResolver.java.off delete mode 100755 ccm-cms/src/main/java/com/arsdigita/cms/ui/BaseTree.java delete mode 100755 ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentItemContextBar.java delete mode 100755 ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentSectionContextBar.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/ImagesPane.java.todo delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/ReportPane.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractBinaryAssetForm.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractBinaryAssetFormController.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractBookmarkForm.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractBookmarkFormController.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractContactableEntityForm.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractContactableEntityFormController.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AudioForm.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AudioFormController.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/BookmarkForm.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/BookmarkFormController.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/ExternalAudioAssetForm.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/ExternalAudioAssetFormController.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/ExternalVideoAssetForm.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/ExternalVideoAssetFormController.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/FileAssetForm.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/FileAssetFormController.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/ImageForm.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/ImageFormController.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/LegalMetadataForm.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/LegalMetadataFormController.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/OrganizationForm.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/OrganizationFormController.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/PersonForm.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/PersonFormController.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/PostalAddressForm.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/PostalAddressFormController.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/RelatedLinkForm.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/SideNoteForm.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/SideNoteFormController.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/VideoForm.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/VideoFormController.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/searchpage/AssetSearchPage.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/searchpage/AssetSearchPageController.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/searchpage/ResultsTableModel.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/searchpage/ResultsTableRow.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/pagemodel/AbstractContentItemComponentForm.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/pagemodel/CategorizedItemComponentForm.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/pagemodel/CategoryTreeComponentForm.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/pagemodel/FixedContentItemComponentForm.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/pagemodel/GreetingItemComponentForm.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/cms/ui/pagemodel/ItemListComponentForm.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/london/terms/ui/CategorySubtree.java delete mode 100644 ccm-cms/src/main/java/com/arsdigita/london/terms/ui/CategorySubtreeController.java diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ContentCenter.java b/ccm-cms/src/main/java/com/arsdigita/cms/ContentCenter.java deleted file mode 100644 index 73eb958ae..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ContentCenter.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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 com.arsdigita.cms; - -import org.libreccm.web.CcmApplication; - -/** - * - * @author Jens Pelzetter - */ -public class ContentCenter extends CcmApplication { - - private static final long serialVersionUID = 6672720141286517654L; - - - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ContentCenterServlet.java b/ccm-cms/src/main/java/com/arsdigita/cms/ContentCenterServlet.java deleted file mode 100644 index 6333b9db6..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ContentCenterServlet.java +++ /dev/null @@ -1,307 +0,0 @@ -/* - * 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 com.arsdigita.cms; - -import com.arsdigita.bebop.Page; -import com.arsdigita.cms.dispatcher.CMSPage; -import com.arsdigita.cms.ui.CMSApplicationPage; -import com.arsdigita.cms.ui.contentcenter.MainPage; - -import com.arsdigita.dispatcher.DispatcherHelper; -import com.arsdigita.dispatcher.RequestContext; -import com.arsdigita.kernel.security.Util; -import com.arsdigita.templating.PresentationManager; -import com.arsdigita.templating.Templating; -import com.arsdigita.ui.login.LoginHelper; -import com.arsdigita.web.ApplicationFileResolver; -import com.arsdigita.web.BaseApplicationServlet; -import com.arsdigita.web.LoginSignal; -import com.arsdigita.web.WebConfig; -import com.arsdigita.xml.Document; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.apache.shiro.authz.AuthorizationException; -import org.libreccm.cdi.utils.CdiUtil; -import org.libreccm.security.PermissionChecker; -import org.libreccm.security.Shiro; -import org.libreccm.web.CcmApplication; -import org.librecms.contentsection.ContentSection; -import org.librecms.contentsection.ContentSectionRepository; -import org.librecms.contentsection.privileges.ItemPrivileges; - -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletException; -import javax.servlet.annotation.WebServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * CMS ContentCenter (content-center) application servlet serves all request - * made within the Content Center application. - * - * @author Peter Boy - * @author Jens Pelzetter - */ -@WebServlet(urlPatterns = "/content-center/*") -public class ContentCenterServlet extends BaseApplicationServlet { - - private static final long serialVersionUID = 16543266935651171L; - - /** - * URL (pathinfo) -> Page object mapping. Based on it (and the http request - * url) the doService method to selects a page to display - */ - private final Map pages = new HashMap<>(); - - /** - * Path to directory containg ccm-cms template files - */ - private String m_templatePath; - /** - * Resolvers to find templates (JSP) and other stuff stored in file system. - */ - private ApplicationFileResolver m_resolver; - - private static final Logger LOGGER = LogManager.getLogger( - ContentCenterServlet.class); - - /** - * Use parent's class initialisation extension point to perform additional - * initialisation tasks. - */ - @Override - protected void doInit() { - LOGGER.info("starting doInit method"); - - // NEW STUFF here used to process the pages in this servlet - // Addresses previously noted in WEB-INF/resources/content-center-map.xml - // Obviously not required. - - - addPage("/", new MainPage()); // index page at address ~/cc - addPage("/index", new MainPage()); - - -// addPage("/item-search", new CMSItemSearchPage()); - // Old style - //addPage("/item-search", new ItemSearchPage()); - //addPage("/searchredirect", new CMSSearchResultRedirector()); - - // STUFF to use for JSP extension, i.e. jsp's to try for URLs which are not - // handled by the this servlet directly. - /** - * Set Template base path for JSP's - */ - // ToDo: Make it configurable by an appropriate config registry entry! - // m_templatePath = CMS.getConfig().getTemplateRoot(); - m_templatePath = "/templates/ccm-cms/content-center"; - /** - * Set TemplateResolver class - */ - m_resolver = WebConfig.getConfig().getResolver(); - } - - @Override - protected void doService(final HttpServletRequest sreq, - final HttpServletResponse sresp, - final CcmApplication app) throws ServletException, - IOException { - LOGGER.info("starting doService method"); - - // ContentCenter workspace = (ContentCenter) app; - - /* Check user and privilegies */ - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final Shiro shiro = cdiUtil.findBean(Shiro.class); - if (!shiro.getSubject().isAuthenticated()) { - throw new LoginSignal(sreq); // send to login page - } - final PermissionChecker permissionChecker = cdiUtil.findBean( - PermissionChecker.class); - final ContentSectionRepository sectionRepo = cdiUtil.findBean( - ContentSectionRepository.class); - final List sections = sectionRepo.findAll(); - boolean hasAccess = false; - for (final ContentSection section : sections) { - if (permissionChecker.isPermitted(ItemPrivileges.EDIT, - section.getRootDocumentsFolder())) { - hasAccess = true; - break; - } - } - - if (!hasAccess) { // user has no access privilege - throw new AuthorizationException( - "User is not entitled to access any content section"); - // throw new LoginSignal(sreq); // send to login page - } - - // New way to fetch the page - String pathInfo = sreq.getPathInfo(); - 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); - } - - // An empty remaining URL or a URL which doesn't end in trailing slash: - // probably want to redirect. - // Probably DEPRECATED with new access method or only relevant for jsp - // extension - // if (m_trailingSlashList.contains(url) && !originalUrl.endsWith("/")) { - // DispatcherHelper.sendRedirect(sresp, originalUrl + "/"); - // return; - // } - final Page page = pages.get(pathInfo); - if (page != null) { - - // Check user access. - checkUserAccess(sreq, sresp); - - if (page instanceof CMSPage) { - // backwards compatibility fix until migration completed - final CMSPage cmsPage = (CMSPage) page; - final RequestContext ctx = DispatcherHelper.getRequestContext(); - cmsPage.init(); - cmsPage.dispatch(sreq, sresp, ctx); - } else { - final CMSApplicationPage cmsAppPage = (CMSApplicationPage) page; - cmsAppPage.init(sreq, sresp, app); - // Serve the page. - final Document doc = cmsAppPage.buildDocument(sreq, sresp); - - PresentationManager pm = Templating.getPresentationManager(); - pm.servePage(doc, sreq, sresp); - } - - } else { - // Fall back on the JSP application dispatcher. - // NOTE: The JSP must ensure the proper authentication and - // authorisation if required! - LOGGER.info("NO page registered to serve the requst url."); - - RequestDispatcher rd = m_resolver.resolve(m_templatePath, - sreq, sresp, app); - if (rd != null) { - LOGGER.debug("Got dispatcher " + rd); - - final HttpServletRequest origreq = DispatcherHelper - .restoreOriginalRequest(sreq); - rd.forward(origreq, sresp); - } else { - - sresp.sendError(404, sreq.getRequestURI() - + " not found on this server."); - } - - } - - LOGGER.info("doService method completed"); - - } // END doService() - - /** - * Internal service mechod, 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) { - - // Current Implementation requires pathInfo to start with a leading '/' - // SUN Servlet API specifies: "PathInfo *may be empty* or will start - // with a '/' character." - pages.put(pathInfo, page); - - } - -// /** -// * Service Method returns the URL stub for the class name, can return null -// * if not mapped -// */ -// // Currently still in use by c.ad.cms.ui.ItemSearchWidget -// public static String getURLStubForClass(String classname) { -// LOGGER.debug("Getting URL Stub for : " + classname); -// Iterator itr = s_pageURLs.keySet().iterator(); -// while (itr.hasNext()) { -// String classname2 = (String) itr.next(); -// s_log.debug("key: " + classname + " value: " -// + (String) s_pageURLs.get(classname2)); -// } -// String url = (String) s_pageURLs.get(classname); -// return url; -// } - /** - * Verify that the user is logged in and is able to view the page. - * Subclasses can override this method if they need to, but should always be - * sure to call super.checkUserAccess(...) - * - * @param request The HTTP request - * @param response The HTTP response - * @param actx The request context - * - */ - protected void checkUserAccess(final HttpServletRequest request, - final HttpServletResponse response //, - /// final RequestContext actx - ) - throws ServletException { - - if (!CdiUtil.createCdiUtil().findBean(Shiro.class).getSubject() - .isAuthenticated()) { - throw new LoginSignal(request); - } - } - - /** - * Redirects the client to the login page, setting the return url to the - * current request URI. - * - * @exception ServletException If there is an exception thrown while trying - * to redirect, wrap that exception in a - * ServletException - * - */ - protected void redirectToLoginPage(HttpServletRequest req, - HttpServletResponse resp) - throws ServletException { - String url = Util.getSecurityHelper() - .getLoginURL(req) - + "?" + LoginHelper.RETURN_URL_PARAM_NAME - + "=" + DispatcherHelper.encodeReturnURL(req); - try { - LoginHelper.sendRedirect(req, resp, url); - } catch (IOException e) { - LOGGER.error("IO Exception", e); - throw new ServletException(e.getMessage(), e); - } - } - - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ContentItemXMLRenderer.java.off b/ccm-cms/src/main/java/com/arsdigita/cms/ContentItemXMLRenderer.java.off deleted file mode 100644 index 0ce8896c3..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ContentItemXMLRenderer.java.off +++ /dev/null @@ -1,155 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.arsdigita.cms; - -import com.arsdigita.cms.contenttypes.GenericAddress; -import com.arsdigita.dispatcher.DispatcherHelper; -import com.arsdigita.domain.DomainObject; -import com.arsdigita.domain.DomainObjectTraversalAdapter; -import com.arsdigita.domain.DomainObjectXMLRenderer; -import com.arsdigita.globalization.GlobalizationHelper; -import com.arsdigita.persistence.metadata.Property; -import com.arsdigita.xml.Element; -import org.apache.log4j.Logger; - -/** - * This is a special ContentItemXMLRenderer for CMS to get a more transparent - * way to handle ContentBundles during XML output. - * - * The problem was to change RelatedLinks and therefore Link to always link to - * the corresponding ContentBundle instead of the content item. To get the - * corresponding content item during XML generation, I have to test for - * ContentBundle and negotiate the language version. - * This is not possible in com.arsdigita.ccm - * - * @author quasi - */ -public class ContentItemXMLRenderer extends DomainObjectXMLRenderer { - - private static final Logger logger = - Logger.getLogger(ContentItemXMLRenderer.class); - private String m_propertyName = ""; - private String m_keyName = ""; - private String m_relationAttribute = ""; - - public ContentItemXMLRenderer(final Element root) { - super(root); - } - - // This method will be called by DomainObjectTraversal.walk() - // It's purpose is to test for ContentBundle objects and if found, replace - // that object with the negotiated version of the content item. - // Otherwise this methd will do nothing. - @Override - protected void walk(final DomainObjectTraversalAdapter adapter, - final DomainObject obj, - final String path, - final String context, - final DomainObject linkObject) { - //final long start = System.nanoTime(); - - DomainObject nObj = obj; - - if (nObj instanceof ContentBundle) { - - nObj = ((ContentBundle) obj).getInstance(GlobalizationHelper.getNegotiatedLocale(), true); - } - - super.walk(adapter, nObj, path, context, linkObject); - - //System.out.printf("Walked object in %d ms\n", (System.nanoTime() - start) / 1000000); - } - - @Override - protected void handleAttribute(final DomainObject obj, final String path, final Property property) { - final String propertyName = property.getName(); - - // Special handling for the isoCountryCode field in GenericAddress - if (obj instanceof GenericAddress && "isoCountryCode".equals(propertyName)) { - //if (propertyName.equals("isoCountryCode")) { - super.handleAttribute(obj, path, property); - - final Element element = newElement(m_element, "country"); - element.setText(GenericAddress.getCountryNameFromIsoCode(((GenericAddress) obj).getIsoCountryCode())); - return; - - } - - // Special handling for the relation attribute keys - if (!m_relationAttribute.isEmpty()) { - String key = ""; - - // The RelationAttribute is part of this domain object as field - if (obj instanceof RelationAttributeInterface - && ((RelationAttributeInterface) obj). - hasRelationAttributeProperty(propertyName)) { - - final RelationAttributeInterface relationAttributeObject = (RelationAttributeInterface) obj; - key = relationAttributeObject.getRelationAttributeKey( - propertyName); - - } - - // This RelationAttribute is part of an n:m association as link attribute - if (obj instanceof LinkDomainObject - && propertyName.equals(m_keyName)) { - key = (String) ((LinkDomainObject) obj).get(m_keyName); - } - - // Replace value of the property defined in RELATION_ATTRIBUTES string - // of the primary domain object with the localized String. - if (!key.isEmpty()) { -// logger.debug(String.format( -// "Getting relation attribute value for key '%s' of relation attribute '%s'", -// key, m_relationAttribute)); - final RelationAttributeCollection relationAttributeCollection = new RelationAttributeCollection( - m_relationAttribute, key); - relationAttributeCollection.addLanguageFilter(GlobalizationHelper. - getNegotiatedLocale().getLanguage()); - if (!relationAttributeCollection.isEmpty()) { - relationAttributeCollection.next(); - final Element element = newElement(m_element, m_keyName); - element.setText(relationAttributeCollection.getName()); - final Element elementId = newElement(m_element, m_keyName + "Id"); - elementId.setText(relationAttributeCollection.getKey()); - relationAttributeCollection.close(); - } - return; - } - } - - super.handleAttribute(obj, path, property); - } - - @Override - protected void beginAssociation(final DomainObject obj, final String path, final Property property) { - super.beginAssociation(obj, path, property); - - final String propertyName = property.getName(); - - if (obj instanceof RelationAttributeInterface - && ((RelationAttributeInterface) obj).hasRelationAttributeProperty( - propertyName)) { - - final RelationAttributeInterface relationAttributeObject = (RelationAttributeInterface) obj; - - m_propertyName = propertyName; - m_keyName = relationAttributeObject.getRelationAttributeKeyName(propertyName); - m_relationAttribute = relationAttributeObject.getRelationAttributeName(propertyName); - - } - } - - @Override - protected void endAssociation(final DomainObject obj, final String path, final Property property) { - - m_propertyName = ""; - m_keyName = ""; - m_relationAttribute = ""; - - super.endAssociation(obj, path, property); - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/ContentSectionDispatcher.java b/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/ContentSectionDispatcher.java index d2988c5c6..b77290f96 100755 --- a/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/ContentSectionDispatcher.java +++ b/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/ContentSectionDispatcher.java @@ -57,10 +57,10 @@ public class ContentSectionDispatcher implements Dispatcher { public ContentSectionDispatcher() { - dispatcherChain.addChainedDispatcher(new CMSDispatcher(true)); - dispatcherChain.addChainedDispatcher(new FileDispatcher()); - dispatcherChain.addChainedDispatcher(new ItemDispatcher()); - dispatcherChain.addChainedDispatcher(new CMSDispatcher()); +// dispatcherChain.addChainedDispatcher(new CMSDispatcher(true)); +// dispatcherChain.addChainedDispatcher(new FileDispatcher()); +// dispatcherChain.addChainedDispatcher(new ItemDispatcher()); +// dispatcherChain.addChainedDispatcher(new CMSDispatcher()); } public void dispatch(HttpServletRequest request, diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/DefaultTemplateResolver.java.off b/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/DefaultTemplateResolver.java.off deleted file mode 100755 index 16c522f5b..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/DefaultTemplateResolver.java.off +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved. - * - * 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.dispatcher; - -import com.arsdigita.cms.ContentItem; -import com.arsdigita.cms.ContentSection; -import com.arsdigita.cms.ContentType; -import com.arsdigita.cms.Folder; -import com.arsdigita.cms.Template; -import com.arsdigita.cms.TemplateManager; -import com.arsdigita.cms.TemplateManagerFactory; -import com.arsdigita.mimetypes.MimeType; -import com.arsdigita.util.Assert; -import org.apache.log4j.Logger; - -import javax.servlet.http.HttpServletRequest; - -/** - * ------- May be outdated. TemplateResolver has been reworked. ---------- - * Resolves the JSP template to use for dispatching an - * item. This replaces TemplateResolver since the latter - * has a useless API. - * ------------------------------------------------------------------------ - * - *

In general, the process for resolving a template involves two - * steps:

- * - *
    - * - *
  1. The template resolver examines specific properties of the - * item, the content section, and/or the request itself and selects - * an appropriate context. A context is simply a token - * such as "plain" or "fancy". - * - *
  2. Based on the selected context, the template resolver - * identifies an appropriate template for the item. This is a - * three-step process: (1) the resolver queries for an association - * between the item and a specific template for the selected - * context; (2) if no such association exists, the resolver queries - * the item's content type for a default template to use in the - * selected context; (3) if a default template is not found, return - * null (at which point the dispatcher should probably give up and - * return a 404 error). - * - *
- */ - -public class DefaultTemplateResolver extends AbstractTemplateResolver - implements TemplateResolver { - - private static Logger s_log = Logger.getLogger(DefaultTemplateResolver.class); - - /** - * Returns the JSP template filename relative to the webapp - * root. - * - * @param section The ContentSection for the request - * @param item The ContentItem for the request - * @param request The current HttpServletRequest - * - * @return The path to the jsp template. - */ - public String getTemplate(ContentSection section, - ContentItem item, - HttpServletRequest request) { - - String template = getItemTemplate(section, item, request); - MimeType mimeType = MimeType.loadMimeType(Template.JSP_MIME_TYPE); - - if (template == null) { - if (s_log.isDebugEnabled()) { - s_log.debug("No item template, looking for content type template"); - } - template = getTypeTemplate(section, item, request, mimeType); - } - - if (template == null) { - if (s_log.isDebugEnabled()) { - s_log.debug("No content type template, looking for default template"); - } - - template = getDefaultTemplate(section, item, request); - - Assert.exists(template, "default template"); - } - - if (s_log.isInfoEnabled()) { - s_log.info("Got template " + template + " for item " + item.getOID()); - } - - return ContentSection.getConfig().getTemplateRoot() + template; - } - - /** - * Returns the JSP template filename relative to the webapp - * root for a given Template reference. - * - * @param template The Template to resolve the URL for. - * - * @return The path to the jsp template. - */ - public String getTemplatePath(Template template) { - - return ContentSection.getConfig().getTemplateRoot() + - getTemplateFilename(template, template.getContentSection()); - } - - /** - * Returns the XSL template filename relative to the webapp - * root for a given Template reference. - * - * @param template The Template to resolve the URL for. - * - * @return The path to the xsl template. - */ - public String getTemplateXSLPath(Template template) { - - return ContentSection.getConfig().getTemplateRoot() + - getTemplateXSLFilename(template, template.getContentSection()); - } - - /** - * Returns the template associated with the item (if any) - */ - protected String getItemTemplate(ContentSection section, - ContentItem item, - HttpServletRequest request) { - TemplateManager manager = TemplateManagerFactory.getInstance(); - String context = getTemplateContext(request); - Template template = manager.getTemplate(item, context); - - return template == null ? null : getTemplateFilename( - template, section - ); - } - - /** - * Returns the template associated with the type (if any) - * @deprecated Use the version that specifies a mime type - */ - protected String getTypeTemplate(ContentSection section, - ContentItem item, - HttpServletRequest request) { - MimeType mimeType = MimeType.loadMimeType(Template.JSP_MIME_TYPE); - return getTypeTemplate(section, item, request, mimeType); - } - - /** - * Returns the template associated with the type (if any) - */ - protected String getTypeTemplate(ContentSection section, - ContentItem item, - HttpServletRequest request, - MimeType mimeType) { - TemplateManager manager = TemplateManagerFactory.getInstance(); - ContentType type = item.getContentType(); - - Template template = null; - - if (type != null ) { - String context = getTemplateContext(request); - template = manager.getDefaultTemplate(section, type, context, mimeType); - } else { - if (s_log.isDebugEnabled()) { - s_log.debug("Item has no content type, not looking for a " + - "content type specific template"); - } - } - - return template == null ? null : getTemplateFilename( - template, section - ); - } - - /** - * Returns the default template - */ - protected String getDefaultTemplate(ContentSection section, - ContentItem item, - HttpServletRequest request) { - String path = (item instanceof Folder) ? - ContentSection.getConfig().getDefaultFolderTemplatePath() : - ContentSection.getConfig().getDefaultItemTemplatePath(); - - return path; - } - - /** - * Returns the filename for a Template object - */ - protected String getTemplateFilename(Template template, - ContentSection section, - ContentItem item, - HttpServletRequest request) { - return getTemplateFilename(template, section); - } - - /** - * Returns the filename for a Template object - */ - protected String getTemplateXSLFilename(Template template, - ContentSection section, - ContentItem item, - HttpServletRequest request) { - return getTemplateXSLFilename(template, section); - } - - /** - * Returns the filename for a Template object - */ - protected String getTemplateFilename(Template template, - ContentSection section) { - - String templateName = template.getPath(); - String sectionURL = section.getPath(); - return sectionURL + "/" + templateName; - } - - /** - * Returns the filename for a Template object - */ - protected String getTemplateXSLFilename(Template template, - ContentSection section) { - - String templateName = template.getPathNoJsp() + ".xsl"; - String sectionURL = section.getPath(); - - return sectionURL + "/" + templateName; - } -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/FileDispatcher.java b/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/FileDispatcher.java deleted file mode 100755 index efea84744..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/FileDispatcher.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved. - * - * 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.dispatcher; - -import com.arsdigita.dispatcher.ChainedDispatcher; -import com.arsdigita.dispatcher.DispatcherHelper; -import com.arsdigita.dispatcher.RequestContext; - -import org.apache.logging.log4j.LogManager; - -import java.io.File; -import java.io.IOException; - -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.logging.log4j.Logger; - -/** - * Dispatches to a file stored under the CMS package root - * (/packages/cms/www). This includes both unmanaged files copied - * or created directly in the file system, as well as pages and assets published - * to the file system from CMS. - * - * @author Karl Goldstein (karlg@arsdigita.com) - * @version $Revision$ $DateTime: 2004/08/17 23:15:09 $ - * @version $Id$ - * - */ -public class FileDispatcher implements ChainedDispatcher { - - private static final Logger LOGGER = LogManager.getLogger( - ChainedDispatcher.class); - - @Override - public int chainedDispatch(HttpServletRequest request, - HttpServletResponse response, - RequestContext context) - throws IOException, ServletException { - - File jspFile = getPackageFile(context); - - if (jspFile.exists() && !jspFile.isDirectory()) { - String packageURL = context.getPageBase() + context - .getRemainingURLPart(); - LOGGER.debug("DISPATCHING to " + packageURL); - - // don't match folders, since they don't actually match a file - if (!packageURL.endsWith("/")) { - LOGGER.debug("DISPATCHING to " + packageURL); - // Don't set caching headers - let JSP file do it if required - //DispatcherHelper.maybeCacheDisable(response); - DispatcherHelper.setRequestContext(request, context); - DispatcherHelper.forwardRequestByPath(packageURL, request, - response); - return ChainedDispatcher.DISPATCH_BREAK; - } - } - - return ChainedDispatcher.DISPATCH_CONTINUE; - } - - /** - * Matches the request URL to a file in the package www directory. - * - */ - private File getPackageFile(RequestContext appContext) { - - ServletContext servletContext = appContext.getServletContext(); - - String filePath = appContext.getRemainingURLPart(); - - String packageDocRoot = servletContext.getRealPath(appContext - .getPageBase()); - - File jspFile = new File(packageDocRoot, filePath); - - return jspFile; - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/SimpleXMLGenerator.java.off b/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/SimpleXMLGenerator.java.off deleted file mode 100755 index 29e87838c..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/SimpleXMLGenerator.java.off +++ /dev/null @@ -1,445 +0,0 @@ -/* - * Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved. - * - * 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.dispatcher; - -import com.arsdigita.bebop.PageState; -import com.arsdigita.cms.CMS; -import com.arsdigita.cms.CMSConfig; -import com.arsdigita.cms.ContentItem; -import com.arsdigita.cms.ContentItemXMLRenderer; -import com.arsdigita.cms.ExtraXMLGenerator; -import com.arsdigita.cms.SecurityManager; -import com.arsdigita.cms.UserDefinedContentItem; -import com.arsdigita.cms.XMLDeliveryCache; -import com.arsdigita.cms.util.GlobalizationUtil; -import com.arsdigita.domain.DataObjectNotFoundException; -import com.arsdigita.domain.DomainObjectFactory; -import com.arsdigita.domain.DomainObjectTraversal; -import com.arsdigita.domain.SimpleDomainObjectTraversalAdapter; -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.kernel.permissions.PrivilegeDescriptor; -import com.arsdigita.metadata.DynamicObjectType; -import com.arsdigita.persistence.OID; -import com.arsdigita.persistence.metadata.Property; -import com.arsdigita.util.UncheckedWrapperException; -import com.arsdigita.xml.Element; -import org.apache.log4j.Logger; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Map; - -/** - *

The default XMLGenerator implementation.

- * - * @author Michael Pih - * @version $Revision: #20 $ $DateTime: 2004/08/17 23:15:09 $ - * @version $Id: SimpleXMLGenerator.java 2167 2011-06-19 21:12:12Z pboy $ - */ -public class SimpleXMLGenerator implements XMLGenerator { - - private static final Logger s_log = Logger.getLogger(SimpleXMLGenerator.class); - public static final String ADAPTER_CONTEXT = SimpleXMLGenerator.class.getName(); - /** - * jensp 2011-10-23: Sometimes the extra XML is not needed, for example - * when embedding the XML of a content item into the XML output of another - * content item. The default value {@code true}. To change the value - * call {@link #setUseExtraXml(booelan)} after creating an instance of - * your generator. - */ - private boolean useExtraXml = true; - /** - * jensp 2012-04-18: This value is forwarded to this ExtraXMLGenerators - * by calling {@link ExtraXMLGenerator#setListMode(boolean)}. The behavior - * triggered by this value depends on the specific implementation of - * the {@code ExtraXMLGenerator} - */ - private boolean listMode = false; - /** - * Extra attributes for the cms:item element. - */ - private final Map itemAttributes = new LinkedHashMap(); - /** - * Allows to overwrite the name and the namespace of the XML element - * used to wrap the rendered item. - */ - private String itemElemName = "cms:item"; - private String itemElemNs = CMS.CMS_XML_NS; - - // Register general purpose adaptor for all content items - static { - s_log.debug("Static initializer starting..."); - final SimpleDomainObjectTraversalAdapter adapter = new SimpleDomainObjectTraversalAdapter(); - adapter.addAssociationProperty("/object/type"); - adapter.addAssociationProperty("/object/categories"); - - DomainObjectTraversal.registerAdapter( - ContentItem.BASE_DATA_OBJECT_TYPE, - adapter, - ADAPTER_CONTEXT); - s_log.debug("Static initializer finished"); - } - - public SimpleXMLGenerator() { - super(); - } - - public void setUseExtraXml(final boolean useExtraXml) { - this.useExtraXml = useExtraXml; - } - - public void setListMode(final boolean listMode) { - this.listMode = listMode; - } - - public void addItemAttribute(final String name, final String value) { - itemAttributes.put(name, value); - } - - public void setItemElemName(final String itemElemName, final String itemElemNs) { - this.itemElemName = itemElemName; - this.itemElemNs = itemElemNs; - } - - /** - * Generates the XML to render the content panel. - * - * @param state The page state - * @param parent The parent DOM element - * @param useContext The use context - */ - @Override - public void generateXML(final PageState state, final Element parent, final String useContext) { - //final long start = System.nanoTime(); - - //ContentSection section = CMS.getContext().getContentSection(); - ContentItem item = getContentItem(state); - - s_log.info("Generate XML for item " + item.getOID()); - - Party currentParty = Kernel.getContext().getParty(); - if (currentParty == null) { - currentParty = Kernel.getPublicUser(); - } - // check if current user can edit the current item (nb privilege is granted on draft item, but live item - // has draft as its permission context - // - // Note that the xml that is generated is only of use if you DO NOT CACHE content pages. - // cg. - final PermissionDescriptor edit = new PermissionDescriptor( - PrivilegeDescriptor.get(SecurityManager.CMS_EDIT_ITEM), item, currentParty); - if (PermissionService.checkPermission(edit)) { - parent.addAttribute("canEdit", "true"); - final Element canEditElem = parent.newChildElement("canEdit"); - canEditElem.setText("true"); - - } - final PermissionDescriptor publish = new PermissionDescriptor( - PrivilegeDescriptor.get(SecurityManager.CMS_PUBLISH), item, currentParty); - if (PermissionService.checkPermission(publish)) { - parent.addAttribute("canPublish", "true"); - } - final String className = item.getDefaultDomainClass(); - - // Ensure correct subtype of ContentItem is instantiated - if (!item.getClass().getName().equals(className)) { - s_log.info("Specializing item"); - try { - item = (ContentItem) DomainObjectFactory.newInstance( - new OID(item.getObjectType().getQualifiedName(), item.getID())); - } catch (DataObjectNotFoundException ex) { - throw new UncheckedWrapperException( - (String) GlobalizationUtil.globalize( - "cms.dispatcher.cannot_find_domain_object").localize(), - ex); - } - } - - // Implementing XMLGenerator directly is now deprecated - if (item instanceof XMLGenerator) { - s_log.info("Item implements XMLGenerator interface"); - final XMLGenerator xitem = (XMLGenerator) item; - xitem.generateXML(state, parent, useContext); - - } else if ("com.arsdigita.cms.UserDefinedContentItem".equals(className)) { - s_log.info("Item is a user defined content item"); - final UserDefinedContentItem UDItem = (UserDefinedContentItem) item; - generateUDItemXML(UDItem, state, parent, useContext); - - } else { - s_log.info("Item is using DomainObjectXMLRenderer"); - - // This is the preferred method - //final Element content = startElement(useContext, parent); - final Element content = startElement(useContext); - s_log.debug("Item is not in cache, generating item."); - - final XMLDeliveryCache xmlCache = XMLDeliveryCache.getInstance(); - - if (CMSConfig.getInstanceOf().getEnableXmlCache() && xmlCache.isCached(item.getOID(), useContext, listMode)) { - xmlCache.retrieveFromCache(content, item.getOID(), useContext, listMode); - } else { - final ContentItemXMLRenderer renderer = new ContentItemXMLRenderer(content); - - renderer.setWrapAttributes(true); - renderer.setWrapRoot(false); - renderer.setWrapObjects(false); - renderer.setRevisitFullObject(true); - - //System.out.printf("Prepared renderer in %d ms\n", (System.nanoTime() - start) - // / 1000000); - - renderer.walk(item, ADAPTER_CONTEXT); - - //System.out.printf("Rendered standard item xml in %d ms\n", (System.nanoTime() - start) - // / 1000000); - - //parent.addContent(content); - - //Only item XML Cache End - -// s_log.debug("Content elem content: "); -// logElementTree(content); -// s_log.debug("Content elem content end -- "); - - - /* - * 2011-08-27 jensp: Introduced to remove the annoying special templates - * for MultiPartArticle, SiteProxy and others. The method called - * here was already definied but not used. - * - * 2011-10-23 jensp: It is now possible to disable the use of - * extra XML. - */ - //final long extraXMLStart = System.nanoTime(); - if (useExtraXml) { - for (ExtraXMLGenerator generator : item.getExtraXMLGenerators()) { - generator.setListMode(listMode); - generator.generateXML(item, content, state); - } - } - - //Only published items - //Only the XML of the item itself, no extra XML - if (CMSConfig.getInstanceOf().getEnableXmlCache() && item.isLiveVersion()) { - xmlCache.cache(item.getOID(), item, content, useContext, listMode); - } - } - - if (PermissionService.checkPermission(edit)) { - final ItemResolver resolver = item.getContentSection().getItemResolver(); - final Element editLinkElem = content.newChildElement("editLink"); - final ContentItem draftItem = item.getDraftVersion(); - editLinkElem.setText(resolver.generateItemURL(state, - draftItem, - item.getContentSection(), - draftItem.getVersion())); - } - - parent.addContent(content); - - //System.out.printf("Rendered item in %d ms\n\n", (System.nanoTime() - start) / 1000000); - } - } - - /** - * Fetches the current content item. This method can be overridden to - * fetch any {@link com.arsdigita.cms.ContentItem}, but by default, - * it fetches the ContentItem that is set in the page state - * by the dispatcher. - * - * @param state The page state - * @return A content item - */ - protected ContentItem getContentItem(final PageState state) { - if (CMS.getContext().hasContentItem()) { - return CMS.getContext().getContentItem(); - } else { - final CMSPage page = (CMSPage) state.getPage(); - return page.getContentItem(state); - } - } - - protected void generateUDItemXML(final UserDefinedContentItem UDItem, - final PageState state, - final Element parent, - final String useContext) { - - final Element element = startElement(useContext, parent); - final Element additionalAttrs = UDItemElement(useContext); - - element.addAttribute("type", UDItem.getContentType().getName()); - element.addAttribute("id", UDItem.getID().toString()); - element.addAttribute("name", UDItem.getName()); - element.addAttribute("title", UDItem.getTitle()); - element.addAttribute("javaClass", UDItem.getContentType().getClassName()); - - final DynamicObjectType dot = new DynamicObjectType(UDItem.getSpecificObjectType()); - final Iterator declaredProperties = - dot.getObjectType().getDeclaredProperties(); - Property currentProperty; - Object value; - while (declaredProperties.hasNext()) { - currentProperty = (Property) declaredProperties.next(); - value = (Object) UDItem.get(currentProperty.getName()); - if (value != null) { - element.addContent( - UDItemAttrElement(currentProperty.getName(), - value.toString())); - } else { - element.addContent( - UDItemAttrElement(currentProperty.getName(), - "none specified")); - } - } - - //element.addContent(additionalAttrs); - //parent.addContent(element); - - } - - private Element startElement(final String useContext, final Element parent) { - //Element element = new Element("cms:item", CMS.CMS_XML_NS); - //final Element element = new Element(itemElemName, itemElemNs); - final Element element = parent.newChildElement(itemElemName, itemElemNs); - if (useContext != null) { - element.addAttribute("useContext", useContext); - } - - for (Map.Entry attr : itemAttributes.entrySet()) { - element.addAttribute(attr.getKey(), attr.getValue()); - } - - return element; - } - - private Element startElement(final String useContext) { - final Element element = new Element(itemElemName, itemElemNs); - - if (useContext != null) { - element.addAttribute("useContext", useContext); - } - - for (Map.Entry attr : itemAttributes.entrySet()) { - element.addAttribute(attr.getKey(), attr.getValue()); - } - - return element; - } - - private Element startCachedElement(final String useContext) { - final Element element = new Element(itemElemName, itemElemNs) { - @Override - public Element newChildElement(Element copyFrom) { - s_log.debug("Copy of element added to cached elem."); - return super.newChildElement(copyFrom); - } - - @Override - public Element newChildElement(String name, Element copyFrom) { - s_log.debug("Copy of element added to cached elem."); - return super.newChildElement(name, copyFrom); - } - - @Override - public Element addContent(final Element newContent) { - s_log.debug("Content added to cached element"); - return super.addContent(newContent); - } - - }; - - if (useContext != null) { - element.addAttribute("useContext", useContext); - } - - for (Map.Entry attr : itemAttributes.entrySet()) { - element.addAttribute(attr.getKey(), attr.getValue()); - } - - return element; - } - - private void copyElement(final Element parent, final Element element) { - final Element copy = parent.newChildElement(element.getName()); - final Iterator attrs = element.getAttributes().entrySet().iterator(); - Map.Entry attr; - while (attrs.hasNext()) { - attr = (Map.Entry) attrs.next(); - copy.addAttribute((String) attr.getKey(), (String) attr.getValue()); - } - - final Iterator childs = element.getChildren().iterator(); - while (childs.hasNext()) { - copyElement(copy, (Element) childs.next()); - } - - if (element.getText() != null) { - copy.setText(element.getText()); - } - - if (element.getCDATASection() != null) { - copy.setCDATASection(element.getCDATASection()); - } - - } - - private Element UDItemElement(final String useContext) { - final Element element = new Element("cms:UDItemAttributes", CMS.CMS_XML_NS); - /* - if ( useContext != null ) { - element.addAttribute("useContext", useContext); - } - */ - return element; - } - - private Element UDItemAttrElement(final String name, final String value) { - final Element element = new Element("cms:UDItemAttribute", CMS.CMS_XML_NS); - element.addAttribute("UDItemAttrName", name); - element.addAttribute("UDItemAttrValue", value); - return element; - } - - private void logElementTree(final Element element) { - s_log.debug("Tree of element" + element.getName() + ":\n"); - s_log.debug("\n" + logElementTree(element, new StringBuilder(), 0)); - } - - private String logElementTree(final Element element, final StringBuilder builder, final int depth) { - for (int i = 0; i < depth; i++) { - builder.append('\t'); - } - builder.append('<').append(element.getName()).append(">\n"); - - for (Object childObj : element.getChildren()) { - final Element child = (Element) childObj; - logElementTree(child, builder, depth + 1); - } - - for (int i = 0; i < depth; i++) { - builder.append('\t'); - } - builder.append("\n"); - return builder.toString(); - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/TemplateResolver.java.off b/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/TemplateResolver.java.off deleted file mode 100755 index cd38be0bc..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/dispatcher/TemplateResolver.java.off +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved. - * - * 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.dispatcher; - -import javax.servlet.http.HttpServletRequest; - -/** - * Reimplementation, based on ItemTemplateResolver - * - *

- * Many sites offer alternative views of the same content item depending on - * device or browser, or on user preference. For example, a site may have - * "plain" and "fancy" versions of its pages. The fancy versions would be the - * defaults, while the plain versions would be appropriate for users with - * low-bandwidth connections, older browsers, or a distaste for flashy - * appurtenances. In this the case the selection might be made based on a - * cookie.

- * - *

- * Another common example is the "printable" version of a page. In this case a - * query variable might be more appropriate.

- * - * - * @author Karl Goldstein (karlg@arsdigita.com) - * @version $Id: TemplateResolver.java 1967 2009-08-29 21:05:51Z pboy $ - * - */ -public interface TemplateResolver { - - /** - * Returns the JSP template filename relative to the webapp root. - * - * @param section The ContentSection for the request - * @param item The ContentItem for the request - * @param request The current HttpServletRequest - * - * @return The path to the jsp template. - */ - public String getTemplate(ContentSection section, - ContentItem item, - HttpServletRequest request); - - /** - * Returns the JSP template filename relative to the webapp root for a given - * Template reference. - * - * @param template The Template to resolve the URL for. - * - * @return The path to the jsp template. - */ - public String getTemplatePath(Template template); - - /** - * Returns the XSL template filename relative to the webapp root for a given - * Template reference. - * - * @param template The Template to resolve the URL for. - * - * @return The path to the xsl template. - */ - public String getTemplateXSLPath(Template template); - - /** - * Sets the TemplateContext parameter in the request - * - * @param sTemplateContext the template context to set - * @param request the request in which to set the template context - */ - public void setTemplateContext(String sTemplateContext, - HttpServletRequest request); - - /** - * Gets the template context from the request. - * - * @param request the request from which to get the template context - * - * @return the template context - */ - public String getTemplateContext(HttpServletRequest request); - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/BaseTree.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/BaseTree.java deleted file mode 100755 index 81940c8c2..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/BaseTree.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved. - * - * 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.ui; - -import com.arsdigita.bebop.PageState; -import com.arsdigita.bebop.Tree; -import com.arsdigita.bebop.event.ChangeEvent; -import com.arsdigita.bebop.event.ChangeListener; -import com.arsdigita.bebop.event.TreeExpansionEvent; -import com.arsdigita.bebop.event.TreeExpansionListener; -import com.arsdigita.bebop.tree.TreeModelBuilder; - -/** - * A convenience class for CMS trees. - * - * @author Justin Ross <jross@redhat.com> - */ -public class BaseTree extends Tree { - - public BaseTree(final TreeModelBuilder builder) { - super(builder); - - addChangeListener(new Change()); - addTreeExpansionListener(new TreeExpansion()); - } - - private class Change implements ChangeListener { - public final void stateChanged(final ChangeEvent e) { - final PageState state = e.getPageState(); - final Object key = BaseTree.this.getSelectedKey(state); - - if (key != null) { - expand(key.toString(), state); - } - } - } - - private class TreeExpansion implements TreeExpansionListener { - public final void treeExpanded(final TreeExpansionEvent e) { - //s_log.error("expanded"); - } - - public final void treeCollapsed(final TreeExpansionEvent e) { - //s_log.error("collapsed"); - } - } -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentItemContextBar.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentItemContextBar.java deleted file mode 100755 index ea833518b..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentItemContextBar.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved. - * - * 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.ui; - -import com.arsdigita.bebop.PageState; -import com.arsdigita.bebop.parameters.StringParameter; -import com.arsdigita.cms.CMS; - -import org.librecms.contentsection.ContentItem; -import org.librecms.contentsection.ContentSection; - -import com.arsdigita.cms.ItemSelectionModel; -import com.arsdigita.cms.PageLocations; -import com.arsdigita.kernel.KernelConfig; -import com.arsdigita.web.ParameterMap; -import com.arsdigita.web.URL; - -import org.libreccm.cdi.utils.CdiUtil; -import org.librecms.contentsection.ContentItemL10NManager; - -import java.util.List; -import java.util.Locale; - -/** - *

- * The context bar of the content section UI.

- * - * @author Justin Ross - * @author Jens Pelzetter - */ -class ContentItemContextBar extends ContentSectionContextBar { - - private final ItemSelectionModel itemSelectionModel; - private final StringParameter selectedLanguageParam; - - ContentItemContextBar(final ItemSelectionModel itemSelectionModel, - final StringParameter selectedLanguageParam) { - super(); - - this.itemSelectionModel = itemSelectionModel; - this.selectedLanguageParam = selectedLanguageParam; - } - - @Override - protected final List entries(final PageState state) { - final List entries = super.entries(state); - final ContentItem item = itemSelectionModel.getSelectedObject(state); - final ContentSection section = CMS.getContext().getContentSection(); - - final URL url = URL.there(state.getRequest(), - section.getPrimaryUrl() + "/" - + PageLocations.ITEM_PAGE, - params(item)); - - final StringBuilder title = new StringBuilder(); - title.append(localize("cms.ui.content_item")); - title.append(": ") - .append(item.getDisplayName()); - - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final ContentItemL10NManager l10nManager = cdiUtil - .findBean(ContentItemL10NManager.class); - final String selectedLanguage = (String) state - .getValue(selectedLanguageParam); - final Locale selectedLocale; - if (selectedLanguage == null - || selectedLanguage.isEmpty()) { - selectedLocale = KernelConfig.getConfig().getDefaultLocale(); - } else { - selectedLocale = new Locale(selectedLanguage); - } - - final String language; - if (l10nManager.hasLanguage(item, selectedLocale)) { - language = selectedLanguage; - } else { - state.setValue(selectedLanguageParam, - KernelConfig.getConfig().getDefaultLanguage()); - language = KernelConfig.getConfig().getDefaultLanguage(); - } - if (language != null) { - title.append(" (") - .append(language) - .append(")"); - } - - entries.add(new Entry(title.toString(), url)); - - return entries; - } - - private static ParameterMap params(final ContentItem item) { - final ParameterMap params = new ParameterMap(); - - params.setParameter(ContentItemPage.ITEM_ID, item.getObjectId()); - - return params; - } - - private static String localize(final String key) { - return (String) ContentSectionPage.globalize(key).localize(); - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentItemPage.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentItemPage.java index fbbec5045..13eb91680 100755 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentItemPage.java +++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentItemPage.java @@ -24,10 +24,8 @@ import com.arsdigita.bebop.FormProcessException; import com.arsdigita.bebop.Label; import com.arsdigita.bebop.Link; import com.arsdigita.bebop.PageState; -import com.arsdigita.bebop.ParameterSingleSelectionModel; import com.arsdigita.bebop.Resettable; import com.arsdigita.bebop.SimpleContainer; -import com.arsdigita.bebop.SingleSelectionModel; import com.arsdigita.bebop.TabbedPane; import com.arsdigita.bebop.event.ActionEvent; import com.arsdigita.bebop.event.ActionListener; @@ -156,7 +154,6 @@ public class ContentItemPage extends CMSPage implements ActionListener { private final ItemTemplates templatesPane; private final Link previewLink; private final GlobalNavigation globalNavigation; - private final ContentItemContextBar contextBar; private final StringParameter selectedLanguageParam; @@ -268,9 +265,7 @@ public class ContentItemPage extends CMSPage implements ActionListener { globalNavigation = new GlobalNavigation(); add(globalNavigation); - contextBar = new ContentItemContextBar(itemSelectionModel, - selectedLanguageParam); - add(contextBar); + // Create panels. summaryPane = new Summary(itemSelectionModel); diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentSectionContextBar.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentSectionContextBar.java deleted file mode 100755 index ebaec6d78..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentSectionContextBar.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (C) 2003-2004 Red Hat Inc. All Rights Reserved. - * - * 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.ui; - -import com.arsdigita.bebop.PageState; -import com.arsdigita.cms.CMS; -import com.arsdigita.cms.PageLocations; - -import org.librecms.contentsection.ContentItem; -import org.librecms.contentsection.ContentSection; - -import com.arsdigita.web.ParameterMap; -import com.arsdigita.web.URL; - -import org.apache.logging.log4j.LogManager; - -import java.math.BigDecimal; -import java.util.List; -import java.util.Stack; - -import org.apache.logging.log4j.Logger; - -/** - * The context bar of the content section UI. - * - * @author Justin Ross - * @author Jens Pelzetter - */ -public class ContentSectionContextBar extends WorkspaceContextBar { - - private static final Logger LOGGER = LogManager.getLogger( - ContentSectionContextBar.class); - - @Override - protected List entries(final PageState state) { - - /* Include breadcrumb entries already set by content-center (i.e. the - * URL of the content center itself */ - final List entries = super.entries(state); - - final ContentSection section = CMS.getContext().getContentSection(); - final Stack folderEntryStack = new Stack<>(); - String currentFolderLabel = null; - ParameterMap params = new ParameterMap(); - boolean isTemplate = false; - BigDecimal templateID = null; - - if (CMS.getContext().hasContentItem()) { - final ContentItem item = CMS.getContext().getContentItem(); - if (item == null) { - LOGGER.warn("item is null"); - } else if (item.getContentType() == null) { - LOGGER.warn( - "item.getContentType() returns null. item.class.getName(): " - + item.getClass().getName()); - } - - //ToDo NG - Not sure what happens here... -// final Optional parent = item.getParent(); -// -// while (!isTemplate -// && parent.isPresent() -// && parent.get() instanceof ContentItem) { -// if (currentFolderLabel != null) { -// final URL folderURL = URL.there -// (state.getRequest(), -// section.getPath() + "/" + PageLocations.SECTION_PAGE, -// params); -// folderEntryStack.push(new Entry(currentFolderLabel, folderURL)); -// currentFolderLabel = null; -// params = new ParameterMap(); -// } -// final ContentItem pitem = (ContentItem) parent; -// -// if (pitem instanceof Folder) { -// final Folder folder = (Folder) pitem; -// parent = folder.getParent(); -// -// currentFolderLabel = folder.getLabel(); -// if (parent != null || folder.equals(section.getRootFolder())) { -// params.setParameter -// (ContentSectionPage.SET_FOLDER, folder.getID()); -// } -// } else if (pitem instanceof ContentBundle) { -// final ACSObject ppitem = pitem.getParent(); -// -// if (ppitem != null && ppitem instanceof Folder) { -// final Folder folder = (Folder) ppitem; -// -// parent = folder.getParent(); -// currentFolderLabel = folder.getLabel(); -// if (parent != null || folder.equals(section -// .getRootFolder())) { -// params.setParameter -// (ContentSectionPage.SET_FOLDER, folder.getID()); -// } -// } else { -// parent = null; -// } -// } else { -// parent = null; -// } -// } - } - - if (isTemplate) { - params.setParameter(ContentSectionPage.SET_TAB, - new BigDecimal( - ContentSectionPage.CONTENTTYPES_TAB)); - params.setParameter(ContentSectionPage.SET_TEMPLATE, templateID); - } - - // add section-level entry. if this is for an item page, the URL - // will be for the root folder. - final URL url = URL.there( - state.getRequest(), - String.format("%s/" + PageLocations.SECTION_PAGE, - section.getPrimaryUrl()), - params); - - final String sectionTitle = lz("cms.ui.content_section"); - final String title = sectionTitle + ": " + section.getLabel(); - - entries.add(new Entry(title, url)); - - // add any folders to the path now - while (!folderEntryStack.empty()) { - entries.add(folderEntryStack.pop()); - } - - return entries; - } - - private static String lz(final String key) { - return (String) ContentSectionPage.globalize(key).localize(); - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentSectionPage.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentSectionPage.java index 94b4d4701..e7cd7552f 100755 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentSectionPage.java +++ b/ccm-cms/src/main/java/com/arsdigita/cms/ui/ContentSectionPage.java @@ -132,7 +132,6 @@ public class ContentSectionPage extends CMSPage implements ActionListener { private ContentTypeAdminPane m_typePane; //private LayoutPanel m_userAdminPane; private LayoutPanel m_csePane; - private ReportPane m_reportPane; /** * Creates the content section index page containing - a Navigaton bar for @@ -145,7 +144,6 @@ public class ContentSectionPage extends CMSPage implements ActionListener { setClassAttr("cms-admin"); add(new GlobalNavigation()); - add(new ContentSectionContextBar()); // Initialize the individual panes m_folderPane = getFolderAdminPane(); @@ -349,13 +347,7 @@ public class ContentSectionPage extends CMSPage implements ActionListener { return m_csePane; } - protected ReportPane getReportPane() { - if (m_reportPane == null) { - m_reportPane = new ReportPane(); - } - return m_reportPane; - } - + /** * Adds the specified component, with the specified tab name, to the tabbed * pane only if it is not null. diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ImagesPane.java.todo b/ccm-cms/src/main/java/com/arsdigita/cms/ui/ImagesPane.java.todo deleted file mode 100644 index 897899eb4..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ImagesPane.java.todo +++ /dev/null @@ -1,265 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package com.arsdigita.cms.ui; - -import com.arsdigita.bebop.Component; -import com.arsdigita.bebop.FormModel; -import com.arsdigita.bebop.Label; -import com.arsdigita.bebop.List; -import com.arsdigita.bebop.MapComponentSelectionModel; -import com.arsdigita.bebop.Page; -import com.arsdigita.bebop.PageState; -import com.arsdigita.bebop.ParameterSingleSelectionModel; -import com.arsdigita.bebop.Resettable; -import com.arsdigita.bebop.SegmentedPanel; -import com.arsdigita.bebop.SegmentedPanel.Segment; -import com.arsdigita.bebop.SimpleContainer; -import com.arsdigita.bebop.event.ChangeEvent; -import com.arsdigita.bebop.event.ChangeListener; -import com.arsdigita.bebop.list.ListModel; -import com.arsdigita.bebop.list.ListModelBuilder; -import com.arsdigita.bebop.parameters.ParameterModel; -import com.arsdigita.bebop.parameters.StringParameter; -import com.arsdigita.cms.util.GlobalizationUtil; -import com.arsdigita.toolbox.ui.ActionGroup; -import com.arsdigita.toolbox.ui.LayoutPanel; -import com.arsdigita.toolbox.ui.Section; -import com.arsdigita.util.Assert; -import com.arsdigita.util.LockableImpl; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import org.apache.log4j.Logger; - -/** - * A {@link LayoutPanel} to insert into {@link ContentSectionPage}. - * - * @author Sören Bernstein - */ -public class ImagesPane extends LayoutPanel implements Resettable { - - public static final Logger S_LOG = Logger.getLogger(ImagesPane.class); - private final StringParameter m_imageComponentKey; - private final MapComponentSelectionModel m_imageComponent; - private final ImageComponentAdminListener m_adminListener; - final private SegmentedPanel m_body; - private HashMap m_bodySegments = new HashMap(); - private final ResettableParameterSingleSelectionModel m_model; - private final List m_links; - private final LinksSection m_modes; - - public ImagesPane() { - super(); - - m_model = new ResettableParameterSingleSelectionModel(new - StringParameter(List.SELECTED)); - m_model.setDefaultSelection(ImageComponent.LIBRARY); - m_model.addChangeListener(new ImageAdminSelectionListener()); - - m_links = new List(new ImageAdminListModelBuilder()); - m_links.setSelectionModel(m_model); - - final SimpleContainer left = new SimpleContainer(); - setLeft(left); - - m_modes = new LinksSection(); - left.add(m_modes); - - m_body = new SegmentedPanel(); - setBody(m_body); - - m_imageComponentKey = new StringParameter("imageComponent"); - - final ParameterSingleSelectionModel componentModel = new - ParameterSingleSelectionModel(m_imageComponentKey); - m_imageComponent = new MapComponentSelectionModel(componentModel, - new HashMap()); - - final Map selectors = m_imageComponent.getComponentsMap(); - m_adminListener = new ImageComponentAdminListener(m_imageComponent, this); - - // Image library component - final ImageLibraryComponent library = new - ImageLibraryComponent(ImageComponent.ADMIN_IMAGES); - library.getForm().addInitListener(m_adminListener); - library.getForm().addProcessListener(m_adminListener); - selectors.put(ImageComponent.LIBRARY, library); - m_bodySegments.put(ImageComponent.LIBRARY, m_body.addSegment( - new Label(GlobalizationUtil.globalize( - "cms.contentasset.image.ui.image_library")), - library)); - - // Image upload component - final ImageUploadComponent upload = new - ImageUploadComponent(ImageComponent.ADMIN_IMAGES); - upload.getForm().addInitListener(m_adminListener); - upload.getForm().addSubmissionListener(m_adminListener); - upload.getForm().addProcessListener(m_adminListener); - selectors.put(ImageComponent.UPLOAD, upload); - m_bodySegments.put(ImageComponent.UPLOAD, m_body.addSegment( - new Label(GlobalizationUtil.globalize( - "cms.contentasset.image.ui.image_upload")), - upload)); - - } - - @Override - public final void register(final Page page) { - super.register(page); - - Iterator keys = m_bodySegments.keySet().iterator(); - - while (keys.hasNext()) { - String key = keys.next(); - page.setVisibleDefault(m_bodySegments.get(key), - m_model.getDefaultSelection().equals(key)); - } - - page.addComponentStateParam(this, m_imageComponentKey); - } - - /** - * Resets this pane and all its resettable components. - * - * @param state Page state - */ - @Override - public final void reset(final PageState state) { - super.reset(state); - - m_model.reset(state); - this.setActiveImageComponent(state, m_model.getDefaultSelection()); - } - - public final void setActiveImageComponent(PageState state, String activeComp) { - - Iterator keys = m_bodySegments.keySet().iterator(); - m_imageComponent.setSelectedKey(state, activeComp); - - while (keys.hasNext()) { - - String key = keys.next(); - final boolean visibility = key.equals(activeComp); - state.setVisible(m_bodySegments.get(key), visibility); - - for (int index = 0; index < m_bodySegments.get(key).size(); index++) { - - Component component = m_bodySegments.get(key).get(index); - - // Reset all components if they are of type Resettable - if (component instanceof Resettable) { - ((Resettable) component).reset(state); - } - - // Set visibility - component.setVisible(state, visibility); - } - } - } - - /** - * - */ - private class ResettableParameterSingleSelectionModel - extends ParameterSingleSelectionModel - implements Resettable { - - private String defaultKey; - - public ResettableParameterSingleSelectionModel(ParameterModel m) { - super(m); - } - - public void setDefaultSelection(String selKey) { - this.defaultKey = selKey; - } - - public String getDefaultSelection() { - return defaultKey; - } - - public void reset(PageState state) { - - if (Assert.isEnabled()) { - final FormModel model = state.getPage().getStateModel(); - Assert.isTrue(model.containsFormParam(getStateParameter())); - } - - state.setValue(getStateParameter(), this.defaultKey); - } - } - - /** - * - */ - private class ImageAdminListModel implements ListModel { - - private ArrayList m_keys; - private int m_index = -1; - - public ImageAdminListModel(ArrayList keys) { - m_keys = keys; - } - - public boolean next() { - return (m_index++ < m_keys.size() - 1); - } - - public Object getElement() { - return GlobalizationUtil.globalize( - "cms.contentasset.image.ui.image_" + m_keys.get(m_index)).localize(); - } - - public String getKey() { - return m_keys.get(m_index); - } - } - - private class ImageAdminListModelBuilder extends LockableImpl - implements ListModelBuilder { - - public ListModel makeModel(final List list, final PageState state) { - ArrayList keys = new ArrayList(2); - keys.add(ImageComponent.LIBRARY); - keys.add(ImageComponent.UPLOAD); - return new ImageAdminListModel(keys); - } - } - - private class ImageAdminSelectionListener implements ChangeListener { - - public final void stateChanged(final ChangeEvent e) { - S_LOG.debug("Selection state changed; I may change " - +"the body's visible pane"); - - final PageState state = e.getPageState(); - -// ImagesPane.this.reset(state); - - if (m_model.isSelected(state)) { - S_LOG.debug("The selection model is selected; displaying " - +"the item pane"); - - ImagesPane.this.setActiveImageComponent( - state, - state.getControlEventValue()); - } - } - } - - private class LinksSection extends Section { - - LinksSection() { - setHeading(GlobalizationUtil.globalize( - "cms.contentasset.image.ui.images")); - - final ActionGroup group = new ActionGroup(); - setBody(group); - - group.setSubject(m_links); - } - } -} \ No newline at end of file diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ReportPane.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/ReportPane.java deleted file mode 100644 index 0eb5efee3..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/ReportPane.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (C) 2009 Permeance Technologies Pty Ltd. All Rights Reserved. - * - * 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.ui; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; - -import com.arsdigita.bebop.Label; -import com.arsdigita.bebop.List; -import com.arsdigita.bebop.PageState; -import com.arsdigita.bebop.ParameterSingleSelectionModel; -import com.arsdigita.bebop.SingleSelectionModel; -import com.arsdigita.bebop.event.ChangeEvent; -import com.arsdigita.bebop.event.ChangeListener; -import com.arsdigita.bebop.list.ListModel; -import com.arsdigita.bebop.list.ListModelBuilder; -import com.arsdigita.bebop.parameters.StringParameter; -import com.arsdigita.cms.ui.report.ContentSectionSummaryTable; -import com.arsdigita.cms.ui.report.Report; -import com.arsdigita.cms.ui.report.ReportListModel; -import com.arsdigita.toolbox.ui.ActionGroup; -import com.arsdigita.toolbox.ui.Section; -import com.arsdigita.util.LockableImpl; - -/** - * A pane that shows selectable reports and their results. A selectable list of - * reports is shown on the left-hand side, a selected report is shown as body. - * - * @author - * thomas-buckel - * @author - * tim-permeance - * @author Jens Pelzetter - */ -public class ReportPane extends BaseAdminPane { - - private final SingleSelectionModel selectionModel; - private final java.util.List availableReports; - - public ReportPane() { - availableReports = getReports(); - - selectionModel = new ParameterSingleSelectionModel<>( - new StringParameter(List.SELECTED)); - selectionModel.addChangeListener(new SelectionListener()); - setSelectionModel(selectionModel); - - List m_reports = new List(new ReportListModelBuilder(availableReports)); - m_reports.setSelectionModel(selectionModel); - - final ReportsListSection reportsListSection = new ReportsListSection( - m_reports); - setLeft(reportsListSection); - - // Register the actual components of the reports for later usage - for (Report report : availableReports) { - getBody().add(report.getComponent()); - } - - setIntroPane(new Label(gz("cms.ui.reports.intro"))); - } - - /** - * @return List of available reports. - */ - private java.util.List getReports() { - java.util.List reports = new ArrayList<>(); - reports.add(new Report("cms.ui.reports.css.reportName", - new ContentSectionSummaryTable())); - // Add other reports as required - - Collections.sort( - reports, - (r1, r2) -> r1.getName().compareTo(r2.getName())); - - return reports; - } - - /** - * Get the report model that matches the given key. - * - * @param key Key to match. - * - * @return Report model that matches that given key, null if no matching - * report was found. - */ - private Report getReportByKey(final String key) { - for (Report report : availableReports) { - if (report.getKey().equals(key)) { - return report; - } - } - return null; - } - - /** - * UI section for left-hand list of reports. - */ - private class ReportsListSection extends Section { - - ReportsListSection(final List reports) { - setHeading(gz("cms.ui.reports.header")); - ActionGroup group = new ActionGroup(); - setBody(group); - group.setSubject(reports); - } - - } - - /** - * SelectionListener for selected report. It shows the selected report in - * the body of this component. - */ - private class SelectionListener implements ChangeListener { - - @Override - public final void stateChanged(final ChangeEvent event) { - - final PageState state = event.getPageState(); - - getBody().reset(state); - - if (selectionModel.isSelected(state)) { - Report selectedReport = getReportByKey(selectionModel - .getSelectedKey(state).toString()); - if (selectedReport != null) { - getBody().push(state, selectedReport.getComponent()); - } - } - } - - } - - /** - * ListModelBuilder creating a ReportListModel for a list of reports. - */ - private static class ReportListModelBuilder - extends LockableImpl - implements ListModelBuilder { - - private final java.util.List reports; - - private ReportListModelBuilder(final java.util.List reports) { - this.reports = reports; - } - - @Override - public final ListModel makeModel(final List list, - final PageState state) { - return new ReportListModel(reports); - } - - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractBinaryAssetForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractBinaryAssetForm.java deleted file mode 100644 index 58cf71b42..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractBinaryAssetForm.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright (C) 2017 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 com.arsdigita.cms.ui.assets.forms; - -import com.arsdigita.bebop.BoxPanel; -import com.arsdigita.bebop.FormProcessException; -import com.arsdigita.bebop.Label; -import com.arsdigita.bebop.PageState; -import com.arsdigita.bebop.Text; -import com.arsdigita.bebop.event.FormSectionEvent; -import com.arsdigita.bebop.form.TextArea; -import com.arsdigita.cms.ui.FileUploadSection; -import com.arsdigita.cms.ui.assets.AbstractAssetForm; -import com.arsdigita.cms.ui.assets.AssetPane; -import com.arsdigita.globalization.GlobalizedMessage; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; - -import org.librecms.CmsConstants; -import org.librecms.assets.BinaryAsset; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -/** - * Base form for assets which extend {@link BinaryAsset}. - * - * @author Jens Pelzetter - * @param Type of binary asset - */ -public abstract class AbstractBinaryAssetForm - extends AbstractAssetForm { - - private TextArea description; - - private Text fileName; - - private Text mimeType; - - private Text size; - - private FileUploadSection fileUpload; - - public AbstractBinaryAssetForm(final AssetPane assetPane) { - super(assetPane); - } - - @Override - protected void addWidgets() { - - final BoxPanel panel = new BoxPanel(BoxPanel.VERTICAL); - - panel.add(new Label(new GlobalizedMessage( - "cms.ui.assets.binaryasset.description", - CmsConstants.CMS_BUNDLE))); - description = new TextArea("binaryasset-description"); - panel.add(description); - - panel.add(new Label( - new GlobalizedMessage("cms.ui.assets.binaryasset.filename", - CmsConstants.CMS_BUNDLE))); - fileName = new Text(); - panel.add(fileName); - - panel.add(new Label( - new GlobalizedMessage("cms.ui.assets.binaryasset.mimetype", - CmsConstants.CMS_BUNDLE))); - mimeType = new Text(); - panel.add(mimeType); - - panel.add(new Label( - new GlobalizedMessage("cms.ui.assets.binaryasset.size", - CmsConstants.CMS_BUNDLE))); - size = new Text(); - panel.add(size); - - fileUpload = new FileUploadSection( - new GlobalizedMessage("cms.ui.assets.binaryasset.mimetype", - CmsConstants.CMS_BUNDLE), - "", - ""); - panel.add(fileUpload); - - add(panel); - - setEncType(CmsConstants.FORM_ENCTYPE_MULTIPART); - } - - @Override - protected void initForm(final PageState state, - final Map data) { - - super.initForm(state, data); - - if (!data.isEmpty()) { - - description.setValue(state, - data.get("description")); - - if (data.containsKey("data")) { - - final byte[] binaryData = (byte[]) data.get("data"); - if (binaryData.length == 0) { - fileName.setText("-"); - mimeType.setText("-"); - size.setText("-"); - } else { - fileName.setText((String) data.get("fileName")); - mimeType.setText((String) data.get("mimeType")); - size.setText(Long.toString((long) data.get("size"))); - } - - } else { - fileName.setText("-"); - mimeType.setText("-"); - size.setText("-"); - } - } - } - - @Override - protected void showLocale(final PageState state) { - - final Long selectedAssetId = getSelectedAssetId(state); - - if (selectedAssetId != null) { - - final Map data = getController() - .getAssetData(selectedAssetId, - getAssetClass(), - getSelectedLocale(state)); - - description - .setValue( - state, - data - .get(AbstractBinaryAssetFormController.DESCRIPTION)); - } - } - - @Override - protected Map collectData(final FormSectionEvent event) - throws FormProcessException { - - return getFileData(event); - } - - private Map getFileData(final FormSectionEvent event) - throws FormProcessException { - - final File file = fileUpload.getFile(event); - if (file == null) { - return Collections.emptyMap(); - } else { - final Path path = file.toPath(); - final byte[] data; - try { - data = Files.readAllBytes(path); - } catch (IOException ex) { - throw new FormProcessException(ex); - } - - final Map assetData = new HashMap<>(); - - assetData.put(AbstractBinaryAssetFormController.DATA, - data); - assetData.put(AbstractBinaryAssetFormController.FILE_NAME, - fileUpload.getFileName(event)); - assetData.put(AbstractBinaryAssetFormController.SIZE, - data.length); - assetData.put(AbstractBinaryAssetFormController.MIME_TYPE, - fileUpload.getMimeType(event)); - - return assetData; - } - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractBinaryAssetFormController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractBinaryAssetFormController.java deleted file mode 100644 index 151f6d651..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractBinaryAssetFormController.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2019 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 com.arsdigita.cms.ui.assets.forms; - -import com.arsdigita.cms.ui.assets.AbstractAssetFormController; - -import org.librecms.assets.BinaryAsset; - -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; - -import javax.activation.MimeType; -import javax.transaction.Transactional; - -/** - * - * @author Jens Pelzetter - * @param - */ -public abstract class AbstractBinaryAssetFormController - extends AbstractAssetFormController { - - protected static final String DESCRIPTION = "description"; - - protected static final String FILE_NAME = "fileName"; - - protected static final String MIME_TYPE = "mimeType"; - - protected static final String DATA = "data"; - - protected static final String SIZE = "size"; - - @Override - @Transactional(Transactional.TxType.REQUIRED) - protected Map getAssetData(final T asset, - final Locale selectedLocale) { - - final Map data = new HashMap<>(); - - final String description = asset - .getDescription() - .getValue(selectedLocale); - - data.put(DESCRIPTION, description); - data.put(FILE_NAME, asset.getFileName()); - data.put(MIME_TYPE, asset.getMimeType()); - data.put(DATA, asset.getData()); - data.put(SIZE, asset.getSize()); - - return data; - } - - @Override - @Transactional(Transactional.TxType.REQUIRED) - public void updateAssetProperties(final T asset, - final Locale selectedLocale, - final Map data) { - - if (data.containsKey(DESCRIPTION)) { - asset.getDescription().putValue(selectedLocale, - (String) data.get(DESCRIPTION)); - } - - if (data.containsKey(FILE_NAME)) { - asset.setFileName((String) data.get(FILE_NAME)); - } - - if (data.containsKey(MIME_TYPE)) { - asset.setMimeType((MimeType) data.get(MIME_TYPE)); - } - - if (data.containsKey(DATA)) { - //asset.setData((byte[]) data.get(DATA)); - } - - if (data.containsKey(SIZE)) { - asset.setSize((long) data.get(SIZE)); - } - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractBookmarkForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractBookmarkForm.java deleted file mode 100644 index 98be1388a..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractBookmarkForm.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (C) 2017 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 com.arsdigita.cms.ui.assets.forms; - -import com.arsdigita.bebop.FormData; -import com.arsdigita.bebop.FormProcessException; -import com.arsdigita.bebop.Label; -import com.arsdigita.bebop.PageState; -import com.arsdigita.bebop.event.FormSectionEvent; -import com.arsdigita.bebop.event.FormValidationListener; -import com.arsdigita.bebop.form.TextArea; -import com.arsdigita.bebop.form.TextField; -import com.arsdigita.cms.ui.assets.AbstractAssetForm; -import com.arsdigita.cms.ui.assets.AssetPane; -import com.arsdigita.globalization.GlobalizedMessage; - -import org.librecms.CmsConstants; -import org.librecms.assets.Bookmark; -import org.librecms.contentsection.Asset; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -/** - * Abstract base form for all forms for {@link BookmarkAsset}s. - * - * @author Jens Pelzetter - * @param Type of the Bookmark Asset. - */ -public abstract class AbstractBookmarkForm - extends AbstractAssetForm { - - private TextArea description; - - private TextField url; - - public AbstractBookmarkForm(final AssetPane assetPane) { - super(assetPane); - } - - @Override - protected void addWidgets() { - - add(new Label( - new GlobalizedMessage("cms.ui.assets.bookmark.description", - CmsConstants.CMS_BUNDLE))); - description = new TextArea("bookmark-description"); - add(description); - - add(new Label(new GlobalizedMessage("cms.ui.assets.bookmark.url", - CmsConstants.CMS_BUNDLE))); - url = new TextField("bookmark-url"); - add(url); - - addValidationListener(new FormValidationListener() { - - @Override - public void validate(final FormSectionEvent event) - throws FormProcessException { - - final PageState state = event.getPageState(); - final FormData data = event.getFormData(); - - try { - new URL((String) url.getValue(state)); - } catch (MalformedURLException ex) { - data.addError(new GlobalizedMessage( - "cms.ui.assets.bookmark.url.malformed", - CmsConstants.CMS_BUNDLE)); - } - } - - }); - - } - - @Override - protected void initForm(final PageState state, - final Map data) { - - super.initForm(state, data); - - if (!data.isEmpty()) { - - description - .setValue( - state, - data.get(AbstractBookmarkFormController.DESCRIPTION)); - url.setValue(state, data.get(AbstractBookmarkFormController.URL)); - - } - } - - @Override - protected void showLocale(final PageState state) { - - final Long selectedAssetId = getSelectedAssetId(state); - - if (selectedAssetId != null) { - - final Map data = getController() - .getAssetData(selectedAssetId, - getAssetClass(), - getSelectedLocale(state)); - - description.setValue( - state, - data.get(AbstractBinaryAssetFormController.DESCRIPTION)); - } - } - - protected void updateData(final Bookmark bookmark, - final PageState state) { - bookmark - .getDescription() - .putValue(getSelectedLocale(state), - (String) description.getValue(state)); - - bookmark.setUrl((String) url.getValue(state)); - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractBookmarkFormController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractBookmarkFormController.java deleted file mode 100644 index db319efa8..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractBookmarkFormController.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2019 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 com.arsdigita.cms.ui.assets.forms; - -import com.arsdigita.cms.ui.assets.AbstractAssetFormController; - -import org.librecms.assets.Bookmark; - -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; - -/** - * - * @author Jens Pelzetter - * @param - */ -public abstract class AbstractBookmarkFormController - extends AbstractAssetFormController { - - protected static final String DESCRIPTION = "description"; - - protected static final String URL = "url"; - - @Override - protected Map getAssetData(final T asset, - final Locale selectedLocale) { - - final String description = asset - .getDescription() - .getValue(selectedLocale); - - final String url = asset.getUrl(); - - final Map data = new HashMap<>(); - - data.put("description", description); - data.put("url", url); - - return data; - } - - @Override - public void updateAssetProperties(final T asset, - final Locale selectedLocale, - final Map data) { - - if (data.containsKey(DESCRIPTION)) { - - asset.getDescription().putValue(selectedLocale, - (String) data.get(DESCRIPTION)); - - } - - if (data.containsKey(URL)) { - - asset.setUrl((String) data.get(URL)); - } - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractContactableEntityForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractContactableEntityForm.java deleted file mode 100644 index c271e493c..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractContactableEntityForm.java +++ /dev/null @@ -1,434 +0,0 @@ -/* - * Copyright (C) 2019 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 com.arsdigita.cms.ui.assets.forms; - -import com.arsdigita.bebop.BoxPanel; -import com.arsdigita.bebop.Component; -import com.arsdigita.bebop.ControlLink; -import com.arsdigita.bebop.FormProcessException; -import com.arsdigita.bebop.Label; -import com.arsdigita.bebop.PageState; -import com.arsdigita.bebop.SimpleContainer; -import com.arsdigita.bebop.Table; -import com.arsdigita.bebop.Text; -import com.arsdigita.bebop.event.FormSectionEvent; -import com.arsdigita.bebop.event.PrintEvent; -import com.arsdigita.bebop.event.PrintListener; -import com.arsdigita.bebop.event.TableActionEvent; -import com.arsdigita.bebop.event.TableActionListener; -import com.arsdigita.bebop.form.Option; -import com.arsdigita.bebop.form.SingleSelect; -import com.arsdigita.bebop.form.Submit; -import com.arsdigita.bebop.form.TextField; -import com.arsdigita.bebop.parameters.StringParameter; -import com.arsdigita.bebop.table.TableCellRenderer; -import com.arsdigita.bebop.table.TableColumn; -import com.arsdigita.bebop.table.TableColumnModel; -import com.arsdigita.bebop.table.TableModel; -import com.arsdigita.bebop.table.TableModelBuilder; -import com.arsdigita.cms.ui.assets.AbstractAssetForm; -import com.arsdigita.cms.ui.assets.AssetPane; -import com.arsdigita.cms.ui.assets.AssetSearchWidget; -import com.arsdigita.globalization.GlobalizedMessage; -import com.arsdigita.util.LockableImpl; - -import org.libreccm.cdi.utils.CdiUtil; -import org.libreccm.l10n.GlobalizationHelper; -import org.librecms.CmsConstants; -import org.librecms.assets.ContactEntryKey; -import org.librecms.assets.ContactableEntity; -import org.librecms.assets.PostalAddress; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.TooManyListenersException; - -import static org.librecms.CmsConstants.*; - -/** - * - * @author Jens Pelzetter - * @param - */ -public abstract class AbstractContactableEntityForm - extends AbstractAssetForm { - - private static final int COL_CONTACT_ENTRIES_KEY = 0; - - private static final int COL_CONTACT_ENTRIES_VALUE = 1; - - private static final int COL_CONTACT_ENTRIES_REMOVE = 2; - - private SimpleContainer contactEntriesContainer; - - private Table contactEntriesTable; - - private SingleSelect contactEntryKeySelect; - - private TextField contactEntryValueField; - - private Submit addContactEntryLink; - - private AssetSearchWidget postalAddressSearchWidget; - - public AbstractContactableEntityForm(final AssetPane assetPane) { - - super(assetPane); - } - - @Override - protected void addWidgets() { - - addPropertyWidgets(); - - contactEntriesContainer = new BoxPanel(BoxPanel.VERTICAL) { - - @Override - public boolean isVisible(final PageState state) { - return getSelectedAssetId(state) != null; - } - - }; - add(contactEntriesContainer); - - contactEntriesTable = buildContactEntriesTable(); - contactEntriesContainer.add(contactEntriesTable); - - contactEntryKeySelect = new SingleSelect(new StringParameter( - "contactentry-key")); - try { - contactEntryKeySelect - .addPrintListener(new ContactEntryKeySelectPrintListener()); - } catch (TooManyListenersException ex) { - throw new RuntimeException(ex); - } - contactEntriesContainer.add(new Label( - new GlobalizedMessage( - "cms.ui.authoring.assets.contactable.contactentries.key", - CMS_BUNDLE)) - ); - contactEntriesContainer.add(contactEntryKeySelect); - - contactEntryValueField = new TextField("contact-entry-value"); - contactEntriesContainer.add(new Label( - new GlobalizedMessage( - "cms.ui.authoring.assets.contactable.contactentries.value", - CMS_BUNDLE)) - ); - contactEntriesContainer.add(contactEntryValueField); - - addContactEntryLink = new Submit( - new GlobalizedMessage( - "cms.ui.authoring.assets.contactable.contactentries.add", - CMS_BUNDLE) - ); - contactEntriesContainer.add(addContactEntryLink); - - contactEntriesContainer.add(new Label( - new GlobalizedMessage( - "cms.ui.authoring.assets.contactable.postaladdress", - CMS_BUNDLE)) - ); - postalAddressSearchWidget = new AssetSearchWidget( - "contactable-postaladdress", PostalAddress.class - ); - contactEntriesContainer.add(postalAddressSearchWidget); - - } - - @Override - public void initForm(final PageState state, - final Map data) { - - super.initForm(state, data); - - final Long selectedAssetId = getSelectedAssetId(state); - - if (selectedAssetId != null) { - - postalAddressSearchWidget.setValue( - state, - data.get(AbstractContactableEntityFormController.POSTAL_ADDRESS) - ); - } - } - - @Override - protected Map collectData( - final FormSectionEvent event) { - - final PageState state = event.getPageState(); - - final Map data = new HashMap<>(); - - if (postalAddressSearchWidget.getValue(state) != null) { - - data.put(AbstractContactableEntityFormController.POSTAL_ADDRESS, - postalAddressSearchWidget.getValue(state)); - } - - return data; - } - - @Override - public void process(final FormSectionEvent event) - throws FormProcessException { - - final PageState state = event.getPageState(); - - if (addContactEntryLink.isSelected(state)) { - - final Long selectedAssetId = getSelectedAssetId(state); - if (selectedAssetId == null) { - throw new FormProcessException( - new GlobalizedMessage( - "cms.ui.assets.none_selected", CMS_BUNDLE) - ); - } - - @SuppressWarnings("unchecked") - final AbstractContactableEntityFormController controller - = (AbstractContactableEntityFormController) getController(); - - final String key = (String) contactEntryKeySelect - .getValue(state); - final String value = (String) contactEntryValueField.getValue(state); - - controller.addContactEntry(key, value, selectedAssetId); - - contactEntryKeySelect.setValue(state, null); - contactEntryValueField.setValue(state, null); - } else { - super.process(event); - } - } - - protected abstract void addPropertyWidgets(); - - private Table buildContactEntriesTable() { - - final Table table = new Table(); -// { - -// @Override -// public boolean isVisible(final PageState state) { -// return getSelectedAsset(state).isPresent(); -// } -// }; - final TableColumnModel columnModel = table.getColumnModel(); - columnModel.add(new TableColumn( - COL_CONTACT_ENTRIES_KEY, - new Label( - new GlobalizedMessage( - "cms.ui.authoring.assets.contactable.contactentries.key", - CmsConstants.CMS_BUNDLE - ) - ) - )); - columnModel.add(new TableColumn( - COL_CONTACT_ENTRIES_VALUE, - new Label( - new GlobalizedMessage( - "cms.ui.authoring.assets.contactable.contactentries.value", - CmsConstants.CMS_BUNDLE - ) - ) - )); - columnModel.add(new TableColumn( - COL_CONTACT_ENTRIES_REMOVE, - new Label( - new GlobalizedMessage( - "cms.ui.authoring.assets.contactable.contactentries.remove", - CmsConstants.CMS_BUNDLE - ) - ) - )); - - table.setModelBuilder(new ContactEntriesTableModelBuilder()); - - table - .getColumn(COL_CONTACT_ENTRIES_REMOVE) - .setCellRenderer(new ContactEntryRemoveCellRenderer()); - - table.setEmptyView( - new Label( - new GlobalizedMessage( - "cms.ui.authoring.assets.contactable.contactentries.none", - CmsConstants.CMS_BUNDLE - ) - ) - ); - - table.addTableActionListener(new TableActionListener() { - - @Override - public void cellSelected(final TableActionEvent event) - throws FormProcessException { - - final Integer rowKey = (Integer) event.getRowKey(); - - @SuppressWarnings("unchecked") - final AbstractContactableEntityFormController controller - = (AbstractContactableEntityFormController) getController(); - final PageState state = event.getPageState(); - final Long selectedId = getSelectedAssetId(state); - if (selectedId != null) { - controller.removeContactEntry(rowKey, selectedId); - } - } - - @Override - public void headSelected(final TableActionEvent event) { - - // Nothing - } - - }); - - return table; - } - - private class ContactEntriesTableModelBuilder - extends LockableImpl implements TableModelBuilder { - - @Override - public TableModel makeModel(final Table table, - final PageState state) { - - final Long selectedId = getSelectedAssetId(state); - if (selectedId == null) { - throw new RuntimeException("No asset selected."); - } - - @SuppressWarnings("unchecked") - final AbstractContactableEntityFormController controller - = (AbstractContactableEntityFormController) getController(); - final List contactEntries = controller - .getContactEntries(selectedId, getSelectedLocale(state)); - - return new ContactEntriesTableModel(contactEntries); - } - - } - - private class ContactEntriesTableModel implements TableModel { - - private final Iterator contactEntries; - - private String[] currentContactEntry; - - public ContactEntriesTableModel( - final List contactEntries) { - - this.contactEntries = contactEntries.iterator(); - } - - @Override - public int getColumnCount() { - return 3; - } - - @Override - public boolean nextRow() { - - if (contactEntries.hasNext()) { - currentContactEntry = contactEntries.next(); - return true; - } else { - return false; - } - } - - @Override - public Object getElementAt(final int columnIndex) { - - switch (columnIndex) { - case COL_CONTACT_ENTRIES_KEY: - return currentContactEntry[1]; - case COL_CONTACT_ENTRIES_VALUE: - return currentContactEntry[2]; - case COL_CONTACT_ENTRIES_REMOVE: - return new Label( - new GlobalizedMessage( - "cms.ui.authoring.assets.contactable" - + ".contactentries.remove", - CmsConstants.CMS_BUNDLE - ) - ); - default: - throw new IllegalArgumentException(String.format( - "Illegal column index %d.", columnIndex)); - - } - } - - @Override - public Object getKeyAt(int columnIndex) { - return currentContactEntry[0]; - } - - } - - private class ContactEntryRemoveCellRenderer implements TableCellRenderer { - - @Override - public Component getComponent(final Table table, - final PageState state, - final Object value, - final boolean isSelected, - final Object key, - final int row, - final int column) { - - return new ControlLink((Component) value); - } - - } - - private class ContactEntryKeySelectPrintListener implements PrintListener { - - @Override - public void prepare(final PrintEvent event) { - - final SingleSelect target = (SingleSelect) event.getTarget(); - target.clearOptions(); - - target.addOption( - new Option("", - new Label(new GlobalizedMessage("cms.ui.select_one", - CMS_BUNDLE))) - ); - - final AbstractContactableEntityFormController controller = (AbstractContactableEntityFormController) getController(); - - final PageState state = event.getPageState(); - - final List keys = controller - .findAvailableContactEntryKeys(getSelectedLocale(state)); - - for (final String[] key : keys) { - target.addOption(new Option(key[0], new Text(key[1]))); - } - } - - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractContactableEntityFormController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractContactableEntityFormController.java deleted file mode 100644 index 4cfebbf64..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AbstractContactableEntityFormController.java +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Copyright (C) 2019 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 com.arsdigita.cms.ui.assets.forms; - -import com.arsdigita.cms.ui.assets.AbstractAssetFormController; - -import org.libreccm.l10n.GlobalizationHelper; -import org.librecms.assets.ContactEntry; -import org.librecms.assets.ContactEntryKey; -import org.librecms.assets.ContactEntryKeyByLabelComparator; -import org.librecms.assets.ContactEntryKeyRepository; -import org.librecms.assets.ContactableEntity; -import org.librecms.assets.ContactableEntityManager; -import org.librecms.assets.ContactableEntityRepository; -import org.librecms.assets.PostalAddress; -import org.librecms.contentsection.AssetRepository; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Objects; -import java.util.stream.Collectors; - -import javax.inject.Inject; -import javax.transaction.Transactional; - -/** - * - * @author Jens Pelzetter - * @param - */ -public abstract class AbstractContactableEntityFormController - extends AbstractAssetFormController { - - protected static final String POSTAL_ADDRESS = "postalAddress"; - - @Inject - private AssetRepository assetRepository; - - @Inject - private ContactableEntityRepository contactableEntityRepository; - - @Inject - private ContactableEntityManager contactableEntityManager; - - @Inject - private ContactEntryKeyRepository keyRepository; - - @Inject - private GlobalizationHelper globalizationHelper; - - @Transactional(Transactional.TxType.REQUIRED) - @Override - protected Map getAssetData(final T asset, - final Locale selectedLocale) { - - final Map data = new HashMap<>(); - - final PostalAddress postalAddress = asset.getPostalAddress(); - if (postalAddress != null) { - data.put(POSTAL_ADDRESS, postalAddress.getObjectId()); - } - - return data; - } - - @Override - public void updateAssetProperties(final T asset, - final Locale selectedLocale, - final Map data) { - - if (data.containsKey(POSTAL_ADDRESS)) { - - final long addressId = (long) data.get(POSTAL_ADDRESS); - final PostalAddress postalAddress = assetRepository - .findById(addressId, PostalAddress.class) - .orElseThrow(() -> new IllegalArgumentException(String.format( - "No PostalAddress with ID %d found.", addressId))); - - contactableEntityManager - .addPostalAddressToContactableEntity(postalAddress, asset); - } - } - - /** - * Returns the contact entries of the provided contentable entity for the - * provided language. - * - * @param contactableId The ID of the contactable entity. - * @param selectedLocale The selected locale. - * - * @return An list of the contact entires - */ - @Transactional(Transactional.TxType.REQUIRED) - public List getContactEntries( - final Long contactableId, final Locale selectedLocale) { - - Objects.requireNonNull(contactableId, - "Can't get contact entries from null."); - - final ContactableEntity entity = contactableEntityRepository - .findById(contactableId) - .orElseThrow(() -> new IllegalArgumentException(String.format( - "No ContactEntity with ID %d found.", contactableId))); - - return entity - .getContactEntries() - .stream() - .map(contactEntry -> toContactEntryArray(contactEntry, - selectedLocale)) - .collect(Collectors.toList()); - } - - private String[] toContactEntryArray(final ContactEntry entry, - final Locale selectedLocale) { - - final String key = entry.getKey().getEntryKey(); - final String label = entry.getKey().getLabel().getValue(selectedLocale); - final String value = entry.getValue(); - - return new String[]{key, label, value}; - } - - @Transactional(Transactional.TxType.REQUIRED) - public void addContactEntry(final String contactEntryKey, - final String contactEntryValue, - final Long toContactableEntityWithId) { - - final ContactableEntity contactable = contactableEntityRepository - .findById(toContactableEntityWithId) - .orElseThrow(() -> new IllegalArgumentException(String.format( - "No ContactableEntity with ID %d found", - toContactableEntityWithId))); - - final ContactEntryKey key = keyRepository - .findByEntryKey(contactEntryKey) - .orElseThrow(() -> new IllegalArgumentException(String.format( - "No ContactEntryKey with key \"%s\" found.", contactEntryKey))); - final ContactEntry entry = new ContactEntry(); - entry.setKey(key); - entry.setValue(contactEntryValue); - entry.setOrder(contactable.getContactEntries().size()); - - contactableEntityManager - .addContactEntryToContactableEntity(entry, contactable); - } - - @Transactional(Transactional.TxType.REQUIRED) - public void removeContactEntry(final int withIndex, - final Long fromContactableEntityWithId) { - - final ContactableEntity contactable = contactableEntityRepository - .findById(fromContactableEntityWithId) - .orElseThrow(() -> new IllegalArgumentException(String.format( - "No ContactableEntity with ID %d found", - fromContactableEntityWithId))); - - if (contactable.getContactEntries().size() > withIndex) { - - final ContactEntry contactEntry = contactable - .getContactEntries() - .get(withIndex); - contactableEntityManager.removeContactEntryFromContactableEntity( - contactEntry, contactable - ); - } - } - - @Transactional(Transactional.TxType.REQUIRED) - public List findAvailableContactEntryKeys( - final Locale selectedLocale) { - - return keyRepository - .findAll() - .stream() - .sorted(new ContactEntryKeyByLabelComparator(selectedLocale)) - .map(key -> buildContactEntryKeyArray(key, - selectedLocale)) - .collect(Collectors.toList()); - } - - private String[] buildContactEntryKeyArray( - final ContactEntryKey contactEntryKey, final Locale selectedLocale) { - - final String key = contactEntryKey.getEntryKey(); - final String label = contactEntryKey.getLabel().getValue(selectedLocale); - - return new String[]{key, label}; - - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AudioForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AudioForm.java deleted file mode 100644 index 67288af40..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AudioForm.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (C) 2017 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 com.arsdigita.cms.ui.assets.forms; - -import com.arsdigita.bebop.Label; -import com.arsdigita.bebop.PageState; -import com.arsdigita.cms.ui.assets.AssetPane; -import com.arsdigita.cms.ui.assets.AssetSearchWidget; -import com.arsdigita.globalization.GlobalizedMessage; - -import org.librecms.CmsConstants; -import org.librecms.assets.AudioAsset; -import org.librecms.assets.LegalMetadata; - -import java.util.Map; - -/** - * - * @author Yannick Bülter - * @author Jens Pelzetter - */ -public class AudioForm extends AbstractBinaryAssetForm { - - private AssetSearchWidget assetSearchWidget; - - public AudioForm(final AssetPane assetPane) { - super(assetPane); - } - - @Override - protected void addWidgets() { - - assetSearchWidget = new AssetSearchWidget("legal-metadata", - LegalMetadata.class); - - add(new Label(new GlobalizedMessage( - "cms.ui.assets.audio.legal_metadata.label", - CmsConstants.CMS_BUNDLE - ))); - add(assetSearchWidget); - } - - @Override - protected void initForm(final PageState state, - final Map data) { - - super.initForm(state, data); - - if (data.containsKey(AudioFormController.LEGAL_METADATA_ID)) { - - final Long legalMetadataId = (Long) data - .get(AudioFormController.LEGAL_METADATA_ID); - if (legalMetadataId != null) { - assetSearchWidget.setValue(state, legalMetadataId); - } - } - } - - @Override - protected Class getAssetClass() { - return AudioAsset.class; - } - -// @Override -// protected Asset createAsset(final FormSectionEvent event) -// throws FormProcessException { -// -// final AudioAsset audioAsset = (AudioAsset) super.createAsset(event); -// -// final PageState state = event.getPageState(); -// -// updateData(audioAsset, state); -// -// return audioAsset; -// } -// @Override -// protected void updateAsset(final Asset asset, -// final FormSectionEvent event) -// throws FormProcessException { -// -// super.updateAsset(asset, event); -// -// final PageState state = event.getPageState(); -// -// final AudioAsset audioAsset = (AudioAsset) asset; -// -// updateData(audioAsset, state); -// } - -// protected void updateData(final AudioAsset audioAsset, -// final PageState state) { -// -// final Long legalMetadataId = (Long) assetSearchWidget.getValue(state); -// if (legalMetadataId != null) { -// final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); -// final AssetRepository assetRepo = cdiUtil.findBean( -// AssetRepository.class); -// final LegalMetadata legalMetadata = (LegalMetadata) assetRepo -// .findById(legalMetadataId) -// .orElseThrow(() -> new IllegalArgumentException(String.format( -// "No LegalMetadata asset with ID %d in the database.", -// legalMetadataId))); -// -// audioAsset.setLegalMetadata(legalMetadata); -// } -// } - -// @Override -// protected BinaryAsset createBinaryAsset(final PageState state) { -// return new AudioAsset(); -// } -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AudioFormController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AudioFormController.java deleted file mode 100644 index a7bf6c172..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/AudioFormController.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2019 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 com.arsdigita.cms.ui.assets.forms; - -import com.arsdigita.cms.ui.assets.IsControllerForAssetType; - -import org.librecms.assets.AudioAsset; -import org.librecms.assets.LegalMetadata; -import org.librecms.contentsection.AssetRepository; -import org.librecms.contentsection.Folder; - -import java.util.Locale; -import java.util.Map; - -import javax.enterprise.context.RequestScoped; -import javax.inject.Inject; - -/** - * - * @author Jens Pelzetter - */ -@RequestScoped -@IsControllerForAssetType(AudioAsset.class) -public class AudioFormController extends AbstractBinaryAssetFormController { - - protected static final String LEGAL_METADATA_ID = "legalMetadataId"; - - @Inject - private AssetRepository assetRepository; - - @Override - protected Map getAssetData(final AudioAsset asset, - final Locale selectedLocale) { - - final Map data = super.getAssetData(asset, - selectedLocale); - - final LegalMetadata legalMetadata = asset.getLegalMetadata(); - if (legalMetadata != null) { - data.put(LEGAL_METADATA_ID, legalMetadata.getObjectId()); - } - - return data; - } - - @Override - public void updateAssetProperties(final AudioAsset asset, - final Locale selectedLocale, - final Map data) { - - super.updateAssetProperties(asset, selectedLocale, data); - - if (data.containsKey(LEGAL_METADATA_ID)) { - - final long legalMetadataId = (long) data.get(LEGAL_METADATA_ID); - - final LegalMetadata legalMetadata = assetRepository - .findById(legalMetadataId, LegalMetadata.class) - .orElseThrow(() -> new IllegalArgumentException(String.format( - "No LegalMetadata with ID %d found.", legalMetadataId))); - - asset.setLegalMetadata(legalMetadata); - } - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/BookmarkForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/BookmarkForm.java deleted file mode 100644 index 124e89df2..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/BookmarkForm.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright (C) 2017 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 com.arsdigita.cms.ui.assets.forms; - -import com.arsdigita.bebop.FormProcessException; -import com.arsdigita.bebop.event.FormSectionEvent; -import com.arsdigita.cms.ui.assets.AssetPane; - -import org.librecms.assets.Bookmark; - -import java.util.Collections; -import java.util.Map; - -/** - * - * @author Jens Pelzetter - */ -public class BookmarkForm extends AbstractBookmarkForm { - -// private TextArea description; -// private TextField url; - public BookmarkForm(final AssetPane assetPane) { - super(assetPane); - } - -// @Override -// protected void addWidgets() { -// -// add(new Label( -// new GlobalizedMessage("cms.ui.assets.bookmark.description", -// CmsConstants.CMS_BUNDLE))); -// description = new TextArea("bookmark-description"); -// add(description); -// -// add(new Label(new GlobalizedMessage("cms.ui.assets.bookmark.url", -// CmsConstants.CMS_BUNDLE))); -// url = new TextField("bookmark-url"); -// add(url); -// -// addValidationListener(new FormValidationListener() { -// -// @Override -// public void validate(final FormSectionEvent event) -// throws FormProcessException { -// -// final PageState state = event.getPageState(); -// final FormData data = event.getFormData(); -// -// try { -// new URL((String) url.getValue(state)); -// } catch (MalformedURLException ex) { -// data.addError(new GlobalizedMessage( -// "cms.ui.assets.bookmark.url.malformed", -// CmsConstants.CMS_BUNDLE)); -// } -// } -// -// }); -// -// } -// -// @Override -// protected void initForm(final PageState state, -// final Optional selectedAsset) { -// -// if (selectedAsset.isPresent()) { -// -// if (!(selectedAsset.get() instanceof Bookmark)) { -// throw new IllegalArgumentException(String.format( -// "The provided asset must be an instanceof of class '%s' or " -// + "an subclass but is an instanceof of class '%s'.", -// Bookmark.class.getName(), -// selectedAsset.get().getClass().getName())); -// } -// -// final Bookmark bookmark = selectedAsset.get(); -// -// description.setValue(state, -// bookmark -// .getDescription() -// .getValue(getSelectedLocale(state))); -// url.setValue(state, bookmark.getUrl()); -// -// } -// -// } -// -// @Override -// protected void showLocale(final PageState state) { -// final Optional selectedAsset = getSelectedAsset(state); -// -// if (selectedAsset.isPresent()) { -// if (!(getSelectedAsset(state).get() instanceof Bookmark)) { -// throw new IllegalArgumentException( -// "Selected asset is not a bookmark"); -// } -// -// final Bookmark bookmark = selectedAsset.get(); -// -// description.setValue(state, -// bookmark -// .getDescription() -// .getValue(getSelectedLocale(state))); -// } -// } - @Override - @SuppressWarnings("unchecked") - protected Class getAssetClass() { - return Bookmark.class; - } - -// @Override -// protected Asset createAsset(final FormSectionEvent event) -// throws FormProcessException { -// -// Objects.requireNonNull(event); -// -// final PageState state = event.getPageState(); -// -// final Bookmark bookmark = new Bookmark(); -// -// updateData(bookmark, state); -// -// return bookmark; -// } -// protected void updateData(final Bookmark bookmark, -// final PageState state) { -// bookmark -// .getDescription() -// .addValue(getSelectedLocale(state), -// (String) description.getValue(state)); -// -// bookmark.setUrl((String) url.getValue(state)); -// } -// -// -// @Override -// protected void updateAsset(final Asset asset, -// final FormSectionEvent event) -// throws FormProcessException { -// -// Objects.requireNonNull(asset); -// Objects.requireNonNull(event); -// -// final PageState state = event.getPageState(); -// -// if (!(asset instanceof Bookmark)) { -// throw new IllegalArgumentException(String.format( -// "Provided asset is not an instance of class (or sub class of) " -// + "'%s' but is an instance of class '%s'", -// Bookmark.class.getName(), -// asset.getClass().getName())); -// } -// -// final Bookmark bookmark = (Bookmark) asset; -// -// updateData(bookmark, state); -// } - @Override - protected Map collectData(final FormSectionEvent event) - throws FormProcessException { - - return Collections.emptyMap(); - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/BookmarkFormController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/BookmarkFormController.java deleted file mode 100644 index 9e5ff7ac3..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/BookmarkFormController.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2019 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 com.arsdigita.cms.ui.assets.forms; - -import com.arsdigita.cms.ui.assets.IsControllerForAssetType; - -import org.librecms.assets.Bookmark; - -import javax.enterprise.context.RequestScoped; - -/** - * - * @author Jens Pelzetter - */ -@RequestScoped -@IsControllerForAssetType(Bookmark.class) -public class BookmarkFormController - extends AbstractBookmarkFormController { - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/ExternalAudioAssetForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/ExternalAudioAssetForm.java deleted file mode 100644 index 25f931406..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/ExternalAudioAssetForm.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (C) 2017 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 com.arsdigita.cms.ui.assets.forms; - -import com.arsdigita.bebop.FormProcessException; -import com.arsdigita.bebop.Label; -import com.arsdigita.bebop.PageState; -import com.arsdigita.bebop.event.FormSectionEvent; -import com.arsdigita.cms.ui.assets.AssetPane; -import com.arsdigita.cms.ui.assets.AssetSearchWidget; -import com.arsdigita.globalization.GlobalizedMessage; - -import org.librecms.CmsConstants; -import org.librecms.assets.ExternalAudioAsset; -import org.librecms.assets.LegalMetadata; - -import java.util.HashMap; -import java.util.Map; - -/** - * - * @author Jens Pelzetter - * @author Yannick Bülter - */ -public class ExternalAudioAssetForm - extends AbstractBookmarkForm { - - private AssetSearchWidget assetSearchWidget; - - public ExternalAudioAssetForm(final AssetPane assetPane) { - super(assetPane); - } - - @Override - public void addWidgets() { - super.addWidgets(); - - add(new Label(new GlobalizedMessage( - "cms.ui.assets.external_audio_asset.legal_metadata.label", - CmsConstants.CMS_BUNDLE))); - assetSearchWidget = new AssetSearchWidget("legal-metadata", - LegalMetadata.class); - add(assetSearchWidget); - } - - @Override - protected void initForm(final PageState state, - final Map data) { - - super.initForm(state, data); - - final Long selectedAssetId = getSelectedAssetId(state); - - if (selectedAssetId != null) { - - if (data.containsKey( - ExternalAudioAssetFormController.LEGAL_METADATA_ID)) { - - final long legalMetadataId = (long) data - .get(ExternalAudioAssetFormController.LEGAL_METADATA_ID); - - assetSearchWidget.setValue(state, legalMetadataId); - } - } - } - - @Override - protected Class getAssetClass() { - return ExternalAudioAsset.class; - } - - @Override - protected Map collectData(final FormSectionEvent event) - throws FormProcessException { - - final PageState state = event.getPageState(); - - final Map data = new HashMap<>(); - if (assetSearchWidget.getValue(state) != null) { - - data.put(ExternalAudioAssetFormController.LEGAL_METADATA_ID, - assetSearchWidget.getValue(state)); - } - - return data; - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/ExternalAudioAssetFormController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/ExternalAudioAssetFormController.java deleted file mode 100644 index 35efe05df..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/ExternalAudioAssetFormController.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2019 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 com.arsdigita.cms.ui.assets.forms; - -import com.arsdigita.cms.ui.assets.IsControllerForAssetType; - -import org.librecms.assets.ExternalAudioAsset; -import org.librecms.assets.LegalMetadata; -import org.librecms.contentsection.AssetRepository; - -import java.util.Locale; -import java.util.Map; - -import javax.enterprise.context.RequestScoped; -import javax.inject.Inject; - -/** - * - * @author Jens Pelzetter - */ -@RequestScoped -@IsControllerForAssetType(ExternalAudioAsset.class) -public class ExternalAudioAssetFormController - extends AbstractBookmarkFormController { - - protected static final String LEGAL_METADATA_ID = "legalMetadataId"; - - @Inject - private AssetRepository assetRepository; - - @Override - protected Map getAssetData(final ExternalAudioAsset asset, - final Locale selectedLocale) { - - final Map data = super.getAssetData(asset, - selectedLocale); - - final LegalMetadata legalMetadata = asset.getLegalMetadata(); - if (legalMetadata != null) { - data.put(LEGAL_METADATA_ID, legalMetadata.getObjectId()); - } - - return data; - } - - @Override - public void updateAssetProperties(final ExternalAudioAsset asset, - final Locale selectedLocale, - final Map data) { - - super.updateAssetProperties(asset, selectedLocale, data); - - if (data.containsKey(LEGAL_METADATA_ID)) { - - final long legalMetadataId = (long) data.get(LEGAL_METADATA_ID); - final LegalMetadata legalMetadata = assetRepository - .findById(legalMetadataId, LegalMetadata.class) - .orElseThrow(() -> new IllegalArgumentException(String.format( - "No LegalMetadata with ID %d found.", legalMetadataId))); - - asset.setLegalMetadata(legalMetadata); - } - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/ExternalVideoAssetForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/ExternalVideoAssetForm.java deleted file mode 100644 index d0760b9ad..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/ExternalVideoAssetForm.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2017 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 com.arsdigita.cms.ui.assets.forms; - -import com.arsdigita.bebop.FormProcessException; -import com.arsdigita.bebop.Label; -import com.arsdigita.bebop.PageState; -import com.arsdigita.bebop.event.FormSectionEvent; -import com.arsdigita.cms.ui.assets.AssetPane; -import com.arsdigita.cms.ui.assets.AssetSearchWidget; -import com.arsdigita.globalization.GlobalizedMessage; - -import org.librecms.CmsConstants; - -import org.librecms.assets.ExternalVideoAsset; -import org.librecms.assets.LegalMetadata; - -import java.util.HashMap; -import java.util.Map; - -/** - * - * @author Jens Pelzetter - */ -public class ExternalVideoAssetForm - extends AbstractBookmarkForm { - - private AssetSearchWidget assetSearchWidget; - - public ExternalVideoAssetForm(final AssetPane assetPane) { - super(assetPane); - } - - @Override - public void addWidgets() { - super.addWidgets(); - - add(new Label(new GlobalizedMessage( - "cms.ui.assets.external_video_asset.legal_metadata.label", - CmsConstants.CMS_BUNDLE))); - assetSearchWidget = new AssetSearchWidget("legal-metadata", - LegalMetadata.class); - add(assetSearchWidget); - } - - @Override - protected void initForm(final PageState state, - final Map data) { - - super.initForm(state, data); - - final Long selectedAssetId = getSelectedAssetId(state); - if (selectedAssetId != null) { - - if (data.containsKey( - ExternalVideoAssetFormController.LEGAL_METADATA_ID)) { - assetSearchWidget.setValue( - state, - data.get(ExternalVideoAssetFormController.LEGAL_METADATA_ID)); - } - } - } - - @Override - protected Class getAssetClass() { - return ExternalVideoAsset.class; - } - - @Override - protected Map collectData(final FormSectionEvent event) - throws FormProcessException { - - final Map data = new HashMap<>(); - final PageState state = event.getPageState(); - - if (assetSearchWidget.getValue(state) != null) { - data.put(ExternalAudioAssetFormController.LEGAL_METADATA_ID, - assetSearchWidget.getValue(state)); - } - - return data; - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/ExternalVideoAssetFormController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/ExternalVideoAssetFormController.java deleted file mode 100644 index bd2cc2c8a..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/ExternalVideoAssetFormController.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2019 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 com.arsdigita.cms.ui.assets.forms; - -import com.arsdigita.cms.ui.assets.IsControllerForAssetType; - -import org.librecms.assets.ExternalVideoAsset; -import org.librecms.assets.LegalMetadata; -import org.librecms.contentsection.AssetRepository; - -import java.util.Locale; -import java.util.Map; - -import javax.enterprise.context.RequestScoped; -import javax.inject.Inject; -import javax.transaction.Transactional; - -/** - * - * @author Jens Pelzetter - */ -@RequestScoped -@IsControllerForAssetType(ExternalVideoAsset.class) -public class ExternalVideoAssetFormController - extends AbstractBookmarkFormController { - - protected static final String LEGAL_METADATA_ID = "legalMetadataId"; - - @Inject - private AssetRepository assetRepository; - - @Transactional(Transactional.TxType.REQUIRED) - @Override - protected Map getAssetData(final ExternalVideoAsset asset, - final Locale selectedLocale) { - - final Map data = super.getAssetData(asset, - selectedLocale); - if (asset.getLegalMetadata() != null) { - - data.put(LEGAL_METADATA_ID, asset.getLegalMetadata().getObjectId()); - } - - return data; - } - - @Override - public void updateAssetProperties(final ExternalVideoAsset asset, - final Locale selectedLocale, - final Map data) { - - super.updateAssetProperties(asset, selectedLocale, data); - - if (data.containsKey(LEGAL_METADATA_ID)) { - - final long legalMetadataId = (long) data.get(LEGAL_METADATA_ID); - - final LegalMetadata legalMetadata = assetRepository - .findById(legalMetadataId, LegalMetadata.class) - .orElseThrow(() -> new IllegalArgumentException(String.format( - "No LegalMetadata with ID %d found.", legalMetadataId))); - - asset.setLegalMetadata(legalMetadata); - } - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/FileAssetForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/FileAssetForm.java deleted file mode 100644 index bc01566bb..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/FileAssetForm.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2017 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 com.arsdigita.cms.ui.assets.forms; - -import com.arsdigita.cms.ui.assets.AssetPane; - -import org.librecms.assets.FileAsset; - -/** - * - * @author Jens Pelzetter - */ -public class FileAssetForm extends AbstractBinaryAssetForm { - - public FileAssetForm(final AssetPane assetPane) { - super(assetPane); - } - - @Override - protected Class getAssetClass() { - return FileAsset.class; - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/FileAssetFormController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/FileAssetFormController.java deleted file mode 100644 index 4e7e6ac52..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/FileAssetFormController.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2019 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 com.arsdigita.cms.ui.assets.forms; - -import com.arsdigita.cms.ui.assets.IsControllerForAssetType; - -import org.librecms.assets.FileAsset; - -import javax.enterprise.context.RequestScoped; - -/** - * - * @author Jens Pelzetter - */ -@RequestScoped -@IsControllerForAssetType(FileAsset.class) -public class FileAssetFormController extends AbstractBinaryAssetFormController { - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/ImageForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/ImageForm.java deleted file mode 100644 index 2ff95c29f..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/ImageForm.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (C) 2017 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 com.arsdigita.cms.ui.assets.forms; - -import com.arsdigita.bebop.FormProcessException; -import com.arsdigita.bebop.Label; -import com.arsdigita.bebop.PageState; -import com.arsdigita.bebop.event.FormSectionEvent; -import com.arsdigita.bebop.form.TextField; -import com.arsdigita.cms.ui.assets.AssetPane; -import com.arsdigita.cms.ui.assets.AssetSearchWidget; -import com.arsdigita.globalization.GlobalizedMessage; - -import org.libreccm.cdi.utils.CdiUtil; -import org.librecms.CmsConstants; -import org.librecms.assets.Image; -import org.librecms.assets.LegalMetadata; -import org.librecms.contentsection.Asset; -import org.librecms.contentsection.AssetRepository; - -import java.util.Map; - -/** - * - * @author Yannick Bülter - * @author Jens Pelzetter - */ -public class ImageForm extends AbstractBinaryAssetForm { - - private TextField width; - private TextField height; - private AssetSearchWidget assetSearchWidget; - - public ImageForm(final AssetPane assetPane) { - super(assetPane); - } - - @Override - protected void addWidgets() { - - super.addWidgets(); - - width = new TextField("width-text"); - height = new TextField("height-text"); - assetSearchWidget = new AssetSearchWidget("legal-metadata", - LegalMetadata.class); - - add(new Label(new GlobalizedMessage( - "cms.ui.assets.image.width.label", - CmsConstants.CMS_BUNDLE - ))); - add(width); - - add(new Label(new GlobalizedMessage( - "cms.ui.assets.image.height.label", - CmsConstants.CMS_BUNDLE - ))); - add(height); - - add(new Label(new GlobalizedMessage( - "cms.ui.assets.image.legal_metadata.label", - CmsConstants.CMS_BUNDLE - ))); - add(assetSearchWidget); - } - - @Override - protected void initForm(final PageState state, - final Map data) { - - super.initForm(state, data); - - if (getSelectedAssetId(state) != null) { - - if (data.containsKey(ImageFormController.WIDTH)) { - final long widthValue = (long) data - .get(ImageFormController.WIDTH); - width.setValue(state, Long.toString(widthValue)); - } - if (data.containsKey(ImageFormController.HEIGHT)) { - final long heightValue = (long) data - .get(ImageFormController.HEIGHT); - height.setValue(state, Long.toString(heightValue)); - } - - if (data.containsKey(ImageFormController.LEGAL_METADATA_ID)) { - assetSearchWidget - .setValue(state, - data.get(ImageFormController.LEGAL_METADATA_ID)); - } - } - } - - @Override - protected Class getAssetClass() { - return Image.class; - } - - @Override - protected Map collectData(final FormSectionEvent event) - throws FormProcessException { - - final Map data = super.collectData(event); - final PageState state = event.getPageState(); - - data.put(ImageFormController.WIDTH, width.getValue(state)); - data.put(ImageFormController.HEIGHT, height.getValue(state)); - - if (assetSearchWidget.getValue(state) != null) { - data.put(ImageFormController.LEGAL_METADATA_ID, - assetSearchWidget.getValue(state)); - } - - return data; - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/ImageFormController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/ImageFormController.java deleted file mode 100644 index 7bf33e469..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/ImageFormController.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2019 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 com.arsdigita.cms.ui.assets.forms; - -import com.arsdigita.cms.ui.assets.IsControllerForAssetType; - -import org.librecms.assets.Image; -import org.librecms.assets.LegalMetadata; -import org.librecms.contentsection.AssetRepository; - -import java.util.Locale; -import java.util.Map; - -import javax.enterprise.context.RequestScoped; - -import javax.inject.Inject; - -/** - * - * @author Jens Pelzetter - */ -@RequestScoped -@IsControllerForAssetType(Image.class) -public class ImageFormController - extends AbstractBinaryAssetFormController { - - protected static final String LEGAL_METADATA_ID = "legalMetadataId"; - protected static final String HEIGHT = "height"; - protected static final String WIDTH = "width"; - - @Inject - private AssetRepository assetRepository; - - @Override - protected Map getAssetData(final Image asset, - final Locale selectedLocale) { - - final Map data = super.getAssetData(asset, - selectedLocale); - - data.put(WIDTH, asset.getWidth()); - data.put(HEIGHT, asset.getHeight()); - - if (asset.getLegalMetadata() != null) { - data.put(LEGAL_METADATA_ID, - asset.getLegalMetadata().getObjectId()); - } - - return data; - } - - @Override - public void updateAssetProperties(final Image asset, - final Locale selectedLocale, - final Map data) { - - super.updateAssetProperties(asset, selectedLocale, data); - - if (data.containsKey(WIDTH)) { - asset.setWidth((long) data.get(WIDTH)); - } - - if (data.containsKey(HEIGHT)) { - asset.setHeight((long) data.get(HEIGHT)); - } - - if (data.containsKey(LEGAL_METADATA_ID)) { - final long legalMetadataId = (long) data.get(LEGAL_METADATA_ID); - - final LegalMetadata legalMetadata = assetRepository - .findById(legalMetadataId, LegalMetadata.class) - .orElseThrow(() -> new IllegalArgumentException(String.format( - "No LegalMetadata with ID %d found.", legalMetadataId))); - - asset.setLegalMetadata(legalMetadata); - } - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/LegalMetadataForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/LegalMetadataForm.java deleted file mode 100644 index 72933c1e4..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/LegalMetadataForm.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (C) 2017 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 com.arsdigita.cms.ui.assets.forms; - -import com.arsdigita.bebop.BoxPanel; -import com.arsdigita.bebop.FormProcessException; -import com.arsdigita.bebop.Label; -import com.arsdigita.bebop.PageState; -import com.arsdigita.bebop.event.FormSectionEvent; -import com.arsdigita.bebop.form.TextArea; -import com.arsdigita.cms.ui.assets.AbstractAssetForm; -import com.arsdigita.cms.ui.assets.AssetPane; -import com.arsdigita.globalization.GlobalizedMessage; - -import org.librecms.CmsConstants; -import org.librecms.assets.LegalMetadata; - -import java.util.HashMap; -import java.util.Map; - -/** - * - * @author Jens Pelzetter - */ -public class LegalMetadataForm extends AbstractAssetForm { - - private TextArea rightsHolder; - private TextArea rights; - private TextArea publisher; - private TextArea creator; - - public LegalMetadataForm(final AssetPane assetPane) { - super(assetPane); - } - - @Override - protected void addWidgets() { - - final BoxPanel panel = new BoxPanel(BoxPanel.VERTICAL); - - panel.add(new Label(new GlobalizedMessage( - "cms.ui.assets.legalmetadata.rightsholder", - CmsConstants.CMS_BUNDLE))); - rightsHolder = new TextArea("legalmetadata-rightsholder"); - panel.add(rightsHolder); - - panel.add(new Label(new GlobalizedMessage( - "cms.ui.assets.legalmetadata.rights", - CmsConstants.CMS_BUNDLE))); - rights = new TextArea("legalmetadata-rights"); - panel.add(rights); - - panel.add(new Label(new GlobalizedMessage( - "cms.ui.assets.legalmetadata.publisher", - CmsConstants.CMS_BUNDLE))); - publisher = new TextArea("legalmetadata-rights"); - panel.add(publisher); - - panel.add(new Label(new GlobalizedMessage( - "cms.ui.assets.legalmetadata.creator", - CmsConstants.CMS_BUNDLE))); - creator = new TextArea("legalmetadata-creator"); - panel.add(creator); - - add(panel); - } - - @Override - protected void initForm(final PageState state, - final Map data) { - - super.initForm(state, data); - - if (getSelectedAssetId(state) != null) { - - rightsHolder.setValue( - state, - data.get(LegalMetadataFormController.RIGHTS_HOLDER)); - rights.setValue(state, - data.get(LegalMetadataFormController.RIGHTS)); - publisher.setValue(state, - data.get(LegalMetadataFormController.PUBLISHER)); - creator.setValue(state, - data.get(LegalMetadataFormController.CREATOR)); - } - } - - @Override - protected void showLocale(final PageState state) { - - final Long selectedAssetId = getSelectedAssetId(state); - - if (selectedAssetId != null) { - - final Map data = getController() - .getAssetData(selectedAssetId, - LegalMetadata.class, - getSelectedLocale(state)); - - rights.setValue(state, - data.get(LegalMetadataFormController.RIGHTS)); - } - } - - @Override - protected Class getAssetClass() { - return LegalMetadata.class; - } - - @Override - protected Map collectData(final FormSectionEvent event) - throws FormProcessException { - - final PageState state = event.getPageState(); - final Map data = new HashMap<>(); - - data.put(LegalMetadataFormController.CREATOR, creator.getValue(state)); - data.put(LegalMetadataFormController.PUBLISHER, - publisher.getValue(state)); - data.put(LegalMetadataFormController.RIGHTS, - rights.getValue(state)); - data.put(LegalMetadataFormController.RIGHTS_HOLDER, - rightsHolder.getValue(state)); - - return data; - } -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/LegalMetadataFormController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/LegalMetadataFormController.java deleted file mode 100644 index 402a19fc7..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/LegalMetadataFormController.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2019 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 com.arsdigita.cms.ui.assets.forms; - -import com.arsdigita.cms.ui.assets.AbstractAssetFormController; -import com.arsdigita.cms.ui.assets.IsControllerForAssetType; - -import org.librecms.assets.LegalMetadata; - -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; - -import javax.enterprise.context.RequestScoped; - -/** - * - * @author Jens Pelzetter - */ -@RequestScoped -@IsControllerForAssetType(LegalMetadata.class) -public class LegalMetadataFormController - extends AbstractAssetFormController { - - protected static final String CONTRIBUTORS = "contributors"; - protected static final String CREATOR = "creator"; - protected static final String PUBLISHER = "publisher"; - protected static final String RIGHTS = "rights"; - protected static final String RIGHTS_HOLDER = "rightsHolder"; - - @Override - protected Map getAssetData(final LegalMetadata asset, - final Locale selectedLocale) { - - final Map data = new HashMap<>(); - - data.put(RIGHTS_HOLDER, asset.getRightsHolder()); - data.put(RIGHTS, asset.getRights().getValue(selectedLocale)); - data.put(PUBLISHER, asset.getPublisher()); - data.put(CREATOR, asset.getCreator()); - data.put(CONTRIBUTORS, asset.getContributors()); - - return data; - } - - @Override - public void updateAssetProperties(final LegalMetadata asset, - final Locale selectedLocale, - final Map data) { - - if (data.containsKey(RIGHTS_HOLDER)) { - asset.setRightsHolder((String) data.get(RIGHTS_HOLDER)); - } - - if (data.containsKey(RIGHTS)) { - asset.getRights().putValue(selectedLocale, - (String) data.get(RIGHTS)); - } - - if (data.containsKey(PUBLISHER)) { - asset.setPublisher((String) data.get(PUBLISHER)); - } - - if (data.containsKey(CREATOR)) { - asset.setCreator((String) data.get(CREATOR)); - } - - if (data.containsKey(CONTRIBUTORS)) { - @SuppressWarnings("unchecked") - final List contributors = (List) data - .get(CONTRIBUTORS); - asset.setContributors(contributors); - } - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/OrganizationForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/OrganizationForm.java deleted file mode 100644 index f76a33eb7..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/OrganizationForm.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2019 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 com.arsdigita.cms.ui.assets.forms; - -import com.arsdigita.bebop.Label; -import com.arsdigita.bebop.PageState; -import com.arsdigita.bebop.event.FormSectionEvent; -import com.arsdigita.bebop.form.TextField; -import com.arsdigita.cms.ui.assets.AssetPane; -import com.arsdigita.globalization.GlobalizedMessage; - -import org.librecms.CmsConstants; -import org.librecms.assets.Organization; - -import java.util.HashMap; -import java.util.Map; - -/** - * - * @author Jens Pelzetter - */ -public class OrganizationForm extends AbstractContactableEntityForm { - - private TextField organizationName; - - public OrganizationForm(final AssetPane assetPane) { - - super(assetPane); - } - - @Override - public void initForm(final PageState state, - final Map data) { - - super.initForm(state, data); - - if (getSelectedAssetId(state) != null) { - - organizationName.setValue( - state, - data.get(OrganizationFormController.ORGANIZATION_NAME)); - } - } - - @Override - protected void addPropertyWidgets() { - - add(new Label( - new GlobalizedMessage("cms.ui.assets.organization.name", - CmsConstants.CMS_BUNDLE))); - organizationName = new TextField("organization-name"); - add(organizationName); - } - - @Override - protected Class getAssetClass() { - - return Organization.class; - } - - @Override - protected void showLocale(final PageState state) { - - // Organization has no localizable fields. - } - - @Override - protected Map collectData(final FormSectionEvent event) { - - final PageState state = event.getPageState(); - - final Map data = super.collectData(event); - data.put(OrganizationFormController.ORGANIZATION_NAME, - organizationName.getValue(state)); - - return data; - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/OrganizationFormController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/OrganizationFormController.java deleted file mode 100644 index 832437182..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/OrganizationFormController.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2019 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 com.arsdigita.cms.ui.assets.forms; - -import com.arsdigita.cms.ui.assets.IsControllerForAssetType; - -import org.librecms.assets.Organization; - -import java.util.Locale; -import java.util.Map; - -import javax.enterprise.context.RequestScoped; - -/** - * - * @author Jens Pelzetter - */ -@RequestScoped -@IsControllerForAssetType(Organization.class) -public class OrganizationFormController - extends AbstractContactableEntityFormController { - - protected static final String ORGANIZATION_NAME = "organizationName"; - - @Override - protected Map getAssetData(final Organization asset, - final Locale selectedLocale) { - - final Map data = super.getAssetData(asset, - selectedLocale); - data.put(ORGANIZATION_NAME, asset.getName()); - - return data; - } - - @Override - public void updateAssetProperties(final Organization asset, - final Locale selectedLocale, - final Map data) { - - super.updateAssetProperties(asset, selectedLocale, data); - - if (data.containsKey(ORGANIZATION_NAME)) { - final String organizationName = (String) data.get(ORGANIZATION_NAME); - asset.setName(organizationName); - } - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/PersonForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/PersonForm.java deleted file mode 100644 index 1d928b84e..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/PersonForm.java +++ /dev/null @@ -1,323 +0,0 @@ -/* - * Copyright (C) 2019 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 com.arsdigita.cms.ui.assets.forms; - -import com.arsdigita.bebop.FormProcessException; -import com.arsdigita.bebop.Label; -import com.arsdigita.bebop.PageState; -import com.arsdigita.bebop.Table; -import com.arsdigita.bebop.event.FormSectionEvent; -import com.arsdigita.bebop.form.Date; -import com.arsdigita.bebop.form.Submit; -import com.arsdigita.bebop.form.TextField; -import com.arsdigita.bebop.table.TableColumn; -import com.arsdigita.bebop.table.TableColumnModel; -import com.arsdigita.bebop.table.TableModel; -import com.arsdigita.bebop.table.TableModelBuilder; -import com.arsdigita.cms.ui.assets.AssetPane; -import com.arsdigita.globalization.GlobalizedMessage; -import com.arsdigita.util.LockableImpl; - -import org.librecms.assets.Person; - -import java.time.LocalDate; -import java.time.ZoneId; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import static org.librecms.CmsConstants.*; - -/** - * - * @author Jens Pelzetter - */ -public class PersonForm extends AbstractContactableEntityForm { - - private TextField surnameField; - - private TextField givenNameField; - - private TextField prefixField; - - private TextField suffixField; - - private Submit addPersonNameButton; - - private Date birthdateField; - - public PersonForm(final AssetPane assetPane) { - super(assetPane); - } - - @Override - protected void addPropertyWidgets() { - - final Label surnameLabel = new Label(new GlobalizedMessage( - "cms.ui.authoring.assets.person.surname", - CMS_BUNDLE)); - surnameField = new TextField("surname"); - add(surnameLabel); - add(surnameField); - - final Label givenNameLabel = new Label(new GlobalizedMessage( - "cms.ui.authoring.assets.person.given_name", - CMS_BUNDLE)); - givenNameField = new TextField("givenName"); - add(givenNameLabel); - add(givenNameField); - - final Label prefixLabel = new Label(new GlobalizedMessage( - "cms.ui.authoring.assets.person.prefix", - CMS_BUNDLE - )); - prefixField = new TextField("prefix"); - add(prefixLabel); - add(prefixField); - - final Label suffixLabel = new Label(new GlobalizedMessage( - "cms.ui.authoring.assets.person.suffix", - CMS_BUNDLE - )); - suffixField = new TextField("suffix"); - add(suffixLabel); - add(suffixField); - - add(buildPersonNamesTable()); - - addPersonNameButton = new Submit(new GlobalizedMessage( - "cms.ui.authoring.assets.person.add_name", - CMS_BUNDLE)); - add(addPersonNameButton); - - final Label birthdateLabel = new Label(new GlobalizedMessage( - "cms.ui.authoring.assets.person.birthdate", - CMS_BUNDLE)); - add(birthdateLabel); - birthdateField = new Date("birthdate"); - final LocalDate today = LocalDate.now(ZoneId.systemDefault()); - birthdateField.setYearRange(1930, today.getYear()); - add(birthdateField); - } - - @Override - protected Class getAssetClass() { - return Person.class; - } - - @Override - protected void showLocale(final PageState state) { - - // Nothing - } - - @Override - protected Map collectData(final FormSectionEvent event) { - - final PageState state = event.getPageState(); - - final Map data = new HashMap<>(); - - data.put(PersonFormController.SURNAME, surnameField.getValue(state)); - data.put(PersonFormController.GIVENNAME, - givenNameField.getValue(state)); - data.put(PersonFormController.PREFIX, prefixField.getValue(state)); - data.put(PersonFormController.SUFFIX, suffixField.getValue(state)); - - data.put(PersonFormController.BIRTHDATE, - birthdateField.getValue(state)); - - return data; - } - - @Override - public void initForm(final PageState state, - final Map data) { - - super.initForm(state, data); - - if (data.containsKey(PersonFormController.SURNAME)) { - surnameField.setValue(state, - data.get(PersonFormController.SURNAME)); - } - - if (data.containsKey(PersonFormController.GIVENNAME)) { - givenNameField.setValue(state, - data.get(PersonFormController.GIVENNAME)); - } - - if (data.containsKey(PersonFormController.PREFIX)) { - prefixField.setValue(state, data.get(PersonFormController.PREFIX)); - } - - if (data.containsKey(PersonFormController.SUFFIX)) { - suffixField.setValue(state, data.get(PersonFormController.SUFFIX)); - } - - if (data.containsKey(PersonFormController.BIRTHDATE)) { - birthdateField.setValue(state, - data.get(PersonFormController.BIRTHDATE)); - } - } - - @Override - public void process(final FormSectionEvent event) throws - FormProcessException { - - if (addPersonNameButton.equals(event.getSource())) { - - final PersonFormController controller - = (PersonFormController) getController(); - controller.addPersonName(getSelectedAssetId(event.getPageState())); - - } else { - super.process(event); - } - } - - private Table buildPersonNamesTable() { - - final Table table = new Table() { - - @Override - public boolean isVisible(final PageState state) { - return getSelectedAssetId(state) != null; - } - }; - - final TableColumnModel columnModel = table.getColumnModel(); - columnModel.add(new TableColumn( - 0, - new Label( - new GlobalizedMessage( - "cms.ui.authoring.assets.person.surname", - CMS_BUNDLE - ) - ) - )); - columnModel.add(new TableColumn( - 1, - new Label( - new GlobalizedMessage( - "cms.ui.authoring.assets.person.givenName", - CMS_BUNDLE - ) - ) - )); - columnModel.add(new TableColumn( - 2, - new Label( - new GlobalizedMessage( - "cms.ui.authoring.assets.person.prefix", - CMS_BUNDLE - ) - ) - )); - columnModel.add(new TableColumn( - 3, - new Label( - new GlobalizedMessage( - "cms.ui.authoring.assets.person.suffix", - CMS_BUNDLE - ) - ) - )); - - table.setModelBuilder(new PersonNamesTableModelBuilder()); - - table.setEmptyView(new Label(new GlobalizedMessage( - "cms.ui.authoring.assets.person.names.none"))); - - return table; - } - - private class PersonNamesTableModelBuilder - extends LockableImpl - implements TableModelBuilder { - - @Override - public TableModel makeModel(final Table table, final PageState state) { - - final Long selectedPersonId = getSelectedAssetId(state); - if (selectedPersonId == null) { - throw new RuntimeException("No asset selected."); - } - - final PersonFormController controller - = (PersonFormController) getController(); - final List personNames = controller - .getPersonNames(selectedPersonId); - - return new PersonNamesTableModel(personNames); - } - - } - - private class PersonNamesTableModel implements TableModel { - - private final Iterator personNames; - - private String[] currentPersonName; - - private int row; - - public PersonNamesTableModel(final List personNames) { - - this.personNames = Objects - .requireNonNull(personNames, - "Can't create PersonNamesTableModel without a " - + "list of person names.") - .iterator(); - } - - @Override - public int getColumnCount() { - return 4; - } - - @Override - public boolean nextRow() { - - if (personNames.hasNext()) { - currentPersonName = personNames.next(); - row++; - return true; - } else { - return false; - } - } - - @Override - public Object getElementAt(final int columnIndex) { - - return currentPersonName[columnIndex]; - - } - - @Override - public Object getKeyAt(final int columnIndex) { - - return row; - } - - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/PersonFormController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/PersonFormController.java deleted file mode 100644 index 07ac21250..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/PersonFormController.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (C) 2019 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 com.arsdigita.cms.ui.assets.forms; - -import com.arsdigita.cms.ui.assets.IsControllerForAssetType; - -import org.librecms.assets.Person; -import org.librecms.assets.PersonManager; -import org.librecms.assets.PersonName; -import org.librecms.assets.PersonRepository; - -import java.time.Instant; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.util.Date; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.stream.Collectors; - -import javax.enterprise.context.RequestScoped; -import javax.inject.Inject; -import javax.transaction.Transactional; - -/** - * - * @author Jens Pelzetter - */ -@RequestScoped -@IsControllerForAssetType(Person.class) -public class PersonFormController - extends AbstractContactableEntityFormController { - - protected static final String SUFFIX = "suffix"; - - protected static final String PREFIX = "prefix"; - - protected static final String GIVENNAME = "givenName"; - - protected static final String SURNAME = "surname"; - - protected static final String BIRTHDATE = "birthdate"; - - protected static final String PERSON_NAMES = "personNames"; - - protected static final int SURNAME_INDEX = 0; - - protected static final int GIVENNAME_INDEX = 1; - - protected static final int PREFIX_INDEX = 2; - - protected static final int SUFFIX_INDEX = 3; - - @Inject - private PersonRepository personRepository; - - @Inject - private PersonManager personManager; - - @Transactional - @Override - protected Map getAssetData(final Person asset, - final Locale selectedLocale) { - - final Map data = super.getAssetData(asset, - selectedLocale); - - final PersonName personName = asset.getPersonName(); - data.put(SURNAME, personName.getSurname()); - data.put(GIVENNAME, personName.getGivenName()); - data.put(PREFIX, personName.getPrefix()); - data.put(SUFFIX, personName.getSuffix()); - - final List names = asset - .getPersonNames() - .subList(0, asset.getPersonNames().size() - 1) - .stream() - .map(this::convertPersonName) - .collect(Collectors.toList()); - data.put(PERSON_NAMES, names); - - final LocalDate birthdate = asset.getBirthdate(); - if (birthdate != null) { - final Instant instant = birthdate - .atStartOfDay() - .atZone(ZoneId.systemDefault()) - .toInstant(); - final Date birthdateValue = Date.from(instant); - data.put(BIRTHDATE, birthdateValue); - } - - return data; - } - - @Transactional(Transactional.TxType.REQUIRED) - protected List getPersonNames(final Long personId) { - - final Person person = personRepository - .findById(personId) - .orElseThrow(() -> new IllegalArgumentException(String.format( - "No Person with ID %d found.", personId))); - - return person - .getPersonNames() - .subList(0, person.getPersonNames().size() - 1) - .stream() - .map(this::convertPersonName) - .collect(Collectors.toList()); - } - - private String[] convertPersonName(final PersonName name) { - - final String[] result = new String[4]; - - result[SURNAME_INDEX] = name.getSurname(); - result[GIVENNAME_INDEX] = name.getGivenName(); - result[PREFIX_INDEX] = name.getPrefix(); - result[SUFFIX_INDEX] = name.getSuffix(); - - return result; - } - - @Override - public void updateAssetProperties(final Person asset, - final Locale selectedLocale, - final Map data) { - - super.updateAssetProperties(asset, selectedLocale, data); - - if (data.containsKey(BIRTHDATE)) { - - final Date birthdateValue = (Date) data.get(BIRTHDATE); - final Instant instant = birthdateValue.toInstant(); - final LocalDate birthdate = LocalDateTime - .ofInstant(instant, ZoneId.systemDefault()) - .toLocalDate(); - - asset.setBirthdate(birthdate); - } - - final String surname = (String) data.get(SURNAME); - final String givenName = (String) data.get(GIVENNAME); - final String prefix = (String) data.get(PREFIX); - final String suffix = (String) data.get(SUFFIX); - - if (asset.getPersonName() == null) { - final PersonName personName = new PersonName(); - personName.setGivenName(givenName); - personName.setSuffix(suffix); - personName.setPrefix(prefix); - personName.setSurname(surname); - personManager.addPersonName(asset, personName); - } - } - - @Transactional(Transactional.TxType.REQUIRED) - public void addPersonName(final long personId) { - final Person person = personRepository - .findById(personId) - .orElseThrow(() -> new IllegalArgumentException(String.format( - "No Person with ID %d found.", personId))); - - personManager.addPersonName(person, new PersonName()); - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/PostalAddressForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/PostalAddressForm.java deleted file mode 100644 index 8e0f5fa34..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/PostalAddressForm.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (C) 2019 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 com.arsdigita.cms.ui.assets.forms; - -import com.arsdigita.bebop.FormProcessException; -import com.arsdigita.bebop.PageState; -import com.arsdigita.bebop.event.FormSectionEvent; -import com.arsdigita.bebop.form.TextArea; -import com.arsdigita.bebop.form.TextField; -import com.arsdigita.cms.ui.assets.AbstractAssetForm; -import com.arsdigita.cms.ui.assets.AssetPane; -import com.arsdigita.globalization.GlobalizedMessage; - -import org.librecms.assets.PostalAddress; - -import java.util.HashMap; -import java.util.Map; - -import static org.librecms.CmsConstants.*; - -/** - * - * @author Jens Pelzetter - */ -public class PostalAddressForm extends AbstractAssetForm { - - private TextArea addressArea; - private TextField postalCodeField; - private TextField cityField; - private TextField stateField; - private TextField isoCountryCodeField; - - public PostalAddressForm(final AssetPane assetPane) { - super(assetPane); - } - - @Override - protected void addWidgets() { - - super.addWidgets(); - - addressArea = new TextArea("address"); - addressArea.setLabel(new GlobalizedMessage( - "cms.ui.authoring.assets.postaladdress.address", CMS_BUNDLE)); - addressArea.setCols(80); - addressArea.setRows(10); - add(addressArea); - - postalCodeField = new TextField("postalCode"); - postalCodeField.setLabel(new GlobalizedMessage( - "cms.ui.authoring.assets.postaladdress.postalcode", CMS_BUNDLE)); - add(postalCodeField); - - cityField = new TextField("city"); - cityField.setLabel(new GlobalizedMessage( - "cms.ui.authoring.assets.postaladdress.city", CMS_BUNDLE)); - add(cityField); - - stateField = new TextField("state"); - stateField.setLabel(new GlobalizedMessage( - "cms.ui.authoring.assets.postaladdress.state", CMS_BUNDLE)); - add(stateField); - } - - @Override - protected Class getAssetClass() { - return PostalAddress.class; - } - - @Override - protected void showLocale(final PageState state) { - // Nothing - } - - @Override - protected Map collectData(final FormSectionEvent event) - throws FormProcessException { - - final PageState state = event.getPageState(); - - final Map data = new HashMap<>(); - - data.put(PostalAddressFormController.ADDRESS, - addressArea.getValue(state)); - data.put(PostalAddressFormController.CITY, - cityField.getValue(state)); - data.put(PostalAddressFormController.POSTAL_CODE, - postalCodeField.getValue(state)); - data.put(PostalAddressFormController.STATE, - stateField.getValue(state)); - - return data; - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/PostalAddressFormController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/PostalAddressFormController.java deleted file mode 100644 index 1b0360f0f..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/PostalAddressFormController.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2019 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 com.arsdigita.cms.ui.assets.forms; - -import com.arsdigita.cms.ui.assets.AbstractAssetFormController; -import com.arsdigita.cms.ui.assets.IsControllerForAssetType; - -import org.librecms.assets.PostalAddress; - -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; - -import javax.enterprise.context.RequestScoped; - -/** - * - * @author Jens Pelzetter - */ -@RequestScoped -@IsControllerForAssetType(PostalAddress.class) -public class PostalAddressFormController - extends AbstractAssetFormController { - - protected static final String STATE = "state"; - protected static final String CITY = "city"; - protected static final String POSTAL_CODE = "postalCode"; - protected static final String ADDRESS = "address"; - - @Override - protected Map getAssetData(final PostalAddress asset, - final Locale selectedLocale) { - - final Map data = new HashMap<>(); - - data.put(ADDRESS, asset.getAddress()); - data.put(POSTAL_CODE, asset.getPostalCode()); - data.put(CITY, asset.getCity()); - data.put(STATE, asset.getState()); - - return data; - } - - @Override - public void updateAssetProperties(final PostalAddress asset, - final Locale selectedLocale, - final Map data) { - - if (data.containsKey(ADDRESS)) { - asset.setAddress((String) data.get(ADDRESS)); - } - - if (data.containsKey(POSTAL_CODE)) { - asset.setPostalCode((String) data.get(POSTAL_CODE)); - } - - if (data.containsKey(CITY)) { - asset.setCity((String) data.get(CITY)); - } - - if (data.containsKey(STATE)) { - asset.setState((String) data.get(STATE)); - } - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/RelatedLinkForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/RelatedLinkForm.java deleted file mode 100644 index d589b4a58..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/RelatedLinkForm.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2021 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 com.arsdigita.cms.ui.assets.forms; - -import com.arsdigita.bebop.FormProcessException; -import com.arsdigita.bebop.PageState; -import com.arsdigita.bebop.event.FormSectionEvent; -import com.arsdigita.cms.ui.assets.AbstractAssetForm; -import com.arsdigita.cms.ui.assets.AssetPane; - -import org.librecms.assets.RelatedLink; -import org.librecms.assets.SideNote; - -import java.util.Map; - -/** - * - * @author Jens Pelzetter - */ -public class RelatedLinkForm extends AbstractAssetForm{ - - public RelatedLinkForm(final AssetPane assetPane) { - super(assetPane); - } - - @Override - protected Class getAssetClass() { - return RelatedLink.class; - } - - @Override - protected void showLocale(final PageState state) { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - - @Override - protected Map collectData(final FormSectionEvent event) throws - FormProcessException { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/SideNoteForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/SideNoteForm.java deleted file mode 100644 index bc5849925..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/SideNoteForm.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (C) 2017 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 com.arsdigita.cms.ui.assets.forms; - -import com.arsdigita.bebop.FormProcessException; -import com.arsdigita.bebop.Label; -import com.arsdigita.bebop.PageState; -import com.arsdigita.bebop.event.FormSectionEvent; -import com.arsdigita.bebop.form.TextArea; -import com.arsdigita.cms.ui.assets.AbstractAssetForm; -import com.arsdigita.cms.ui.assets.AssetPane; -import com.arsdigita.globalization.GlobalizedMessage; - -import org.librecms.CmsConstants; -import org.librecms.assets.SideNote; - -import java.util.HashMap; -import java.util.Map; - -/** - * - * @author Jens Pelzetter - */ -public class SideNoteForm extends AbstractAssetForm { - - private TextArea text; - - public SideNoteForm(final AssetPane assetPane) { - super(assetPane); - } - - @Override - protected void addWidgets() { - - add(new Label(new GlobalizedMessage("cms.ui.assets.sidenote.text", - CmsConstants.CMS_BUNDLE))); - text = new TextArea("sidenote-text"); - add(text); - } - - @Override - protected void initForm(final PageState state, - final Map data) { - - super.initForm(state, data); - - if (getSelectedAssetId(state) != null) { - - text.setValue(state, data.get(SideNoteFormController.TEXT)); - } - - } - - @Override - protected void showLocale(final PageState state) { - - if (getSelectedAssetId(state) != null) { - - final Long selectedAssetId = getSelectedAssetId(state); - final Map data = getController() - .getAssetData(selectedAssetId, - SideNote.class, - getSelectedLocale(state)); - - text.setValue(state, data.get(SideNoteFormController.TEXT)); - } - } - - @Override - protected Class getAssetClass() { - return SideNote.class; - } - - @Override - protected Map collectData(final FormSectionEvent event) - throws FormProcessException { - - final Map data = new HashMap<>(); - final PageState state = event.getPageState(); - - data.put(SideNoteFormController.TEXT, text.getValue(state)); - - return data; - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/SideNoteFormController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/SideNoteFormController.java deleted file mode 100644 index 01ccd05dc..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/SideNoteFormController.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2019 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 com.arsdigita.cms.ui.assets.forms; - -import com.arsdigita.cms.ui.assets.AbstractAssetFormController; -import com.arsdigita.cms.ui.assets.IsControllerForAssetType; - -import org.librecms.assets.SideNote; - -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; - -import javax.enterprise.context.RequestScoped; - -/** - * - * @author Jens Pelzetter - */ -@RequestScoped -@IsControllerForAssetType(SideNote.class) -public class SideNoteFormController - extends AbstractAssetFormController { - - protected static final String TEXT = "text"; - - @Override - protected Map getAssetData(final SideNote asset, - final Locale selectedLocale) { - - final Map data = new HashMap<>(); - - data.put(TEXT, asset.getText().getValue(selectedLocale)); - - return data; - } - - @Override - public void updateAssetProperties(final SideNote asset, - final Locale selectedLocale, - final Map data) { - - if (data.containsKey(TEXT)) { - - final String value = (String) data.get(TEXT); - asset.getText().putValue(selectedLocale, value); - } - - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/VideoForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/VideoForm.java deleted file mode 100644 index 32b320ab6..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/VideoForm.java +++ /dev/null @@ -1,130 +0,0 @@ - /* - * Copyright (C) 2017 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 com.arsdigita.cms.ui.assets.forms; - -import com.arsdigita.bebop.FormProcessException; -import com.arsdigita.bebop.Label; -import com.arsdigita.bebop.PageState; -import com.arsdigita.bebop.event.FormSectionEvent; -import com.arsdigita.bebop.form.TextField; -import com.arsdigita.cms.ui.assets.AssetPane; -import com.arsdigita.cms.ui.assets.AssetSearchWidget; -import com.arsdigita.globalization.GlobalizedMessage; - -import org.librecms.CmsConstants; -import org.librecms.assets.VideoAsset; -import org.librecms.assets.LegalMetadata; - -import java.util.Map; - -/** - * - * @author Yannick Bülter - * @author Jens Pelzetter - * - */ -public class VideoForm extends AbstractBinaryAssetForm { - - private TextField width; - private TextField height; - private AssetSearchWidget assetSearchWidget; - - public VideoForm(final AssetPane assetPane) { - super(assetPane); - } - - @Override - protected void addWidgets() { - - width = new TextField("width-text"); - height = new TextField("height-text"); - assetSearchWidget = new AssetSearchWidget("legal-metadata", - LegalMetadata.class); - - add(new Label(new GlobalizedMessage( - "cms.ui.assets.video.width.label", - CmsConstants.CMS_BUNDLE - ))); - add(width); - - add(new Label(new GlobalizedMessage( - "cms.ui.assets.video.height.label", - CmsConstants.CMS_BUNDLE - ))); - add(height); - - add(new Label(new GlobalizedMessage( - "cms.ui.assets.video.legal_metadata.label", - CmsConstants.CMS_BUNDLE - ))); - add(assetSearchWidget); - } - - @Override - protected void initForm(final PageState state, - final Map data) { - - super.initForm(state, data); - - if (getSelectedAssetId(state) != null) { - - final long widthValue = (long) data.get(VideoFormController.WIDTH); - final long heightValue = (long) data - .get(VideoFormController.HEIGHT); - - width.setValue(state, Long.toString(widthValue)); - height.setValue(state, Long.toString(heightValue)); - - if (data.containsKey(VideoFormController.LEGAL_METADATA_ID)) { - - assetSearchWidget.setValue( - state, - data.containsKey(VideoFormController.LEGAL_METADATA_ID)); - - } - } - } - - @Override - protected Class getAssetClass() { - return VideoAsset.class; - } - - @Override - protected Map collectData(final FormSectionEvent event) - throws FormProcessException { - - final PageState state = event.getPageState(); - - final Map data = super.collectData(event); - - data.put(VideoFormController.WIDTH, width.getValue(state)); - data.put(VideoFormController.HEIGHT, height.getValue(state)); - - if (assetSearchWidget.getValue(state) != null) { - - data.put(VideoFormController.LEGAL_METADATA_ID, - assetSearchWidget.getValue(state)); - - } - - return data; - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/VideoFormController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/VideoFormController.java deleted file mode 100644 index f2d4c6c7e..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/forms/VideoFormController.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2019 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 com.arsdigita.cms.ui.assets.forms; - -import com.arsdigita.cms.ui.assets.IsControllerForAssetType; - -import org.librecms.contentsection.AssetRepository; - -import java.util.Locale; -import java.util.Map; - -import javax.enterprise.context.RequestScoped; -import javax.inject.Inject; - -import org.librecms.assets.LegalMetadata; -import org.librecms.assets.VideoAsset; - -/** - * - * @author Jens Pelzetter - */ -@RequestScoped -@IsControllerForAssetType(VideoAsset.class) -public class VideoFormController - extends AbstractBinaryAssetFormController { - - protected static final String LEGAL_METADATA_ID = "legalMetadataId"; - protected static final String HEIGHT = "height"; - protected static final String WIDTH = "width"; - - @Inject - private AssetRepository assetRepository; - - @Override - protected Map getAssetData(final VideoAsset asset, - final Locale selectedLocale) { - - final Map data = super.getAssetData(asset, - selectedLocale); - - data.put(WIDTH, asset.getWidth()); - data.put(HEIGHT, asset.getHeight()); - - if (asset.getLegalMetadata() != null) { - final long legalMetadataId = asset.getLegalMetadata().getObjectId(); - data.put(LEGAL_METADATA_ID, legalMetadataId); - } - - return data; - } - - @Override - public void updateAssetProperties(final VideoAsset asset, - final Locale selectedLocale, - final Map data) { - - super.updateAssetProperties(asset, selectedLocale, data); - - if (data.containsKey(WIDTH)) { - final long width = (long) data.get(WIDTH); - asset.setWidth(width); - } - - if (data.containsKey(HEIGHT)) { - final long height = (long) data.get(HEIGHT); - asset.setHeight(height); - } - - if (data.containsKey(LEGAL_METADATA_ID)) { - - final LegalMetadata legalMetadata = assetRepository - .findById((long) data.get(LEGAL_METADATA_ID), - LegalMetadata.class) - .orElseThrow(() -> new IllegalArgumentException(String.format( - "No LegalMetadata with ID %d found", - data.get(LEGAL_METADATA_ID) - ))); - asset.setLegalMetadata(legalMetadata); - } - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/searchpage/AssetSearchPage.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/searchpage/AssetSearchPage.java deleted file mode 100644 index 2ce5e16df..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/searchpage/AssetSearchPage.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright (C) 2017 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 com.arsdigita.cms.ui.assets.searchpage; - -import com.arsdigita.bebop.Component; -import com.arsdigita.bebop.Form; -import com.arsdigita.bebop.FormData; -import com.arsdigita.bebop.FormProcessException; -import com.arsdigita.bebop.Label; -import com.arsdigita.bebop.Link; -import com.arsdigita.bebop.PageState; -import com.arsdigita.bebop.SimpleContainer; -import com.arsdigita.bebop.Table; -import com.arsdigita.bebop.Text; -import com.arsdigita.bebop.event.FormInitListener; -import com.arsdigita.bebop.event.FormSectionEvent; -import com.arsdigita.bebop.form.Submit; -import com.arsdigita.bebop.form.TextField; -import com.arsdigita.bebop.parameters.LongParameter; -import com.arsdigita.bebop.parameters.StringParameter; -import com.arsdigita.bebop.table.TableCellRenderer; -import com.arsdigita.bebop.table.TableColumn; -import com.arsdigita.bebop.table.TableColumnModel; -import com.arsdigita.bebop.table.TableModel; -import com.arsdigita.bebop.table.TableModelBuilder; -import com.arsdigita.cms.dispatcher.CMSPage; -import com.arsdigita.globalization.GlobalizedMessage; -import com.arsdigita.toolbox.ui.LayoutPanel; -import com.arsdigita.util.LockableImpl; -import java.util.List; -import org.libreccm.cdi.utils.CdiUtil; - -import org.librecms.CmsConstants; - -/** - * Page contains the widgets for selecting an asset. - * - * @author Jens Pelzetter - */ -public class AssetSearchPage extends CMSPage { - - private static final String QUERY_PARAM = "query"; - private static final String WIDGET_PARAM = "widget"; - private static final String ASSET_TYPE_PARAM = "assettype"; - - private static final int RESULTS_TABLE_COL_TITLE = 0; - private static final int RESULTS_TABLE_COL_PLACE = 1; - private static final int RESULTS_TABLE_COL_TYPE = 2; - - private final LongParameter contentSectionId; - - private TextField query; - - public AssetSearchPage() { - super(new Label(new GlobalizedMessage("cms.ui.assets.search_page.title", - CmsConstants.CMS_BUNDLE)), - new SimpleContainer()); - - addGlobalStateParam(new StringParameter(ASSET_TYPE_PARAM)); - addGlobalStateParam(new StringParameter(WIDGET_PARAM)); - addGlobalStateParam(new StringParameter(QUERY_PARAM)); - - contentSectionId = new LongParameter("content-section-id"); - - final LayoutPanel mainPanel = new LayoutPanel(); - - final Form queryForm = new Form("asset-search-page-query-form"); - queryForm.add(new Label(new GlobalizedMessage( - "cms.ui.assets.search_page.query", - CmsConstants.CMS_BUNDLE))); - query = new TextField("asset-search-page-query-form"); - queryForm.add(query); - final Submit querySubmit = new Submit(new GlobalizedMessage( - "cms.ui.assets.search_page.query.submit")); - queryForm.add(querySubmit); - - queryForm.addInitListener(new FormInitListener() { - - @Override - public void init(final FormSectionEvent event) - throws FormProcessException { - - final PageState state = event.getPageState(); - final FormData data = event.getFormData(); - - final String query = (String) data.get(QUERY_PARAM); - - } - - }); - - mainPanel.setLeft(queryForm); - - final Table resultsTable = new Table(); - resultsTable.setEmptyView( - new Label( - new GlobalizedMessage( - "cms.ui.assets.search_page.none", - CmsConstants.CMS_BUNDLE))); - resultsTable.setClassAttr("dataTable"); - - final TableColumnModel columnModel = resultsTable.getColumnModel(); - columnModel.add(new TableColumn( - RESULTS_TABLE_COL_TITLE, - new GlobalizedMessage( - "cms.ui.assets.search_page.results_table.title", - CmsConstants.CMS_BUNDLE))); - columnModel.add(new TableColumn( - RESULTS_TABLE_COL_PLACE, - new GlobalizedMessage( - "cms.ui.assets.search_page.results_table.place", - CmsConstants.CMS_BUNDLE))); - columnModel.add(new TableColumn( - RESULTS_TABLE_COL_TYPE, - new GlobalizedMessage( - "cms.ui.assets.search_page.results_table.type", - CmsConstants.CMS_BUNDLE))); - resultsTable.setModelBuilder(new ResultsTableModelBuilder()); - - mainPanel.setBody(resultsTable); - - } - - private class ResultsTableModelBuilder - extends LockableImpl - implements TableModelBuilder { - - @Override - public TableModel makeModel(final Table table, final PageState state) { - - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final AssetSearchPageController controller = cdiUtil - .findBean(AssetSearchPageController.class); - - final List rows = controller - .findAssets((String) query.getValue(state)); - return new ResultsTableModel(rows); - } - - } - - private class TitleCellRenderer - extends LockableImpl - implements TableCellRenderer { - - @Override - public Component getComponent(final Table table, - final PageState state, - final Object value, - final boolean isSelected, - final Object key, - final int row, - final int column) { - - if (value == null) { - return new Text("???"); - } - - final Link link = new Link(new Text(value.toString()), ""); - - return link; - - - } - - - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/searchpage/AssetSearchPageController.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/searchpage/AssetSearchPageController.java deleted file mode 100644 index e62e8c967..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/searchpage/AssetSearchPageController.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2017 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 com.arsdigita.cms.ui.assets.searchpage; - -import java.util.List; -import java.util.ResourceBundle; -import java.util.stream.Collectors; -import javax.enterprise.context.RequestScoped; -import javax.inject.Inject; -import javax.transaction.Transactional; -import org.libreccm.configuration.ConfigurationManager; -import org.libreccm.l10n.GlobalizationHelper; -import org.librecms.assets.AssetTypeInfo; -import org.librecms.assets.AssetTypesManager; -import org.librecms.contentsection.Asset; -import org.librecms.contentsection.AssetManager; -import org.librecms.contentsection.AssetRepository; - -/** - * - * @author Jens Pelzetter - */ -@RequestScoped -class AssetSearchPageController { - - @Inject - private AssetRepository assetRepo; - - @Inject - private AssetTypesManager assetTypesManager; - - @Inject - private AssetManager assetManager; - - @Inject - private GlobalizationHelper globalizationHelper; - - @Transactional(Transactional.TxType.REQUIRED) - protected List findAssets(final String title) { - - final List assets = assetRepo.findByTitle(title); - - return assets - .stream() - .map(asset -> createRow(asset)) - .collect(Collectors.toList()); - - } - - private ResultsTableRow createRow(final Asset asset) { - final ResultsTableRow row = new ResultsTableRow(); - - row.setAssetUuid(asset.getUuid()); - row.setTitle(globalizationHelper - .getValueFromLocalizedString(asset.getTitle())); - - final AssetTypeInfo typeInfo = assetTypesManager - .getAssetTypeInfo(asset.getClass()); - final ResourceBundle bundle = ResourceBundle - .getBundle(typeInfo.getLabelBundle(), - globalizationHelper.getNegotiatedLocale()); - row.setType(bundle.getString(typeInfo.getLabelKey())); - - row.setPlace(assetManager.getAssetPath(asset)); - - return row; - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/searchpage/ResultsTableModel.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/searchpage/ResultsTableModel.java deleted file mode 100644 index 85c84d05c..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/searchpage/ResultsTableModel.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2017 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 com.arsdigita.cms.ui.assets.searchpage; - -import com.arsdigita.bebop.table.TableModel; -import java.util.Iterator; -import java.util.List; - -/** - * - * @author Jens Pelzetter - */ -class ResultsTableModel implements TableModel { - - private static final int COL_TITLE = 0; - private static final int COL_PLACE = 1; - private static final int COL_TYPE = 2; - - private final Iterator iterator; - private ResultsTableRow currentRow; - - public ResultsTableModel(final List rows) { - iterator = rows.iterator(); - } - - @Override - public int getColumnCount() { - return 3; - } - - @Override - public boolean nextRow() { - if (iterator.hasNext()) { - currentRow = iterator.next(); - return true; - } else { - return false; - } - } - - @Override - public Object getElementAt(final int columnIndex) { - switch(columnIndex) { - case COL_TITLE: - return currentRow.getTitle(); - case COL_PLACE: - return currentRow.getPlace(); - case COL_TYPE: - return currentRow.getType(); - default: - throw new IllegalArgumentException("Illegal column index."); - } - } - - @Override - public Object getKeyAt(final int columnIndex) { - return currentRow.getAssetUuid(); - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/searchpage/ResultsTableRow.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/searchpage/ResultsTableRow.java deleted file mode 100644 index aaf2292d0..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/assets/searchpage/ResultsTableRow.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2017 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 com.arsdigita.cms.ui.assets.searchpage; - -/** - * - * @author Jens Pelzetter - */ -class ResultsTableRow { - - private String assetUuid; - private String title; - private String place; - private String type; - - public String getAssetUuid() { - return assetUuid; - } - - public void setAssetUuid(final String assetUuid) { - this.assetUuid = assetUuid; - } - - public String getTitle() { - return title; - } - - public void setTitle(final String title) { - this.title = title; - } - - public String getPlace() { - return place; - } - - public void setPlace(final String place) { - this.place = place; - } - - public String getType() { - return type; - } - - public void setType(final String type) { - this.type = type; - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/pagemodel/AbstractContentItemComponentForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/pagemodel/AbstractContentItemComponentForm.java deleted file mode 100644 index b5d5f4bbf..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/pagemodel/AbstractContentItemComponentForm.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2017 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 com.arsdigita.cms.ui.pagemodel; - -import com.arsdigita.bebop.FormData; -import com.arsdigita.bebop.FormProcessException; -import com.arsdigita.bebop.PageState; -import com.arsdigita.bebop.ParameterSingleSelectionModel; -import com.arsdigita.bebop.event.FormSectionEvent; -import com.arsdigita.bebop.form.TextField; -import com.arsdigita.globalization.GlobalizedMessage; -import com.arsdigita.ui.admin.pagemodels.AbstractComponentModelForm; -import com.arsdigita.ui.admin.pagemodels.PageModelsTab; - -import org.librecms.CmsConstants; -import org.librecms.pagemodel.ContentItemComponent; - -/** - * Basic form for all subclasses of {@link ContentItemComponent}. - * - * @param - * - * @author Jens Pelzetter - * - */ -public abstract class AbstractContentItemComponentForm - extends AbstractComponentModelForm { - - /** - * Constant for the name of the {@link #modeField}. - */ - private static final String ITEM_MODE = "itemMode"; - - /** - * Text field for {@link ContentItemComponent#mode}. - */ - private TextField modeField; - - public AbstractContentItemComponentForm( - final String name, - final PageModelsTab pageModelTab, - final ParameterSingleSelectionModel selectedModelId, - final ParameterSingleSelectionModel selectedComponentId) { - - super(name, pageModelTab, selectedModelId, selectedComponentId); - } - - @Override - protected void addWidgets() { - - modeField = new TextField(ITEM_MODE); - modeField.setLabel(new GlobalizedMessage( - "cms.ui.pagemodel.contentitem_component_form.mode.label", - CmsConstants.CMS_BUNDLE)); - add(modeField); - } - - @Override - public void updateComponentModel(final ContentItemComponent componentModel, - final PageState state, - final FormData data) { - - final String modeValue = data.getString(ITEM_MODE); - componentModel.setMode(modeValue); - } - - @Override - public void init(final FormSectionEvent event) - throws FormProcessException { - - super.init(event); - - final PageState state = event.getPageState(); - final ContentItemComponent component = getComponentModel(); - - if (getComponentModel() != null) { - modeField.setValue(state, component.getMode()); - } - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/pagemodel/CategorizedItemComponentForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/pagemodel/CategorizedItemComponentForm.java deleted file mode 100644 index a48e89e32..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/pagemodel/CategorizedItemComponentForm.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2017 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 com.arsdigita.cms.ui.pagemodel; - -import com.arsdigita.bebop.ParameterSingleSelectionModel; -import com.arsdigita.ui.admin.pagemodels.PageModelsTab; - -import org.librecms.pagemodel.CategorizedItemComponent; - -/** - * Form for editing/creating a {@link CategorizedItemComponent}. - * - * @author Jens Pelzetter - */ -public class CategorizedItemComponentForm - extends AbstractContentItemComponentForm { - - public CategorizedItemComponentForm( - final PageModelsTab pageModelTab, - final ParameterSingleSelectionModel selectedModelId, - final ParameterSingleSelectionModel selectedComponentId) { - - super("CategorizedItemComponentForm", - pageModelTab, - selectedModelId, - selectedComponentId); - } - - @Override - public CategorizedItemComponent createComponentModel() { - return new CategorizedItemComponent(); - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/pagemodel/CategoryTreeComponentForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/pagemodel/CategoryTreeComponentForm.java deleted file mode 100644 index de7c52a12..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/pagemodel/CategoryTreeComponentForm.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (C) 2017 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 com.arsdigita.cms.ui.pagemodel; - -import com.arsdigita.bebop.FormData; -import com.arsdigita.bebop.FormProcessException; -import com.arsdigita.bebop.Label; -import com.arsdigita.bebop.PageState; -import com.arsdigita.bebop.ParameterSingleSelectionModel; -import com.arsdigita.bebop.event.FormSectionEvent; -import com.arsdigita.bebop.form.CheckboxGroup; -import com.arsdigita.bebop.form.Option; -import com.arsdigita.globalization.GlobalizedMessage; -import com.arsdigita.ui.admin.pagemodels.AbstractComponentModelForm; -import com.arsdigita.ui.admin.pagemodels.PageModelsTab; - -import org.librecms.CmsConstants; -import org.librecms.pagemodel.CategoryTreeComponent; - -/** - * Form for creating/editing a {@link CategoryTreeComponent}. - * - * @author Jens Pelzetter - */ -public class CategoryTreeComponentForm extends AbstractComponentModelForm { - - private final static String SHOW_FULL_TREE_BOX = "showFullTreeBox"; - private final static String SHOW_FULL_TREE = "showFullTree"; - - private CheckboxGroup showFullTreeCheckbox; - - public CategoryTreeComponentForm( - final PageModelsTab pageModelTab, - final ParameterSingleSelectionModel selectedModelId, - final ParameterSingleSelectionModel selectedComponentId) { - - super("CategoryTreeComponentForm", pageModelTab, selectedModelId, - selectedComponentId); - } - - @Override - protected void addWidgets() { - - showFullTreeCheckbox = new CheckboxGroup(SHOW_FULL_TREE_BOX); - showFullTreeCheckbox.addOption(new Option( - SHOW_FULL_TREE, - new Label(new GlobalizedMessage( - "cms.ui.pagemodel.category_tree_component_form.show_full_tree.label", - CmsConstants.CMS_BUNDLE)))); - add(showFullTreeCheckbox); - } - - @Override - protected CategoryTreeComponent createComponentModel() { - return new CategoryTreeComponent(); - } - - @Override - protected void updateComponentModel( - final CategoryTreeComponent componentModel, - final PageState state, - final FormData data) { - - final Object[] value = (Object[]) data.get(SHOW_FULL_TREE_BOX); - if (value != null - && value.length != 0 - && SHOW_FULL_TREE.equals(value[0])) { - - componentModel.setShowFullTree(true); - } else { - componentModel.setShowFullTree(false); - } - } - - @Override - public void init(final FormSectionEvent event) - throws FormProcessException { - - super.init(event); - - final PageState state = event.getPageState(); - - final CategoryTreeComponent component = getComponentModel(); - - final Object[] showFullTreeValue; - if (component != null && component.isShowFullTree()) { - showFullTreeValue = new Object[]{SHOW_FULL_TREE}; - } else { - showFullTreeValue = new Object[]{}; - } - - showFullTreeCheckbox.setValue(state, showFullTreeValue); - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/pagemodel/FixedContentItemComponentForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/pagemodel/FixedContentItemComponentForm.java deleted file mode 100644 index a806129b7..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/pagemodel/FixedContentItemComponentForm.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (C) 2017 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 com.arsdigita.cms.ui.pagemodel; - -import com.arsdigita.bebop.FormData; -import com.arsdigita.bebop.FormProcessException; -import com.arsdigita.bebop.PageState; -import com.arsdigita.bebop.ParameterSingleSelectionModel; -import com.arsdigita.bebop.event.FormSectionEvent; -import com.arsdigita.cms.ui.assets.ItemSearchWidget; -import com.arsdigita.globalization.GlobalizedMessage; -import com.arsdigita.ui.admin.pagemodels.PageModelsTab; - -import org.libreccm.cdi.utils.CdiUtil; -import org.librecms.CmsConstants; -import org.librecms.contentsection.ContentItem; -import org.librecms.contentsection.ContentItemRepository; -import org.librecms.pagemodel.FixedContentItemComponent; - -/** - * Form for creating/editing a {@link FixedContentItemComponent}. - * - * @author Jens Pelzetter - */ -public class FixedContentItemComponentForm - extends AbstractContentItemComponentForm { - - private final static String ITEM_SEARCH = "itemSearch"; - - private ItemSearchWidget itemSearchWidget; - - public FixedContentItemComponentForm( - final PageModelsTab pageModelTab, - final ParameterSingleSelectionModel selectedModelId, - final ParameterSingleSelectionModel selectedComponentId) { - - super("FixedContentItemComponentForm", - pageModelTab, - selectedModelId, - selectedComponentId); - } - - @Override - protected void addWidgets() { - - itemSearchWidget = new ItemSearchWidget(ITEM_SEARCH); - itemSearchWidget.setLabel(new GlobalizedMessage( - "cms.ui.pagemodel.fixed_contentitem_component_form.itemsearch.label", - CmsConstants.CMS_BUNDLE)); - add(itemSearchWidget); - } - - @Override - protected FixedContentItemComponent createComponentModel() { - return new FixedContentItemComponent(); - } - - @Override - protected void updateComponentModel( - final FixedContentItemComponent component, - final PageState state, - final FormData data) { - - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final ContentItemRepository itemRepo = cdiUtil - .findBean(ContentItemRepository.class); - - final long itemId = (long) itemSearchWidget.getValue(state); - - final ContentItem item = itemRepo - .findById(itemId) - .orElseThrow(() -> new IllegalArgumentException()); - - component.setContentItem(item); - } - - @Override - public void init(final FormSectionEvent event) - throws FormProcessException { - - super.init(event); - - final PageState state = event.getPageState(); - final FixedContentItemComponent component = getComponentModel(); - - if (component != null) { - itemSearchWidget.setValue(state, component.getContentItem()); - } - } - - @Override - public void validate(final FormSectionEvent event) - throws FormProcessException { - - super.validate(event); - - final FormData data = event.getFormData(); - final Object value = data.get(ITEM_SEARCH); - - if (value == null) { - data.addError(new GlobalizedMessage( - "cms.ui.pagemodel.fixed_contentitem_component_form.error.no_item_selected", - CmsConstants.CMS_BUNDLE)); - } - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/pagemodel/GreetingItemComponentForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/pagemodel/GreetingItemComponentForm.java deleted file mode 100644 index 994643ecf..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/pagemodel/GreetingItemComponentForm.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2017 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 com.arsdigita.cms.ui.pagemodel; - -import com.arsdigita.bebop.ParameterSingleSelectionModel; -import com.arsdigita.ui.admin.pagemodels.PageModelsTab; - -import org.librecms.pagemodel.GreetingItemComponent; - -/** - * Form for creating/editing a {@link GreetingItemComponent}. - * - * @author Jens Pelzetter - */ -public class GreetingItemComponentForm - extends AbstractContentItemComponentForm { - - public GreetingItemComponentForm( - final PageModelsTab pageModelTab, - final ParameterSingleSelectionModel selectedModelId, - final ParameterSingleSelectionModel selectedComponentId) { - - super("GreetingItemComponentForm", - pageModelTab, - selectedModelId, - selectedComponentId); - } - - @Override - public GreetingItemComponent createComponentModel() { - return new GreetingItemComponent(); - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/cms/ui/pagemodel/ItemListComponentForm.java b/ccm-cms/src/main/java/com/arsdigita/cms/ui/pagemodel/ItemListComponentForm.java deleted file mode 100644 index 06f89bc05..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/cms/ui/pagemodel/ItemListComponentForm.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright (C) 2017 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 com.arsdigita.cms.ui.pagemodel; - -import com.arsdigita.bebop.FormData; -import com.arsdigita.bebop.FormProcessException; -import com.arsdigita.bebop.Label; -import com.arsdigita.bebop.PageState; -import com.arsdigita.bebop.ParameterSingleSelectionModel; -import com.arsdigita.bebop.event.FormSectionEvent; -import com.arsdigita.bebop.form.CheckboxGroup; -import com.arsdigita.bebop.form.Option; -import com.arsdigita.bebop.form.TextArea; -import com.arsdigita.bebop.form.TextField; -import com.arsdigita.globalization.GlobalizedMessage; -import com.arsdigita.ui.admin.pagemodels.AbstractComponentModelForm; -import com.arsdigita.ui.admin.pagemodels.PageModelsTab; - -import org.libreccm.cdi.utils.CdiUtil; -import org.libreccm.pagemodel.ComponentModelRepository; -import org.librecms.CmsConstants; -import org.librecms.pagemodel.ItemListComponent; - -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -/** - * Form for adding/editing a {@link ItemListComponent}. - * - * @author Jens Pelzetter - */ -public class ItemListComponentForm - extends AbstractComponentModelForm { - - private static final String DESCENDING_BOX = "descendingBox"; - private static final String DESCENDING = "descending"; - private static final String LIMIT_TO_TYPE = "limitToType"; - private static final String PAGE_SIZE = "pageSize"; - private static final String LIST_ORDER = "listOrder"; - - private CheckboxGroup descendingBox; - private TextField limitToTypeField; - private TextField pageSizeField; - private TextArea listOrderArea; - - public ItemListComponentForm( - final PageModelsTab pageModelTab, - final ParameterSingleSelectionModel selectedModelId, - final ParameterSingleSelectionModel selectedComponentId) { - - super("ItemListComponentForm", - pageModelTab, - selectedModelId, - selectedComponentId); - } - - @Override - protected void addWidgets() { - - descendingBox = new CheckboxGroup(DESCENDING_BOX); - descendingBox.addOption(new Option( - DESCENDING, new Label( - new GlobalizedMessage( - "cms.ui.pagemodel.itemlist_component_form.descending.label", - CmsConstants.CMS_BUNDLE)))); - add(descendingBox); - - limitToTypeField = new TextField(LIMIT_TO_TYPE); - limitToTypeField.setLabel(new GlobalizedMessage( - "cms.ui.pagemodel.itemlist_component_form.limit_to_type.label", - CmsConstants.CMS_BUNDLE)); - add(limitToTypeField); - - pageSizeField = new TextField(PAGE_SIZE); - pageSizeField.setLabel(new GlobalizedMessage( - "cms.ui.pagemodel.itemlist_component_form.page_size.label", - CmsConstants.CMS_BUNDLE)); - add(pageSizeField); - - listOrderArea = new TextArea(LIST_ORDER); - listOrderArea.setLabel(new GlobalizedMessage( - "cms.ui.pagemodel.itemlist_component_form.list_order.label", - CmsConstants.CMS_BUNDLE)); - add(listOrderArea); - } - - @Override - protected ItemListComponent createComponentModel() { - return new ItemListComponent(); - } - - @Override - protected void updateComponentModel(final ItemListComponent componentModel, - final PageState state, - final FormData data) { - - final Object[] descendingValues = (Object[]) data.get(DESCENDING_BOX); - final String limitToTypeValue = data.getString(LIMIT_TO_TYPE); - final String pageSizeValue = data.getString(PAGE_SIZE); - final String listOrderValue = data.getString(LIST_ORDER); - - final boolean descendingValue = isDescending(descendingValues); - final List listOrder = Arrays - .stream(listOrderValue.split("\n")) - .collect(Collectors.toList()); - - componentModel.setDescending(descendingValue); - componentModel.setLimitToType(limitToTypeValue); - componentModel.setPageSize(Integer.parseInt(pageSizeValue)); - - componentModel.setListOrder(listOrder); - } - - private boolean isDescending(final Object[] descendingValues) { - return descendingValues != null - && descendingValues.length != 0 - && DESCENDING.equals(descendingValues[0]); - } - - @Override - public void init(final FormSectionEvent event) throws FormProcessException { - - super.init(event); - - final PageState state = event.getPageState(); - - final ItemListComponent component = getComponentModel(); - - if (component == null) { - pageSizeField.setValue(state, "30"); - } else { - final Object[] descendingValue; - if (component.isDescending()) { - descendingValue = new Object[]{DESCENDING}; - } else { - descendingValue = new Object[]{}; - } - descendingBox.setValue(state, descendingValue); - - limitToTypeField.setValue(state, component.getLimitToType()); - - pageSizeField.setValue(state, Integer.toString(component - .getPageSize())); - - listOrderArea.setValue(state, - String.join("\n", component.getListOrder())); - } - } - - @Override - protected ItemListComponent loadSelectedComponent(final long componentId) { - - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final ComponentModelRepository componentModelRepo = cdiUtil - .findBean(ComponentModelRepository.class); - - return componentModelRepo.findById(componentId, - ItemListComponent.class, - new String[]{"listOrder"}) - .orElseThrow(() -> new IllegalArgumentException(String - .format("No ComponentModel with ID %d in the database.", - componentId))); - } - - @Override - public void validate(final FormSectionEvent event) - throws FormProcessException { - - super.validate(event); - - final PageState state = event.getPageState(); - final FormData data = event.getFormData(); - - if (getSaveCancelSection().getSaveButton().isSelected(state)) { - - final String pageSizeValue = data.getString(PAGE_SIZE); - if (pageSizeValue != null - && !pageSizeValue.isEmpty() - && !pageSizeValue.matches("\\d*")) { - - data.addError( - PAGE_SIZE, - new GlobalizedMessage( - "cms.ui.pagemodel.itemlist_component_form.page_size.error.not_a_number", - CmsConstants.CMS_BUNDLE)); - } - } - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/london/terms/ui/CategorySubtree.java b/ccm-cms/src/main/java/com/arsdigita/london/terms/ui/CategorySubtree.java deleted file mode 100644 index 9dd28193e..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/london/terms/ui/CategorySubtree.java +++ /dev/null @@ -1,161 +0,0 @@ -package com.arsdigita.london.terms.ui; - - -import org.apache.commons.lang.StringUtils; -import org.apache.logging.log4j.Logger; - -import com.arsdigita.bebop.Page; -import com.arsdigita.bebop.PageState; -import com.arsdigita.bebop.SimpleComponent; -import com.arsdigita.bebop.parameters.StringParameter; -import com.arsdigita.cms.CMS; - -import org.libreccm.categorization.Category; - -import com.arsdigita.xml.Element; - -import org.apache.logging.log4j.LogManager; -import org.libreccm.categorization.CategoryRepository; -import org.libreccm.cdi.utils.CdiUtil; -import org.libreccm.core.UnexpectedErrorException; -import org.libreccm.l10n.GlobalizationHelper; - -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.StringTokenizer; - -/** - * Generate part of the category tree. Used by Assign Category authoring step. - * - * Class is directly used by JSP page(s), eg. load-cat.jsp (currently in - * ~/packages/content-section/www/admin, source in ccm-ldn-aplaws or - * corresponding integration module). - * - * @author Alan Pevec - * @author Jens Pelzetter - */ -public class CategorySubtree extends SimpleComponent { - - private static final Logger LOGGER = LogManager - .getLogger(CategorySubtree.class); - - private final StringParameter selectedCatsParam = new StringParameter( - "selectedCats"); - private final StringParameter nodeIdParam = new StringParameter("nodeID"); - - @Override - public void register(final Page page) { - super.register(page); - page.addGlobalStateParam(nodeIdParam); - page.addGlobalStateParam(selectedCatsParam); - } - - @Override - public void generateXML(final PageState state, final Element parent) { - - final String node = (String) state.getValue(nodeIdParam); - final Set ids = new HashSet<>(); - - if (((String) state.getValue(selectedCatsParam)) != null) { - StringTokenizer values = new StringTokenizer((String) state - .getValue(selectedCatsParam), ","); - while (values.hasMoreTokens()) { - ids.add(Long.parseLong(values.nextToken().trim())); - } - } - - LOGGER.debug("selected node = {}", node); - final String[] pathElements = StringUtils.split(node, "-"); - - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final CategoryRepository categoryRepo = cdiUtil - .findBean(CategoryRepository.class); - - final Category root = categoryRepo - .findById(Long.parseLong(pathElements[pathElements.length - 1])) - .orElseThrow(() -> new UnexpectedErrorException(String - .format("No Category with ID %s in the database.", - pathElements[pathElements.length - 1]))); - - LOGGER.debug("generating subtree for cat {}...", root.getObjectId()); -// TermWidget.generateSubtree(parent, root, ids); - generateSubtreeXml(parent, root, ids); - } - - private void generateSubtreeXml(final Element parentElem, - final Category root, - final Set ids) { - - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final CategorySubtreeController controller = cdiUtil - .findBean(CategorySubtreeController.class); - - final List subCategories = controller.getSubCategories(root); - - final Element rootCategoryElem = generateCategoryXml(parentElem, - root, - ids); - - controller - .getSubCategories(root) - .stream() - .sorted((category1, category2) -> { - return category1.getName().compareTo(category2.getName()); - }) - .forEach(subCategory -> generateCategoryXml(rootCategoryElem, - root, - ids)); - } - - private Element generateCategoryXml(final Element parentElem, - final Category category, - final Set ids) { - - final CdiUtil cdiUtil = CdiUtil.createCdiUtil(); - final GlobalizationHelper globalizationHelper = cdiUtil - .findBean(GlobalizationHelper.class); - - final Element element = parentElem.newChildElement("cms:category", - CMS.CMS_XML_NS); - element.addAttribute("id", Long.toString(category.getObjectId())); - element.addAttribute("name", category.getName()); - final String desc = globalizationHelper - .getValueFromLocalizedString(category.getDescription()); - element.addAttribute("description", desc); - if (ids.contains(category.getObjectId())) { - element.addAttribute("isSelected", "1"); - } else { - element.addAttribute("isSelected", "0"); - } - if (category.isAbstractCategory()) { - element.addAttribute("isAbstract", "1"); - } else { - element.addAttribute("isAbstract", "0"); - } - if (category.isEnabled()) { - element.addAttribute("isEnabled", "1"); - } else { - element.addAttribute("isEnabled", "0"); - } - - final StringBuilder path = new StringBuilder(parentElem - .getAttribute("fullname")); - if (path.length() > 0) { - path.append(" > "); - } - path.append(category.getName()); - element.addAttribute("fullname", path.toString()); - - final StringBuilder nodeId = new StringBuilder(parentElem - .getAttribute("node-id")); - if (nodeId.length() > 0) { - nodeId.append("-"); - } - nodeId.append(category.getObjectId()); - element.addAttribute("node-id", nodeId.toString()); - - return element; - } - -} diff --git a/ccm-cms/src/main/java/com/arsdigita/london/terms/ui/CategorySubtreeController.java b/ccm-cms/src/main/java/com/arsdigita/london/terms/ui/CategorySubtreeController.java deleted file mode 100644 index 1732b8732..000000000 --- a/ccm-cms/src/main/java/com/arsdigita/london/terms/ui/CategorySubtreeController.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2017 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 com.arsdigita.london.terms.ui; - -import org.libreccm.categorization.Category; -import org.libreccm.categorization.CategoryRepository; - -import java.util.List; - -import javax.enterprise.context.RequestScoped; -import javax.inject.Inject; - -/** - * - * @author Jens Pelzetter - */ -@RequestScoped -class CategorySubtreeController { - - @Inject - private CategoryRepository categoryRepo; - - protected List getSubCategories(final Category ofCategory) { - - final Category category = categoryRepo - .findById(ofCategory.getObjectId()) - .orElseThrow(() -> new IllegalArgumentException(String - .format("No Category with ID %d in the database.", - ofCategory.getObjectId()))); - - return category.getSubCategories(); - } - -} diff --git a/ccm-cms/src/main/java/org/librecms/Cms.java b/ccm-cms/src/main/java/org/librecms/Cms.java index 464e03a96..0d9d2e720 100644 --- a/ccm-cms/src/main/java/org/librecms/Cms.java +++ b/ccm-cms/src/main/java/org/librecms/Cms.java @@ -4,13 +4,7 @@ package org.librecms; import com.arsdigita.cms.ContentCenterAppCreator; -import com.arsdigita.cms.ContentCenterServlet; import com.arsdigita.cms.ContentCenterSetup; -import com.arsdigita.cms.ui.pagemodel.CategorizedItemComponentForm; -import com.arsdigita.cms.ui.pagemodel.CategoryTreeComponentForm; -import com.arsdigita.cms.ui.pagemodel.FixedContentItemComponentForm; -import com.arsdigita.cms.ui.pagemodel.GreetingItemComponentForm; -import com.arsdigita.cms.ui.pagemodel.ItemListComponentForm; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -22,7 +16,6 @@ import org.libreccm.modules.Module; import org.libreccm.modules.RequiredModule; import org.libreccm.modules.ShutdownEvent; import org.libreccm.modules.UnInstallEvent; -import org.libreccm.pagemodel.PageModelComponentModel; import org.libreccm.ui.admin.contentsections.ContentSectionApplicationController; import org.libreccm.web.ApplicationType; import org.libreccm.web.CcmApplication; @@ -43,18 +36,11 @@ import org.librecms.assets.VideoAsset; import org.librecms.contentsection.ContentSection; import org.librecms.contentsection.ContentSectionCreator; import org.librecms.contentsection.ContentSectionSetup; -import org.librecms.contentsection.ui.admin.ApplicationInstanceForm; -import org.librecms.contentsection.ui.admin.SettingsPane; import org.librecms.contenttypes.Article; import org.librecms.contenttypes.ContentTypes; import org.librecms.contenttypes.Event; import org.librecms.contenttypes.MultiPartArticle; import org.librecms.contenttypes.News; -import org.librecms.pagemodel.CategorizedItemComponent; -import org.librecms.pagemodel.CategoryTreeComponent; -import org.librecms.pagemodel.FixedContentItemComponent; -import org.librecms.pagemodel.GreetingItemComponent; -import org.librecms.pagemodel.ItemListComponent; import org.librecms.pages.Pages; import org.librecms.pages.PagesCreator; @@ -71,24 +57,19 @@ import java.util.Properties; name = CmsConstants.CONTENT_CENTER_APP_TYPE, applicationClass = CcmApplication.class, descBundle = CmsConstants.CONTENT_CENTER_DESC_BUNDLE, - creator = ContentCenterAppCreator.class, - servlet = ContentCenterServlet.class + creator = ContentCenterAppCreator.class ), @ApplicationType( name = CmsConstants.CONTENT_SECTION_APP_TYPE, applicationClass = ContentSection.class, - instanceForm = ApplicationInstanceForm.class, - settingsPane = SettingsPane.class, descBundle = CmsConstants.CONTENT_SECTION_DESC_BUNDLE, creator = ContentSectionCreator.class, servletPath = "/templates/servlet/content-section", - applicationController = ContentSectionApplicationController.class + applicationController = ContentSectionApplicationController.class ), @ApplicationType( name = "org.librecms.pages.Pages", applicationClass = Pages.class, - instanceForm = ApplicationInstanceForm.class, - settingsPane = SettingsPane.class, descBundle = CmsConstants.CMS_BUNDLE, titleKey = "pages_application.title", creator = PagesCreator.class, @@ -98,44 +79,6 @@ import java.util.Properties; configurations = { org.librecms.CMSConfig.class, org.librecms.assets.BinaryAssetConfig.class - }, - pageModelComponentModels = { - @PageModelComponentModel( - modelClass = CategorizedItemComponent.class, - editor = CategorizedItemComponentForm.class, - descBundle = CmsConstants.CMS_BUNDLE, - titleKey - = "cms.ui.pagemodel.components.categorized_item_component.title", - descKey - = "cms.ui.pagemodel.components.categorized_item_component.desc"), - @PageModelComponentModel( - modelClass = CategoryTreeComponent.class, - editor = CategoryTreeComponentForm.class, - descBundle = CmsConstants.CMS_BUNDLE, - titleKey - = "cms.ui.pagemodel.components.category_tree_component.title", - descKey = "cms.ui.pagemodel.components.category_tree_component.desc"), - @PageModelComponentModel( - modelClass = FixedContentItemComponent.class, - editor = FixedContentItemComponentForm.class, - descBundle = CmsConstants.CMS_BUNDLE, - titleKey - = "cms.ui.pagemodel.components.fixed_contentitem_component.title", - descKey - = "cms.ui.pagemodel.components.fixed_contentitem_component.desc"), - @PageModelComponentModel( - modelClass = GreetingItemComponent.class, - editor = GreetingItemComponentForm.class, - descBundle = CmsConstants.CMS_BUNDLE, - titleKey - = "cms.ui.pagemodel.components.greetingitem_component.title", - descKey = "cms.ui.pagemodel.components.greetingitem_component.desc"), - @PageModelComponentModel( - modelClass = ItemListComponent.class, - editor = ItemListComponentForm.class, - descBundle = CmsConstants.CMS_BUNDLE, - titleKey = "cms.ui.pagemodel.components.itemlist_component.title", - descKey = "cms.ui.pagemodel.components.itemlist_component.desc") } ) @ContentTypes({Article.class, diff --git a/ccm-cms/src/main/java/org/librecms/assets/AssetType.java b/ccm-cms/src/main/java/org/librecms/assets/AssetType.java index b1bda857f..f8be27c60 100644 --- a/ccm-cms/src/main/java/org/librecms/assets/AssetType.java +++ b/ccm-cms/src/main/java/org/librecms/assets/AssetType.java @@ -43,15 +43,6 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) public @interface AssetType { - /** - * The form for editing and creating an asset of the annotated class. This - * parameter is required. - * - * @return The form for editing and creating assets of the annotated sub - * class {@link org.librecms.contentsection.Asset}. - */ - Class assetForm(); - /** * The key for the localised label of the asset type. If not set the default * value {@code label} is used. @@ -88,7 +79,7 @@ public @interface AssetType { * {@code org.librecms.assets.ImageBundle}. * * @return The fully qualified name of the bundle providing the description - * of the asset type. + * of the asset type. */ String descriptionBundle() default ""; diff --git a/ccm-cms/src/main/java/org/librecms/assets/AssetTypesManager.java b/ccm-cms/src/main/java/org/librecms/assets/AssetTypesManager.java index 97db086a0..063d1f36e 100644 --- a/ccm-cms/src/main/java/org/librecms/assets/AssetTypesManager.java +++ b/ccm-cms/src/main/java/org/librecms/assets/AssetTypesManager.java @@ -132,8 +132,6 @@ public class AssetTypesManager { } else { assetTypeInfo.setDescriptionKey(assetType.descriptionKey()); } - - assetTypeInfo.setAssetForm(assetType.assetForm()); } return assetTypeInfo; diff --git a/ccm-cms/src/main/java/org/librecms/assets/AudioAsset.java b/ccm-cms/src/main/java/org/librecms/assets/AudioAsset.java index 1c37154fb..a6bf98331 100644 --- a/ccm-cms/src/main/java/org/librecms/assets/AudioAsset.java +++ b/ccm-cms/src/main/java/org/librecms/assets/AudioAsset.java @@ -18,7 +18,6 @@ */ package org.librecms.assets; -import com.arsdigita.cms.ui.assets.forms.AudioForm; import org.hibernate.envers.Audited; import org.librecms.ui.contentsections.assets.AudioAssetCreateStep; @@ -44,11 +43,12 @@ import static org.librecms.assets.AssetConstants.ASSETS_BUNDLE; @Entity @Table(name = "AUDIO_ASSETS", schema = DB_SCHEMA) @Audited -@AssetType(assetForm = AudioForm.class, +@AssetType( labelKey = "audio_asset.label", labelBundle = ASSETS_BUNDLE, descriptionKey = "audio_asset.description", - descriptionBundle = ASSETS_BUNDLE) + descriptionBundle = ASSETS_BUNDLE +) @MvcAssetEditKit( createStep = AudioAssetCreateStep.class, editStep = AudioAssetEditStep.class diff --git a/ccm-cms/src/main/java/org/librecms/assets/Bookmark.java b/ccm-cms/src/main/java/org/librecms/assets/Bookmark.java index 4bb76066f..233a54f85 100644 --- a/ccm-cms/src/main/java/org/librecms/assets/Bookmark.java +++ b/ccm-cms/src/main/java/org/librecms/assets/Bookmark.java @@ -18,7 +18,6 @@ */ package org.librecms.assets; -import com.arsdigita.cms.ui.assets.forms.BookmarkForm; import org.librecms.contentsection.Asset; @@ -48,11 +47,12 @@ import static org.librecms.assets.AssetConstants.*; * * @author Jens Pelzetter */ -@AssetType(assetForm = BookmarkForm.class, - labelBundle = ASSETS_BUNDLE, - labelKey = "bookmark.label", - descriptionBundle = ASSETS_BUNDLE, - descriptionKey = "bookmark.description") +@AssetType( + labelBundle = ASSETS_BUNDLE, + labelKey = "bookmark.label", + descriptionBundle = ASSETS_BUNDLE, + descriptionKey = "bookmark.description" +) @Entity @Table(name = "BOOKMARKS", schema = DB_SCHEMA) @Audited diff --git a/ccm-cms/src/main/java/org/librecms/assets/ExternalAudioAsset.java b/ccm-cms/src/main/java/org/librecms/assets/ExternalAudioAsset.java index 3eb7c7de6..bf2c39c48 100644 --- a/ccm-cms/src/main/java/org/librecms/assets/ExternalAudioAsset.java +++ b/ccm-cms/src/main/java/org/librecms/assets/ExternalAudioAsset.java @@ -18,7 +18,6 @@ */ package org.librecms.assets; -import com.arsdigita.cms.ui.assets.forms.ExternalAudioAssetForm; import org.hibernate.envers.Audited; import org.librecms.ui.contentsections.assets.ExternalAudioAssetCreateStep; @@ -47,11 +46,12 @@ import static org.librecms.assets.AssetConstants.*; @Entity @Table(name = "EXTERNAL_AUDIO_ASSETS", schema = DB_SCHEMA) @Audited -@AssetType(assetForm = ExternalAudioAssetForm.class, - labelKey = "external_audio_asset.label", - labelBundle = ASSETS_BUNDLE, - descriptionKey = "external_audio_asset.description", - descriptionBundle = ASSETS_BUNDLE) +@AssetType( + labelKey = "external_audio_asset.label", + labelBundle = ASSETS_BUNDLE, + descriptionKey = "external_audio_asset.description", + descriptionBundle = ASSETS_BUNDLE +) @MvcAssetEditKit( createStep = ExternalAudioAssetCreateStep.class, editStep = ExternalAudioAssetEditStep.class diff --git a/ccm-cms/src/main/java/org/librecms/assets/ExternalVideoAsset.java b/ccm-cms/src/main/java/org/librecms/assets/ExternalVideoAsset.java index 2b9fb529d..223800d88 100644 --- a/ccm-cms/src/main/java/org/librecms/assets/ExternalVideoAsset.java +++ b/ccm-cms/src/main/java/org/librecms/assets/ExternalVideoAsset.java @@ -18,7 +18,6 @@ */ package org.librecms.assets; -import com.arsdigita.cms.ui.assets.forms.ExternalVideoAssetForm; import org.hibernate.envers.Audited; import org.librecms.ui.contentsections.assets.ExternalVideoAssetCreateStep; @@ -38,17 +37,18 @@ import static org.librecms.assets.AssetConstants.*; /** * An asset for external videos, like videos from YouTube. - * + * * @author Jens Pelzetter */ @Entity @Table(name = "EXTERNAL_VIDEO_ASSETS", schema = DB_SCHEMA) @Audited -@AssetType(assetForm = ExternalVideoAssetForm.class, - labelKey = "external_video_asset.label", - labelBundle = ASSETS_BUNDLE, - descriptionKey = "external_video_asset.description", - descriptionBundle = ASSETS_BUNDLE) +@AssetType( + labelKey = "external_video_asset.label", + labelBundle = ASSETS_BUNDLE, + descriptionKey = "external_video_asset.description", + descriptionBundle = ASSETS_BUNDLE +) @MvcAssetEditKit( createStep = ExternalVideoAssetCreateStep.class, editStep = ExternalVideoAssetEditStep.class diff --git a/ccm-cms/src/main/java/org/librecms/assets/FileAsset.java b/ccm-cms/src/main/java/org/librecms/assets/FileAsset.java index c7103c2a0..5e321598b 100644 --- a/ccm-cms/src/main/java/org/librecms/assets/FileAsset.java +++ b/ccm-cms/src/main/java/org/librecms/assets/FileAsset.java @@ -17,7 +17,6 @@ * MA 02110-1301 USA */package org.librecms.assets; -import com.arsdigita.cms.ui.assets.forms.FileAssetForm; import java.io.Serializable; @@ -34,17 +33,18 @@ import static org.librecms.assets.AssetConstants.*; /** * An asset for making files available for download. - * + * * @author Jens Pelzetter */ @Entity @Table(name = "FILES", schema = DB_SCHEMA) @Audited -@AssetType(assetForm = FileAssetForm.class, - labelKey = "fileasset.label", - labelBundle = ASSETS_BUNDLE, - descriptionKey = "fileasset.description", - descriptionBundle = ASSETS_BUNDLE) +@AssetType( + labelKey = "fileasset.label", + labelBundle = ASSETS_BUNDLE, + descriptionKey = "fileasset.description", + descriptionBundle = ASSETS_BUNDLE +) @MvcAssetEditKit( createStep = FileAssetCreateStep.class, editStep = FileAssetEditStep.class @@ -58,7 +58,7 @@ public class FileAsset extends BinaryAsset implements Serializable { return super.hashCode(); } - @Override + @Override public boolean equals(final Object obj) { if (this == obj) { return true; @@ -76,11 +76,10 @@ public class FileAsset extends BinaryAsset implements Serializable { final FileAsset other = (FileAsset) obj; return other.canEqual(this); } - + @Override public boolean canEqual(final Object obj) { return obj instanceof FileAsset; } - - + } diff --git a/ccm-cms/src/main/java/org/librecms/assets/Image.java b/ccm-cms/src/main/java/org/librecms/assets/Image.java index 8e6f05177..ae1d31b01 100644 --- a/ccm-cms/src/main/java/org/librecms/assets/Image.java +++ b/ccm-cms/src/main/java/org/librecms/assets/Image.java @@ -26,8 +26,6 @@ import javax.persistence.Entity; import javax.persistence.JoinColumn; import javax.persistence.Table; -import com.arsdigita.cms.ui.assets.forms.ImageForm; - import org.hibernate.envers.Audited; import org.librecms.ui.contentsections.assets.ImageCreateStep; import org.librecms.ui.contentsections.assets.ImageEditStep; @@ -39,7 +37,7 @@ import static org.librecms.CmsConstants.*; import static org.librecms.assets.AssetConstants.*; /** - * An asset for images (in a format which can be displayed by a browser, like + * An asset for images (in a format which can be displayed by a browser, like * PNG, JPEG or GIF). * * @author Jens Pelzetter @@ -47,11 +45,12 @@ import static org.librecms.assets.AssetConstants.*; @Entity @Table(name = "IMAGES", schema = DB_SCHEMA) @Audited -@AssetType(assetForm = ImageForm.class, - labelKey = "image.label", - labelBundle = ASSETS_BUNDLE, - descriptionKey = "image.description", - descriptionBundle = ASSETS_BUNDLE) +@AssetType( + labelKey = "image.label", + labelBundle = ASSETS_BUNDLE, + descriptionKey = "image.description", + descriptionBundle = ASSETS_BUNDLE +) @MvcAssetEditKit( createStep = ImageCreateStep.class, editStep = ImageEditStep.class diff --git a/ccm-cms/src/main/java/org/librecms/assets/LegalMetadata.java b/ccm-cms/src/main/java/org/librecms/assets/LegalMetadata.java index 33c279a2f..7e4262cfb 100644 --- a/ccm-cms/src/main/java/org/librecms/assets/LegalMetadata.java +++ b/ccm-cms/src/main/java/org/librecms/assets/LegalMetadata.java @@ -18,7 +18,6 @@ */ package org.librecms.assets; -import com.arsdigita.cms.ui.assets.forms.LegalMetadataForm; import org.librecms.contentsection.Asset; import org.hibernate.envers.Audited; @@ -56,7 +55,6 @@ import static org.librecms.assets.AssetConstants.*; @Table(name = "LEGAL_METADATA", schema = DB_SCHEMA) @Audited @AssetType( - assetForm = LegalMetadataForm.class, labelKey = "legal_metadata.label", labelBundle = ASSETS_BUNDLE, descriptionKey = "legal_metadata.description", diff --git a/ccm-cms/src/main/java/org/librecms/assets/Organization.java b/ccm-cms/src/main/java/org/librecms/assets/Organization.java index 442761a42..15d0d0eb3 100644 --- a/ccm-cms/src/main/java/org/librecms/assets/Organization.java +++ b/ccm-cms/src/main/java/org/librecms/assets/Organization.java @@ -18,7 +18,6 @@ */ package org.librecms.assets; -import com.arsdigita.cms.ui.assets.forms.OrganizationForm; import org.hibernate.envers.Audited; import org.librecms.ui.contentsections.assets.MvcAssetEditKit; @@ -39,11 +38,12 @@ import static org.librecms.assets.AssetConstants.*; * * @author Jens Pelzetter */ -@AssetType(assetForm = OrganizationForm.class, - labelBundle = ASSETS_BUNDLE, - labelKey = "organization.label", - descriptionBundle = ASSETS_BUNDLE, - descriptionKey = "organization.description") +@AssetType( + labelBundle = ASSETS_BUNDLE, + labelKey = "organization.label", + descriptionBundle = ASSETS_BUNDLE, + descriptionKey = "organization.description" +) @MvcAssetEditKit( createStep = OrganizationCreateStep.class, editStep = OrganizationEditStep.class diff --git a/ccm-cms/src/main/java/org/librecms/assets/Person.java b/ccm-cms/src/main/java/org/librecms/assets/Person.java index 550c73977..8e9439dc9 100644 --- a/ccm-cms/src/main/java/org/librecms/assets/Person.java +++ b/ccm-cms/src/main/java/org/librecms/assets/Person.java @@ -18,7 +18,6 @@ */ package org.librecms.assets; -import com.arsdigita.cms.ui.assets.forms.PersonForm; import org.hibernate.envers.Audited; import org.librecms.ui.contentsections.assets.MvcAssetEditKit; @@ -50,11 +49,10 @@ import static org.librecms.assets.AssetConstants.*; @Table(name = "PERSONS", schema = DB_SCHEMA) @Audited @AssetType( - assetForm = PersonForm.class, - labelBundle = ASSETS_BUNDLE, - labelKey = "person.label", - descriptionBundle = ASSETS_BUNDLE, - descriptionKey = "person.description" + labelBundle = ASSETS_BUNDLE, + labelKey = "person.label", + descriptionBundle = ASSETS_BUNDLE, + descriptionKey = "person.description" ) @MvcAssetEditKit( createStep = PersonCreateStep.class, diff --git a/ccm-cms/src/main/java/org/librecms/assets/PostalAddress.java b/ccm-cms/src/main/java/org/librecms/assets/PostalAddress.java index 2db3d563b..672ef0ba7 100644 --- a/ccm-cms/src/main/java/org/librecms/assets/PostalAddress.java +++ b/ccm-cms/src/main/java/org/librecms/assets/PostalAddress.java @@ -18,7 +18,6 @@ */ package org.librecms.assets; -import com.arsdigita.cms.ui.assets.forms.PostalAddressForm; import org.hibernate.envers.Audited; import org.librecms.contentsection.Asset; @@ -35,7 +34,6 @@ import javax.persistence.Table; import static org.librecms.CmsConstants.DB_SCHEMA; import static org.librecms.assets.AssetConstants.ASSETS_BUNDLE; - /** * A reuable postal address. * @@ -45,11 +43,10 @@ import static org.librecms.assets.AssetConstants.ASSETS_BUNDLE; @Audited @Table(name = "POSTAL_ADDRESSES", schema = DB_SCHEMA) @AssetType( - assetForm = PostalAddressForm.class, - labelBundle = ASSETS_BUNDLE, - labelKey = "postaladdress.label", - descriptionBundle = ASSETS_BUNDLE, - descriptionKey = "postaladdress.description" + labelBundle = ASSETS_BUNDLE, + labelKey = "postaladdress.label", + descriptionBundle = ASSETS_BUNDLE, + descriptionKey = "postaladdress.description" ) @MvcAssetEditKit( createStep = PostalAddressCreateStep.class, diff --git a/ccm-cms/src/main/java/org/librecms/assets/RelatedLink.java b/ccm-cms/src/main/java/org/librecms/assets/RelatedLink.java index aed4a2d70..3dfed2f9e 100644 --- a/ccm-cms/src/main/java/org/librecms/assets/RelatedLink.java +++ b/ccm-cms/src/main/java/org/librecms/assets/RelatedLink.java @@ -18,7 +18,6 @@ */ package org.librecms.assets; -import com.arsdigita.cms.ui.assets.forms.RelatedLinkForm; import org.librecms.contentsection.Asset; import org.hibernate.envers.Audited; @@ -46,7 +45,6 @@ import static org.librecms.assets.AssetConstants.ASSETS_BUNDLE; @Table(name = "RELATED_LINKS", schema = DB_SCHEMA) @Audited @AssetType( - assetForm = RelatedLinkForm.class, labelBundle = ASSETS_BUNDLE, labelKey = "relatedlink.label", descriptionBundle = ASSETS_BUNDLE, diff --git a/ccm-cms/src/main/java/org/librecms/assets/SideNote.java b/ccm-cms/src/main/java/org/librecms/assets/SideNote.java index 22d45f5cf..dae2d4a7c 100644 --- a/ccm-cms/src/main/java/org/librecms/assets/SideNote.java +++ b/ccm-cms/src/main/java/org/librecms/assets/SideNote.java @@ -18,7 +18,6 @@ */ package org.librecms.assets; -import com.arsdigita.cms.ui.assets.forms.SideNoteForm; import org.librecms.contentsection.Asset; import org.hibernate.envers.Audited; @@ -49,7 +48,6 @@ import static org.librecms.assets.AssetConstants.*; @Table(name = "SIDE_NOTES", schema = DB_SCHEMA) @Audited @AssetType( - assetForm = SideNoteForm.class, labelBundle = ASSETS_BUNDLE, labelKey = "sidenote.label", descriptionBundle = ASSETS_BUNDLE, diff --git a/ccm-cms/src/main/java/org/librecms/assets/VideoAsset.java b/ccm-cms/src/main/java/org/librecms/assets/VideoAsset.java index ffc921ee3..680b2867b 100644 --- a/ccm-cms/src/main/java/org/librecms/assets/VideoAsset.java +++ b/ccm-cms/src/main/java/org/librecms/assets/VideoAsset.java @@ -18,7 +18,6 @@ */ package org.librecms.assets; -import com.arsdigita.cms.ui.assets.forms.AudioForm; import org.hibernate.envers.Audited; import org.librecms.ui.contentsections.assets.MvcAssetEditKit; @@ -45,11 +44,12 @@ import static org.librecms.assets.AssetConstants.ASSETS_BUNDLE; @Entity @Table(name = "VIDEO_ASSETS", schema = DB_SCHEMA) @Audited -@AssetType(assetForm = AudioForm.class, +@AssetType( labelKey = "video_asset.label", labelBundle = ASSETS_BUNDLE, descriptionKey = "video_asset.description", - descriptionBundle = ASSETS_BUNDLE) + descriptionBundle = ASSETS_BUNDLE +) @MvcAssetEditKit( createStep = VideoAssetCreateStep.class, editStep = VideoAssetEditStep.class diff --git a/ccm-core/src/main/java/org/libreccm/modules/Module.java b/ccm-core/src/main/java/org/libreccm/modules/Module.java index 7fabb9a69..26ba25f37 100644 --- a/ccm-core/src/main/java/org/libreccm/modules/Module.java +++ b/ccm-core/src/main/java/org/libreccm/modules/Module.java @@ -99,6 +99,7 @@ public @interface Module { * @return An array containing all {@link ComponentModel}s provided by the * annotated module. */ + @Deprecated PageModelComponentModel[] pageModelComponentModels() default {}; } diff --git a/ccm-core/src/main/java/org/libreccm/web/ApplicationType.java b/ccm-core/src/main/java/org/libreccm/web/ApplicationType.java index a66cd3a61..81498bf77 100644 --- a/ccm-core/src/main/java/org/libreccm/web/ApplicationType.java +++ b/ccm-core/src/main/java/org/libreccm/web/ApplicationType.java @@ -118,8 +118,10 @@ public @interface ApplicationType { @SuppressWarnings("rawtypes") // Can't specify type here, otherwise problems in using classes. Class creator(); + @Deprecated Class instanceForm() default DefaultApplicationInstanceForm.class; + @Deprecated Class settingsPane() default DefaultApplicationSettingsPane.class; Class applicationController() default DefaultApplicationController.class;