001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portlet.documentlibrary.action;
022:
023: import com.liferay.portal.kernel.portlet.ConfigurationAction;
024: import com.liferay.portal.kernel.util.Constants;
025: import com.liferay.portal.kernel.util.ParamUtil;
026: import com.liferay.portlet.PortletPreferencesFactoryUtil;
027: import com.liferay.portlet.documentlibrary.NoSuchFolderException;
028: import com.liferay.portlet.documentlibrary.model.impl.DLFolderImpl;
029: import com.liferay.portlet.documentlibrary.service.DLFolderLocalServiceUtil;
030: import com.liferay.util.servlet.SessionErrors;
031: import com.liferay.util.servlet.SessionMessages;
032:
033: import javax.portlet.ActionRequest;
034: import javax.portlet.ActionResponse;
035: import javax.portlet.PortletConfig;
036: import javax.portlet.PortletPreferences;
037: import javax.portlet.RenderRequest;
038: import javax.portlet.RenderResponse;
039:
040: /**
041: * <a href="ConfigurationActionImpl.java.html"><b><i>View Source</i></b></a>
042: *
043: * @author Jorge Ferrer
044: *
045: */
046: public class ConfigurationActionImpl implements ConfigurationAction {
047:
048: public void processAction(PortletConfig config, ActionRequest req,
049: ActionResponse res) throws Exception {
050:
051: String cmd = ParamUtil.getString(req, Constants.CMD);
052:
053: if (!cmd.equals(Constants.UPDATE)) {
054: return;
055: }
056:
057: String folderDisplayStyle = ParamUtil.getString(req,
058: "folderDisplayStyle");
059:
060: long rootFolderId = ParamUtil.getLong(req, "rootFolderId");
061:
062: boolean showBreadcrumbs = ParamUtil.getBoolean(req,
063: "showBreadcrumbs");
064: boolean showFoldersSearch = ParamUtil.getBoolean(req,
065: "showFoldersSearch");
066: boolean showSubfolders = ParamUtil.getBoolean(req,
067: "showSubfolders");
068: int foldersPerPage = ParamUtil
069: .getInteger(req, "foldersPerPage");
070: String folderColumns = ParamUtil
071: .getString(req, "folderColumns");
072:
073: boolean showFileEntriesSearch = ParamUtil.getBoolean(req,
074: "showFileEntriesSearch");
075: int fileEntriesPerPage = ParamUtil.getInteger(req,
076: "fileEntriesPerPage");
077: String fileEntryColumns = ParamUtil.getString(req,
078: "fileEntryColumns");
079:
080: String portletResource = ParamUtil.getString(req,
081: "portletResource");
082:
083: PortletPreferences prefs = PortletPreferencesFactoryUtil
084: .getPortletSetup(req, portletResource, true, true);
085:
086: if (rootFolderId != DLFolderImpl.DEFAULT_PARENT_FOLDER_ID) {
087: try {
088: DLFolderLocalServiceUtil.getFolder(rootFolderId);
089: } catch (NoSuchFolderException e) {
090: SessionErrors.add(req, "rootFolderIdInvalid");
091: }
092: }
093:
094: prefs.setValue("folderDisplayStyle", folderDisplayStyle);
095:
096: prefs.setValue("rootFolderId", String.valueOf(rootFolderId));
097:
098: prefs.setValue("showBreadcrumbs", String
099: .valueOf(showBreadcrumbs));
100: prefs.setValue("showFoldersSearch", String
101: .valueOf(showFoldersSearch));
102: prefs
103: .setValue("showSubfolders", String
104: .valueOf(showSubfolders));
105: prefs
106: .setValue("foldersPerPage", String
107: .valueOf(foldersPerPage));
108: prefs.setValue("folderColumns", folderColumns);
109:
110: prefs.setValue("showFileEntriesSearch", String
111: .valueOf(showFileEntriesSearch));
112: prefs.setValue("fileEntriesPerPage", String
113: .valueOf(fileEntriesPerPage));
114: prefs.setValue("fileEntryColumns", fileEntryColumns);
115:
116: if (SessionErrors.isEmpty(req)) {
117: prefs.store();
118:
119: SessionMessages.add(req, config.getPortletName()
120: + ".doConfigure");
121: }
122: }
123:
124: public String render(PortletConfig config, RenderRequest req,
125: RenderResponse res) throws Exception {
126:
127: return "/html/portlet/document_library/configuration.jsp";
128: }
129:
130: }
|