file_name
stringlengths
6
86
file_path
stringlengths
45
249
content
stringlengths
47
6.26M
file_size
int64
47
6.26M
language
stringclasses
1 value
extension
stringclasses
1 value
repo_name
stringclasses
767 values
repo_stars
int64
8
14.4k
repo_forks
int64
0
1.17k
repo_open_issues
int64
0
788
repo_created_at
stringclasses
767 values
repo_pushed_at
stringclasses
767 values
UIPresentationEventListener.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/presentation/action/UIPresentationEventListener.java
/*************************************************************************** * Copyright (C) 2003-2009 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. * **************************************************************************/ package org.exoplatform.ecm.webui.presentation.action; import java.util.HashMap; import java.util.Map; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.webui.core.UIComponent; import org.exoplatform.webui.event.Event; import org.exoplatform.webui.event.EventListener; /** * Created by The eXo Platform SARL * Author : Hoang Van Hung * hunghvit@gmail.com * Sep 17, 2009 */ public abstract class UIPresentationEventListener<T extends UIComponent> extends EventListener<T> { /** * Prepare variable to execute action * @param event * @return */ protected Map<String, Object> createVariables(Event<T> event) { Map<String, Object> variables = new HashMap<String, Object>(); String repository = event.getRequestContext().getRequestParameter(Utils.REPOSITORY); String wsname = event.getRequestContext().getRequestParameter(Utils.WORKSPACE_PARAM); String nodepath = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID); variables.put(Utils.REPOSITORY, repository); variables.put(Utils.WORKSPACE_PARAM, wsname); variables.put(UIComponent.OBJECTID, nodepath); variables.put(UIComponent.UICOMPONENT, event.getSource()); variables.put(Utils.REQUESTCONTEXT, event.getRequestContext()); return variables; } /** * {@inheritDoc} */ public void execute(Event<T> event) throws Exception { executeAction(createVariables(event)); } /** * Run action for each event * @param variables * @throws Exception */ protected abstract void executeAction(Map<String, Object> variables) throws Exception; }
2,544
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
RemoveAttachmentComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/presentation/removeattach/RemoveAttachmentComponent.java
/*************************************************************************** * Copyright (C) 2003-2009 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. * **************************************************************************/ package org.exoplatform.ecm.webui.presentation.removeattach; import java.util.Map; import javax.jcr.Node; import javax.jcr.Session; import org.exoplatform.services.log.Log; import org.exoplatform.ecm.webui.presentation.AbstractActionComponent; import org.exoplatform.ecm.webui.presentation.action.UIPresentationEventListener; import org.exoplatform.ecm.webui.utils.JCRExceptionManager; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.services.cms.link.NodeFinder; import org.exoplatform.services.log.ExoLogger; import org.exoplatform.webui.application.WebuiRequestContext; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.config.annotation.EventConfig; import org.exoplatform.webui.core.UIApplication; /** * Created by The eXo Platform SARL * Author : Hoang Van Hung * hunghvit@gmail.com * Sep 16, 2009 */ @ComponentConfig(events = { @EventConfig(listeners = RemoveAttachmentComponent.RemoveAttachActionListener.class, confirm = "RemoveAttachmentComponent.msg.confirm-deleteattachment") } ) public class RemoveAttachmentComponent extends AbstractActionComponent { private static final Log LOG = ExoLogger.getLogger(RemoveAttachmentComponent.class.getName()); /** * Overide method UIComponent.loadConfirmMesssage() to get resource bundle in jar file */ protected String loadConfirmMesssage(org.exoplatform.webui.config.Event event, WebuiRequestContext context, String beanId) { String confirmKey = event.getConfirm(); if (confirmKey.length() < 1) return confirmKey; try { String confirm = Utils.getResourceBundle(Utils.LOCALE_WEBUI_DMS, confirmKey, getClass().getClassLoader()); return confirm.replaceAll("\\{0\\}", beanId); } catch (Exception e) { return confirmKey; } } public static void doDelete(Map<String, Object> variables) throws Exception { AbstractActionComponent uicomponent = (AbstractActionComponent)variables.get(UICOMPONENT); UIApplication uiApp = uicomponent.getAncestorOfType(UIApplication.class); NodeFinder nodefinder = uicomponent.getApplicationComponent(NodeFinder.class); String wsname = String.valueOf(variables.get(Utils.WORKSPACE_PARAM)); String nodepath = String.valueOf(variables.get(OBJECTID)); WebuiRequestContext requestcontext = (WebuiRequestContext)variables.get(Utils.REQUESTCONTEXT); try { Node node = (Node) nodefinder.getItem(wsname, nodepath); // begin of lampt's modification. Session session = node.getSession(); Node parentNode = null; // In case of node path begin with slash sign. if (nodepath.startsWith("/")) { if (node.hasProperty(Utils.JCR_DATA)) { node.setProperty(Utils.JCR_DATA, Utils.EMPTY); node.save(); } else { parentNode = node.getParent(); node.remove(); parentNode.save(); } } else { if (node.hasProperty(nodepath)) { node.setProperty(nodepath, Utils.EMPTY); node.save(); } } // end of modification. session.save(); uicomponent.updateAjax(requestcontext); return; } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error("an unexpected error occurs while removing the node", e); } JCRExceptionManager.process(uiApp, e); return; } } public static class RemoveAttachActionListener extends UIPresentationEventListener<RemoveAttachmentComponent> { @Override protected void executeAction(Map<String, Object> variables) throws Exception { RemoveAttachmentComponent.doDelete(variables); } } }
4,906
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
RemoveCommentComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/presentation/removecomment/RemoveCommentComponent.java
/*************************************************************************** * Copyright (C) 2003-2009 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. * **************************************************************************/ package org.exoplatform.ecm.webui.presentation.removecomment; import java.util.Map; import javax.jcr.Node; import javax.jcr.version.VersionException; import org.exoplatform.ecm.utils.text.Text; import org.exoplatform.ecm.webui.presentation.AbstractActionComponent; import org.exoplatform.ecm.webui.presentation.action.UIPresentationEventListener; import org.exoplatform.ecm.webui.utils.JCRExceptionManager; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.services.cms.comments.CommentsService; import org.exoplatform.services.cms.link.NodeFinder; import org.exoplatform.services.log.ExoLogger; import org.exoplatform.services.log.Log; import org.exoplatform.web.application.ApplicationMessage; import org.exoplatform.webui.application.WebuiRequestContext; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.config.annotation.EventConfig; import org.exoplatform.webui.core.UIApplication; /** * Created by The eXo Platform SARL * Author : Hoang Van Hung * hunghvit@gmail.com * Sep 17, 2009 */ @ComponentConfig(events = { @EventConfig(listeners = RemoveCommentComponent.RemoveCommentActionListener.class, confirm = "RemoveCommentComponent.msg.confirm-deletecomment") }) public class RemoveCommentComponent extends AbstractActionComponent { private static final Log LOG = ExoLogger.getLogger(RemoveCommentComponent.class.getName()); /** * Overide method UIComponent.loadConfirmMesssage() to get resource bundle in jar file */ protected String loadConfirmMesssage(org.exoplatform.webui.config.Event event, WebuiRequestContext context, String beanId) { String confirmKey = event.getConfirm(); if(confirmKey.length() < 1) return confirmKey; String confirm = Utils.getResourceBundle(Utils.LOCALE_WEBUI_DMS, confirmKey, getClass().getClassLoader()); return confirm.replaceAll("\\{0\\}", beanId); } public static void doDelete(Map<String, Object> variables) throws Exception { AbstractActionComponent uicomponent = (AbstractActionComponent)variables.get(UICOMPONENT); UIApplication uiApp = uicomponent.getAncestorOfType(UIApplication.class); NodeFinder nodefinder = uicomponent.getApplicationComponent(NodeFinder.class); String wsname = String.valueOf(variables.get(Utils.WORKSPACE_PARAM)); String nodepath = String.valueOf(variables.get(OBJECTID)); WebuiRequestContext requestcontext = (WebuiRequestContext)variables.get(Utils.REQUESTCONTEXT); try { Node commentNode = (Node) nodefinder.getItem(wsname, Text.escapeIllegalJcrChars(nodepath)); CommentsService commentService = uicomponent.getApplicationComponent(CommentsService.class); commentService.deleteComment(commentNode); uicomponent.updateAjax(requestcontext); } catch(VersionException e) { if (LOG.isErrorEnabled()) { LOG.error("Version exception"); } Object[] args = { nodepath } ; uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.can-not-delete-version", args, ApplicationMessage.WARNING)); } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error("an unexpected error occurs while removing the node", e); } JCRExceptionManager.process(uiApp, e); } } public static class RemoveCommentActionListener extends UIPresentationEventListener<RemoveCommentComponent> { protected void executeAction(Map<String, Object> variables) throws Exception { RemoveCommentComponent.doDelete(variables); } } }
4,589
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIAnyPermission.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/selector/UIAnyPermission.java
/* * Copyright (C) 2003-2008 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.selector; import org.exoplatform.ecm.webui.form.UIFormInputSetWithAction; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.config.annotation.EventConfig; import org.exoplatform.webui.core.UIComponent; import org.exoplatform.webui.core.lifecycle.UIFormLifecycle; import org.exoplatform.webui.event.Event; import org.exoplatform.webui.event.EventListener; import org.exoplatform.webui.form.UIForm; import org.exoplatform.webui.form.UIFormInputInfo; /** * Created by The eXo Platform SAS * Author : Ly Dinh Quang * quang.ly@exoplatform.com * xxx5669@yahoo.com * Oct 9, 2008 */ @ComponentConfig( lifecycle = UIFormLifecycle.class, template = "classpath:groovy/ecm/webui/form/UIFormWithoutAction.gtmpl", events = { @EventConfig(listeners = UIAnyPermission.AddAnyPermissionActionListener.class) } ) public class UIAnyPermission extends UIForm { static private String ANYPERMISSION = "anyPermission"; public UIAnyPermission() throws Exception { UIFormInputSetWithAction rootNodeInfo = new UIFormInputSetWithAction(ANYPERMISSION); rootNodeInfo.addUIFormInput(new UIFormInputInfo("any", "any", null)); String[] actionInfor = {"AddAnyPermission"}; rootNodeInfo.setActionInfo("any", actionInfor); rootNodeInfo.showActionInfo(true); addUIComponentInput(rootNodeInfo); } static public class AddAnyPermissionActionListener extends EventListener<UIAnyPermission> { public void execute(Event<UIAnyPermission> event) throws Exception { UIAnyPermission uiAnyPermission = event.getSource(); uiAnyPermission.<UIComponent>getParent().broadcast(event, event.getExecutionPhase()) ; } } }
2,514
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UISelectable.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/selector/UISelectable.java
/* * Copyright (C) 2003-2008 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.selector; /* * Created by The eXo Platform SAS * @author : Hoa.Pham * hoa.pham@exoplatform.com * Jun 23, 2008 */ public interface UISelectable { /** * Do select. * * @param selectField the select field * @param value the value * @throws Exception the exception */ public void doSelect(String selectField, Object value) throws Exception; }
1,152
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIGroupMemberSelector.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/selector/UIGroupMemberSelector.java
/*************************************************************************** * Copyright 2001-2008 The eXo Platform SARL All rights reserved. * * Please look at license.txt in info directory for more license detail. * **************************************************************************/ package org.exoplatform.ecm.webui.selector; import java.util.*; import java.util.stream.Collectors; import org.exoplatform.portal.config.UserACL; import org.exoplatform.services.organization.Group; import org.exoplatform.services.organization.MembershipType; import org.exoplatform.services.organization.OrganizationService; import org.exoplatform.services.security.ConversationState; import org.exoplatform.services.security.Identity; import org.exoplatform.services.security.IdentityConstants; import org.exoplatform.services.security.MembershipEntry; import org.exoplatform.services.wcm.utils.WCMCoreUtils; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.config.annotation.ComponentConfigs; import org.exoplatform.webui.config.annotation.EventConfig; import org.exoplatform.webui.core.UIBreadcumbs; import org.exoplatform.webui.core.UIBreadcumbs.LocalPath; import org.exoplatform.webui.core.UIComponent; import org.exoplatform.webui.core.UIContainer; import org.exoplatform.webui.core.UIPopupWindow; import org.exoplatform.webui.core.UITree; import org.exoplatform.webui.event.Event; import org.exoplatform.webui.event.EventListener; import org.exoplatform.webui.form.UIForm; /** * Created by The eXo Platform SARL * Author : Hoang Van Hung * hunghvit@gmail.com * Dec 10, 2008 */ @ComponentConfigs( { @ComponentConfig( template = "classpath:groovy/ecm/webui/UIMemberSelector.gtmpl", events = { @EventConfig(listeners = UIGroupMemberSelector.ChangeNodeActionListener.class), @EventConfig(listeners = UIGroupMemberSelector.SelectMembershipActionListener.class), @EventConfig(listeners = UIGroupMemberSelector.SelectPathActionListener.class), @EventConfig(listeners = UIGroupMemberSelector.AddAnyPermissionActionListener.class) }), @ComponentConfig( type = UITree.class, id = "UITreeMembershipSelector", template = "system:/groovy/webui/core/UITree.gtmpl", events = @EventConfig(listeners = UITree.ChangeNodeActionListener.class)), @ComponentConfig( type = UIBreadcumbs.class, id = "BreadcumbMembershipSelector", template = "system:/groovy/webui/core/UIBreadcumbs.gtmpl", events = @EventConfig(listeners = UIBreadcumbs.SelectPathActionListener.class)) } ) public class UIGroupMemberSelector extends UIContainer implements ComponentSelector { /** The Constant defaultValue. */ final static public String defaultValue = "/admin"; private OrganizationService organizationService; private UserACL userACL; /** The ui component. */ private UIComponent uiComponent; /** The return field name. */ private String returnFieldName = null; /** The is selected membership. */ private boolean isSelectedMembership = true; /** The is selected user. */ private boolean isSelectedUser; /** The is use popup. */ private boolean isUsePopup = true; /** Show/hide Add AnyPermission form */ private boolean isShowAnyPermission = true; private Group selectGroup_; private List<String> listMemberhip; public UIGroupMemberSelector() throws Exception { organizationService = getApplicationComponent(OrganizationService.class); userACL = getApplicationComponent(UserACL.class); addChild(UIAnyPermission.class, null, "UIQueriesAnyPermission"); UIBreadcumbs uiBreadcumbs = addChild(UIBreadcumbs.class, "BreadcumbMembershipSelector", "BreadcumbMembershipSelector") ; UITree tree = addChild(UITree.class, "UITreeMembershipSelector", "TreeMembershipSelector"); OrganizationService service = WCMCoreUtils.getService(OrganizationService.class); Collection<?> collection = service.getMembershipTypeHandler().findMembershipTypes(); listMemberhip = new ArrayList<>(5); for(Object obj : collection){ listMemberhip.add(((MembershipType)obj).getName()); } if (!listMemberhip.contains("*")) listMemberhip.add("*"); Collections.sort(listMemberhip); tree.setSibbling(getChildrenGroups(null)); tree.setIcon("GroupAdminIcon"); tree.setSelectedIcon("PortalIcon"); tree.setBeanIdField("id"); tree.setBeanLabelField("label"); uiBreadcumbs.setBreadcumbsStyle("UIExplorerHistoryPath") ; } public Group getCurrentGroup() { return selectGroup_ ; } public List<String> getListMemberhip() { return listMemberhip; } public void changeGroup(String groupId) throws Exception { OrganizationService service = WCMCoreUtils.getService(OrganizationService.class); UIBreadcumbs uiBreadcumb = getChild(UIBreadcumbs.class); uiBreadcumb.setPath(getPath(null, groupId)) ; UITree tree = getChild(UITree.class); if(groupId == null) { tree.setSibbling(getChildrenGroups(null)); tree.setChildren(null); tree.setSelected(null); selectGroup_ = null; return; } selectGroup_ = service.getGroupHandler().findGroupById(groupId); String parentGroupId = null; if(selectGroup_ != null) parentGroupId = selectGroup_.getParentId(); Group parentGroup = null ; if(parentGroupId != null) parentGroup = service.getGroupHandler().findGroupById(parentGroupId); tree.setSibbling(getChildrenGroups(parentGroup)); tree.setChildren(getChildrenGroups(selectGroup_)); tree.setSelected(selectGroup_); tree.setParentSelected(parentGroup); } protected List<Group> getChildrenGroups(Group parentGroup) throws Exception { ConversationState conversationState = ConversationState.getCurrent(); if(conversationState != null && conversationState.getIdentity() != null) { return organizationService.getGroupHandler().findGroups(parentGroup) .stream() .filter(group -> userACL.hasPermission(conversationState.getIdentity(), group, "document_permissions")) .collect(Collectors.toList()); } else { return Collections.EMPTY_LIST; } } private List<LocalPath> getPath(List<LocalPath> list, String id) throws Exception { if(list == null) list = new ArrayList<>(5); if(id == null) return list; OrganizationService service = WCMCoreUtils.getService(OrganizationService.class); Group group = service.getGroupHandler().findGroupById(id); if(group == null) return list; list.add(0, new LocalPath(group.getId(), group.getLabel())); getPath(list, group.getParentId()); return list ; } @SuppressWarnings("unchecked") public List<String> getListGroup() throws Exception { OrganizationService service = WCMCoreUtils.getService(OrganizationService.class); List<String> listGroup = new ArrayList<>(); if(getCurrentGroup() == null) return null; Collection<Group> groups = service.getGroupHandler().findGroups(getCurrentGroup()); if(groups.size() > 0) { for (Object child : groups) { Group childGroup = (Group)child; listGroup.add(childGroup.getId()) ; } } return listGroup; } /** * Gets the return component. * * @return the return component */ public UIComponent getSourceComponent() { return uiComponent; } /** * Gets the return field. * * @return the return field */ public String getReturnField() { return returnFieldName; } public void setIsUsePopup(boolean isUsePopup) { this.isUsePopup = isUsePopup; } public boolean isUsePopup() { return isUsePopup; } /** * Sets the selected user. * * @param bool the new selected user */ public void setSelectedUser(boolean bool) { isSelectedUser = bool; } /** * Checks if is selected user. * * @return true, if is selected user */ public boolean isSelectedUser() { return isSelectedUser; } /** * Sets the selected membership. * * @param bool the new selected membership */ public void setSelectedMembership(boolean bool) { isSelectedMembership = bool; } /** * Checks if is selected membership. * * @return true, if is selected membership */ public boolean isSelectedMembership() { return isSelectedMembership; } public void setSourceComponent(UIComponent uicomponent, String[] initParams) { uiComponent = uicomponent; if (initParams == null || initParams.length == 0) return; for (int i = 0; i < initParams.length; i++) { if (initParams[i].indexOf("returnField") > -1) { String[] array = initParams[i].split("="); returnFieldName = array[1]; break; } returnFieldName = initParams[0]; } } public String event(String name, String beanId) throws Exception { UIForm uiForm = getAncestorOfType(UIForm.class) ; if(uiForm != null) return uiForm.event(name, getId(), beanId); return super.event(name, beanId); } static public class ChangeNodeActionListener extends EventListener<UITree> { public void execute(Event<UITree> event) throws Exception { UIGroupMemberSelector uiGroupMemberSelector = event.getSource().getParent(); String groupId = event.getRequestContext().getRequestParameter(OBJECTID); uiGroupMemberSelector.changeGroup(groupId); event.getRequestContext().addUIComponentToUpdateByAjax(uiGroupMemberSelector); } } static public class SelectMembershipActionListener extends EventListener<UIGroupMemberSelector> { public void execute(Event<UIGroupMemberSelector> event) throws Exception { UIGroupMemberSelector uiGroupMemberSelector = event.getSource(); if (uiGroupMemberSelector.getCurrentGroup() == null) return; String groupId = uiGroupMemberSelector.getCurrentGroup().getId(); String permission = event.getRequestContext().getRequestParameter(OBJECTID); String value = ""; if(uiGroupMemberSelector.isSelectedUser()) { value = permission; } else { value = permission + ":" + groupId; } String returnField = uiGroupMemberSelector.getReturnField(); ((UISelectable) uiGroupMemberSelector.getSourceComponent()).doSelect(returnField, value); if (uiGroupMemberSelector.isUsePopup) { UIPopupWindow uiPopup = uiGroupMemberSelector.getParent(); uiPopup.setShow(false); UIComponent uicomp = uiGroupMemberSelector.getSourceComponent().getParent(); event.getRequestContext().addUIComponentToUpdateByAjax(uicomp); if (!uiPopup.getId().equals("PopupComponent")) event.getRequestContext().addUIComponentToUpdateByAjax(uiPopup); } else { event.getRequestContext().addUIComponentToUpdateByAjax( uiGroupMemberSelector.getSourceComponent()); } } } /** * The listener interface for receiving selectPathAction events. The class * that is interested in processing a selectPathAction event implements this * interface, and the object created with that class is registered with a * component using the component's * <code>addSelectPathActionListener</code> method. When * the selectPathAction event occurs, that object's appropriate * method is invoked. */ static public class SelectPathActionListener extends EventListener<UIBreadcumbs> { public void execute(Event<UIBreadcumbs> event) throws Exception { UIBreadcumbs uiBreadcumbs = event.getSource(); UIGroupMemberSelector uiGroupMemberSelector = uiBreadcumbs.getParent(); String objectId = event.getRequestContext().getRequestParameter(OBJECTID); uiBreadcumbs.setSelectPath(objectId); String selectGroupId = uiBreadcumbs.getSelectLocalPath().getId(); uiGroupMemberSelector.changeGroup(selectGroupId); if (uiGroupMemberSelector.isUsePopup) { UIPopupWindow uiPopup = uiBreadcumbs.getAncestorOfType(UIPopupWindow.class); uiPopup.setShow(true); uiPopup.setShowMask(true); } event.getRequestContext().addUIComponentToUpdateByAjax(uiGroupMemberSelector); } } static public class AddAnyPermissionActionListener extends EventListener<UIAnyPermission> { public void execute(Event<UIAnyPermission> event) throws Exception { UIAnyPermission uiAnyPermission = event.getSource(); UIGroupMemberSelector uiGroupMemberSelector = uiAnyPermission.getParent(); String returnField = uiGroupMemberSelector.getReturnField(); String value = IdentityConstants.ANY; ((UISelectable)uiGroupMemberSelector.getSourceComponent()).doSelect(returnField, value); if (uiGroupMemberSelector.isUsePopup()) { UIPopupWindow uiPopup = uiGroupMemberSelector.getParent(); uiPopup.setShow(false); UIComponent uicomp = uiGroupMemberSelector.getSourceComponent().getParent(); event.getRequestContext().addUIComponentToUpdateByAjax(uicomp); if (!uiPopup.getId().equals("PopupComponent")) event.getRequestContext().addUIComponentToUpdateByAjax(uiPopup); } else { event.getRequestContext().addUIComponentToUpdateByAjax( uiGroupMemberSelector.getSourceComponent()); } } } /** * Check show/hide form to set any permission * @return */ public boolean isShowAnyPermission() { return isShowAnyPermission; } /** * Set show/hide any permission form * @param isShowAnyPermission * isShowAnyPermission = true: Show form <br> * isShowAnyPermission = false: Hide form */ public void setShowAnyPermission(boolean isShowAnyPermission) { this.isShowAnyPermission = isShowAnyPermission; } }
14,170
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
ComponentSelector.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/selector/ComponentSelector.java
/* * Copyright (C) 2003-2007 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.selector; import org.exoplatform.webui.core.UIComponent; /** * Created by The eXo Platform SARL Author : Dang Van Minh * minh.dang@exoplatform.com Nov 16, 2006 */ public interface ComponentSelector { /** * Gets the source component of a selector * * @return the source component */ public UIComponent getSourceComponent(); /** * Sets the source component of a selector * * @param uicomponent the uicomponent * @param initParams the init params */ public void setSourceComponent(UIComponent uicomponent, String[] initParams) ; }
1,316
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIPermissionSelector.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/selector/UIPermissionSelector.java
/* * Copyright (C) 2003-2007 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.selector; import java.util.ArrayList; import java.util.Collection; import java.util.List; import org.exoplatform.commons.utils.ListAccess; import org.exoplatform.services.organization.Group; import org.exoplatform.services.organization.OrganizationService; import org.exoplatform.services.organization.User; import org.exoplatform.services.wcm.utils.WCMCoreUtils; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.config.annotation.ComponentConfigs; import org.exoplatform.webui.config.annotation.EventConfig; import org.exoplatform.webui.core.UIBreadcumbs; import org.exoplatform.webui.core.UIComponent; import org.exoplatform.webui.core.UIPopupWindow; import org.exoplatform.webui.core.UITree; import org.exoplatform.webui.event.Event; import org.exoplatform.webui.event.EventListener; import org.exoplatform.webui.organization.UIGroupMembershipSelector; /** * Created by The eXo Platform SARL Author : Dang Van Minh * minh.dang@exoplatform.com Nov 17, 2006 */ @ComponentConfigs( { @ComponentConfig( template = "classpath:groovy/ecm/webui/UIMemberSelector.gtmpl", events = { @EventConfig(listeners = UIPermissionSelector.ChangeNodeActionListener.class), @EventConfig(listeners = UIPermissionSelector.SelectMembershipActionListener.class), @EventConfig(listeners = UIPermissionSelector.SelectPathActionListener.class), @EventConfig(listeners = UIPermissionSelector.AddAnyPermissionActionListener.class) }), @ComponentConfig( type = UITree.class, id = "UITreeGroupSelector", template = "system:/groovy/webui/core/UITree.gtmpl", events = @EventConfig(listeners = UITree.ChangeNodeActionListener.class)), @ComponentConfig( type = UIBreadcumbs.class, id = "BreadcumbGroupSelector", template = "system:/groovy/webui/core/UIBreadcumbs.gtmpl", events = @EventConfig(listeners = UIBreadcumbs.SelectPathActionListener.class)) } ) public class UIPermissionSelector extends UIGroupMembershipSelector implements ComponentSelector { /** The Constant defaultValue. */ final static public String defaultValue = "/admin"; /** The ui component. */ private UIComponent uiComponent; /** The return field name. */ private String returnFieldName = null; /** The is selected membership. */ private boolean isSelectedMembership = true; /** The is selected user. */ private boolean isSelectedUser; /** The is use popup. */ private boolean isUsePopup = true; /** Show/hide Add AnyPermission form */ private boolean isShowAnyPermission = true; /** * Instantiates a new uI permission selector. * * @throws Exception the exception */ public UIPermissionSelector() throws Exception { changeGroup(defaultValue); addChild(UIAnyPermission.class, null, null); } /** * Sets the current permission. * * @param per the new current permission * * @throws Exception the exception */ public void setCurrentPermission(String per) throws Exception { changeGroup(per); } /** * Gets the return component. * * @return the return component */ public UIComponent getSourceComponent() { return uiComponent; } /** * Gets the return field. * * @return the return field */ public String getReturnField() { return returnFieldName; } public void setIsUsePopup(boolean isUsePopup) { this.isUsePopup = isUsePopup; } public boolean isUsePopup() { return isUsePopup; } /* * (non-Javadoc) * @seeorg.exoplatform.ecm.webui.selector.ComponentSelector#setComponent(org. * exoplatform.webui.core.UIComponent, java.lang.String[]) */ public void setSourceComponent(UIComponent uicomponent, String[] initParams) { uiComponent = uicomponent; if (initParams == null || initParams.length == 0) return; for (int i = 0; i < initParams.length; i++) { if (initParams[i].indexOf("returnField") > -1) { String[] array = initParams[i].split("="); returnFieldName = array[1]; break; } returnFieldName = initParams[0]; } } /** * The listener interface for receiving selectMembershipAction events. The * class that is interested in processing a selectMembershipAction event * implements this interface, and the object created with that class is * registered with a component using the component's * <code>addSelectMembershipActionListener</code> method. When * the selectMembershipAction event occurs, that object's appropriate * method is invoked. */ static public class SelectMembershipActionListener extends EventListener<UIPermissionSelector> { /* (non-Javadoc) * @see org.exoplatform.webui.event.EventListener#execute(org.exoplatform.webui.event.Event) */ public void execute(Event<UIPermissionSelector> event) throws Exception { UIPermissionSelector uiPermissionSelector = event.getSource(); if (uiPermissionSelector.getCurrentGroup() == null) return; String groupId = uiPermissionSelector.getCurrentGroup().getId(); String permission = event.getRequestContext().getRequestParameter(OBJECTID); String value = ""; if(uiPermissionSelector.isSelectedUser()) { value = permission; } else { value = permission + ":" + groupId; } String returnField = uiPermissionSelector.getReturnField(); ((UISelectable) uiPermissionSelector.getSourceComponent()).doSelect(returnField, value); if (uiPermissionSelector.isUsePopup) { UIPopupWindow uiPopup = uiPermissionSelector.getParent(); uiPopup.setShow(false); uiPopup.setRendered(false); UIComponent uicomp = uiPermissionSelector.getSourceComponent().getParent(); event.getRequestContext().addUIComponentToUpdateByAjax(uicomp); if (!uiPopup.getId().equals("PopupComponent")) event.getRequestContext().addUIComponentToUpdateByAjax(uiPopup); } else { event.getRequestContext().addUIComponentToUpdateByAjax( uiPermissionSelector.getSourceComponent()); } } } /** * The listener interface for receiving changeNodeAction events. The class * that is interested in processing a changeNodeAction event implements this * interface, and the object created with that class is registered with a * component using the component's * <code>addChangeNodeActionListener</code> method. When * the changeNodeAction event occurs, that object's appropriate * method is invoked. */ static public class ChangeNodeActionListener extends EventListener<UITree> { /* (non-Javadoc) * @see org.exoplatform.webui.event.EventListener#execute(org.exoplatform.webui.event.Event) */ public void execute(Event<UITree> event) throws Exception { UIPermissionSelector uiPermissionSelector = event.getSource().getParent(); String groupId = event.getRequestContext().getRequestParameter(OBJECTID); uiPermissionSelector.changeGroup(groupId); event.getRequestContext().addUIComponentToUpdateByAjax(uiPermissionSelector); } } /** * The listener interface for receiving selectPathAction events. The class * that is interested in processing a selectPathAction event implements this * interface, and the object created with that class is registered with a * component using the component's * <code>addSelectPathActionListener</code> method. When * the selectPathAction event occurs, that object's appropriate * method is invoked. */ static public class SelectPathActionListener extends EventListener<UIBreadcumbs> { /* (non-Javadoc) * @see org.exoplatform.webui.event.EventListener#execute(org.exoplatform.webui.event.Event) */ public void execute(Event<UIBreadcumbs> event) throws Exception { UIBreadcumbs uiBreadcumbs = event.getSource(); UIPermissionSelector uiPermissionSelector = uiBreadcumbs.getParent(); String objectId = event.getRequestContext().getRequestParameter(OBJECTID); uiBreadcumbs.setSelectPath(objectId); String selectGroupId = uiBreadcumbs.getSelectLocalPath().getId(); uiPermissionSelector.changeGroup(selectGroupId); if (uiPermissionSelector.isUsePopup) { UIPopupWindow uiPopup = uiBreadcumbs.getAncestorOfType(UIPopupWindow.class); uiPopup.setShow(true); uiPopup.setShowMask(true); } event.getRequestContext().addUIComponentToUpdateByAjax(uiPermissionSelector); } } static public class AddAnyPermissionActionListener extends EventListener<UIAnyPermission> { public void execute(Event<UIAnyPermission> event) throws Exception { UIAnyPermission uiAnyPermission = event.getSource(); UIPermissionSelector uiPermissionSelector = uiAnyPermission.getParent(); String returnField = uiPermissionSelector.getReturnField(); String value = "*"; ((UISelectable)uiPermissionSelector.getSourceComponent()).doSelect(returnField, value); if (uiPermissionSelector.isUsePopup()) { UIPopupWindow uiPopup = uiPermissionSelector.getParent(); uiPopup.setShow(false); UIComponent uicomp = uiPermissionSelector.getSourceComponent().getParent(); event.getRequestContext().addUIComponentToUpdateByAjax(uicomp); if (!uiPopup.getId().equals("PopupComponent")) event.getRequestContext().addUIComponentToUpdateByAjax(uiPopup); } else { event.getRequestContext().addUIComponentToUpdateByAjax( uiPermissionSelector.getSourceComponent()); } } } /** * Sets the selected user. * * @param bool the new selected user */ public void setSelectedUser(boolean bool) { isSelectedUser = bool; } /** * Checks if is selected user. * * @return true, if is selected user */ public boolean isSelectedUser() { return isSelectedUser; } /** * Sets the selected membership. * * @param bool the new selected membership */ public void setSelectedMembership(boolean bool) { isSelectedMembership = bool; } /** * Checks if is selected membership. * * @return true, if is selected membership */ public boolean isSelectedMembership() { return isSelectedMembership; } /** * Gets the users. * * @return the users * * @throws Exception the exception */ public List getUsers() throws Exception { List<User> children = new ArrayList<User>(); OrganizationService service = WCMCoreUtils.getService(OrganizationService.class); ListAccess<User> userPageList = service.getUserHandler().findUsersByGroupId(this.getCurrentGroup().getId()); for (User child : userPageList.load(0, userPageList.getSize())) { children.add(child); } return children; } /** * Check show/hide form to set any permission * @return */ public boolean isShowAnyPermission() { return isShowAnyPermission; } /** * Set show/hide any permission form * @param isShowAnyPermission * isShowAnyPermission = true: Show form <br> * isShowAnyPermission = false: Hide form */ public void setShowAnyPermission(boolean isShowAnyPermission) { this.isShowAnyPermission = isShowAnyPermission; } @SuppressWarnings("unchecked") public List<String> getListGroup() throws Exception { OrganizationService service = WCMCoreUtils.getService(OrganizationService.class); List<String> listGroup = new ArrayList<String>(); if(getCurrentGroup() == null) return null; Collection<Group> groups = service.getGroupHandler().findGroups(getCurrentGroup()); if(groups.size() > 0) { for (Object child : groups) { Group childGroup = (Group)child; listGroup.add(childGroup.getId()) ; } } return listGroup; } }
12,653
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
PermissionsGroupVisibilityPlugin.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/selector/PermissionsGroupVisibilityPlugin.java
package org.exoplatform.ecm.webui.selector; import org.exoplatform.portal.config.GroupVisibilityPlugin; import org.exoplatform.portal.config.UserACL; import org.exoplatform.services.organization.Group; import org.exoplatform.services.security.Identity; import org.exoplatform.services.security.MembershipEntry; import java.util.Collection; /** * Implementation of GroupVisibilityPlugin for documents permissions which * allows to see a group if any of these conditions is fulfilled: * * the given user is the super user * * the given user is a platform administrator * * the given user is a manager of the group * * the group is a space group and the given user has a role in the group */ public class PermissionsGroupVisibilityPlugin extends GroupVisibilityPlugin { private UserACL userACL; public PermissionsGroupVisibilityPlugin(UserACL userACL) { this.userACL = userACL; } public boolean hasPermission(Identity userIdentity, Group group) { Collection<MembershipEntry> userMemberships = userIdentity.getMemberships(); return userACL.getSuperUser().equals(userIdentity.getUserId()) || userMemberships.stream() .anyMatch(userMembership -> userMembership.getGroup().equals(userACL.getAdminGroups()) || ((userMembership.getGroup().equals(group.getId()) || userMembership.getGroup().startsWith(group.getId() + "/")) && (group.getId().equals("/spaces") || group.getId().startsWith("/spaces/") || userMembership.getMembershipType().equals("*") || userMembership.getMembershipType().equals("manager")))); } }
1,785
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
DialogFormField.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/DialogFormField.java
/* * Copyright (C) 2003-2008 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.form; import java.util.HashMap; import org.exoplatform.services.cms.JcrInputProperty; import org.exoplatform.webui.form.UIFormInputBase; /** * Created by The eXo Platform SAS * @author : Hoa.Pham * hoa.pham@exoplatform.com * Jun 23, 2008 */ public abstract class DialogFormField { protected final String SEPARATOR = "="; protected final String JCR_PATH = "jcrPath" + SEPARATOR; protected final String EDITABLE = "editable" + SEPARATOR; protected final String ONCHANGE = "onchange" + SEPARATOR; protected final String OPTIONS = "options" + SEPARATOR; protected final String TYPE = "type" + SEPARATOR ; protected final String VISIBLE = "visible" + SEPARATOR; protected final String NODETYPE = "nodetype" + SEPARATOR; protected final String MIXINTYPE = "mixintype" + SEPARATOR; protected final String MIMETYPE = "mimetype" + SEPARATOR; protected final String VALIDATE = "validate" + SEPARATOR; protected final String SELECTOR_ACTION = "selectorAction" + SEPARATOR; protected final String SELECTOR_CLASS = "selectorClass" + SEPARATOR; protected final String SELECTOR_ICON = "selectorIcon" + SEPARATOR; protected final String SELECTOR_PARAMS = "selectorParams" + SEPARATOR; protected final String WORKSPACE_FIELD = "workspaceField" + SEPARATOR; protected final String SCRIPT = "script" + SEPARATOR; protected final String SCRIPT_PARAMS = "scriptParams" + SEPARATOR; protected final String MULTI_VALUES = "multiValues" + SEPARATOR; protected final String REFERENCE = "reference" + SEPARATOR; protected final String REPOSITORY = "repository"; protected final String DEFAULT_VALUES = "defaultValues" + SEPARATOR ; protected final String ROW_SIZE = "rows" + SEPARATOR ; protected final String COL_SIZE = "columns" + SEPARATOR ; protected final String SIZE = "size" + SEPARATOR ; protected final String CHANGE_IN_JCR_PATH_PARAM = "changeInJcrPathParam" + SEPARATOR; protected final String FILL_JCR_DATA_OF_FILE = "fillJcrDataOfFile" + SEPARATOR; protected String editable; protected String defaultValue; protected String rowSize; protected String colSize; protected String jcrPath; protected String selectorAction; protected String selectorClass; protected String workspaceField; protected String selectorIcon; protected String multiValues; protected String reference; protected String validateType; protected String selectorParams; protected String name; protected String label; protected String options; protected String visible; protected String nodeType; protected String mixinTypes; protected String mimeTypes; protected String onchange; protected String groovyScript; protected String[] scriptParams; protected String type; protected String size; protected String changeInJcrPathParam; protected String fillJcrDataOfFile = "true"; public DialogFormField(String name, String label, String[] arguments) { HashMap<String,String> parsedArguments = parseArguments(arguments) ; this.editable = parsedArguments.get(EDITABLE); this.defaultValue = parsedArguments.get(DEFAULT_VALUES); this.rowSize = parsedArguments.get(ROW_SIZE); this.colSize = parsedArguments.get(COL_SIZE); this.jcrPath = parsedArguments.get(JCR_PATH); this.selectorAction = parsedArguments.get(SELECTOR_ACTION); this.selectorClass = parsedArguments.get(SELECTOR_CLASS); this.workspaceField = parsedArguments.get(WORKSPACE_FIELD); this.selectorIcon = parsedArguments.get(SELECTOR_ICON); this.multiValues = parsedArguments.get(MULTI_VALUES); this.reference = parsedArguments.get(REFERENCE); this.validateType = parsedArguments.get(VALIDATE); this.selectorParams = parsedArguments.get(SELECTOR_PARAMS) ; this.options = parsedArguments.get(OPTIONS); this.visible = parsedArguments.get(VISIBLE); this.nodeType = parsedArguments.get(NODETYPE); this.mixinTypes = parsedArguments.get(MIXINTYPE); this.mimeTypes = parsedArguments.get(MIMETYPE); this.onchange = parsedArguments.get(ONCHANGE); this.groovyScript = parsedArguments.get(SCRIPT); this.type = parsedArguments.get(TYPE); this.size = parsedArguments.get(SIZE); this.changeInJcrPathParam = parsedArguments.get(CHANGE_IN_JCR_PATH_PARAM); this.fillJcrDataOfFile = parsedArguments.get(FILL_JCR_DATA_OF_FILE); String scriptParam = parsedArguments.get(SCRIPT_PARAMS); if(scriptParam != null) { scriptParams = scriptParam.split(","); } this.name = name; this.label = label; } @SuppressWarnings("unchecked") public abstract <T extends UIFormInputBase> T createUIFormInput() throws Exception; public JcrInputProperty createJcrInputProperty (){ JcrInputProperty inputProperty = new JcrInputProperty(); inputProperty.setJcrPath(jcrPath); return inputProperty; } public String getEditable() { return editable; } public void setEditable(String editable) { this.editable = editable; } public String getDefaultValue() { return defaultValue; } public void setDefaultValue(String defaultValue) { this.defaultValue = defaultValue; } public String getRowSize() { return rowSize; } public void setRowSize(String rowSize) { this.rowSize = rowSize; } public String getColSize() { return colSize; } public void setColSize(String colSize) { this.colSize = colSize; } public String getJcrPath() { return jcrPath; } public void setJcrPath(String jcrPath) { this.jcrPath = jcrPath; } public String getSelectorAction() { return selectorAction; } public void setSelectorAction(String selectorAction) { this.selectorAction = selectorAction; } public String getSelectorClass() { return selectorClass; } public void setSelectorClass(String selectorClass) { this.selectorClass = selectorClass; } public String getWorkspaceField() { return workspaceField; } public void setWorkspaceField(String workspaceField) { this.workspaceField = workspaceField; } public String getSelectorIcon() { return selectorIcon; } public void setSelectorIcon(String selectorIcon) { this.selectorIcon = selectorIcon; } public String getMultiValues() { return multiValues; } public void setMultiValues(String multiValues) { this.multiValues = multiValues; } public String getReference() { return reference; } public void setReferenceType(String reference) { this.reference = reference; } public String getValidateType() { return validateType; } public void setValidateType(String validateType) { this.validateType = validateType; } public String[] getSelectorParams() { if(selectorParams != null) { return selectorParams.split(","); } return null; } public String getSelectorParam() { return selectorParams; } public void setSelectorParam(String param) { this.selectorParams = param; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getLabel() { return label; } public void setLabel(String label) {this.label = label;} public String getOptions() { return options; } public void setOptions(String options) { this.options = options; } public String getVisible() { return visible;} public void setVisible(String visible) {this.visible = visible; } public String getNodeType() { return nodeType; } public void setNodeType(String nodeType) { this.nodeType = nodeType; } public String getMixinTypes() { return mixinTypes; } public void setMixinTypes(String mixinTypes) { this.mixinTypes = mixinTypes; } public String getMimeTypes() { return mimeTypes; } public void setMimeTypes(String mimeTypes) { this.mimeTypes = mimeTypes; } public String getOnchange() { return onchange; } public void setOnchange(String onchange) { this.onchange = onchange; } public String getGroovyScript() { return groovyScript; } public void setGroovyScript(String groovyScript) { this.groovyScript = groovyScript; } public String[] getScriptParams() { return scriptParams; } public void setScriptParams(String[] scriptParams) { this.scriptParams = scriptParams; } public String getType() { return type; } public void setType(String type) { this.type = type;} public String getSize() { return size; } public void setSize(String size) { this.size = size;} public String getChangeInJcrPathParam() { return changeInJcrPathParam; } public void setChangeInJcrPathParam(String value) { this.changeInJcrPathParam = value; } public String getFillJcrDataFile() { return fillJcrDataOfFile; } public void setFillJcrDataFile(String value) { fillJcrDataOfFile = value; } public boolean isMultiValues() { return "true".equalsIgnoreCase(multiValues); } public boolean isReference() { return "true".equalsIgnoreCase(reference); } public boolean isEditable() { return !"false".equalsIgnoreCase(editable); } public boolean isEditableIfNull() { return "if-null".equalsIgnoreCase(editable); } public boolean isVisibleIfNotNull() { return "if-not-null".equals(visible); } public boolean isFillJcrDataFile() { return "true".equals(fillJcrDataOfFile) || fillJcrDataOfFile == null; } private HashMap<String,String> parseArguments(String[] arguments) { HashMap<String,String> map = new HashMap<String,String>() ; for(String argument:arguments) { String value = null; if(argument.indexOf(SEPARATOR)>0) { value = argument.substring(argument.indexOf(SEPARATOR)+1) ; }else { value = argument; map.put(DEFAULT_VALUES,value) ; continue; } if (argument.startsWith(JCR_PATH)) { map.put(JCR_PATH,value); continue; } else if (argument.startsWith(EDITABLE)) { map.put(EDITABLE,value); continue; } else if (argument.startsWith(SELECTOR_ACTION)) { map.put(SELECTOR_ACTION,value) ; continue; } else if (argument.startsWith(SELECTOR_CLASS)) { map.put(SELECTOR_CLASS,value); continue; } else if (argument.startsWith(MULTI_VALUES)) { map.put(MULTI_VALUES,value); continue; } else if (argument.startsWith(SELECTOR_ICON)) { map.put(SELECTOR_ICON,value); continue; } else if (argument.startsWith(SELECTOR_PARAMS)) { map.put(SELECTOR_PARAMS,value); continue; }else if (argument.startsWith(WORKSPACE_FIELD)) { map.put(WORKSPACE_FIELD,value); continue; } else if (argument.startsWith(VALIDATE)) { map.put(VALIDATE,value); continue; } else if (argument.startsWith(REFERENCE)) { map.put(REFERENCE, value); continue; } else if(argument.startsWith(DEFAULT_VALUES)) { map.put(DEFAULT_VALUES,value); continue; } else if(argument.startsWith(ROW_SIZE)) { map.put(ROW_SIZE,value); continue; } else if(argument.startsWith(COL_SIZE)) { map.put(COL_SIZE,value); continue; } else if(argument.startsWith(OPTIONS)){ map.put(OPTIONS,value); continue; } else if(argument.startsWith(SCRIPT)) { map.put(SCRIPT,value); continue; } else if(argument.startsWith(SCRIPT_PARAMS)){ map.put(SCRIPT_PARAMS,value); continue; } else if(argument.startsWith(VISIBLE)){ map.put(VISIBLE,value); continue; } else if(argument.startsWith(TYPE)){ map.put(TYPE,value) ; continue; } else if(argument.startsWith(ONCHANGE)){ map.put(ONCHANGE,value); continue; } else if (argument.startsWith(MIXINTYPE)) { map.put(MIXINTYPE, value); continue; } else if (argument.startsWith(MIMETYPE)) { map.put(MIMETYPE, value); continue; } else if(argument.startsWith(NODETYPE)) { map.put(NODETYPE, value) ; continue ; } else if(argument.startsWith(SIZE)) { map.put(SIZE, value) ; continue ; } else if (argument.startsWith(CHANGE_IN_JCR_PATH_PARAM)) { map.put(CHANGE_IN_JCR_PATH_PARAM, value); continue; } else if (argument.startsWith(FILL_JCR_DATA_OF_FILE)) { map.put(FILL_JCR_DATA_OF_FILE, value); continue; } else { map.put(DEFAULT_VALUES,argument); } } return map; } }
13,183
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIFormRichtextInput.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/UIFormRichtextInput.java
package org.exoplatform.ecm.webui.form; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import org.apache.commons.lang3.StringUtils; import org.exoplatform.webui.application.WebuiRequestContext; import org.exoplatform.webui.form.UIFormInputBase; import org.exoplatform.webui.utils.TimeConvertUtils; /** * Created by The eXo Platform SAS * Author : Ha Quang Tan * tanhq@exoplatform.com * July 15, 2013 */ public class UIFormRichtextInput extends UIFormInputBase<String> { public static final String FULL_TOOLBAR = "CompleteWCM"; public static final String BASIC_TOOLBAR = "Basic"; public static final String SUPER_BASIC_TOOLBAR = "SuperBasicWCM"; public static final String INLINE_TOOLBAR = "InlineEdit"; public static final String COMMENT_TOOLBAR = "Comment"; public static final String FORUM_TOOLBAR = "Forum"; public static final String FAQ_TOOLBAR = "FAQ"; public static final String ENTER_P = "1"; public static final String ENTER_BR = "2"; public static final String ENTER_DIV = "3"; private static final String CKEDITOR_ENTER_P = "CKEDITOR.ENTER_P"; private static final String CKEDITOR_ENTER_BR = "CKEDITOR.ENTER_BR"; private static final String CKEDITOR_ENTER_DIV = "CKEDITOR.ENTER_DIV"; private String width; private String height; private String toolbar; private String enterMode; private String shiftEnterMode; private boolean forceEnterMode = false; private String css; private boolean isPasteAsPlainText = false; private boolean isIgnoreParserHTML = false; public UIFormRichtextInput(String name, String bindingField, String value) { super(name, bindingField, String.class); this.value_ = value; } public UIFormRichtextInput(String name, String bindingField, String value, String enterMode) { super(name, bindingField, String.class); this.value_ = value; this.enterMode = enterMode; } public UIFormRichtextInput(String name, String bindingField, String value, String enterMode, String toolbar) { super(name, bindingField, String.class); this.value_ = value; this.enterMode = enterMode; this.toolbar = toolbar; } public UIFormRichtextInput(String name, String bindingField, String value, String enterMode, String toolbar, String css) { super(name, bindingField, String.class); this.value_ = value; this.enterMode = enterMode; this.toolbar = toolbar; this.css = css; } public String getWidth() { return width; } public void setWidth(String width) { this.width = width; } public String getHeight() { return height; } public void setHeight(String height) { this.height = height; } public String getToolbar() { return toolbar; } public String getEnterMode() { return enterMode; } public String getShiftEnterMode() { return shiftEnterMode; } public void setToolbar(String toolbar) { this.toolbar = toolbar; } public void setEnterMode(String enterMode) { this.enterMode = enterMode; } public void setShiftEnterMode(String shiftEnterMode) { this.shiftEnterMode = shiftEnterMode; } public UIFormRichtextInput setIsPasteAsPlainText(boolean isPasteAsPlainText) { this.isPasteAsPlainText = isPasteAsPlainText; return this; } public boolean getIsPasteAsPlainText() { return this.isPasteAsPlainText; } public boolean isIgnoreParserHTML() { return isIgnoreParserHTML; } public UIFormRichtextInput setIgnoreParserHTML(boolean isIgnoreParserHTML) { this.isIgnoreParserHTML = isIgnoreParserHTML; return this; } public void setCss(String css) { this.css = css; } public String getCss() { return css; } private static String encodeURLComponent(String s) { String result = null; try { result = URLEncoder.encode(s, "UTF-8") .replaceAll("\\+", "%20") .replaceAll("\\%21", "!") .replaceAll("\\%28", "(") .replaceAll("\\%29", ")") .replaceAll("\\%7E", "~"); } catch (UnsupportedEncodingException e) { result = s; } return result; } private String buildEditorLayout(WebuiRequestContext context) throws Exception { if (toolbar == null) toolbar = BASIC_TOOLBAR; if (width == null) width = "98%"; if (height == null) height = "'200px'"; if (enterMode == null) enterMode = CKEDITOR_ENTER_P; if (shiftEnterMode == null) shiftEnterMode = CKEDITOR_ENTER_BR; if (CKEDITOR_ENTER_P.equals(enterMode) && CKEDITOR_ENTER_DIV.equals(shiftEnterMode) || CKEDITOR_ENTER_DIV.equals(enterMode) && CKEDITOR_ENTER_P.equals(shiftEnterMode)) { forceEnterMode = true; } if (css == null) css = "\"/commons-extension/ckeditor/contents.css\""; if (value_ == null) value_ = ""; StringBuilder builder = new StringBuilder(); builder.append("<div class=\"clearfix\">"); builder.append(" <span style=\"float:left; width:").append(width).append(";\">"); // builder.append(" <textarea style=\"width:1px;height:1px;\" id=\"").append(name).append("\" name=\"").append(name).append("\">") .append(value_).append("</textarea>\n"); builder.append(" </span>"); if (isMandatory()) { builder.append(" <span style=\"float:left\"> &nbsp;*</span>"); } builder.append("</div>"); StringBuilder jsBuilder = new StringBuilder(); //fix issue INTEG-320 String str = name; String variableName = TimeConvertUtils.santializeJavaVariable(str); String textArea = "textarea" + variableName; String textArea1 = "textarea" + variableName; String instance = "instance" + variableName; String form = "form" + variableName; String functionName = "ckeditorGenerate" + variableName; jsBuilder.append("function " + functionName + "() {"); jsBuilder.append(" var " + textArea + " = document.getElementById('").append(name).append("'); "); if (isIgnoreParserHTML() && StringUtils.isNotEmpty(value_)) { String value = encodeURLComponent(value_); jsBuilder.append(" if(" + textArea + ") {") .append(" var isFirefox = typeof InstallTrigger !== 'undefined';") .append(" var value = decodeURIComponent('").append(value).append("');") .append(" if(isFirefox) { " + textArea + ".value = value; } else { " + textArea + ".innerText = value;}") .append(" }"); } jsBuilder .append("var " + instance + " = CKEDITOR.instances['").append(name).append("'];\n") .append("if (" + instance + ") { ") .append(" CKEDITOR.remove(" + instance + "); " + instance + " = null;\n") .append("}\n") .append("$('[name=\\'").append(name).append("\\']').ckeditor({") .append("customConfig: '/ecmexplorer/javascript/eXo/ecm/ckeditorCustom/config.js',") .append("removePlugins: 'hideBottomToolbar',") .append("toolbar:'").append(toolbar).append("',") .append("toolbarLocation: 'top',") .append("height:").append(height).append(", contentsCss:").append(css).append(", enterMode:").append(enterMode) .append((isPasteAsPlainText) ? ", forcePasteAsPlainText: true" : "") .append(", forceEnterMode:").append(forceEnterMode) .append(", shiftEnterMode:").append(shiftEnterMode).append("});\n") .append(instance + " = CKEDITOR.instances['").append(name).append("'];\n") .append(instance +".on( 'change', function(e) { \n") .append(" document.getElementById('").append(name).append("').value = " + instance + ".getData(); \n") .append("});\n") .append("var " + form + " = " + textArea + "; \n") .append("while ("+ form + " && (" + form + ".nodeName.toLowerCase() != 'form')) { \n") .append(" "+ form +" = " + form + ".parentNode;\n") .append("} \n") .append("if (" + form + ") {\n") .append(" " + form + ".textareaName = '").append(name).append("'; \n") .append(" " + form + ".onmouseover=function() { \n") .append(" this.onmouseover=''; \n") .append(" var " + textArea1 + " = document.getElementById('").append(name).append("'); \n") .append(" " + textArea1 + ".style.display='block'; \n") .append(" " + textArea1 + ".style.visibility='visible'; \n") .append(" " + textArea1 + ".focus(); \n") .append(" " + textArea1 + ".style.display='none'; \n") .append(" } \n") .append("} \n"); //end function jsBuilder.append("}\n"); jsBuilder.append(functionName + "();\n"); context.getJavascriptManager().require("SHARED/commons-editor", "editor").require("SHARED/jquery", "$").addScripts(jsBuilder.toString()); // return builder.toString(); } public void processRender(WebuiRequestContext context) throws Exception { // context.getWriter().write(buildEditorLayout(context)); } public void decode(Object input, WebuiRequestContext context) { value_ = (String) input; if (value_ != null && value_.length() == 0) { value_ = null; } } }
9,353
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
DialogFormActionListeners.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/DialogFormActionListeners.java
/* * Copyright (C) 2003-2008 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.form; import javax.jcr.Node; import org.apache.commons.lang3.StringUtils; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.services.pdfviewer.ObjectKey; import org.exoplatform.services.pdfviewer.PDFViewerService; import org.exoplatform.services.wcm.utils.WCMCoreUtils; import org.exoplatform.web.application.ApplicationMessage; import org.exoplatform.webui.event.Event; import org.exoplatform.webui.event.EventListener; /** * Created by The eXo Platform SAS * Author : Phan Le Thanh Chuong * chuong.phan@exoplatform.com, phan.le.thanh.chuong@gmail.com * Nov 14, 2008 */ public class DialogFormActionListeners { static public class RemoveDataActionListener extends EventListener<UIDialogForm> { public void execute(Event<UIDialogForm> event) throws Exception { UIDialogForm uiForm = event.getSource(); // uiForm.isRemovePreference = true; String referenceNodePath = event.getRequestContext().getRequestParameter(UIDialogForm.OBJECTID); //String removedNode = event.getRequestContext().getRequestParameter('removedNode"); uiForm.releaseLock(); if (referenceNodePath.indexOf("$") > -1) { int index = referenceNodePath.indexOf("$"); String removedNode = referenceNodePath.substring(index + 1); referenceNodePath = referenceNodePath.substring(0, index); if (StringUtils.isNotEmpty(removedNode)) { Node currentNode = uiForm.getNode(); if (currentNode.isLocked()) { Object[] args = { currentNode.getPath() }; org.exoplatform.wcm.webui.Utils.createPopupMessage(uiForm, "UIPermissionManagerGrid.msg.node-locked", args, ApplicationMessage.WARNING); return; } uiForm.addRemovedNode(removedNode); } } if (referenceNodePath.startsWith("/")) { Node referenceNode = (Node)uiForm.getSession().getItem(uiForm.getNodePath() + referenceNodePath); if(referenceNode.hasProperty(Utils.JCR_DATA)) { uiForm.removeData(referenceNodePath); // uiForm.setDataRemoved(true); } } else { Node currentNode = uiForm.getNode(); if (currentNode.isLocked()) { Object[] args = { currentNode.getPath() }; org.exoplatform.wcm.webui.Utils.createPopupMessage(uiForm, "UIPermissionManagerGrid.msg.node-locked", args, ApplicationMessage.WARNING); return; } if (currentNode.hasProperty(referenceNodePath)) { uiForm.removeData(referenceNodePath); // uiForm.setDataRemoved(true); } } clearPDFCached(uiForm.getNode()); event.getRequestContext().addUIComponentToUpdateByAjax(uiForm); } private void clearPDFCached(Node currentNode) throws Exception{ PDFViewerService pdfViewerService = WCMCoreUtils.getService(PDFViewerService.class); String wsName = currentNode.getSession().getWorkspace().getName(); String repoName = WCMCoreUtils.getRepository().getConfiguration().getName(); String uuid = currentNode.getUUID(); StringBuilder bd = new StringBuilder(); StringBuilder bd1 = new StringBuilder(); bd.append(repoName).append("/").append(wsName).append("/").append(uuid); bd1.append(bd).append("/jcr:lastModified"); pdfViewerService.getCache().remove(new ObjectKey(bd.toString())); pdfViewerService.getCache().remove(new ObjectKey(bd1.toString())); } } static public class ChangeTabActionListener extends EventListener<UIDialogForm> { /* (non-Javadoc) * @see org.exoplatform.webui.event.EventListener#execute(org.exoplatform.webui.event.Event) */ public void execute(Event<UIDialogForm> event) throws Exception { UIDialogForm uiForm = event.getSource(); uiForm.setSelectedTab(event.getRequestContext().getRequestParameter(UIDialogForm.OBJECTID)); event.getRequestContext().addUIComponentToUpdateByAjax(uiForm); } } }
4,829
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIFormUploadInputExtension.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/UIFormUploadInputExtension.java
/* * Copyright (C) 2003-2011 eXo Platform SAS. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program 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 Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.form; import org.exoplatform.webui.form.input.UIUploadInput; /** * Created by The eXo Platform SAS * Author : eXoPlatform * exo@exoplatform.com * Nov 24, 2011 */ public class UIFormUploadInputExtension extends UIUploadInput { protected byte[] byteValue; protected String fileName; protected String mimeType; public UIFormUploadInputExtension(String name, String bindingExpression) { super(name, bindingExpression); } public UIFormUploadInputExtension(String name, String bindingExpression, int limit) { super(name, bindingExpression, 1, limit); } public void setByteValue(byte[] value) { byteValue = value; } public byte[] getByteValue() { return byteValue; } public String getFileName() { return fileName; } public void setFileName(String fileName) { this.fileName = fileName; } public void setMimeType(String value) { mimeType = value; } public String getMimeType() { return mimeType; } }
1,706
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIFormInputSetWithAction.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/UIFormInputSetWithAction.java
/* * Copyright (C) 2003-2007 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.form; import java.util.HashMap; import java.util.List; import org.exoplatform.webui.application.WebuiRequestContext; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.form.UIForm; import org.exoplatform.webui.form.UIFormInput; import org.exoplatform.webui.form.UIFormInputSet; /** * Created by The eXo Platform SARL * Author : Dang Van Minh * minh.dang@exoplatform.com * Sep 20, 2006 */ @ComponentConfig( template = "classpath:groovy/ecm/webui/form/UIFormInputSetWithAction.gtmpl" ) public class UIFormInputSetWithAction extends UIFormInputSet implements UIFormInput { private String[] actions_ ; private String[] values_ ; private boolean isView_ ; private boolean isShowOnly_ = false ; private boolean isDeleteOnly_ = false ; private HashMap<String, String> infor_ = new HashMap<String, String>() ; private HashMap<String, List<String>> listInfor_ = new HashMap<String, List<String>>() ; private HashMap<String, String[]> actionInfo_ = new HashMap<String, String[]>() ; private HashMap<String, String[]> fieldActions_ = new HashMap<String, String[]>() ; private boolean isShowActionInfo_ = false ; private HashMap<String, String> msgKey_ = new HashMap<String, String>(); public UIFormInputSetWithAction(String name) { setId(name) ; setComponentConfig(getClass(), null) ; } public boolean isShowActionInfo() {return isShowActionInfo_ ;} public void showActionInfo(boolean isShow) {isShowActionInfo_ = isShow ;} public void processRender(WebuiRequestContext context) throws Exception { super.processRender(context) ; } public void setActions(String[] actionList, String[] values){ actions_ = actionList ; values_ = values ; } public String[] getInputSetActions() { return actions_ ; } public String[] getActionValues() { return values_ ; } public String getFormName() { UIForm uiForm = getAncestorOfType(UIForm.class); return uiForm.getId() ; } public boolean isShowOnly() { return isShowOnly_ ; } public void setIsShowOnly(boolean isShowOnly) { isShowOnly_ = isShowOnly ; } public boolean isDeleteOnly() { return isDeleteOnly_ ; } public void setIsDeleteOnly(boolean isDeleteOnly) { isDeleteOnly_ = isDeleteOnly ; } public void setListInfoField(String fieldName, List<String> listInfor) { listInfor_.put(fieldName, listInfor) ; } public List<String> getListInfoField(String fieldName) { if(listInfor_.containsKey(fieldName)) return listInfor_.get(fieldName) ; return null ; } public void setInfoField(String fieldName, String fieldInfo) { infor_.put(fieldName, fieldInfo) ; } public String getInfoField(String fieldName) { if(infor_.containsKey(fieldName)) return infor_.get(fieldName) ; return null ; } public void setActionInfo(String fieldName, String[] actionNames) { actionInfo_.put(fieldName, actionNames) ; } public String[] getActionInfo(String fieldName) { if(actionInfo_.containsKey(fieldName)) return actionInfo_.get(fieldName) ; return null ; } public void setFieldActions(String fieldName, String[] actionNames) { fieldActions_.put(fieldName, actionNames) ; } public String[] getFieldActions(String fieldName) { return fieldActions_.get(fieldName) ; } public void setIsView(boolean isView) { isView_ = isView; } public boolean isView() { return isView_ ; } public String getBindingField() { return null; } public List getValidators() { return null; } @SuppressWarnings("unused") public UIFormInput addValidator(Class clazz, Object...params) throws Exception { return this; } public Object getValue() throws Exception { return null; } @SuppressWarnings("unused") public UIFormInput setValue(Object value) throws Exception { return null; } public Class getTypeValue() { return null ; } public void setIntroduction(String fieldName, String msgKey) { msgKey_.put(fieldName, msgKey) ; } public String getMsgKey(String fieldName) { return msgKey_.get(fieldName) ; } public String getLabel() { return getId(); } @SuppressWarnings("unused") public UIFormInput addValidator(Class arg0) throws Exception { return null; } }
5,076
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIFormUploadInputNoRemoveButton.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/UIFormUploadInputNoRemoveButton.java
/* * Copyright (C) 2003-2011 eXo Platform SAS. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program 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 Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.form; import org.exoplatform.webui.config.annotation.ComponentConfig; /** * Created by The eXo Platform SAS * Author : eXoPlatform * exo@exoplatform.com * Nov 21, 2011 */ @ComponentConfig(type = UIFormUploadInputNoRemoveButton.class, template = "classpath:groovy/ecm/webui/form/UIFormUploadInputNoRemoveButton.gtmpl") public class UIFormUploadInputNoRemoveButton extends UIFormUploadInputExtension { public UIFormUploadInputNoRemoveButton(String name, String bindingExpression) { super(name, bindingExpression); setComponentConfig(UIFormUploadInputNoRemoveButton.class, null); } public UIFormUploadInputNoRemoveButton(String name, String bindingExpression, int limit) { super (name, bindingExpression, limit); setComponentConfig(UIFormUploadInputNoRemoveButton.class, null); } }
1,593
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIFormUploadMultiValueInputSet.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/UIFormUploadMultiValueInputSet.java
/* * Copyright (C) 2003-2011 eXo Platform SAS. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program 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 Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.form; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.config.annotation.EventConfig; import org.exoplatform.webui.event.Event.Phase; import org.exoplatform.webui.form.UIFormInputBase; import org.exoplatform.webui.form.UIFormMultiValueInputSet; /** * Created by The eXo Platform SAS * Author : eXoPlatform * exo@exoplatform.com * Nov 21, 2011 */ @ComponentConfig(events = { @EventConfig(listeners = UIFormMultiValueInputSet.AddActionListener.class, phase = Phase.DECODE), @EventConfig(listeners = UIFormMultiValueInputSet.RemoveActionListener.class, phase = Phase.DECODE)}) public class UIFormUploadMultiValueInputSet extends UIFormMultiValueInputSet { public UIFormUploadMultiValueInputSet() throws Exception { super(); setComponentConfig(getClass(), null); } public UIFormUploadMultiValueInputSet(String name, String bindingField) throws Exception { super(name, bindingField); setComponentConfig(getClass(), null); } public UIFormInputBase createUIFormInput(int idx) throws Exception { return super.createUIFormInput(idx); } }
1,891
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIDialogForm.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/UIDialogForm.java
/* * Copyright (C) 2003-2008 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.form; import java.io.InputStream; import java.io.Writer; import java.net.URLDecoder; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; import java.util.GregorianCalendar; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.MissingResourceException; import java.util.ResourceBundle; import java.util.Set; import javax.jcr.ItemNotFoundException; import javax.jcr.Node; import javax.jcr.NodeIterator; import javax.jcr.PathNotFoundException; import javax.jcr.PropertyType; import javax.jcr.RepositoryException; import javax.jcr.Session; import javax.jcr.Value; import javax.jcr.ValueFormatException; import javax.jcr.lock.LockException; import org.apache.commons.lang3.StringUtils; import org.exoplatform.commons.utils.IOUtil; import org.exoplatform.download.DownloadService; import org.exoplatform.download.InputStreamDownloadResource; import org.exoplatform.ecm.resolver.JCRResourceResolver; import org.exoplatform.ecm.webui.core.fckconfig.FCKConfigService; import org.exoplatform.ecm.webui.core.fckconfig.FCKEditorContext; import org.exoplatform.ecm.webui.form.field.UIFormActionField; import org.exoplatform.ecm.webui.form.field.UIFormCalendarField; import org.exoplatform.ecm.webui.form.field.UIFormCheckBoxField; import org.exoplatform.ecm.webui.form.field.UIFormHiddenField; import org.exoplatform.ecm.webui.form.field.UIFormRadioBoxField; import org.exoplatform.ecm.webui.form.field.UIFormRichtextField; import org.exoplatform.ecm.webui.form.field.UIFormSelectBoxField; import org.exoplatform.ecm.webui.form.field.UIFormTextAreaField; import org.exoplatform.ecm.webui.form.field.UIFormTextField; import org.exoplatform.ecm.webui.form.field.UIFormUploadField; import org.exoplatform.ecm.webui.form.field.UIFormWYSIWYGField; import org.exoplatform.ecm.webui.form.field.UIMixinField; import org.exoplatform.ecm.webui.form.validator.UploadFileMimeTypesValidator; import org.exoplatform.ecm.webui.utils.DialogFormUtil; import org.exoplatform.ecm.webui.utils.JCRExceptionManager; import org.exoplatform.ecm.utils.lock.LockUtil; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.portal.webui.util.Util; import org.exoplatform.services.cms.BasePath; import org.exoplatform.services.cms.JcrInputProperty; import org.exoplatform.services.cms.impl.DMSConfiguration; import org.exoplatform.services.cms.scripts.CmsScript; import org.exoplatform.services.cms.scripts.ScriptService; import org.exoplatform.services.cms.templates.TemplateService; import org.exoplatform.services.jcr.RepositoryService; import org.exoplatform.services.jcr.core.ManageableRepository; import org.exoplatform.services.jcr.ext.hierarchy.NodeHierarchyCreator; import org.exoplatform.services.jcr.util.Text; import org.exoplatform.services.log.ExoLogger; import org.exoplatform.services.log.Log; import org.exoplatform.services.wcm.core.NodetypeConstant; import org.exoplatform.services.wcm.utils.WCMCoreUtils; import org.exoplatform.web.application.ApplicationMessage; import org.exoplatform.web.application.RequestContext; import org.exoplatform.webui.application.WebuiRequestContext; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.config.annotation.ComponentConfigs; import org.exoplatform.webui.config.annotation.EventConfig; import org.exoplatform.webui.core.UIApplication; import org.exoplatform.webui.core.UIComponent; import org.exoplatform.webui.core.model.SelectItemOption; import org.exoplatform.webui.event.Event; import org.exoplatform.webui.event.Event.Phase; import org.exoplatform.webui.event.EventListener; import org.exoplatform.webui.form.UIForm; import org.exoplatform.webui.form.UIFormDateTimeInput; import org.exoplatform.webui.form.UIFormInput; import org.exoplatform.webui.form.UIFormInputBase; import org.exoplatform.webui.form.UIFormMultiValueInputSet; import org.exoplatform.webui.form.UIFormRadioBoxInput; import org.exoplatform.webui.form.UIFormSelectBox; import org.exoplatform.webui.form.UIFormStringInput; import org.exoplatform.webui.form.UIFormTextAreaInput; import org.exoplatform.webui.form.input.UICheckBoxInput; import org.exoplatform.webui.form.input.UIUploadInput; import org.exoplatform.webui.form.wysiwyg.FCKEditorConfig; import org.exoplatform.webui.form.wysiwyg.UIFormWYSIWYGInput; /** * Created by The eXo Platform SAS * @author : Hoa.Pham * hoa.pham@exoplatform.com * Jun 23, 2008 */ @ComponentConfigs( { @ComponentConfig(type = UIFormMultiValueInputSet.class, id = "WYSIWYGRichTextMultipleInputset", events = { @EventConfig(listeners = UIDialogForm.AddActionListener.class, phase = Phase.DECODE), @EventConfig(listeners = UIFormMultiValueInputSet.RemoveActionListener.class, phase = Phase.DECODE) }) }) @SuppressWarnings("unused") public class UIDialogForm extends UIForm { /** * Logger. */ private static final Log LOG = ExoLogger.getLogger(UIDialogForm.class.getName()); private final String REPOSITORY = "repository"; protected final static String CANCEL_ACTION = "Cancel"; protected final static String SAVE_ACTION = "Save"; protected static final String SAVE_AND_CLOSE = "SaveAndClose"; protected static final String[] ACTIONS = { SAVE_ACTION, CANCEL_ACTION }; private static final String WYSIWYG_MULTI_ID = "WYSIWYGRichTextMultipleInputset"; protected Map<String, Map<String,String>> componentSelectors = new HashMap<String, Map<String,String>>(); protected Map<String, String> fieldNames = new HashMap<String, String>(); protected Map<String, String> propertiesName = new HashMap<String, String>(); protected Map<String, String[]> uiMultiValueParam = new HashMap<String, String[]>(); protected String contentType; protected boolean isAddNew = true; protected boolean isRemovePreference; protected boolean isRemoveActionField; protected boolean isShowingComponent; protected boolean isUpdateSelect; protected Map<String, JcrInputProperty> properties = new HashMap<String, JcrInputProperty>(); protected Map<String, String> options = new HashMap<String, String>(); protected String repositoryName; protected JCRResourceResolver resourceResolver; private String childPath; private boolean isNotEditNode; private boolean dataRemoved_ = false;; private boolean isNTFile; private boolean isOnchange; private boolean isResetForm; private boolean isResetMultiField; protected String nodePath; protected String i18nNodePath = null; private List<String> postScriptInterceptor = new ArrayList<String>(); private List<String> prevScriptInterceptor = new ArrayList<String>(); private List<String> listTaxonomy = new ArrayList<String>(); private List<String> removedNodes = new ArrayList<String>(); private String storedPath; protected String workspaceName; protected boolean isReference; protected boolean isShowActionsOnTop_ = false; private List<String> removedBinary ; /** Selected Tab id */ private String selectedTab; private String SEPARATOR_VALUE = "::"; public UIDialogForm() { removedBinary = new ArrayList<String>(); } public boolean isEditing() { return !isAddNew;} public boolean isAddNew() { return isAddNew;} public void addNew(boolean b) { this.isAddNew = b; } private boolean isKeepinglock = false; public void setSelectedTab(String selectedTab) { this.selectedTab = selectedTab; } public String getSelectedTab() { return selectedTab; } public boolean isKeepinglock() { return isKeepinglock; } public void setIsKeepinglock(boolean isKeepinglock) { this.isKeepinglock = isKeepinglock; } public boolean isShowActionsOnTop() { return isShowActionsOnTop_; } public void setShowActionsOnTop(boolean isShowActionsOnTop) { this.isShowActionsOnTop_ = isShowActionsOnTop; } public void releaseLock() throws Exception { if (isKeepinglock()) { Node currentNode = getNode(); if ((currentNode!=null) && currentNode.isLocked()) { try { if(currentNode.holdsLock()) { String lockToken = LockUtil.getLockTokenOfUser(currentNode); if(lockToken != null) { currentNode.getSession().addLockToken(LockUtil.getLockToken(currentNode)); } currentNode.unlock(); currentNode.removeMixin(Utils.MIX_LOCKABLE); currentNode.save(); //remove lock from Cache LockUtil.removeLock(currentNode); } } catch(LockException le) { if (LOG.isErrorEnabled()) { LOG.error("Fails when unlock node that is editing", le); } } } } setIsKeepinglock(false); } public List<String> getListTaxonomy() { return listTaxonomy; } public void setListTaxonomy(List<String> listTaxonomy) { this.listTaxonomy = listTaxonomy; } public void setStoredLocation(String workspace, String storedPath) { try { this.repositoryName = getApplicationComponent(RepositoryService.class).getCurrentRepository() .getConfiguration() .getName(); } catch (RepositoryException ex) { this.repositoryName = null; } setWorkspace(workspace); setStoredPath(storedPath); } protected String getCategoryLabel(String resource) { String[] taxonomyPathSplit = resource.split("/"); StringBuilder buildlabel; StringBuilder buildPathlabel = new StringBuilder(); for (int i = 0; i < taxonomyPathSplit.length; i++) { buildlabel = new StringBuilder("eXoTaxonomies"); for (int j = 0; j <= i; j++) { buildlabel.append(".").append(taxonomyPathSplit[j]); } try { buildPathlabel.append(Utils.getResourceBundle(buildlabel.append(".label").toString())).append("/"); } catch (MissingResourceException me) { buildPathlabel.append(taxonomyPathSplit[i]).append("/"); } } return buildPathlabel.substring(0, buildPathlabel.length() - 1); } public void seti18nNodePath(String nodePath) { i18nNodePath = nodePath; } public String geti18nNodePath() { return i18nNodePath; } @SuppressWarnings("unchecked") public void addActionField(String name,String label,String[] arguments) throws Exception { UIFormActionField formActionField = new UIFormActionField(name,label,arguments); if(formActionField.useSelector()) { componentSelectors.put(name, formActionField.getSelectorInfo()); } String jcrPath = formActionField.getJcrPath(); JcrInputProperty inputProperty = new JcrInputProperty(); inputProperty.setJcrPath(jcrPath); inputProperty.setChangeInJcrPathParam(formActionField.getChangeInJcrPathParam()); setInputProperty(name, inputProperty); Node node = getNode(); UIComponent uiInput; boolean isFirstTimeRender = false; if(formActionField.isMultiValues()) { uiInput = findComponentById(name); if (uiInput == null) { isFirstTimeRender = true; uiInput = addMultiValuesInput(UIFormStringInput.class,name,label); String defaultValue = formActionField.getDefaultValue(); if (defaultValue != null) { if (UIFormMultiValueInputSet.class.isInstance(uiInput)) { String[] arrDefaultValues = defaultValue.split(","); List<String> lstValues = new ArrayList<String>(); for (String itemDefaultValues : arrDefaultValues) { if (!lstValues.contains(itemDefaultValues.trim())) lstValues.add(itemDefaultValues.trim()); } ((UIFormMultiValueInputSet) uiInput).setValue(lstValues); } } } ((UIFormMultiValueInputSet)uiInput).setEditable(formActionField.isEditable()); if (node == null) { renderField(name); return; } } else { uiInput = findComponentById(name); if(uiInput == null) { isFirstTimeRender = true; uiInput = formActionField.createUIFormInput(); addUIFormInput((UIFormInput<?>)uiInput); } ((UIFormStringInput)uiInput).setReadOnly(!formActionField.isEditable()); } String propertyName = getPropertyName(jcrPath); propertiesName.put(name, propertyName); fieldNames.put(propertyName, name); if (node != null && !isShowingComponent && !isRemovePreference && !isRemoveActionField) { if (jcrPath.equals("/node") && (!formActionField.isEditable() || formActionField.isEditableIfNull())) { ((UIFormStringInput) uiInput).setDisabled(true); } } if (node != null && !isShowingComponent && !isRemovePreference && !isRemoveActionField && isFirstTimeRender) { if(jcrPath.equals("/node") && (!formActionField.isEditable() || formActionField.isEditableIfNull())) { ((UIFormStringInput)uiInput).setValue(node.getName()); } else if(node.hasProperty(propertyName) && !isUpdateSelect) { String relPath = ""; String itemRelPath = ""; if (node.getProperty(propertyName).getDefinition().isMultiple()) { StringBuffer buffer = new StringBuffer(); Value[] values = node.getProperty(propertyName).getValues(); if (UIFormStringInput.class.isInstance(uiInput)) { for (Value value : values) { buffer.append(value).append(","); } if (buffer.toString().endsWith(",")) buffer.deleteCharAt(buffer.length() - 1); ((UIFormStringInput) uiInput).setValue(buffer.toString()); } if (UIFormMultiValueInputSet.class.isInstance(uiInput)) { List<String> lstValues = new ArrayList<String>(); for (Value value : values) { lstValues.add(value.getString()); } ((UIFormMultiValueInputSet) uiInput).setValue(lstValues); } } else { String value = node.getProperty(propertyName).getValue().getString(); if (node.getProperty(propertyName).getDefinition().getRequiredType() == PropertyType.REFERENCE) value = getNodePathByUUID(value); ((UIFormStringInput) uiInput).setValue(value); } } } Node childNode = getChildNode(); if(isNotEditNode && !isShowingComponent && !isRemovePreference && !isRemoveActionField) { if(childNode != null) { ((UIFormInput<String>)uiInput).setValue(propertyName); } else if(childNode == null && jcrPath.equals("/node") && node != null) { ((UIFormInput<String>)uiInput).setValue(node.getName()); } else { ((UIFormInput<?>)uiInput).setValue(null); } } renderField(name); } public void addActionField(String name, String[] arguments) throws Exception { addActionField(name,null,arguments); } public void addCalendarField(String name, String label, String[] arguments) throws Exception { UIFormCalendarField calendarField = new UIFormCalendarField(name,label,arguments); String jcrPath = calendarField.getJcrPath(); JcrInputProperty inputProperty = new JcrInputProperty(); inputProperty.setJcrPath(jcrPath); inputProperty.setChangeInJcrPathParam(calendarField.getChangeInJcrPathParam()); setInputProperty(name, inputProperty); if(calendarField.isMultiValues()) { renderMultiValuesInput(UIFormDateTimeInput.class,name,label); return; } boolean isFirstTimeRender = false; UIFormDateTimeInput uiDateTime = findComponentById(name); if (uiDateTime == null) { isFirstTimeRender = true; uiDateTime = calendarField.createUIFormInput(); if (calendarField.validateType != null) { DialogFormUtil.addValidators(uiDateTime, calendarField.validateType); } if (isAddNew && uiDateTime.getCalendar() == null) { uiDateTime.setCalendar(new GregorianCalendar()); } } uiDateTime.setDisplayTime(calendarField.isDisplayTime()); String propertyName = getPropertyName(jcrPath); propertiesName.put(name, propertyName); fieldNames.put(propertyName, name); Node node = getNode(); uiDateTime.setCalendar(uiDateTime.getCalendar()); if(node != null && node.hasProperty(propertyName) && !isShowingComponent && !isRemovePreference) { if (isFirstTimeRender) uiDateTime.setCalendar(node.getProperty(propertyName).getDate()); } Node childNode = getChildNode(); if(isNotEditNode && !isShowingComponent && !isRemovePreference) { if(childNode != null) { if(childNode.hasProperty(propertyName)) { if(childNode.getProperty(propertyName).getDefinition().isMultiple()) { Value[] values = childNode.getProperty(propertyName).getValues(); for(Value value : values) { if (uiDateTime.getDefaultValue() == null) { uiDateTime.setCalendar(value.getDate()); uiDateTime.setDefaultValue(uiDateTime.getValue()); } } } else { uiDateTime.setCalendar(childNode.getProperty(propertyName).getValue().getDate()); } } } else if(childNode == null && jcrPath.equals("/node") && node != null) { uiDateTime.setCalendar(node.getProperty(propertyName).getDate()); } else { uiDateTime.setCalendar(new GregorianCalendar()); } }else{ if((node != null) && node.hasNode("jcr:content") && (childNode == null)) { Node jcrContentNode = node.getNode("jcr:content"); if(jcrContentNode.hasProperty(propertyName)) { if(jcrContentNode.getProperty(propertyName).getDefinition().isMultiple()) { Value[] values = jcrContentNode.getProperty(propertyName).getValues(); for(Value value : values) { if (uiDateTime.getDefaultValue() == null) { uiDateTime.setCalendar(value.getDate()); uiDateTime.setDefaultValue(uiDateTime.getValue()); } } }else{ uiDateTime.setCalendar(jcrContentNode.getProperty(propertyName).getValue().getDate()); } } } } if (findComponentById(name) == null) addUIFormInput(uiDateTime); if(calendarField.isVisible()) renderField(name); } public void addCalendarField(String name, String[] arguments) throws Exception { addCalendarField(name,null,arguments); } public void addHiddenField(String name, String[] arguments) throws Exception { UIFormHiddenField formHiddenField = new UIFormHiddenField(name,null,arguments); String jcrPath = formHiddenField.getJcrPath(); JcrInputProperty inputProperty = formHiddenField.createJcrInputProperty(); inputProperty.setJcrPath(jcrPath); inputProperty.setChangeInJcrPathParam(formHiddenField.getChangeInJcrPathParam()); inputProperty.setValue(formHiddenField.getDefaultValue()); if(formHiddenField.getMixinTypes() != null) inputProperty.setMixintype(formHiddenField.getMixinTypes()); if(formHiddenField.getNodeType() != null ) inputProperty.setNodetype(formHiddenField.getNodeType()); setInputProperty(name, inputProperty); } public void addInterceptor(String scriptPath, String type) { if(scriptPath.length() > 0 && type.length() > 0){ if(type.equals("prev") && !prevScriptInterceptor.contains(scriptPath)){ prevScriptInterceptor.add(scriptPath); } else if(type.equals("post") && !postScriptInterceptor.contains(scriptPath)){ postScriptInterceptor.add(scriptPath); } } } public void addMixinField(String name,String label,String[] arguments) throws Exception { UIMixinField mixinField = new UIMixinField(name,label,arguments); String jcrPath = mixinField.getJcrPath(); String nodetype = mixinField.getNodeType(); String mixintype = mixinField.getMixinTypes(); JcrInputProperty inputProperty = new JcrInputProperty(); inputProperty.setJcrPath(jcrPath); inputProperty.setChangeInJcrPathParam(mixinField.getChangeInJcrPathParam()); if (nodetype != null || mixintype != null) { inputProperty.setType(JcrInputProperty.NODE); if(nodetype != null) inputProperty.setNodetype(nodetype); if(mixintype != null) inputProperty.setMixintype(mixintype); } setInputProperty(name, inputProperty); Node node = getNode(); if(node != null && mixinField.isVisibleIfNotNull()) { UIFormStringInput uiMixin = findComponentById(name); if(uiMixin == null) { uiMixin = mixinField.createUIFormInput(); uiMixin.setValue(node.getName()); addUIFormInput(uiMixin); } else uiMixin.setValue(node.getName()); uiMixin.setReadOnly(true); renderField(name); } } public void addMixinField(String name, String[] arguments) throws Exception { addMixinField(name,null,arguments); } public void addCheckBoxField(String name, String lable, String[] arguments) throws Exception{ UIFormCheckBoxField formCheckBoxField = new UIFormCheckBoxField(name, lable, arguments); String jcrPath = formCheckBoxField.getJcrPath(); String defaultValue = formCheckBoxField.getDefaultValue(); if (defaultValue == null) defaultValue = "false"; JcrInputProperty inputProperty = new JcrInputProperty(); inputProperty.setJcrPath(jcrPath); inputProperty.setChangeInJcrPathParam(formCheckBoxField.getChangeInJcrPathParam()); setInputProperty(name, inputProperty); String propertyName = getPropertyName(jcrPath); propertiesName.put(name, propertyName); fieldNames.put(propertyName, name); Node node = getNode(); Node childNode = getChildNode(); UICheckBoxInput uiCheckBoxInput = findComponentById(name); boolean isFirstTimeRender = false; if(uiCheckBoxInput == null || isResetForm ){ isFirstTimeRender = true; uiCheckBoxInput = new UICheckBoxInput(name, name, null); if (defaultValue != null) { uiCheckBoxInput.setValue(Boolean.parseBoolean(defaultValue)); uiCheckBoxInput.setChecked(Boolean.parseBoolean(defaultValue)); } } if (node != null && node.hasProperty(propertyName) && isFirstTimeRender) { uiCheckBoxInput.setValue(Boolean.parseBoolean(node.getProperty(propertyName).getValue().toString())); uiCheckBoxInput.setChecked(node.getProperty(propertyName).getValue().getBoolean()); }else if( childNode != null && childNode.hasProperty(propertyName) && isFirstTimeRender){ uiCheckBoxInput.setValue(Boolean.parseBoolean(childNode.getProperty(propertyName).getValue().toString())); uiCheckBoxInput.setChecked(childNode.getProperty(propertyName).getValue().getBoolean()); } if (formCheckBoxField.validateType != null) { DialogFormUtil.addValidators(uiCheckBoxInput, formCheckBoxField.validateType); } if(formCheckBoxField.isOnchange()){ uiCheckBoxInput.setOnChange("Onchange"); uiCheckBoxInput.setValue(uiCheckBoxInput.getValue()); } removeChildById(name); addUIFormInput(uiCheckBoxInput); renderField(name); } public void addCheckBoxField(String name, String[] arguments) throws Exception{ addCheckBoxField(name, null, arguments); } public void addRadioBoxField(String name, String label, String[] arguments) throws Exception{ UIFormRadioBoxField formRadioBoxField = new UIFormRadioBoxField(name, label, arguments); String jcrPath = formRadioBoxField.getJcrPath(); String options = formRadioBoxField.getOptions(); String defaultValue = formRadioBoxField.getDefaultValue(); List<SelectItemOption<String>> optionsList = new ArrayList<SelectItemOption<String>>(); UIFormRadioBoxInput uiRadioBox = findComponentById(name); boolean isFirstTimeRender = false; if(uiRadioBox == null){ isFirstTimeRender = true; uiRadioBox = new UIFormRadioBoxInput(name, defaultValue, null); if(options != null && options.length() > 0){ String[] array = options.split(";"); for(int i = 0; i < array.length; i++) { String[] arrayChild = array[i].trim().split(","); for(int j=0; j<arrayChild.length; j++) { optionsList.add(new SelectItemOption<String>(arrayChild[j], arrayChild[j])); } } uiRadioBox.setOptions(optionsList); } else { uiRadioBox.setOptions(optionsList); } if(defaultValue != null) uiRadioBox.setDefaultValue(defaultValue); } addUIFormInput(uiRadioBox); String propertyName = getPropertyName(jcrPath); propertiesName.put(name, propertyName); fieldNames.put(propertyName, name); JcrInputProperty inputProperty = new JcrInputProperty(); inputProperty.setJcrPath(jcrPath); inputProperty.setChangeInJcrPathParam(formRadioBoxField.getChangeInJcrPathParam()); setInputProperty(name, inputProperty); Node node = getNode(); Node childNode = getChildNode(); if(childNode != null) { if(childNode.hasProperty(propertyName) && isFirstTimeRender) { uiRadioBox.setValue(childNode.getProperty(propertyName).getValue().getString()); } } else { if(node != null && node.hasProperty(propertyName) && isFirstTimeRender) { uiRadioBox.setValue(node.getProperty(propertyName).getString()); } } if(isNotEditNode) { Node child = getChildNode(); if(child != null && child.hasProperty(propertyName) && isFirstTimeRender) { uiRadioBox.setValue(DialogFormUtil.getPropertyValueAsString(child,propertyName)); } } renderField(name); } public void addRadioBoxField(String name, String[] arguments) throws Exception{ addRadioBoxField(name, null, arguments); } public void addSelectBoxField(String name, String label, String[] arguments) throws Exception { UIFormSelectBoxField formSelectBoxField = new UIFormSelectBoxField(name,label,arguments); String jcrPath = formSelectBoxField.getJcrPath(); String editable = formSelectBoxField.getEditable(); String onchange = formSelectBoxField.getOnchange(); String defaultValue = formSelectBoxField.getDefaultValue(); String options = formSelectBoxField.getOptions(); String script = formSelectBoxField.getGroovyScript(); if (editable == null) formSelectBoxField.setEditable("true"); List<SelectItemOption<String>> optionsList = new ArrayList<SelectItemOption<String>>(); UIFormSelectBox uiSelectBox = findComponentById(name); boolean isFirstTimeRender = false; if (uiSelectBox == null || isResetForm) { isFirstTimeRender = true; uiSelectBox = new UIFormSelectBox(name, name, null); if (script != null) { try { String[] scriptParams = formSelectBoxField.getScriptParams(); executeScript(script, uiSelectBox, scriptParams, true); } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error("An unexpected error occurs", e); } uiSelectBox.setOptions(optionsList); } } else if (options != null && options.length() >0) { String[] array = options.split(","); RequestContext context = RequestContext.getCurrentInstance(); ResourceBundle res = context.getApplicationResourceBundle(); String optionLabel; for(int i = 0; i < array.length; i++) { List<String> listValue = new ArrayList<String>(); String[] arrayChild = array[i].trim().split(SEPARATOR_VALUE); for (int j = 0; j < arrayChild.length; j++) { if (!arrayChild[j].trim().equals("")) { listValue.add(arrayChild[j].trim()); } } try { String tagName = listValue.get(0).replaceAll(" ", "-"); optionLabel = res.getString(tagName); } catch (MissingResourceException e) { optionLabel = listValue.get(0); } if (listValue.size() > 1) { optionsList.add(new SelectItemOption<String>(optionLabel, listValue.get(1))); } else { optionsList.add(new SelectItemOption<String>(optionLabel, listValue.get(0))); } } uiSelectBox.setOptions(optionsList); } else { uiSelectBox.setOptions(optionsList); } if(defaultValue != null) uiSelectBox.setValue(defaultValue); } propertiesName.put(name, getPropertyName(jcrPath)); fieldNames.put(getPropertyName(jcrPath), name); if (formSelectBoxField.validateType != null) { DialogFormUtil.addValidators(uiSelectBox, formSelectBoxField.validateType); } String[] arrNodes = jcrPath.split("/"); Node childNode = null; Node node = getNode(); String propertyName = getPropertyName(jcrPath); if(node != null && arrNodes.length == 4) childNode = node.getNode(arrNodes[2]); if (formSelectBoxField.isMultiValues()) { if (formSelectBoxField.getSize() != null && StringUtils.isAlphanumeric(formSelectBoxField.getSize())) { uiSelectBox.setSize(Integer.parseInt(formSelectBoxField.getSize())); } uiSelectBox.setMultiple(true); StringBuffer buffer = new StringBuffer(); if((childNode != null) && isFirstTimeRender && childNode.hasProperty(propertyName)) { List<String> valueList = new ArrayList<String>(); Value[] values = childNode.getProperty(propertyName).getValues(); for(Value value : values) { buffer.append(value.getString()).append(","); } uiSelectBox.setSelectedValues(StringUtils.split(buffer.toString(), ",")); } else { if(node != null && isFirstTimeRender && node.hasProperty(propertyName)) { List<String> valueList = new ArrayList<String>(); if (node.getProperty(propertyName).getDefinition().isMultiple() && (!"true".equals(onchange) || !isOnchange)) { Value[] values = node.getProperty(propertyName).getValues(); for(Value value : values) { buffer.append(value.getString()).append(","); } } else if("true".equals(onchange) && isOnchange) { if (uiSelectBox.isMultiple()) { String[] values = uiSelectBox.getSelectedValues(); for (String value : values) { buffer.append(value).append(","); } } else { String values = uiSelectBox.getValue(); buffer.append(values).append(","); } } else { Value[] values = node.getProperty(propertyName).getValues(); for(Value value : values) { buffer.append(value.getString()).append(","); } } uiSelectBox.setSelectedValues(StringUtils.split(buffer.toString(), ",")); } } } else { if ((childNode != null) && isFirstTimeRender && childNode.hasProperty(propertyName)) { uiSelectBox.setValue(childNode.getProperty(propertyName).getValue().getString()); } else { if (node != null && node.hasProperty(propertyName)) { if (node.getProperty(propertyName).getDefinition().isMultiple()) { if (findComponentById(name) == null) uiSelectBox.setValue(node.getProperty(propertyName).getValues().toString()); } else if (formSelectBoxField.isOnchange() && isOnchange) { uiSelectBox.setValue(uiSelectBox.getValue()); } else { if (findComponentById(name) == null) uiSelectBox.setValue(node.getProperty(propertyName).getValue().getString()); } } } } uiSelectBox.setReadOnly(!formSelectBoxField.isEditable()); // addUIFormInput(uiSelectBox); if(isNotEditNode) { Node child = getChildNode(); if(child != null && child.hasProperty(propertyName)) { if(child.getProperty(propertyName).getDefinition().isMultiple()) { Value[] values = child.getProperty(propertyName).getValues(); List<String> listValues = new ArrayList<String>(); for(Value value : values) { listValues.add(value.getString()); } uiSelectBox.setSelectedValues(listValues.toArray(new String[listValues.size()])); } else { uiSelectBox.setValue(DialogFormUtil.getPropertyValueAsString(child,propertyName)); } } } if(formSelectBoxField.isOnchange()) uiSelectBox.setOnChange("Onchange"); if (findComponentById(name) == null) addUIFormInput(uiSelectBox); StringBuilder newValues = new StringBuilder(); int count = 0; for (String v : ((UIFormSelectBox)findComponentById(name)).getSelectedValues()) { if (count++ > 0) newValues.append(","); newValues.append(v); } String newValue = newValues.toString(); JcrInputProperty inputProperty = properties.get(name); if (inputProperty== null) { inputProperty = new JcrInputProperty(); inputProperty.setJcrPath(jcrPath); inputProperty.setChangeInJcrPathParam(formSelectBoxField.getChangeInJcrPathParam()); setInputProperty(name, inputProperty); } else { if (inputProperty.getValue() != null) { String oldValue = inputProperty.getValue().toString(); if ((oldValue != null) && (!oldValue.equals(newValue))) { Iterator<String> componentSelector = componentSelectors.keySet().iterator(); Map<String, String> obj = null; while (componentSelector.hasNext()) { String componentName = componentSelector.next(); obj = (Map<String, String>) componentSelectors.get(componentName); Set<String> set = obj.keySet(); for (String key : set) { if (name.equals(obj.get(key))) { UIComponent uiInput = findComponentById(componentName); ((UIFormStringInput) uiInput).reset(); } } } } } } inputProperty.setValue(newValue); if (isUpdateSelect && newValue != null) { String[] values1 = newValue.split(","); uiSelectBox.setSelectedValues(values1); } renderField(name); } public void addSelectBoxField(String name, String[] arguments) throws Exception { addSelectBoxField(name,null,arguments); } public void addTextAreaField(String name, String label, String[] arguments) throws Exception { UIFormTextAreaField formTextAreaField = new UIFormTextAreaField(name,label,arguments); if(formTextAreaField.useSelector()) { componentSelectors.put(name, formTextAreaField.getSelectorInfo()); } String jcrPath = formTextAreaField.getJcrPath(); JcrInputProperty inputProperty = new JcrInputProperty(); inputProperty.setJcrPath(jcrPath); inputProperty.setChangeInJcrPathParam(formTextAreaField.getChangeInJcrPathParam()); setInputProperty(name, inputProperty); String option = formTextAreaField.getOptions(); setInputOption(name, option); String propertyName = getPropertyName(jcrPath); propertiesName.put(name, propertyName); fieldNames.put(propertyName, name); Node node = getNode(); Node childNode = getChildNode(); boolean isFirstTimeRender = false; if(formTextAreaField.isMultiValues()) { UIFormMultiValueInputSet uiMulti; if(node == null && childNode == null) { uiMulti = findComponentById(name); if(uiMulti == null) { isFirstTimeRender = true; uiMulti = createUIComponent(UIFormMultiValueInputSet.class, null, null); uiMulti.setId(name); uiMulti.setName(name); uiMulti.setType(UIFormTextAreaInput.class); uiMulti.setEditable(formTextAreaField.isEditable()); if (formTextAreaField.validateType != null) { String validateType = formTextAreaField.validateType; String[] validatorList = null; if (validateType.indexOf(',') > -1) validatorList = validateType.split(","); else validatorList = new String[] {validateType}; for (String validator : validatorList) { Object[] params; String s_param=null; int p_begin, p_end; p_begin = validator.indexOf(DialogFormUtil.VALIDATOR_PARAM_BEGIN); p_end = validator.indexOf(DialogFormUtil.VALIDATOR_PARAM_END); if (p_begin>=0 && p_end > p_begin) { s_param = validator.substring(p_begin, p_end); params = s_param.split(DialogFormUtil.VALIDATOR_PARAM_SEPERATOR); uiMulti.addValidator(DialogFormUtil.getValidator(validator.trim()), params) ; }else { uiMulti.addValidator(DialogFormUtil.getValidator(validator.trim())) ; } } } List<String> valueList = new ArrayList<String>(); List<UIComponent> listChildren = uiMulti.getChildren(); if (listChildren.size() == 0) { valueList.add(formTextAreaField.getDefaultValue()); } else { for (UIComponent component : listChildren) { UIFormTextAreaInput uiTextAreaInput = (UIFormTextAreaInput)component; if(uiTextAreaInput.getValue() != null) { valueList.add(uiTextAreaInput.getValue().trim()); } else{ valueList.add(formTextAreaField.getDefaultValue()); } } } uiMulti.setValue(valueList); addUIFormInput(uiMulti); } } else { uiMulti = createUIComponent(UIFormMultiValueInputSet.class, null, null); isFirstTimeRender = true; uiMulti.setId(name); uiMulti.setName(name); uiMulti.setType(UIFormTextAreaInput.class); uiMulti.setEditable(formTextAreaField.isEditable()); if (formTextAreaField.validateType != null) { String validateType = formTextAreaField.validateType; String[] validatorList = null; if (validateType.indexOf(',') > -1) validatorList = validateType.split(","); else validatorList = new String[] { validateType }; for (String validator : validatorList) { Object[] params; String s_param = null; int p_begin, p_end; p_begin = validator.indexOf(DialogFormUtil.VALIDATOR_PARAM_BEGIN); p_end = validator.indexOf(DialogFormUtil.VALIDATOR_PARAM_END); if (p_begin >= 0 && p_end > p_begin) { s_param = validator.substring(p_begin, p_end); params = s_param.split(DialogFormUtil.VALIDATOR_PARAM_SEPERATOR); uiMulti.addValidator(DialogFormUtil.getValidator(validator.trim()), params); } else { uiMulti.addValidator(DialogFormUtil.getValidator(validator.trim())); } } } addUIFormInput(uiMulti); } List<String> valueList = new ArrayList<String>(); boolean valueListIsSet = false; if((node != null) && node.hasNode("jcr:content") && (childNode == null)) { Node jcrContentNode = node.getNode("jcr:content"); if(jcrContentNode.hasProperty(propertyName)) { Value[] values = jcrContentNode.getProperty(propertyName).getValues(); for(Value value : values) { valueList.add(value.getString()); } uiMulti.setEditable(formTextAreaField.isEditable()); uiMulti.setValue(valueList); valueListIsSet = true; } } else { if(childNode != null) { if(childNode.hasProperty(propertyName)) { Value[] values = childNode.getProperty(propertyName).getValues(); for(Value value : values) { valueList.add(value.getString()); } uiMulti.setEditable(formTextAreaField.isEditable()); uiMulti.setValue(valueList); valueListIsSet = true; } } } if (!valueListIsSet && node != null && !isShowingComponent && !isRemovePreference && isFirstTimeRender) { String propertyPath = jcrPath.substring("/node/".length()); if (node.hasProperty(propertyPath)) { Value[] values = node.getProperty(propertyPath).getValues(); // if the node type is mix:referenceable, its values will contain the UUIDs of the reference nodes // we need to get the paths of the reference nodes instead of its UUIDs to display onto screen if (node.getProperty(propertyPath).getType() == PropertyType.REFERENCE) { for (Value vl : values) { if (vl != null) { String strUUID = vl.getString(); try { String strReferenceableNodePath = node.getSession().getNodeByUUID(strUUID).getPath(); //if the referenceable node is not ROOT, remove the "/" character at head if (strReferenceableNodePath.length() > 1){ strReferenceableNodePath = strReferenceableNodePath.substring(1); } valueList.add(strReferenceableNodePath); } catch (ItemNotFoundException infEx) { valueList.add(formTextAreaField.getDefaultValue()); } catch (RepositoryException repoEx) { valueList.add(formTextAreaField.getDefaultValue()); } } } } else { for (Value vl : values) { if (vl != null) { valueList.add(vl.getString()); } } } } uiMulti.setValue(valueList); } if(isResetMultiField) { uiMulti.setValue(new ArrayList<Value>()); } uiMulti.setEditable(formTextAreaField.isEditable()); renderField(name); return; } UIFormTextAreaInput uiTextArea = findComponentById(name); if(uiTextArea == null) { isFirstTimeRender = true; uiTextArea = formTextAreaField.createUIFormInput(); if(formTextAreaField.getRowSize() != null){ uiTextArea.setRows(Integer.parseInt(formTextAreaField.getRowSize())); } else { uiTextArea.setRows(UIFormTextAreaField.DEFAULT_ROW); } if(formTextAreaField.getColSize() != null){ uiTextArea.setColumns(Integer.parseInt(formTextAreaField.getColSize())); } else { uiTextArea.setColumns(UIFormTextAreaField.DEFAULT_COL); } addUIFormInput(uiTextArea); } if (node != null && !isShowingComponent && !isRemovePreference && isFirstTimeRender) { StringBuffer value = new StringBuffer(); if (node.hasProperty(propertyName)) { value.append(node.getProperty(propertyName).getValue().getString()); uiTextArea.setValue(value.toString()); } else if (node.isNodeType("nt:file")) { Node jcrContentNode = node.getNode("jcr:content"); if (jcrContentNode.hasProperty(propertyName)) { if (jcrContentNode.getProperty(propertyName).getDefinition().isMultiple()) { Value[] values = jcrContentNode.getProperty(propertyName).getValues(); for (Value v : values) { value.append(v.getString()); } uiTextArea.setValue(value.toString()); } else { uiTextArea.setValue(jcrContentNode.getProperty(propertyName).getValue().getString()); } } } } if (isNotEditNode && !isShowingComponent && !isRemovePreference && isFirstTimeRender) { if (node != null && node.hasNode("jcr:content") && childNode != null) { Node jcrContentNode = node.getNode("jcr:content"); uiTextArea.setValue(jcrContentNode.getProperty("jcr:data").getValue().getString()); } else { if (childNode != null) { uiTextArea.setValue(propertyName); } else if (childNode == null && jcrPath.equals("/node") && node != null) { uiTextArea.setValue(node.getName()); } else { uiTextArea.setValue(null); } } } //set default value for textarea if no value was set by above code if (uiTextArea.getValue() == null) { if (formTextAreaField.getDefaultValue() != null) uiTextArea.setValue(formTextAreaField.getDefaultValue()); else uiTextArea.setValue(""); } uiTextArea.setReadOnly(!formTextAreaField.isEditable()); renderField(name); } public void addTextAreaField(String name, String[] arguments) throws Exception { addTextAreaField(name,null,arguments); } public String getPathTaxonomy() throws Exception { NodeHierarchyCreator nodeHierarchyCreator = getApplicationComponent(NodeHierarchyCreator.class); DMSConfiguration dmsConfiguration = getApplicationComponent(DMSConfiguration.class); String workspace = dmsConfiguration.getConfig().getSystemWorkspace(); String userName = Util.getPortalRequestContext().getRemoteUser(); Session session; if (userName != null) session = WCMCoreUtils.getUserSessionProvider().getSession(workspace, getRepository()); else session = WCMCoreUtils.createAnonimProvider().getSession(workspace, getRepository()); return ((Node)session.getItem(nodeHierarchyCreator.getJcrPath(BasePath.TAXONOMIES_TREE_STORAGE_PATH))).getPath(); } @SuppressWarnings("unchecked") public void addTextField(String name, String label, String[] arguments) throws Exception { UIFormTextField formTextField = new UIFormTextField(name,label,arguments); String jcrPath = formTextField.getJcrPath(); String mixintype = formTextField.getMixinTypes(); String nodetype = formTextField.getNodeType(); JcrInputProperty inputProperty = new JcrInputProperty(); inputProperty.setJcrPath(jcrPath); inputProperty.setChangeInJcrPathParam(formTextField.getChangeInJcrPathParam()); setInputProperty(name, inputProperty); String option = formTextField.getOptions(); setInputOption(name, option); String propertyName = getPropertyName(jcrPath); if(mixintype != null) inputProperty.setMixintype(mixintype); if(jcrPath.equals("/node") && nodetype != null ) inputProperty.setNodetype(nodetype); properties.put(name, inputProperty); propertiesName.put(name, propertyName); fieldNames.put(propertyName, name); Node node = getNode(); Node childNode = getChildNode(); if(!isReference) { if(formTextField.isReference()) isReference = true; else isReference = false; } boolean isFirstTimeRender = false; if(formTextField.isMultiValues()) { UIFormMultiValueInputSet uiMulti; if(node == null &&childNode == null) { uiMulti = findComponentById(name); if(uiMulti == null) { isFirstTimeRender = true; uiMulti = createUIComponent(UIFormMultiValueInputSet.class, null, null); uiMulti.setId(name); uiMulti.setName(name); uiMulti.setType(UIFormStringInput.class); uiMulti.setEditable(formTextField.isEditable()); if (formTextField.validateType != null) { String validateType = formTextField.validateType; String[] validatorList = null; if (validateType.indexOf(',') > -1) validatorList = validateType.split(","); else validatorList = new String[] {validateType}; for (String validator : validatorList) { Object[] params; String s_param=null; int p_begin, p_end; p_begin = validator.indexOf(DialogFormUtil.VALIDATOR_PARAM_BEGIN); p_end = validator.indexOf(DialogFormUtil.VALIDATOR_PARAM_END); if (p_begin>=0 && p_end > p_begin) { s_param = validator.substring(p_begin, p_end); params = s_param.split(DialogFormUtil.VALIDATOR_PARAM_SEPERATOR); uiMulti.addValidator(DialogFormUtil.getValidator(validator.trim()), params) ; }else { uiMulti.addValidator(DialogFormUtil.getValidator(validator.trim())) ; } } } List<String> valueList = new ArrayList<String>(); List<UIComponent> listChildren = uiMulti.getChildren(); if (listChildren.size() == 0) { valueList.add(formTextField.getDefaultValue()); } else { for (UIComponent component : listChildren) { UIFormStringInput uiStringInput = (UIFormStringInput)component; if(uiStringInput.getValue() != null) { valueList.add(uiStringInput.getValue().trim()); } else{ valueList.add(formTextField.getDefaultValue()); } } } uiMulti.setValue(valueList); addUIFormInput(uiMulti); } } else { uiMulti = createUIComponent(UIFormMultiValueInputSet.class, null, null); isFirstTimeRender = true; uiMulti.setId(name); uiMulti.setName(name); uiMulti.setType(UIFormStringInput.class); uiMulti.setEditable(formTextField.isEditable()); if (formTextField.validateType != null) { String validateType = formTextField.validateType; String[] validatorList = null; if (validateType.indexOf(',') > -1) validatorList = validateType.split(","); else validatorList = new String[] {validateType}; for (String validator : validatorList) { Object[] params; String s_param=null; int p_begin, p_end; p_begin = validator.indexOf(DialogFormUtil.VALIDATOR_PARAM_BEGIN); p_end = validator.indexOf(DialogFormUtil.VALIDATOR_PARAM_END); if (p_begin>=0 && p_end > p_begin) { s_param = validator.substring(p_begin, p_end); params = s_param.split(DialogFormUtil.VALIDATOR_PARAM_SEPERATOR); uiMulti.addValidator(DialogFormUtil.getValidator(validator.trim()), params) ; }else { uiMulti.addValidator(DialogFormUtil.getValidator(validator.trim())) ; } } } if (getChildById(name) == null) addUIFormInput(uiMulti); } List<String> valueList = new ArrayList<String>(); boolean valueListIsSet = false; if((node != null) && node.hasNode("jcr:content") && (childNode == null)) { Node jcrContentNode = node.getNode("jcr:content"); if(jcrContentNode.hasProperty(propertyName)) { Value[] values = jcrContentNode.getProperty(propertyName).getValues(); for(Value value : values) { valueList.add(value.getString()); } uiMulti.setEditable(formTextField.isEditable()); uiMulti.setValue(valueList); valueListIsSet = true; } } else { if(childNode != null) { if(childNode.hasProperty(propertyName)) { Value[] values = childNode.getProperty(propertyName).getValues(); for(Value value : values) { valueList.add(value.getString()); } uiMulti.setEditable(formTextField.isEditable()); uiMulti.setValue(valueList); valueListIsSet = true; } } } if (!valueListIsSet && node != null && !isShowingComponent && !isRemovePreference && isFirstTimeRender) { String propertyPath = jcrPath.substring("/node/".length()); if (node.hasProperty(propertyPath)) { Value[] values = node.getProperty(propertyPath).getValues(); // if the node type is mix:referenceable, its values will contain the UUIDs of the reference nodes // we need to get the paths of the reference nodes instead of its UUIDs to display onto screen if (node.getProperty(propertyPath).getType() == PropertyType.REFERENCE) { for (Value vl : values) { if (vl != null) { String strUUID = vl.getString(); try { String strReferenceableNodePath = node.getSession().getNodeByUUID(strUUID).getPath(); //if the referenceable node is not ROOT, remove the "/" character at head if (strReferenceableNodePath.length() > 1){ strReferenceableNodePath = strReferenceableNodePath.substring(1); } valueList.add(strReferenceableNodePath); } catch (ItemNotFoundException infEx) { valueList.add(formTextField.getDefaultValue()); } catch (RepositoryException repoEx) { valueList.add(formTextField.getDefaultValue()); } } } } else { for (Value vl : values) { if (vl != null) { valueList.add(vl.getString()); } } } } uiMulti.setValue(valueList); } if(isResetMultiField) { uiMulti.setValue(new ArrayList<Value>()); } uiMulti.setEditable(formTextField.isEditable()); renderField(name); return; } UIFormStringInput uiInput = findComponentById(name); if(uiInput == null) { isFirstTimeRender = true; uiInput = formTextField.createUIFormInput(); addUIFormInput(uiInput); } uiInput.setReadOnly(!formTextField.isEditable()); if(uiInput.getValue() == null) uiInput.setValue(formTextField.getDefaultValue()); else uiInput.setReadOnly(false); if(node != null && !isShowingComponent && !isRemovePreference) { if(jcrPath.equals("/node") && (!formTextField.isEditable() || formTextField.isEditableIfNull())) { uiInput.setDisabled(true); } } if(node != null && !isShowingComponent && !isRemovePreference && isFirstTimeRender) { if(jcrPath.equals("/node") && (!formTextField.isEditable() || formTextField.isEditableIfNull())) { String value = uiInput.getValue(); if(i18nNodePath != null) { uiInput.setValue(i18nNodePath.substring(i18nNodePath.lastIndexOf("/") + 1)); } else { String nameValue = node.getPath().substring(node.getPath().lastIndexOf("/") + 1); uiInput.setValue(URLDecoder.decode(URLDecoder.decode(nameValue))); } } else if(node.hasProperty(propertyName)) { uiInput.setValue(node.getProperty(propertyName).getValue().getString()); } } if(isNotEditNode && !isShowingComponent && !isRemovePreference) { if(childNode != null && childNode.hasProperty(propertyName)) { if(childNode.hasProperty(propertyName)) { uiInput.setValue(childNode.getProperty(propertyName).getValue().getString()); } } else if(childNode == null && jcrPath.equals("/node") && node != null) { uiInput.setValue(node.getName()); } else if(i18nNodePath != null && jcrPath.equals("/node")) { uiInput.setValue(i18nNodePath.substring(i18nNodePath.lastIndexOf("/") + 1)); } else { uiInput.setValue(formTextField.getDefaultValue()); } } renderField(name); } public void addTextField(String name, String[] arguments) throws Exception { addTextField(name,null,arguments); } public void addUploadField(String name,String label,String[] arguments) throws Exception { UIFormUploadField formUploadField = new UIFormUploadField(name,label,arguments); String mimeTypes = formUploadField.getMimeTypes(); String jcrPath = formUploadField.getJcrPath(); JcrInputProperty inputProperty = new JcrInputProperty(); inputProperty.setJcrPath(jcrPath); inputProperty.setChangeInJcrPathParam(formUploadField.getChangeInJcrPathParam()); setInputProperty(name, inputProperty); String option = formUploadField.getOptions(); setInputOption(name, option); setMultiPart(true); String propertyName = getPropertyName(jcrPath); properties.put(name, inputProperty); propertiesName.put(name, propertyName); fieldNames.put(propertyName, name); Node node = getNode(); if(formUploadField.isMultiValues()) { UIFormMultiValueInputSet multiValueField = getChildById(name); if (multiValueField == null) { String propertyPath = jcrPath.substring("/node/".length()); if (node != null && node.hasNode(propertyPath)) { multiValueField = createUIComponent(UIFormUploadMultiValueInputSet.class, null, null); multiValueField.setId(name); multiValueField.setName(name); multiValueField.setType(UIFormUploadInputNoUploadButton.class); addUIFormInput(multiValueField); NodeIterator nodeIter = node.getNode(propertyPath).getNodes(); int count = 0; while (nodeIter.hasNext()) { Node childNode = nodeIter.nextNode(); if (!childNode.isNodeType(NodetypeConstant.NT_FILE)) continue; UIFormInputBase<?> uiInput = multiValueField.createUIFormInput(count++); ((UIFormUploadInputNoUploadButton)uiInput).setFileName(childNode.getName()); Value value = childNode.getNode(NodetypeConstant.JCR_CONTENT).getProperty(NodetypeConstant.JCR_DATA).getValue(); ((UIFormUploadInputNoUploadButton)uiInput).setByteValue( IOUtil.getStreamContentAsBytes(value.getStream())); } if(label != null) multiValueField.setLabel(label); multiValueField.setType(UIFormUploadInputNoRemoveButton.class); renderField(name); return; } multiValueField = renderMultiValuesInput(UIFormUploadInputNoRemoveButton.class,name,label); if (mimeTypes != null) { multiValueField.addValidator(UploadFileMimeTypesValidator.class, mimeTypes); } return; } } else { UIUploadInput uiInputUpload = findComponentById(name); if(uiInputUpload == null) { uiInputUpload = formUploadField.createUIFormInput(); if (mimeTypes != null) { uiInputUpload.addValidator(UploadFileMimeTypesValidator.class, mimeTypes); } addUIFormInput(uiInputUpload); } } renderField(name); } public void addUploadField(String name, String[] arguments) throws Exception { addUploadField(name,null,arguments); } public void addWYSIWYGField(String name, String label, String[] arguments) throws Exception { UIFormWYSIWYGField formWYSIWYGField = new UIFormWYSIWYGField(name,label,arguments); String jcrPath = formWYSIWYGField.getJcrPath(); JcrInputProperty inputProperty = new JcrInputProperty(); inputProperty.setJcrPath(jcrPath); inputProperty.setChangeInJcrPathParam(formWYSIWYGField.getChangeInJcrPathParam()); setInputProperty(name, inputProperty); String option = formWYSIWYGField.getOptions(); setInputOption(name, option); String propertyName = getPropertyName(jcrPath); propertiesName.put(name, propertyName); fieldNames.put(propertyName, name); List<UIFormInputBase<String>> wysiwygList = getUIFormInputList(name, formWYSIWYGField, false); if(formWYSIWYGField.isMultiValues()) { UIFormMultiValueInputSet uiMulti = findComponentById(name); if (uiMulti == null) { uiMulti = createUIComponent(UIFormMultiValueInputSet.class, WYSIWYG_MULTI_ID, null); this.uiMultiValueParam.put(name, arguments); uiMulti.setId(name); uiMulti.setName(name); uiMulti.setType(UIFormWYSIWYGInput.class); for (int i = 0; i < wysiwygList.size(); i++) { uiMulti.addChild(wysiwygList.get(i)); wysiwygList.get(i).setId(name + i); wysiwygList.get(i).setName(name + i); } addUIFormInput(uiMulti); if(label != null) uiMulti.setLabel(label); } } else { if (wysiwygList.size() > 0) addUIFormInput(wysiwygList.get(0)); } renderField(name); } @SuppressWarnings("unchecked") private List<UIFormInputBase<String>> getUIFormInputList(String name, DialogFormField formField, boolean isCreateNew) throws Exception { String jcrPath = formField.getJcrPath(); String propertyName = getPropertyName(jcrPath); List<UIFormInputBase<String>> ret = new ArrayList<UIFormInputBase<String>>(); UIFormInputBase<String> formInput = formField.isMultiValues() ? null : (UIFormInputBase<String>)findComponentById(name); boolean isFirstTimeRender = false; if(formInput == null) { isFirstTimeRender = true; formInput = formField.createUIFormInput(); } /** * Broadcast some info about current node by FCKEditorConfig Object * FCKConfigService used to allow add custom config for fckeditor from service * */ FCKEditorConfig config = new FCKEditorConfig(); FCKEditorContext editorContext = new FCKEditorContext(); if(repositoryName != null) { config.put("repositoryName",repositoryName); editorContext.setRepository(repositoryName); } if(workspaceName != null) { config.put("workspaceName",workspaceName); editorContext.setWorkspace(workspaceName); } if(nodePath != null) { config.put("jcrPath",nodePath); editorContext.setCurrentNodePath(nodePath); }else { config.put("jcrPath",storedPath); editorContext.setCurrentNodePath(storedPath); } FCKConfigService fckConfigService = getApplicationComponent(FCKConfigService.class); editorContext.setPortalName(Util.getUIPortal().getName()); editorContext.setSkinName(Util.getUIPortalApplication().getSkin()); fckConfigService.processFCKEditorConfig(config,editorContext); if (formInput instanceof UIFormWYSIWYGInput) ((UIFormWYSIWYGInput)formInput).setFCKConfig(config); if(formInput.getValue() == null) formInput.setValue(formField.getDefaultValue()); Node node = getNode(); if (isCreateNew) { ret.add(formInput); return ret; } if (!formField.isMultiValues() && isFirstTimeRender) { if(!isShowingComponent && !isRemovePreference) { if(node != null && (node.isNodeType("nt:file") || isNTFile) && formField.isFillJcrDataFile()) { Node jcrContentNode = node.getNode("jcr:content"); formInput.setValue(jcrContentNode.getProperty("jcr:data").getValue().getString()); } else { if(node != null && node.hasProperty(propertyName)) { formInput.setValue(node.getProperty(propertyName).getValue().getString()); } } } if(isNotEditNode && !isShowingComponent && !isRemovePreference && isFirstTimeRender) { Node childNode = getChildNode(); if(node != null && node.hasNode("jcr:content") && childNode != null && formField.isFillJcrDataFile()) { Node jcrContentNode = node.getNode("jcr:content"); formInput.setValue(jcrContentNode.getProperty("jcr:data").getValue().getString()); } else { if(childNode != null) { formInput.setValue(propertyName); } else if(childNode == null && jcrPath.equals("/node") && node != null) { formInput.setValue(node.getName()); } else { formInput.setValue(null); } } } ret.add(formInput); return ret; } Value[] values = null; if(!isShowingComponent && !isRemovePreference && isFirstTimeRender) { if(node != null && node.hasProperty(propertyName)) { values = node.getProperty(propertyName).getValues(); } } if(isNotEditNode && !isShowingComponent && !isRemovePreference && isFirstTimeRender) { Node childNode = getChildNode(); if(childNode != null) { values = new Value[] {node.getSession().getValueFactory().createValue(propertyName)}; } else if(childNode == null && jcrPath.equals("/node") && node != null) { values = new Value[] {node.getSession().getValueFactory().createValue(node.getName())}; } else { values = new Value[] {node.getSession().getValueFactory().createValue("")}; } } if (values != null && isFirstTimeRender) { for (Value v : values) { UIFormInputBase<String> uiFormInput = formField.createUIFormInput(); if (uiFormInput instanceof UIFormWYSIWYGInput) ((UIFormWYSIWYGInput)uiFormInput).setFCKConfig((FCKEditorConfig)config.clone()); if(v == null || v.getString() == null) uiFormInput.setValue(formField.getDefaultValue()); else uiFormInput.setValue(v.getString()); ret.add(uiFormInput); } } else { ret.add(formInput); } return ret; } public void addWYSIWYGField(String name, String[] arguments) throws Exception { addWYSIWYGField(name,null,arguments); } public void addRichtextField(String name, String label, String[] arguments) throws Exception { UIFormRichtextField richtextField = new UIFormRichtextField(name,label,arguments); String jcrPath = richtextField.getJcrPath(); JcrInputProperty inputProperty = new JcrInputProperty(); inputProperty.setJcrPath(jcrPath); inputProperty.setChangeInJcrPathParam(richtextField.getChangeInJcrPathParam()); setInputProperty(name, inputProperty); String option = richtextField.getOptions(); setInputOption(name, option); String propertyName = getPropertyName(jcrPath); propertiesName.put(name, propertyName); fieldNames.put(propertyName, name); List<UIFormInputBase<String>> richtextList = getUIFormInputList(name, richtextField, false); if(richtextField.isMultiValues()) { UIFormMultiValueInputSet uiMulti = findComponentById(name); if (uiMulti == null) { uiMulti = createUIComponent(UIFormMultiValueInputSet.class, WYSIWYG_MULTI_ID, null); this.uiMultiValueParam.put(name, arguments); uiMulti.setId(name); uiMulti.setName(name); uiMulti.setType(UIFormRichtextInput.class); for (int i = 0; i < richtextList.size(); i++) { uiMulti.addChild(richtextList.get(i)); richtextList.get(i).setId(name + i); richtextList.get(i).setName(name + i); } addUIFormInput(uiMulti); if(label != null) uiMulti.setLabel(label); } } else { if (getChildById(name) == null && richtextList.size() > 0) addUIFormInput(richtextList.get(0)); } renderField(name); } public void addRichtextField(String name, String[] arguments) throws Exception { addRichtextField(name,null,arguments); } public Node getChildNode() throws Exception { if(childPath == null) return null; return (Node) getSession().getItem(childPath); } public String getContentType() { return contentType; }; public Map<String, JcrInputProperty> getInputProperties() { return properties; } public Map<String, String> getInputOptions() { return options; } public JcrInputProperty getInputProperty(String name) { return properties.get(name); } public String getInputOption(String name) { return options.get(name); } public JCRResourceResolver getJCRResourceResolver() { return resourceResolver; } public Node getNode() { if(nodePath == null) return null; try { return (Node) getSession().getItem(nodePath); } catch (Exception e) { return null; } } public String getPropertyName(String jcrPath) { return jcrPath.substring(jcrPath.lastIndexOf("/") + 1); } public String getSelectBoxFieldValue(String name) { UIFormSelectBox uiSelectBox = findComponentById(name); if (uiSelectBox != null) return uiSelectBox.getValue(); return null; } public List<String> getSelectedBoxFieldValue(String name) { UIFormSelectBox uiSelectBox = findComponentById(name); if (uiSelectBox != null) return Arrays.asList(uiSelectBox.getSelectedValues()); return null; } public Session getSession() throws Exception { return WCMCoreUtils.getUserSessionProvider().getSession(workspaceName, getRepository()); } public String getTemplate() { TemplateService templateService = getApplicationComponent(TemplateService.class); String userName = Util.getPortalRequestContext().getRemoteUser(); try { return templateService.getTemplatePathByUser(true, contentType, userName); } catch (Exception e) { UIApplication uiApp = getAncestorOfType(UIApplication.class); Object[] arg = { contentType }; uiApp.addMessage(new ApplicationMessage("UIDialogForm.msg.not-support-contenttype", arg, ApplicationMessage.ERROR)); return null; } } public boolean isResetForm() { return isResetForm; } public void onchange(Event<?> event) throws Exception { } @Override public void processAction(WebuiRequestContext context) throws Exception { String action = context.getRequestParameter(UIForm.ACTION); boolean clearInterceptor = false; if (SAVE_ACTION.equalsIgnoreCase(action) || SAVE_AND_CLOSE.equalsIgnoreCase(action)) { try { if (executePreSaveEventInterceptor()) { super.processAction(context); String nodePath_ = (String) context.getAttribute("nodePath"); if (nodePath_ != null) { executePostSaveEventInterceptor(nodePath_); clearInterceptor = true; } } else { context.setProcessRender(true); super.processAction(context); } } finally { if (clearInterceptor) { prevScriptInterceptor.clear(); postScriptInterceptor.clear(); } } } else { super.processAction(context); } } public void removeComponent(String name) { if (!properties.isEmpty() && properties.containsKey(name)) { properties.remove(name); String jcrPath = propertiesName.get(name); propertiesName.remove(name); fieldNames.remove(jcrPath); removeChildById(name); } } private String getResourceBundle(WebuiRequestContext context, String key) { try { ResourceBundle rs = context.getApplicationResourceBundle(); return rs.getString(key); } catch(MissingResourceException e) { if (LOG.isWarnEnabled()) { LOG.warn("Missing resource " + key); } key = key.contains(".") ? key.substring(key.lastIndexOf(".") + 1) : key; return key; } } public void renderField(String name) throws Exception { UIComponent uiInput = findComponentById(name); WebuiRequestContext context = WebuiRequestContext.getCurrentInstance(); Writer w = context.getWriter(); if(componentSelectors.get(name) != null && name.equals(componentSelectors.get(name).get("returnField"))) { uiInput.processRender(context); } else { uiInput.processRender(context); } if(componentSelectors.get(name) != null) { Map<String,String> fieldPropertiesMap = componentSelectors.get(name); String fieldName = fieldPropertiesMap.get("returnField"); String iconClass = "uiIconPlus"; if(fieldPropertiesMap.get("selectorIcon") != null) { iconClass = fieldPropertiesMap.get("selectorIcon"); } ResourceBundle rs = context.getApplicationResourceBundle(); String showComponent = getResourceBundle(context, getId().concat(".title.ShowComponent")); String removeReference = getResourceBundle(context, getId().concat(".title.removeReference")); if (name.equals(fieldName)) { w.write("<a rel=\"tooltip\" data-placement=\"bottom\" class=\"actionIcon\" title=\"" + showComponent + "\"" + "onclick=\"javascript:eXo.webui.UIForm.submitEvent('" + "" + getId() + "','ShowComponent','&objectId=" + fieldName + "' )\"><i" + " class='" + iconClass + " uiIconLightGray'></i></a>"); /* No need Remove action if uiInput is UIFormMultiValueInputSet */ if (!UIFormMultiValueInputSet.class.isInstance(uiInput)) w.write("<a rel=\"tooltip\" data-placement=\"bottom\" class=\"actionIcon\" title=\"" + removeReference + "\"" + "onclick=\"javascript:eXo.webui.UIForm.submitEvent('" + "" + getId() + "','RemoveReference','&objectId=" + fieldName + "' )\"><i" +" class='uiIconTrash uiIconLightGray'></i>" + "</a>"); } } } public String getImage(Node node, String nodeTypeName) throws Exception { DownloadService dservice = getApplicationComponent(DownloadService.class); Node imageNode = node.getNode(nodeTypeName); InputStream input = imageNode.getProperty(Utils.JCR_DATA).getStream(); InputStreamDownloadResource dresource = new InputStreamDownloadResource(input, "image"); dresource.setDownloadName(node.getName()); return dservice.getDownloadLink(dservice.addDownloadResource(dresource)); } public String getImage(InputStream input, String nodeName) throws Exception { DownloadService dservice = getApplicationComponent(DownloadService.class); InputStreamDownloadResource dresource = new InputStreamDownloadResource(input, "image"); dresource.setDownloadName(nodeName); return dservice.getDownloadLink(dservice.addDownloadResource(dresource)); } @Deprecated /** * Deprecated method, should used removeData(String path) next time */ public boolean dataRemoved() { return dataRemoved_; } @Deprecated public void setDataRemoved(boolean dataRemoved) { dataRemoved_ = dataRemoved; } /** * Mark a uploaded field as removed. * * @param path: of property content binarydata for uploading */ public void removeData(String path) { if (!removedBinary.contains(path)) { removedBinary.add(path); } } /** * Checking the binary field is removed or not * * @param path: of property content binarydata for uploading * @return : True if the uploaded field is removed from UI */ public boolean isDataRemoved(String path) { return removedBinary.contains(path); } public void clearDataRemovedList() { removedBinary.clear(); } public void resetProperties() { properties.clear(); } public void resetInterceptors(){ this.prevScriptInterceptor.clear(); this.postScriptInterceptor.clear(); } public void setChildPath(String childPath) { this.childPath = childPath; } public void setContentType(String type) { this.contentType = type; } public void setInputProperty(String name, JcrInputProperty value) { properties.put(name, value); } public void setInputOption(String name, String value) { options.put(name, value); } public void setIsNotEditNode(boolean isNotEditNode) { this.isNotEditNode = isNotEditNode; } public void setIsNTFile(boolean isNTFile) { this.isNTFile = isNTFile; } public void setIsOnchange(boolean isOnchange) { this.isOnchange = isOnchange; } public void setIsResetForm(boolean isResetForm) { this.isResetForm = isResetForm; } public void setIsResetMultiField(boolean isResetMultiField) { this.isResetMultiField = isResetMultiField; } public void setIsUpdateSelect(boolean isUpdateSelect) { this.isUpdateSelect = isUpdateSelect; } public void setJCRResourceResolver(JCRResourceResolver resourceResolver) { this.resourceResolver = resourceResolver; } public void setNodePath(String nodePath) { this.nodePath = nodePath; } public String getNodePath() { return nodePath; } public void setRepositoryName(String repositoryName){ this.repositoryName = repositoryName; } public void setStoredPath(String storedPath) { this.storedPath = storedPath; } public String getStoredPath() { return storedPath; } public void setWorkspace(String workspace) { this.workspaceName = workspace; } public String getLastModifiedDate() throws Exception { return getLastModifiedDate(getNode()); } public String getLastModifiedDate(Node node) { String d = StringUtils.EMPTY; try { if (node.hasProperty("exo:dateModified")) { Locale locale = Util.getPortalRequestContext().getLocale(); DateFormat dateFormater = SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.MEDIUM, SimpleDateFormat.MEDIUM, locale); Calendar calendar = node.getProperty("exo:dateModified").getValue().getDate(); d = dateFormater.format(calendar.getTime()); } } catch (ValueFormatException e) { d = StringUtils.EMPTY; } catch (IllegalStateException e) { d = StringUtils.EMPTY; } catch (PathNotFoundException e) { d = StringUtils.EMPTY; } catch (RepositoryException e) { d = StringUtils.EMPTY; } return d; } protected List<String> getRemovedNodes() { return removedNodes; } public void addRemovedNode(String path) { removedNodes.add(path); } public void clearRemovedNode() { removedNodes = new ArrayList<String>(); } private void executePostSaveEventInterceptor(String nodePath_) throws Exception { if (postScriptInterceptor.size() > 0) { String path = nodePath_ + "&workspaceName=" + this.workspaceName + "&repository=" + this.repositoryName; for (String interceptor : postScriptInterceptor) { this.executeScript(interceptor, path, null, true); } } } private boolean executePreSaveEventInterceptor() throws Exception { if (!prevScriptInterceptor.isEmpty()) { Map<String, JcrInputProperty> maps = DialogFormUtil.prepareMap(this.getChildren(), getInputProperties(), getInputOptions()); for (String interceptor : prevScriptInterceptor) { if(!executeScript(interceptor, maps, null, false)){ return false; } } } return true; } private boolean executeScript(String script, Object o, String[] params, boolean printException) throws Exception { ScriptService scriptService = getApplicationComponent(ScriptService.class); try { CmsScript dialogScript = scriptService.getScript(script); if (params != null) { dialogScript.setParams(params); } dialogScript.execute(o); return true; } catch (Exception e) { if(printException){ if (LOG.isWarnEnabled()) { LOG.warn("An unexpected error occurs", e); } } else { UIApplication uiApp = getAncestorOfType(UIApplication.class); if (e instanceof DialogFormException) { for (ApplicationMessage message : ((DialogFormException) e).getMessages()) { uiApp.addMessage(message); } } else { JCRExceptionManager.process(uiApp, e); } } } return false; } private String getNodePathByUUID(String uuid) throws Exception{ String[] workspaces = getRepository().getWorkspaceNames(); Node node = null; for(String ws : workspaces) { try{ node = WCMCoreUtils.getSystemSessionProvider().getSession(ws, getRepository()).getNodeByUUID(uuid); return ws + ":" + node.getPath(); } catch(ItemNotFoundException e) { continue; } } if (LOG.isErrorEnabled()) { LOG.error("No node with uuid ='" + uuid + "' can be found"); } return null; } private ManageableRepository getRepository() throws Exception{ RepositoryService repositoryService = getApplicationComponent(RepositoryService.class); return repositoryService.getCurrentRepository(); } private UIFormMultiValueInputSet renderMultiValuesInput(Class<? extends UIFormInputBase<?>> type, String name,String label) throws Exception{ UIFormMultiValueInputSet ret = addMultiValuesInput(type, name, label); renderField(name); return ret; } private UIFormMultiValueInputSet addMultiValuesInput(Class<? extends UIFormInputBase<?>> type, String name,String label) throws Exception{ UIFormMultiValueInputSet uiMulti = null; if (UIUploadInput.class.isAssignableFrom(type)) { uiMulti = createUIComponent(UIFormUploadMultiValueInputSet.class, null, null); } else { uiMulti = createUIComponent(UIFormMultiValueInputSet.class, null, null); } uiMulti.setId(name); uiMulti.setName(name); uiMulti.setType(type); addUIFormInput(uiMulti); if(label != null) uiMulti.setLabel(label); return uiMulti; } static public class OnchangeActionListener extends EventListener<UIDialogForm> { public void execute(Event<UIDialogForm> event) throws Exception { event.getSource().isOnchange = true; event.getSource().onchange(event); } } public boolean isOnchange() { return isOnchange; } public void processRenderAction() throws Exception { WebuiRequestContext context = WebuiRequestContext.getCurrentInstance(); Writer writer = context.getWriter(); writer.append("<div class=\"uiAction uiActionBorder\">"); String[] listAction = getActions(); ResourceBundle res = context.getApplicationResourceBundle(); String actionLabel; String link; for (String action : listAction) { try { actionLabel = res.getString(getName() + ".action." + action); } catch (MissingResourceException e) { actionLabel = action; } link = event(action); writer.append("<button type=\"button\" class=\"btn\" onclick =\"") .append(link) .append("\">") .append(actionLabel) .append("</button>"); } writer.append("</div>"); } public Node getNodeByType(String nodeType) throws Exception { if (this.getNode() == null) return null; NodeIterator nodeIter = this.getNode().getNodes(); while (nodeIter.hasNext()) { Node node = nodeIter.nextNode(); if (node.isNodeType(nodeType)) return node; } return null; } static public class AddActionListener extends EventListener<UIFormMultiValueInputSet> { public void execute(Event<UIFormMultiValueInputSet> event) throws Exception { UIFormMultiValueInputSet uiSet = event.getSource(); String id = event.getRequestContext().getRequestParameter(OBJECTID); if (uiSet.getId().equals(id)) { // get max id List<UIComponent> children = uiSet.getChildren(); if (children.size() > 0) { UIFormInputBase<?> uiInput = (UIFormInputBase<?>) children.get(children.size() - 1); String index = uiInput.getId(); int maxIndex = Integer.parseInt(index.replaceAll(id, "")); UIDialogForm uiDialogForm = uiSet.getAncestorOfType(UIDialogForm.class); String[] arguments = uiDialogForm.uiMultiValueParam.get(uiSet.getName()); UIFormInputBase<?> newUIInput = null; if (uiInput instanceof UIFormWYSIWYGInput) { newUIInput = uiDialogForm.getUIFormInputList(uiSet.getName(), new UIFormWYSIWYGField(uiSet.getName(), null, arguments), true).get(0); } else { newUIInput = uiDialogForm.getUIFormInputList(uiSet.getName(), new UIFormRichtextField(uiSet.getName(), null, arguments), true).get(0); } uiSet.addChild(newUIInput); newUIInput.setId(uiSet.getName() + (maxIndex + 1)); newUIInput.setName(uiSet.getName() + (maxIndex + 1)); } } } } }
84,638
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIOpenDocumentForm.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/UIOpenDocumentForm.java
package org.exoplatform.ecm.webui.form; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.config.annotation.EventConfig; import org.exoplatform.webui.core.UIComponent; import org.exoplatform.webui.core.UIPopupComponent; import org.exoplatform.webui.core.UIPopupWindow; import org.exoplatform.webui.event.Event; import org.exoplatform.webui.event.EventListener; /** * Created by The eXo Platform SAS * Author : eXoPlatform * toannh@exoplatform.com * On Dec 10, 2014 * Popup window when open read-only a document in SE */ @ComponentConfig( template = "classpath:groovy/ecm/webui/UIConfirmMessage.gtmpl", events = { @EventConfig(listeners = UIOpenDocumentForm.ReadOnlyActionListener.class), @EventConfig(listeners = UIOpenDocumentForm.CancelActionListener.class) } ) public class UIOpenDocumentForm extends UIComponent implements UIPopupComponent { public UIOpenDocumentForm() throws Exception {} public String filePath; public String mountPath; public String absolutePath; public String[] getActions() { return new String[] {"ReadOnly", "Cancel"}; } /** * Only open document with read-only mode. */ public static class ReadOnlyActionListener extends EventListener<UIOpenDocumentForm> { @Override public void execute(Event<UIOpenDocumentForm> event) throws Exception { UIOpenDocumentForm uiConfirm = event.getSource(); // impl readonly action UIPopupWindow popupAction = uiConfirm.getAncestorOfType(UIPopupWindow.class) ; popupAction.setShow(false) ; event.getRequestContext().addUIComponentToUpdateByAjax(popupAction); event.getRequestContext().getJavascriptManager().require("SHARED/openDocumentInOffice") .addScripts("eXo.ecm.OpenDocumentInOffice.openDocument('" + uiConfirm.absolutePath + "', '" + uiConfirm.mountPath + "');"); } } /** * Cancel action, close all popup include popup of ITHIT */ public static class CancelActionListener extends EventListener<UIOpenDocumentForm> { @Override public void execute(Event<UIOpenDocumentForm> event) throws Exception { UIOpenDocumentForm uiConfirm = event.getSource(); UIPopupWindow popupAction = uiConfirm.getAncestorOfType(UIPopupWindow.class) ; popupAction.setShow(false) ; event.getRequestContext().addUIComponentToUpdateByAjax(popupAction); } } private String messageKey_; private String[] args_ = {}; public void setMessageKey(String messageKey) { messageKey_ = messageKey; } public String getMessageKey() { return messageKey_; } public void setArguments(String[] args) { args_ = args; } public String[] getArguments() { return args_; } public void activate() { } public void deActivate() { } public void setFilePath(String filePath) { this.filePath = filePath; } public void setMountPath(String mountPath) { this.mountPath = mountPath; } public void setAbsolutePath(String absolutePath) { this.absolutePath = absolutePath; } }
3,087
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
DialogFormException.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/DialogFormException.java
/*************************************************************************** * Copyright (C) 2003-2009 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. * **************************************************************************/ package org.exoplatform.ecm.webui.form; import java.util.ArrayList; import java.util.List; import org.exoplatform.web.application.ApplicationMessage; /** * Created by eXo Platform * Author : Nguyen Manh Cuong * manhcuongpt@gmail.com * Jun 26, 2009 */ /** * This is an exception which will be thrown when there is a problem with pre save interceptor */ public class DialogFormException extends Exception { private List<ApplicationMessage> appMsgList = new ArrayList<ApplicationMessage>(); public DialogFormException(ApplicationMessage app){ appMsgList.add(app); } public void addApplicationMessage(ApplicationMessage app) { appMsgList.add(app); } public List<ApplicationMessage> getMessages() { return appMsgList; } }
1,673
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIFormUploadInputNoUploadButton.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/UIFormUploadInputNoUploadButton.java
/* * Copyright (C) 2003-2011 eXo Platform SAS. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program 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 Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.form; import org.exoplatform.webui.config.annotation.ComponentConfig; /** * Created by The eXo Platform SAS * Author : eXoPlatform * exo@exoplatform.com * Nov 21, 2011 */ @ComponentConfig(type = UIFormUploadInputNoUploadButton.class, template = "classpath:groovy/ecm/webui/form/UIFormUploadInputNoUploadButton.gtmpl") public class UIFormUploadInputNoUploadButton extends UIFormUploadInputExtension { public UIFormUploadInputNoUploadButton(String name, String bindingExpression) { super(name, bindingExpression); setComponentConfig(UIFormUploadInputNoUploadButton.class, null); } public UIFormUploadInputNoUploadButton(String name, String bindingExpression, int limit) { super (name, bindingExpression, limit); setComponentConfig(UIFormUploadInputNoUploadButton.class, null); } }
1,594
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIFormTextField.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/field/UIFormTextField.java
/* * Copyright (C) 2003-2008 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.form.field; import org.exoplatform.ecm.webui.form.DialogFormField; import org.exoplatform.ecm.webui.utils.DialogFormUtil; import org.exoplatform.services.cms.JcrInputProperty; import org.exoplatform.webui.form.UIFormInputBase; import org.exoplatform.webui.form.UIFormStringInput; /** * Created by The eXo Platform SAS * @author : Hoa.Pham * hoa.pham@exoplatform.com * Jun 23, 2008 */ public class UIFormTextField extends DialogFormField{ public UIFormTextField(String name, String label, String[] arguments) { super(name, label, arguments); } @SuppressWarnings("unchecked") public <T extends UIFormInputBase> T createUIFormInput() throws Exception { UIFormStringInput uiInput = new UIFormStringInput(name, name, defaultValue) ; //TODO need use full class name for validate type. if (validateType != null) { DialogFormUtil.addValidators(uiInput, validateType); } if(label != null && label.length()!=0) { uiInput.setLabel(label); } if("password".equals(type)) uiInput.setType(UIFormStringInput.PASSWORD_TYPE); return (T)uiInput; } public boolean isEditIfNull() { return "if-null".equals(editable); } public JcrInputProperty createJcrInputProperty (){ JcrInputProperty inputProperty = new JcrInputProperty(); inputProperty.setJcrPath(jcrPath); if(mixinTypes != null) inputProperty.setMixintype(mixinTypes) ; if(jcrPath.equals("/node") && nodeType != null ) inputProperty.setNodetype(nodeType); return inputProperty; } }
2,321
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIFormCheckBoxField.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/field/UIFormCheckBoxField.java
/*************************************************************************** * Copyright (C) 2003-2009 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. * **************************************************************************/ package org.exoplatform.ecm.webui.form.field; import org.exoplatform.ecm.webui.form.DialogFormField; import org.exoplatform.webui.form.UIFormInputBase; /** * Created by The eXo Platform SARL * Author : Nguyen Manh Cuong * manhcuongpt@gmail.com * Jul 2, 2009 */ public class UIFormCheckBoxField extends DialogFormField{ public UIFormCheckBoxField(String name, String label, String[] arguments) { super(name, label, arguments); } @SuppressWarnings("unchecked") public <T extends UIFormInputBase> T createUIFormInput() throws Exception { return null; } public boolean isOnchange() { return "true".equalsIgnoreCase(onchange); } }
1,562
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIMixinField.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/field/UIMixinField.java
/* * Copyright (C) 2003-2008 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.form.field; import org.exoplatform.ecm.webui.form.DialogFormField; import org.exoplatform.services.cms.JcrInputProperty; import org.exoplatform.webui.form.UIFormInputBase; import org.exoplatform.webui.form.UIFormStringInput; /** * Created by The eXo Platform SAS * @author : Hoa.Pham * hoa.pham@exoplatform.com * Jun 23, 2008 */ public class UIMixinField extends DialogFormField{ public UIMixinField(String name, String label, String[] arguments) { super(name, label, arguments); } @SuppressWarnings("unchecked") public <T extends UIFormInputBase> T createUIFormInput() throws Exception { UIFormStringInput uiMixin = new UIFormStringInput(name, name, defaultValue) ; if(label != null) uiMixin.setLabel(label) ; return (T)uiMixin; } public JcrInputProperty createJcrInputProperty() { JcrInputProperty inputProperty = new JcrInputProperty(); inputProperty.setJcrPath(jcrPath); if(defaultValue != null && defaultValue.length() > 0) { inputProperty.setValue(defaultValue) ; } if (nodeType != null || mixinTypes != null) { inputProperty.setType(JcrInputProperty.NODE); if(nodeType != null) inputProperty.setNodetype(nodeType); if(mixinTypes != null) inputProperty.setMixintype(mixinTypes); } return inputProperty; } }
2,110
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIFormTextAreaField.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/field/UIFormTextAreaField.java
/* * Copyright (C) 2003-2008 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.form.field; import java.util.HashMap; import java.util.Map; import org.exoplatform.ecm.webui.form.DialogFormField; import org.exoplatform.ecm.webui.utils.DialogFormUtil; import org.exoplatform.webui.form.UIFormInputBase; import org.exoplatform.webui.form.UIFormTextAreaInput; /** * Created by The eXo Platform SAS * @author : Hoa.Pham * hoa.pham@exoplatform.com * Jun 23, 2008 */ public class UIFormTextAreaField extends DialogFormField { public final static int DEFAULT_ROW = 10; public final static int DEFAULT_COL = 30; public UIFormTextAreaField(String name, String label, String[] arguments) { super(name, label, arguments); } @SuppressWarnings("unchecked") public <T extends UIFormInputBase> T createUIFormInput() throws Exception { UIFormTextAreaInput uiTextArea = new UIFormTextAreaInput(name, name, defaultValue) ; if(validateType != null) { DialogFormUtil.addValidators(uiTextArea, validateType); } if(label != null) uiTextArea.setLabel(label) ; return (T)uiTextArea; } public Map<String, String> getSelectorInfo() { Map<String, String> map = new HashMap<String, String>() ; map.put("selectorClass", selectorClass) ; map.put("returnField", name) ; map.put("selectorIcon", selectorIcon) ; map.put("workspaceField", workspaceField) ; if(selectorParams != null) map.put("selectorParams", selectorParams) ; return map; } public boolean useSelector() { return selectorClass != null; } }
2,295
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIFormRichtextField.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/field/UIFormRichtextField.java
/* * Copyright (C) 2003-2010 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.form.field; import org.exoplatform.ecm.webui.form.DialogFormField; import org.exoplatform.ecm.webui.form.UIFormRichtextInput; import org.exoplatform.ecm.webui.utils.DialogFormUtil; import org.exoplatform.portal.resource.SkinConfig; import org.exoplatform.portal.resource.SkinService; import org.exoplatform.portal.webui.util.Util; import org.exoplatform.services.wcm.utils.WCMCoreUtils; import org.exoplatform.webui.form.UIFormInputBase; import java.util.Collection; /** * Created by The eXo Platform SAS * Author : Phan Le Thanh Chuong * chuong.phan@exoplatform.com; phan.le.thanh.chuong@gmail.com * May 10, 2010 */ public class UIFormRichtextField extends DialogFormField { private final String TOOLBAR = "toolbar"; private final String WIDTH = "width"; private final String HEIGHT = "height"; private final String ENTERMODE = "enterMode"; private final String SHIFT_ENTER_MODE = "shiftEnterMode"; private String toolbar; private String width; private String height; private String enterMode; private String shiftEnterMode; public UIFormRichtextField(String name, String label, String[] arguments) { super(name, label, arguments); } @SuppressWarnings("unchecked") public <T extends UIFormInputBase> T createUIFormInput() throws Exception { UIFormRichtextInput richtext = new UIFormRichtextInput(name, name, defaultValue); setPredefineOptions(); richtext.setToolbar(toolbar); richtext.setWidth(width); richtext.setHeight(height); richtext.setEnterMode(enterMode); richtext.setShiftEnterMode(shiftEnterMode); richtext.setIgnoreParserHTML(true); StringBuffer contentsCss = new StringBuffer(); contentsCss.append("["); SkinService skinService = WCMCoreUtils.getService(SkinService.class); String skin = Util.getUIPortalApplication().getUserPortalConfig().getPortalConfig().getSkin(); String portal = Util.getUIPortal().getName(); Collection<SkinConfig> portalSkins = skinService.getPortalSkins(skin); SkinConfig customSkin = skinService.getSkin(portal, Util.getUIPortalApplication() .getUserPortalConfig() .getPortalConfig() .getSkin()); if (customSkin != null) portalSkins.add(customSkin); for (SkinConfig portalSkin : portalSkins) { contentsCss.append("'").append(portalSkin.createURL(Util.getPortalRequestContext().getControllerContext())).append("',"); } contentsCss.append("'/commons-extension/ckeditor/contents.css'"); contentsCss.append("]"); richtext.setCss(contentsCss.toString()); if(validateType != null) { DialogFormUtil.addValidators(richtext, validateType); } return (T)richtext; } private void setPredefineOptions() { if (options == null) return; for(String option: options.split(",")) { String[] entry = option.split(":"); if(TOOLBAR.equals(entry[0])) { toolbar = entry[1]; } else if(WIDTH.equals(entry[0])) { width = entry[1]; } else if(HEIGHT.equals(entry[0])) { height = entry[1]; } else if(ENTERMODE.equals(entry[0])) { enterMode = entry[1]; } else if(SHIFT_ENTER_MODE.equals(entry[0])) { shiftEnterMode = entry[1]; } } } }
4,135
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIFormUploadField.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/field/UIFormUploadField.java
/* * Copyright (C) 2003-2008 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.form.field; import org.exoplatform.ecm.webui.form.DialogFormField; import org.exoplatform.services.wcm.utils.WCMCoreUtils; import org.exoplatform.wcm.connector.fckeditor.DriverConnector; import org.exoplatform.webui.form.UIFormInputBase; import org.exoplatform.webui.form.input.UIUploadInput; /** * Created by The eXo Platform SAS * @author : Hoa.Pham * hoa.pham@exoplatform.com * Jun 23, 2008 */ public class UIFormUploadField extends DialogFormField{ public UIFormUploadField(String name, String label, String[] arguments) { super(name, label, arguments); } @SuppressWarnings("unchecked") public <T extends UIFormInputBase> T createUIFormInput() throws Exception { UIUploadInput uiInputUpload = null; int limitSize = WCMCoreUtils.getService(DriverConnector.class).getLimitSize(); uiInputUpload = new UIUploadInput(name, name, 1, limitSize); if(label != null) uiInputUpload.setLabel(label) ; return (T)uiInputUpload; } }
1,759
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIFormWYSIWYGField.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/field/UIFormWYSIWYGField.java
/* * Copyright (C) 2003-2008 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.form.field; import org.exoplatform.ecm.webui.form.DialogFormField; import org.exoplatform.ecm.webui.utils.DialogFormUtil; import org.exoplatform.webui.form.UIFormInputBase; import org.exoplatform.webui.form.wysiwyg.UIFormWYSIWYGInput; /** * Created by The eXo Platform SAS * @author : Hoa.Pham * hoa.pham@exoplatform.com * Jun 23, 2008 */ public class UIFormWYSIWYGField extends DialogFormField { private final String TOOBAR = "toolbar"; private final String SOURCE_MODE = "SourceModeOnStartup"; private final String WIDTH = "width"; private final String HEIGHT = "height"; private String toolbarName; private boolean sourceModeOnStartup = false; private String width; private String height; public UIFormWYSIWYGField(String name, String label, String[] arguments) { super(name, label, arguments); } @SuppressWarnings("unchecked") public <T extends UIFormInputBase> T createUIFormInput() throws Exception { UIFormWYSIWYGInput wysiwyg = new UIFormWYSIWYGInput(name, name, defaultValue); parseOptions(); wysiwyg.setToolBarName(toolbarName); wysiwyg.setSourceModeOnStartup(sourceModeOnStartup); wysiwyg.setWidth(width); wysiwyg.setHeight(height); if(validateType != null) { DialogFormUtil.addValidators(wysiwyg, validateType); } return (T)wysiwyg; } private void parseOptions() { if("basic".equals(options)) { toolbarName = UIFormWYSIWYGInput.BASIC_TOOLBAR; }else if("default".equals(options) || options == null) { toolbarName = UIFormWYSIWYGInput.DEFAULT_TOOLBAR; }else if(options.indexOf(",")>0){ for(String s: options.split(",")) { setPredefineOptions(s); } }else if(options.indexOf(":")>0) { setPredefineOptions(options); }else { toolbarName = UIFormWYSIWYGInput.DEFAULT_TOOLBAR; sourceModeOnStartup = false; } } private void setPredefineOptions(String option) { String[] entry = option.split(":"); if(TOOBAR.equals(entry[0])) { toolbarName = entry[1]; }else if(SOURCE_MODE.equals(entry[0])) { sourceModeOnStartup = Boolean.parseBoolean(entry[1]); }else if(WIDTH.equals(entry[0])) { width = entry[1]; }else if(HEIGHT.equals(entry[0])) { height = entry[1]; } } }
3,114
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIFormCalendarField.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/field/UIFormCalendarField.java
/* * Copyright (C) 2003-2008 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.form.field; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import org.exoplatform.ecm.webui.form.DialogFormField; import org.exoplatform.webui.form.UIFormDateTimeInput; import org.exoplatform.webui.form.UIFormInputBase; /** * Created by The eXo Platform SAS * @author : Hoa.Pham * hoa.pham@exoplatform.com * Jun 23, 2008 */ public class UIFormCalendarField extends DialogFormField { public UIFormCalendarField(String name, String label, String[] args) { super(name, label, args); } @SuppressWarnings("unchecked") public <T extends UIFormInputBase> T createUIFormInput() throws Exception { String[] arrDate = null; SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss") ; Date date = null; if(options == null) formatter = new SimpleDateFormat("MM/dd/yyyy") ; if(defaultValue != null && defaultValue.length() > 0) { try { date = formatter.parse(defaultValue) ; if(defaultValue.indexOf("/") > -1) arrDate = defaultValue.split("/") ; String[] arrDf = formatter.format(date).split("/") ; if(Integer.parseInt(arrDate[0]) != Integer.parseInt(arrDf[0])) date = new Date() ; } catch(Exception e) { date = null; } } UIFormDateTimeInput uiDateTime = null; if(isDisplayTime()) { uiDateTime = new UIFormDateTimeInput(name, name, date) ; } else { uiDateTime = new UIFormDateTimeInput(name, name, date, false) ; } if (date != null) { Calendar calendar = new GregorianCalendar(); calendar.setTime(date); uiDateTime.setCalendar(calendar); } else { uiDateTime.setCalendar(null); } if(label != null) uiDateTime.setLabel(label); return (T)uiDateTime; } public boolean isVisible() { if (visible == null) return true; return "true".equalsIgnoreCase(visible); } public boolean isDisplayTime() { return "displaytime".equals(options); } }
2,826
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIFormHiddenField.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/field/UIFormHiddenField.java
/* * Copyright (C) 2003-2008 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.form.field; import org.exoplatform.ecm.webui.form.DialogFormField; import org.exoplatform.services.cms.JcrInputProperty; import org.exoplatform.webui.form.UIFormInputBase; /** * Created by The eXo Platform SAS * @author : Hoa.Pham * hoa.pham@exoplatform.com * Jun 23, 2008 */ public class UIFormHiddenField extends DialogFormField { public UIFormHiddenField(String name, String label, String[] arguments) { super(name, label, arguments); } @SuppressWarnings("unchecked") public <T extends UIFormInputBase> T createUIFormInput() throws Exception { throw new UnsupportedOperationException("Unsupported this method"); } public JcrInputProperty createJcrInputProperty() { JcrInputProperty inputProperty = new JcrInputProperty(); inputProperty.setJcrPath(jcrPath); if(defaultValue != null && defaultValue.length() > 0) { inputProperty.setValue(defaultValue) ; } if (nodeType != null || mixinTypes != null) { inputProperty.setType(JcrInputProperty.NODE); if(nodeType != null) inputProperty.setNodetype(nodeType); if(mixinTypes != null) inputProperty.setMixintype(mixinTypes); } return inputProperty; } }
1,984
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIFormRadioBoxField.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/field/UIFormRadioBoxField.java
/*************************************************************************** * Copyright (C) 2003-2009 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. * **************************************************************************/ package org.exoplatform.ecm.webui.form.field; import org.exoplatform.ecm.webui.form.DialogFormField; import org.exoplatform.webui.form.UIFormInputBase; /** * Created by eXo Platform * Author : Nguyen Manh Cuong * manhcuongpt@gmail.com * Jul 3, 2009 */ public class UIFormRadioBoxField extends DialogFormField{ public UIFormRadioBoxField(String name, String label, String[] arguments) { super(name, label, arguments); } @SuppressWarnings("unchecked") public <T extends UIFormInputBase> T createUIFormInput() throws Exception { return null; } }
1,474
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIFormSelectBoxField.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/field/UIFormSelectBoxField.java
/* * Copyright (C) 2003-2008 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.form.field; import org.exoplatform.ecm.webui.form.DialogFormField; import org.exoplatform.webui.form.UIFormInputBase; /** * Created by The eXo Platform SAS * @author : Hoa.Pham * hoa.pham@exoplatform.com * Jun 23, 2008 */ public class UIFormSelectBoxField extends DialogFormField { public UIFormSelectBoxField(String name, String label, String[] arguments) { super(name, label, arguments); } @SuppressWarnings("unchecked") public <T extends UIFormInputBase> T createUIFormInput() throws Exception { return null; } public boolean isOnchange() { return "true".equalsIgnoreCase(onchange); } public boolean isEditable() { return "true".equalsIgnoreCase(editable); } }
1,486
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIFormActionField.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/field/UIFormActionField.java
/* * Copyright (C) 2003-2008 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.form.field; import java.util.HashMap; import java.util.Map; import org.exoplatform.ecm.webui.form.DialogFormField; import org.exoplatform.ecm.webui.utils.DialogFormUtil; import org.exoplatform.webui.form.UIFormInputBase; import org.exoplatform.webui.form.UIFormStringInput; /** * Created by The eXo Platform SAS * @author : Hoa.Pham * hoa.pham@exoplatform.com * Jun 23, 2008 */ public class UIFormActionField extends DialogFormField { public UIFormActionField(String name, String label, String[] arguments) { super(name, label, arguments); } @SuppressWarnings("unchecked") public <T extends UIFormInputBase> T createUIFormInput() throws Exception { UIFormStringInput uiInput = new UIFormStringInput(name, name, defaultValue) ; //TODO need use full class name for validate type. if(validateType != null) { DialogFormUtil.addValidators(uiInput, validateType); } if(label != null && label.length()!=0) { uiInput.setLabel(label); } uiInput.setReadOnly(!isEditable()); return (T)uiInput; } public Map<String, String> getSelectorInfo() { Map<String, String> map = new HashMap<String, String>() ; map.put("selectorClass", selectorClass) ; map.put("returnField", name) ; map.put("selectorIcon", selectorIcon) ; map.put("workspaceField", workspaceField) ; if(selectorParams != null) map.put("selectorParams", selectorParams) ; return map; } public boolean useSelector() { return selectorClass != null; } }
2,314
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
RepeatIntervalValidator.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/validator/RepeatIntervalValidator.java
/* * Copyright (C) 2003-2007 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.form.validator; import org.exoplatform.web.application.ApplicationMessage; import org.exoplatform.webui.exception.MessageException; import org.exoplatform.webui.form.UIFormInput; import org.exoplatform.webui.form.validator.Validator; import org.quartz.impl.triggers.SimpleTriggerImpl; /** * Created by The eXo Platform SARL * Author : Dang Van Minh * minh.dang@exoplatform.com * Aug 21, 2007 6:25:58 PM */ public class RepeatIntervalValidator implements Validator { public void validate(UIFormInput uiInput) throws Exception { try { long timeInterval = Long.parseLong(uiInput.getValue().toString()) ; new SimpleTriggerImpl().setRepeatInterval(timeInterval) ; } catch(Exception e) { throw new MessageException( new ApplicationMessage("RepeatIntervalValidator.msg.invalid-value", null, ApplicationMessage.WARNING)) ; } } }
1,643
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
CategoryValidator.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/validator/CategoryValidator.java
package org.exoplatform.ecm.webui.form.validator; import org.exoplatform.services.cms.taxonomy.TaxonomyService; import org.exoplatform.services.wcm.utils.WCMCoreUtils; import org.exoplatform.web.application.ApplicationMessage; import org.exoplatform.webui.exception.MessageException; import org.exoplatform.webui.form.UIFormInput; import org.exoplatform.webui.form.UIFormStringInput; import org.exoplatform.webui.form.validator.Validator; public class CategoryValidator implements Validator{ public void validate(UIFormInput uiInput) throws Exception { if (uiInput.getValue() == null) return; if (uiInput instanceof UIFormStringInput) { TaxonomyService taxonomyService = WCMCoreUtils.getService(TaxonomyService.class); try{ int index = 0; String categoryPath = (String) uiInput.getValue(); index = categoryPath.indexOf("/"); if (index < 0) { taxonomyService.getTaxonomyTree(categoryPath); } else { taxonomyService.getTaxonomyTree(categoryPath.substring(0, index)).getNode(categoryPath.substring(index + 1)); } }catch (Exception e) { throw new MessageException( new ApplicationMessage( "CategoryValidator.msg.non-categories", null, ApplicationMessage.WARNING)); } } } }
1,496
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
CronExpressionValidator.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/validator/CronExpressionValidator.java
/* * Copyright (C) 2003-2007 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.form.validator; import org.exoplatform.web.application.ApplicationMessage; import org.exoplatform.webui.exception.MessageException; import org.exoplatform.webui.form.UIFormInput; import org.exoplatform.webui.form.validator.Validator; import org.quartz.impl.triggers.CronTriggerImpl; /** * Created by The eXo Platform SAS * Author : Hoa Pham * hoa.pham@exoplatform.com * Aug 13, 2007 */ public class CronExpressionValidator implements Validator{ public void validate(UIFormInput uiInput) throws Exception { try{ new CronTriggerImpl().setCronExpression((String)uiInput.getValue()) ; }catch (Exception e) { throw new MessageException(new ApplicationMessage("CronExpressionValidator.invalid-input", null, ApplicationMessage.WARNING)); } } }
1,655
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
StandardNameValidator.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/validator/StandardNameValidator.java
/* * Copyright (C) 2003-2008 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.form.validator; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.web.application.ApplicationMessage; import org.exoplatform.webui.exception.MessageException; import org.exoplatform.webui.form.UIFormInput; import org.exoplatform.webui.form.validator.Validator; /** * Created by The eXo Platform SAS * Author : Ly Dinh Quang * quang.ly@exoplatform.com * xxx5669@yahoo.com * Mar 20, 2008 */ public class StandardNameValidator implements Validator { public void validate(UIFormInput uiInput) throws Exception { String inputValue = ((String)uiInput.getValue()).trim(); if (inputValue == null || inputValue.length() == 0) { throwException("ECMStandardPropertyNameValidator.msg.empty-input", uiInput); } switch (inputValue.length()) { case 1: checkOneChar(inputValue, uiInput); break; case 2: checkTwoChars(inputValue, uiInput); default: checkMoreChars(inputValue, uiInput); break; } } /** * * @param s * @param arrFilterChars * @return */ private boolean checkArr(String s, String[] arrFilterChars) { for (String filter : arrFilterChars) { if (s.equals(filter)) { return true; } } return false; } /** * Check String Input s if s.length() = 1 * @param s * @param uiInput * @throws MessageException */ private void checkOneChar(String s, UIFormInput uiInput) throws MessageException { if (checkArr(s, Utils.SPECIALCHARACTER)) { throwException("ECMStandardPropertyNameValidator.msg.Invalid-char", uiInput); } } /** * Check String Input s if s.length() = 2 * @param s * @param uiInput */ private void checkTwoChars(String s, UIFormInput uiInput) throws MessageException { String s2 = ""; if (s.startsWith(".")) { s2 = s.substring(1, 2); checkOneChar(s2, uiInput); } else if (s.endsWith(".")) { s2 = s.substring(0, 1); checkOneChar(s2, uiInput); } else { String s3 = s.substring(0, 1); String s4 = s.substring(1, 2); String[] arrFilterChars = {".", "/", ":", "[", "]", "*", "'", "|", "\""} ; if (checkArr(s3, arrFilterChars)) { throwException("ECMStandardPropertyNameValidator.msg.Invalid-char", uiInput); } else { if (checkArr(s4, arrFilterChars)) { throwException("ECMStandardPropertyNameValidator.msg.Invalid-char", uiInput); } } } } /** * Check String Input s if s.length() > 2 * @param s * @param uiInput */ private void checkMoreChars(String s, UIFormInput uiInput) throws MessageException { //check nonspace start and end char String[] arrFilterChars = {"/", ":", "[", "]", "*", "'", "|", "\""} ; //get start and end char String s1 = s.substring(0, 1); String s2 = s.substring(s.length() - 1, s.length()); if (checkArr(s1, arrFilterChars)) { throwException("ECMStandardPropertyNameValidator.msg.Invalid-char", uiInput); } else if (checkArr(s2, arrFilterChars)){ throwException("ECMStandardPropertyNameValidator.msg.Invalid-char", uiInput); } else { String s3 = s.substring(1, s.length() - 1); for(String filterChar : arrFilterChars) { if(s3.indexOf(filterChar) > -1) { throwException("ECMStandardPropertyNameValidator.msg.Invalid-char", uiInput); } } } } private void throwException(String s, UIFormInput uiInput) throws MessageException { Object[] args = { uiInput.getName() }; throw new MessageException(new ApplicationMessage(s, args, ApplicationMessage.WARNING)); } }
4,514
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
NodeTypeNameValidator.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/validator/NodeTypeNameValidator.java
/*************************************************************************** * Copyright (C) 2003-2009 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. * **************************************************************************/ package org.exoplatform.ecm.webui.form.validator; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.web.application.ApplicationMessage; import org.exoplatform.webui.exception.MessageException; import org.exoplatform.webui.form.UIFormInput; import org.exoplatform.webui.form.validator.Validator; /** * Created by The eXo Platform SARL * Author : Hoang Van Hung * hunghvit@gmail.com * Dec 30, 2009 */ public class NodeTypeNameValidator implements Validator { public void validate(UIFormInput uiInput) throws Exception { String inputValue = (String) uiInput.getValue(); if (inputValue == null || inputValue.trim().length() == 0) { throwException("NodeTypeNameValidator.msg.empty-input", uiInput); } switch (inputValue.length()) { case 1: checkOneChar(inputValue, uiInput); break; case 2: checkTwoChars(inputValue, uiInput); break; default: checkMoreChars(inputValue, uiInput); break; } } /** * * @param s * @param arrFilterChars * @return */ private boolean checkArr(String s, String[] arrFilterChars) { for (String filter : arrFilterChars) { if (s.equals(filter)) { return true; } } return false; } /** * Check String Input s if s.length() = 1 * @param s * @param uiInput * @throws MessageException */ private void checkOneChar(String s, UIFormInput uiInput) throws MessageException { if (checkArr(s, Utils.SPECIALCHARACTER)) { throwException("NodeTypeNameValidator.msg.Invalid-char", uiInput); } } /** * Check String Input s if s.length() = 2 * @param s * @param uiInput */ private void checkTwoChars(String s, UIFormInput uiInput) throws MessageException { String s2 = ""; if (s.startsWith(".")) { s2 = s.substring(1, 2); checkOneChar(s2, uiInput); } else if (s.endsWith(".")) { s2 = s.substring(0, 1); checkOneChar(s2, uiInput); } else { String s3 = s.substring(0, 1); String s4 = s.substring(1, 2); if (checkArr(s3, Utils.SPECIALCHARACTER)) { throwException("NodeTypeNameValidator.msg.Invalid-char", uiInput); } else { if (checkArr(s4, Utils.SPECIALCHARACTER)) { throwException("NodeTypeNameValidator.msg.Invalid-char", uiInput); } } } } /** * Check String Input s if s.length() > 2 * @param s * @param uiInput */ private void checkMoreChars(String s, UIFormInput uiInput) throws MessageException { //get start and end char String s1 = s.substring(0, 1); String s2 = s.substring(s.length() - 1, s.length()); if (checkArr(s1, Utils.SPECIALCHARACTER)) { throwException("NodeTypeNameValidator.msg.Invalid-char", uiInput); } else if (checkArr(s2, Utils.SPECIALCHARACTER)){ throwException("NodeTypeNameValidator.msg.Invalid-char", uiInput); } else { String s3 = s.substring(1, s.length() - 1); for(String filterChar : Utils.SPECIALCHARACTER) { if(s3.indexOf(filterChar) > -1) { throwException("NodeTypeNameValidator.msg.Invalid-char", uiInput); } } } } private void throwException(String s, UIFormInput uiInput) throws MessageException { throw new MessageException(new ApplicationMessage(s, null, ApplicationMessage.WARNING)); } }
4,370
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
SearchValidator.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/validator/SearchValidator.java
/* * Copyright (C) 2003-2008 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.form.validator; import org.exoplatform.web.application.ApplicationMessage; import org.exoplatform.webui.exception.MessageException; import org.exoplatform.webui.form.UIFormInput; import org.exoplatform.webui.form.validator.Validator; /** * Created by The eXo Platform SAS * Author : Ly Dinh Quang * quang.ly@exoplatform.com * xxx5669@yahoo.com * Jul 9, 2008 */ public class SearchValidator implements Validator { public void validate(UIFormInput uiInput) throws Exception { String inputValue = ((String)uiInput.getValue()); if (inputValue == null || inputValue.trim().length() == 0) { throwException("SearchValidator.msg.empty-input", uiInput); } inputValue = inputValue.trim(); switch (inputValue.length()) { case 1: checkOneChar(inputValue, uiInput); break; case 2: checkTwoChars(inputValue, uiInput); break; default: checkMoreChars(inputValue, uiInput); break; } } private void checkOneChar(String s, UIFormInput uiInput) throws MessageException { String[] arrFilterChars = {"+", "-", "&", "|", "!", "(", ")", "{", "}", "[", "]", "^", "\"", "~", "*", "?", ":", "\\"}; if (checkArr(s, arrFilterChars)) { throwException("SearchValidator.msg.Invalid-char", uiInput); } } private void checkTwoChars(String s, UIFormInput uiInput) throws MessageException { String s2 = ""; if (s.startsWith("+") || s.startsWith("-") || s.startsWith("!")) { s2 = s.substring(1, 2); checkOneChar(s2, uiInput); } else if (s.endsWith("~") || s.endsWith("?") || s.endsWith("*")) { s2 = s.substring(0, 1); String[] arrFilterChars1 = {"+", "-", "&", "|", "!", "(", ")", "{", "}", "[", "]", "^", "\"", ":", "\\"}; if (checkArr(s2, arrFilterChars1)) { throwException("SearchValidator.msg.Invalid-char", uiInput); } } else { String s3 = s.substring(0, 1); String s4 = s.substring(1, 2); String[] arrFilterChars2 = {"+", "-", "&", "|", "!", "(", ")", "{", "}", "[", "]", "^", "\"", "~", "*", "?", ":", "\\"}; if (checkArr(s3, arrFilterChars2)) { throwException("SearchValidator.msg.Invalid-char", uiInput); } if (checkArr(s4, arrFilterChars2)) { throwException("SearchValidator.msg.Invalid-char", uiInput); } } } private void checkMoreChars(String s, UIFormInput uiInput) throws MessageException { String[] arrFilterChars = {"-", "&&", "||", "!", "(", ")", "}", "]", "^", ":", "&", "|"}; for (String filter : arrFilterChars) { if (s.startsWith(filter)) { throwException("SearchValidator.msg.Invalid-char", uiInput); } } String[] arrFilterChars2 = {"+", "-", "&&", "||", "!", "(", ")", "{", "}", "[", "]", "^", "\"", "~", "*", "?", ":", "\\", "&", "|"}; for (String filter : arrFilterChars2) { int index = s.indexOf(filter); if (index > -1 && !checkBackSlash(s, index)) { //Check FuzzySearch if (filter.equals("~")) { if (index == 0) { String regex = "~\\w+"; if (!s.matches(regex)) { throwException("SearchValidator.msg.Invalid-char", uiInput); } } else { if (checkChar(s, index, -1, " ") || checkChar(s, index, +1, " ")) { throwException("SearchValidator.msg.Invalid-char4", uiInput); } else if (checkChar(s, index, -1, "\"")) { int x = s.indexOf("\""); if (x > -1 && x != index - 1) { try { String subString = concatSpace(s.substring(index + 1, s.length())); Double.parseDouble(subString); } catch (Exception e) { throwException("SearchValidator.msg.Invalid-char2", uiInput); } } else { throwException("SearchValidator.msg.Invalid-char", uiInput); } } else { String subString = concatSpace(s.substring(index + 1, s.length())); double numberAt = 0; try { numberAt = Double.parseDouble(subString); } catch (NumberFormatException e) { throwException("SearchValidator.msg.Invalid-char2", uiInput); } if (numberAt >= 1 || numberAt < 0) { throwException("SearchValidator.msg.Invalid-char1", uiInput); } } } } else if (filter.equals("^")) { if (checkChar(s, index, -1, " ") || checkChar(s, index, +1, " ")) { throwException("SearchValidator.msg.Invalid-char5", uiInput); } else { String subString = concatSpace(s.substring(index + 1, s.length())); try { Double.parseDouble(subString); } catch (NumberFormatException e) { throwException("SearchValidator.msg.Invalid-char3", uiInput); } } } else { if (filter.equals("*") || filter.equals("?")) { return; } throwException("SearchValidator.msg.Invalid-char", uiInput); // } else if (filter.equals("[") || filter.equals("]")) { // String regex = "\\w*\\[\\w+ [Tt][Oo] \\w+\\]\\w*"; // if (!s.matches(regex)) { // throwException("SearchValidator.msg.Invalid-char", uiInput); // } } } } } private boolean checkChar(String s, int index, int forward, String c) { if (index == 0 || (index + forward == s.length())) { return false; } String charToString = String.valueOf(s.charAt(index + forward)); if (charToString.equals(c)) { return true; } return false; } private boolean checkBackSlash(String s, int index) { if (index == 0) { return false; } String charToString = String.valueOf(s.charAt(index - 1)); if (charToString.equalsIgnoreCase("\\")) { return true; } return false; } private boolean checkArr(String s, String[] arrFilterChars) { for (String filter : arrFilterChars) { if (s.equals(filter)) { return true; } } return false; } private String concatSpace(String s) { char[] arrayChar = s.toCharArray(); int index = 0; for (int i = 0; i < arrayChar.length; i++) { if (String.valueOf(arrayChar[i]).equals(" ")) { index = i; break; } } if (index != 0) { return s.substring(0, index); } return s; } private void throwException(String s, UIFormInput uiInput) throws MessageException { Object[] args = { uiInput.getName() }; throw new MessageException(new ApplicationMessage(s, args, ApplicationMessage.WARNING)); } }
7,654
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
XSSValidator.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/validator/XSSValidator.java
/* * Copyright (C) 2003-2012 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.form.validator; import org.apache.commons.lang3.StringUtils; import org.exoplatform.commons.utils.HTMLSanitizer; import org.exoplatform.web.application.ApplicationMessage; import org.exoplatform.webui.exception.MessageException; import org.exoplatform.webui.form.UIFormInput; import org.exoplatform.webui.form.validator.Validator; import java.net.URLDecoder; import java.nio.charset.StandardCharsets; /** * Created by The eXo Platform SAS Author : Tran Hung Phong * phongth@exoplatform.com Jul 24, 2012 */ public class XSSValidator implements Validator { @Override public void validate(UIFormInput uiInput) throws Exception { String inputValue = ((String) uiInput.getValue()); if (inputValue == null || inputValue.trim().length() == 0) { return; } inputValue = URLDecoder.decode(inputValue, StandardCharsets.UTF_8); inputValue = HTMLSanitizer.sanitize(inputValue); if (StringUtils.isEmpty(inputValue)) { String message = "UIActionForm.msg.xss-vulnerability-character"; if (uiInput.getLabel() == null) message = "UIActionForm.msg.xss-vulnerability-character-wo-label"; Object[] args = { uiInput.getLabel() }; throw new MessageException(new ApplicationMessage(message, args, ApplicationMessage.WARNING)); } } }
2,029
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
PermissionValidator.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/validator/PermissionValidator.java
/* * Copyright (C) 2003-2007 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.form.validator; import org.exoplatform.services.organization.OrganizationService; import org.exoplatform.services.wcm.utils.WCMCoreUtils; import org.exoplatform.web.application.ApplicationMessage; import org.exoplatform.webui.exception.MessageException; import org.exoplatform.webui.form.UIFormInput; import org.exoplatform.webui.form.validator.Validator; /** * Created by The eXo Platform SEA * Author : Ha Quang Tan * tanhq@exoplatform.com * May 16, 2011 4:52:44 PM */ public class PermissionValidator implements Validator { public void validate(UIFormInput uiInput) throws Exception { if (uiInput.getValue() == null || ((String) uiInput.getValue()).trim().length() == 0 || ((String) uiInput.getValue()).trim().equals("*")) return; String permissions = ((String) uiInput.getValue()).trim(); OrganizationService oservice = WCMCoreUtils.getService(OrganizationService.class); String[] arrPermissions = permissions.split(","); for (String itemPermission : arrPermissions) { if (itemPermission.length() == 0) { Object[] args = { itemPermission }; throw new MessageException(new ApplicationMessage("PermissionValidator.msg.permission-path-invalid", args)); } if (itemPermission.equals("*")) continue; else if (itemPermission.contains(":")) { String[] permission = itemPermission.split(":"); if ((permission[0] == null) || (permission[0].length() == 0)) { Object[] args = { itemPermission }; throw new MessageException(new ApplicationMessage("PermissionValidator.msg.permission-path-invalid", args)); } else if (!permission[0].equals("*") && (oservice.getMembershipTypeHandler().findMembershipType(permission[0]) == null)) { Object[] args = { itemPermission }; throw new MessageException(new ApplicationMessage("PermissionValidator.msg.permission-path-invalid", args)); } if ((permission[1] == null) || (permission[1].length() == 0)) { Object[] args = { itemPermission }; throw new MessageException(new ApplicationMessage("PermissionValidator.msg.permission-path-invalid", args)); } else if (oservice.getGroupHandler().findGroupById(permission[1]) == null) { Object[] args = { itemPermission }; throw new MessageException(new ApplicationMessage("PermissionValidator.msg.permission-path-invalid", args)); } } else { Object[] args = { itemPermission }; throw new MessageException(new ApplicationMessage("PermissionValidator.msg.permission-path-invalid", args)); } } } }
3,732
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
DrivePermissionValidator.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/validator/DrivePermissionValidator.java
/* * Copyright (C) 2003-2011 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.form.validator; import org.exoplatform.webui.form.UIFormInput; /** * Created by The eXo Platform SAS * Author : Nguyen Anh Vu * anhvurz90@gmail.com * May 19, 2011 */ public class DrivePermissionValidator extends PermissionValidator { public void validate(UIFormInput uiInput) throws Exception { if (uiInput.getValue() == null || ((String) uiInput.getValue()).trim().length() == 0 || "*".equals(((String) uiInput.getValue()).trim()) || "${userId}".equals(((String) uiInput.getValue()).trim()) || "*:${groupId}".equals(((String) uiInput.getValue()).trim())) return; super.validate(uiInput); } }
1,392
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
PhoneFormatValidator.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/validator/PhoneFormatValidator.java
/** * Copyright (C) 2009 eXo Platform SAS. * * This 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 software 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 software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.exoplatform.ecm.webui.form.validator; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.commons.lang3.StringUtils; import org.exoplatform.web.application.ApplicationMessage; import org.exoplatform.webui.exception.MessageException; import org.exoplatform.webui.form.UIFormInput; import org.exoplatform.webui.form.validator.Validator; /** * Validates whether this number is in a correct format */ public class PhoneFormatValidator implements Validator { @Override public void validate(UIFormInput uiInput) throws Exception { // TODO Auto-generated method stub String rex = "(?:(?:\\+?1\\s*(?:[.-]\\s*)?)?(?:(\\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]‌​)\\s*)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\\s*(?:[.-]\\s*)?)([2-9]1[02-9]‌​|[2-9][02-9]1|[2-9][02-9]{2})\\s*(?:[.-]\\s*)?([0-9]{4})\\s*(?:\\s*(?:#|x\\.?|ext\\.?|extension)\\s*(\\d+)\\s*)?$"; String value = (String)uiInput.getValue(); if(StringUtils.isEmpty(value)) return; Pattern pattern = Pattern.compile(rex);; Matcher matcher = pattern.matcher(value);; if(!matcher.matches()){ Object[] args = { uiInput.getName() }; throw new MessageException(new ApplicationMessage("ECMPhoneFormatValidator.msg.Invalid", args, ApplicationMessage.WARNING)) ; } } }
2,191
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IllegalDMSCharValidator.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/validator/IllegalDMSCharValidator.java
/* * Copyright (C) 2003-2007 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.form.validator; import org.exoplatform.web.application.ApplicationMessage; import org.exoplatform.webui.core.UIComponent; import org.exoplatform.webui.exception.MessageException; import org.exoplatform.webui.form.UIForm; import org.exoplatform.webui.form.UIFormInput; import org.exoplatform.webui.form.validator.Validator; /** * Created by The eXo Platform SARL * Author : Dang Van Minh * minh.dang@exoplatform.com * May 8, 2008 3:50:44 PM */ public class IllegalDMSCharValidator implements Validator { public void validate(UIFormInput uiInput) throws Exception { if (uiInput.getValue()==null || ((String)uiInput.getValue()).trim().length()==0) return; UIComponent uiComponent = (UIComponent) uiInput ; UIForm uiForm = uiComponent.getAncestorOfType(UIForm.class) ; String label; try{ label = uiForm.getLabel(uiInput.getName()); } catch(Exception e) { label = uiInput.getName(); } label = label.trim(); if(label.charAt(label.length() - 1) == ':') label = label.substring(0, label.length() - 1); String s = (String)uiInput.getValue(); if(s == null || s.trim().length() == 0) { Object[] args = { uiInput.getLabel() }; throw new MessageException(new ApplicationMessage("ECMNameValidator.msg.empty-input", args, ApplicationMessage.WARNING)); } for(int i = 0; i < s.length(); i ++){ char c = s.charAt(i); if(c=='[' || c==']' || c=='/' || c=='"') { Object[] args = { label }; throw new MessageException(new ApplicationMessage("ECMNameValidator.msg.Invalid-char", args, ApplicationMessage.WARNING)); } } } }
2,666
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
DateValidator.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/validator/DateValidator.java
/* * Copyright (C) 2003-2009 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.form.validator; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import org.exoplatform.web.application.ApplicationMessage; import org.exoplatform.webui.application.WebuiRequestContext; import org.exoplatform.webui.core.UIComponent; import org.exoplatform.webui.exception.MessageException; import org.exoplatform.webui.form.UIForm; import org.exoplatform.webui.form.UIFormDateTimeInput; import org.exoplatform.webui.form.UIFormInput; import org.exoplatform.webui.form.validator.DateTimeValidator; /** * Created by The eXo Platform SAS * Author : Phan Le Thanh Chuong * chuong_phan@exoplatform.com, phan.le.thanh.chuong@gmail.com * Oct 15, 2009 */ public class DateValidator extends DateTimeValidator { @SuppressWarnings("unchecked") public void validate(UIFormInput uiInput) throws Exception { String inputValue = ((String)uiInput.getValue()); if (inputValue.trim().indexOf(" ") > 0) { super.validate(uiInput); } else { validateDateFormat(uiInput); } } private void validateDateFormat(UIFormInput uiInput) throws Exception { String inputValue = ((String)uiInput.getValue()); try { WebuiRequestContext requestContext = WebuiRequestContext.getCurrentInstance(); DateFormat dateFormat_ = SimpleDateFormat.getDateInstance(DateFormat.SHORT, requestContext.getLocale()); dateFormat_.setLenient(false); dateFormat_.parse(inputValue); ((UIFormDateTimeInput)uiInput).setValue(inputValue + " 00:00:00"); } catch (ParseException parseEx) { //get label of datetime field UIComponent uiComponent = (UIComponent) uiInput ; UIForm uiForm = uiComponent.getAncestorOfType(UIForm.class) ; String label; try{ label = uiForm.getLabel(uiInput.getName()); } catch(Exception ex) { label = uiInput.getName(); } label = label.trim(); if(label.charAt(label.length() - 1) == ':') label = label.substring(0, label.length() - 1); //throw exception with msg throw new MessageException(new ApplicationMessage("DateTimeValidator.msg.Invalid-input", new Object[] { label, inputValue })); } } }
3,006
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
ECMNameValidator.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/validator/ECMNameValidator.java
/* * Copyright (C) 2003-2007 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.form.validator; import org.exoplatform.web.application.ApplicationMessage; import org.exoplatform.webui.core.UIComponent; import org.exoplatform.webui.exception.MessageException; import org.exoplatform.webui.form.UIForm; import org.exoplatform.webui.form.UIFormInput; import org.exoplatform.webui.form.validator.Validator; /** * Created by The eXo Platform SARL * Author : Dang Van Minh * minh.dang@exoplatform.com * May 8, 2008 3:50:44 PM */ public class ECMNameValidator implements Validator { public void validate(UIFormInput uiInput) throws Exception { if (uiInput.getValue()==null || ((String)uiInput.getValue()).trim().length()==0) return; UIComponent uiComponent = (UIComponent) uiInput ; UIForm uiForm = uiComponent.getAncestorOfType(UIForm.class) ; String label; try{ label = uiForm.getLabel(uiInput.getName()); } catch(Exception e) { label = uiInput.getName(); } label = label.trim(); if(label.charAt(label.length() - 1) == ':') label = label.substring(0, label.length() - 1); String s = (String)uiInput.getValue(); if(s == null || s.trim().length() == 0) { Object[] args = { uiInput.getLabel() }; throw new MessageException(new ApplicationMessage("ECMNameValidator.msg.empty-input", args, ApplicationMessage.WARNING)) ; } if(s.length() == 1) if(s.equals(".")){ Object[] args = { label }; throw new MessageException(new ApplicationMessage("ECMNameValidator.msg.Invalid-char", args, ApplicationMessage.WARNING)) ; } for(int i = 0; i < s.length(); i ++){ char c = s.charAt(i); if(Character.isLetter(c) || Character.isDigit(c) || Character.isSpaceChar(c) || c=='_' || c=='-' || c=='.' || c=='@' || c=='^' || c==',' || c=='\'') { continue ; } Object[] args = { label }; throw new MessageException(new ApplicationMessage("ECMNameValidator.msg.Invalid-char", args, ApplicationMessage.WARNING)) ; } } }
2,791
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
RepeatCountValidator.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/validator/RepeatCountValidator.java
/* * Copyright (C) 2003-2007 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.form.validator; import org.exoplatform.web.application.ApplicationMessage; import org.exoplatform.webui.exception.MessageException; import org.exoplatform.webui.form.UIFormInput; import org.exoplatform.webui.form.validator.Validator; import org.quartz.impl.triggers.SimpleTriggerImpl; /** * Created by The eXo Platform SARL * Author : Dang Van Minh * minh.dang@exoplatform.com * Aug 21, 2007 3:38:21 PM */ public class RepeatCountValidator implements Validator { public void validate(UIFormInput uiInput) throws Exception { try { int repeatCount = Integer.parseInt(uiInput.getValue().toString()) ; new SimpleTriggerImpl().setRepeatCount(repeatCount) ; } catch(Exception e) { throw new MessageException( new ApplicationMessage("RepeatCountValidator.msg.invalid-value", null, ApplicationMessage.WARNING)) ; } } }
1,637
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UploadFileMimeTypesValidator.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/form/validator/UploadFileMimeTypesValidator.java
/* * Copyright (C) 2003-2008 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.form.validator; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.exoplatform.web.application.ApplicationMessage; import org.exoplatform.webui.exception.MessageException; import org.exoplatform.webui.form.UIFormInput; import org.exoplatform.webui.form.input.UIUploadInput; import org.exoplatform.webui.form.validator.Validator; /** * Created by The eXo Platform SAS * Author : Nguyen Anh Vu * vuna@exoplatform.com * anhvurz90@yahoo.com * Jul 13, 2011 */ public class UploadFileMimeTypesValidator implements Validator { private String mimeTypes_; public UploadFileMimeTypesValidator() { } public UploadFileMimeTypesValidator(String mimeTypes) { this.mimeTypes_ = mimeTypes; } public void validate(UIFormInput uiInput) throws Exception { if (uiInput instanceof UIUploadInput) { UIUploadInput uploadInput = UIUploadInput.class.cast(uiInput); String uploadId = uploadInput.getUploadIds()[0]; String mimeTypeInput = uploadInput.getUploadResource(uploadId) == null ? null : uploadInput.getUploadResource(uploadId).getMimeType(); if (mimeTypes_ != null && mimeTypeInput != null) { if (mimeTypes_.contains(mimeTypeInput)) { return; } Pattern pattern = Pattern.compile(mimeTypes_.replace("*", ".*")); Matcher matcher = pattern.matcher(mimeTypeInput); if (!matcher.find()) { Object[] args = { mimeTypeInput, uploadInput.getName() }; throw new MessageException( new ApplicationMessage("UploadFileMimeTypesValidator.msg.wrong-mimetype",args, ApplicationMessage.WARNING)); } } } } }
2,413
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UINodeTypeSearch.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/nodetype/selector/UINodeTypeSearch.java
/*************************************************************************** * Copyright (C) 2003-2009 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. * **************************************************************************/ package org.exoplatform.ecm.webui.nodetype.selector; import org.exoplatform.ecm.webui.form.validator.NodeTypeNameValidator; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.form.UIForm; import org.exoplatform.webui.form.UIFormInputContainer; import org.exoplatform.webui.form.UIFormStringInput; import org.exoplatform.webui.form.UIFormInputBase; /** * Created by The eXo Platform SARL * Author : Hoang Van Hung * hunghvit@gmail.com * Dec 23, 2009 */ @ComponentConfig( template = "classpath:groovy/ecm/webui/nodetype/selector/UINodeTypeSearch.gtmpl" ) public class UINodeTypeSearch extends UIFormInputContainer<String> { public void init() throws Exception { if (getChild(UIFormStringInput.class) != null) { removeChild(UIFormStringInput.class); } UIFormInputBase typeInput = new UIFormStringInput("NodeTypeText", "NodeTypeText", null); String placeholder = getResource("UINodeTypeSearh.msg.title"); typeInput.setHTMLAttribute("placeholder", placeholder); addChild(typeInput); } public String event(String name) throws Exception { return getAncestorOfType(UIForm.class).event(name); } public String getResource(String key) { try { return Utils.getResourceBundle(Utils.LOCALE_WEBUI_DMS, key, getClass().getClassLoader()); } catch (Exception e) { return key; } } @Override public String getValue() throws Exception { return getChild(UIFormStringInput.class).getValue(); } public Class getTypeValue() { return String.class; } }
2,556
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UINodeTypeSelector.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/nodetype/selector/UINodeTypeSelector.java
/*************************************************************************** * Copyright (C) 2003-2009 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. * **************************************************************************/ package org.exoplatform.ecm.webui.nodetype.selector; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.regex.Pattern; import javax.jcr.nodetype.NodeType; import javax.jcr.nodetype.NodeTypeIterator; import javax.jcr.nodetype.NodeTypeManager; import org.exoplatform.commons.utils.LazyPageList; import org.exoplatform.commons.utils.ListAccess; import org.exoplatform.commons.utils.ListAccessImpl; import org.exoplatform.ecm.webui.selector.ComponentSelector; import org.exoplatform.ecm.webui.selector.UISelectable; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.services.cms.templates.TemplateService; import org.exoplatform.services.jcr.RepositoryService; import org.exoplatform.services.jcr.core.ManageableRepository; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.config.annotation.EventConfig; import org.exoplatform.webui.core.UIComponent; import org.exoplatform.webui.core.UIPageIterator; import org.exoplatform.webui.core.UIPopupWindow; import org.exoplatform.webui.core.lifecycle.UIFormLifecycle; import org.exoplatform.webui.event.Event; import org.exoplatform.webui.event.Event.Phase; import org.exoplatform.webui.event.EventListener; import org.exoplatform.webui.form.UIForm; import org.exoplatform.webui.form.UIFormStringInput; import org.exoplatform.webui.form.input.UICheckBoxInput; /** * Created by The eXo Platform SARL Author : Hoang Van Hung hunghvit@gmail.com * Dec 22, 2009 */ @ComponentConfig( lifecycle = UIFormLifecycle.class, template = "classpath:groovy/ecm/webui/nodetype/selector/UINodeTypeSelector.gtmpl", events = { @EventConfig(listeners = UINodeTypeSelector.SearchNodeTypeActionListener.class), @EventConfig(listeners = UINodeTypeSelector.SaveActionListener.class, phase = Phase.DECODE), @EventConfig(listeners = UINodeTypeSelector.RefreshActionListener.class, phase = Phase.DECODE), @EventConfig(listeners = UINodeTypeSelector.ShowPageActionListener.class, phase = Phase.DECODE), @EventConfig(listeners = UINodeTypeSelector.OnChangeActionListener.class, phase = Phase.DECODE), @EventConfig(listeners = UINodeTypeSelector.CloseActionListener.class, phase = Phase.DECODE) } ) public class UINodeTypeSelector extends UIForm implements ComponentSelector { private UIPageIterator uiPageIterator_; private UIComponent sourceUIComponent; private String returnFieldName = null; private String repositoryName = null; private List<String> selectedNodetypes = new ArrayList<String>(); private List<String> documentNodetypes = new ArrayList<String>(); private static final String ALL_DOCUMENT_TYPES = "ALL_DOCUMENT_TYPES"; private List<NodeTypeBean> lstNodetype; private String[] actions_ = {"Save", "Refresh", "Close"}; public String[] getActions() { return actions_; } public String getRepositoryName() { return repositoryName; } public void setRepositoryName(String repositoryName) { this.repositoryName = repositoryName; } public String getResource(String key) { try { return Utils.getResourceBundle(Utils.LOCALE_WEBUI_DMS, key, getClass().getClassLoader()); } catch (Exception e) { return key; } } public List<NodeTypeBean> getLSTNodetype() { return lstNodetype; } public void setLSTNodetype(List<NodeTypeBean> lstNodetype) { this.lstNodetype = lstNodetype; } public List<String> getDocumentNodetypes() { return documentNodetypes; } public void setDocumentNodetypes(List<String> documentNodetypes) { this.documentNodetypes = documentNodetypes; } public UINodeTypeSelector() throws Exception { addChild(UINodeTypeSearch.class, null, "SearchNodeType"); uiPageIterator_ = addChild(UIPageIterator.class, null, "UINodeTypeSelectorIterator"); } public String getReturnFieldName() { return returnFieldName; } public void setReturnFieldName(String name) { this.returnFieldName = name; } public UIComponent getSourceComponent() { return sourceUIComponent; } public void setSourceComponent(UIComponent uicomponent, String[] initParams) { sourceUIComponent = uicomponent; if (initParams == null || initParams.length < 0) return; for (int i = 0; i < initParams.length; i++) { if (initParams[i].indexOf("returnField") > -1) { String[] array = initParams[i].split("="); returnFieldName = array[1]; break; } returnFieldName = initParams[0]; } } public UIPageIterator getUIPageIterator() { return uiPageIterator_; } public List<NodeTypeBean> getNodeTypeList() throws Exception { return uiPageIterator_.getCurrentPageData(); } public List<NodeTypeBean> getAllNodeTypes() throws Exception{ List<NodeTypeBean> nodeList = new ArrayList<NodeTypeBean>(); ManageableRepository mRepository = getApplicationComponent(RepositoryService.class).getCurrentRepository() ; NodeTypeManager ntManager = mRepository.getNodeTypeManager() ; NodeTypeIterator nodeTypeIter = ntManager.getAllNodeTypes() ; while(nodeTypeIter.hasNext()) { nodeList.add(new NodeTypeBean(nodeTypeIter.nextNodeType())) ; } Collections.sort(nodeList, new NodeTypeNameComparator()) ; return nodeList ; } protected boolean getCheckedValue(List<String> values, String name) { if (values.contains(name)) return true; return false; } public void init(int currentPage, List<String> values) throws Exception { lstNodetype = getAllNodeTypes(); TemplateService templateService = getApplicationComponent(TemplateService.class); documentNodetypes = templateService.getAllDocumentNodeTypes(); getChild(UINodeTypeSearch.class).init(); init(currentPage, values, lstNodetype); } protected void init(int currentPage, List<String> values, List<NodeTypeBean> lstNodetype) throws Exception { if (lstNodetype == null) return; ListAccess<NodeTypeBean> nodeTypeList = new ListAccessImpl<NodeTypeBean>(NodeTypeBean.class, lstNodetype); LazyPageList<NodeTypeBean> pageList = new LazyPageList<NodeTypeBean>(nodeTypeList, 5); uiPageIterator_.setPageList(pageList); if (currentPage > uiPageIterator_.getAvailablePage()) uiPageIterator_.setCurrentPage(uiPageIterator_.getAvailablePage()); else uiPageIterator_.setCurrentPage(currentPage); UICheckBoxInput uiCheckbox = new UICheckBoxInput(ALL_DOCUMENT_TYPES, null, null); uiCheckbox.setOnChange("OnChange"); if (values != null) { if (values.containsAll(getDocumentNodetypes()) && !values.contains(ALL_DOCUMENT_TYPES)) values.add(ALL_DOCUMENT_TYPES); if (values.contains(ALL_DOCUMENT_TYPES)) { uiCheckbox.setChecked(true); if (!getSelectedNodetypes().contains(ALL_DOCUMENT_TYPES)) getSelectedNodetypes().add(ALL_DOCUMENT_TYPES); } } addChild(uiCheckbox); for(NodeTypeBean nt : lstNodetype) { String ntName = nt.getName(); uiCheckbox = new UICheckBoxInput(ntName, ntName, null); uiCheckbox.setOnChange("OnChange"); if(values != null) { if(values.contains(ntName)) { uiCheckbox.setChecked(true); if (!getSelectedNodetypes().contains(ntName)) getSelectedNodetypes().add(ntName); } } removeChildById(ntName); addChild(uiCheckbox); } if (values == null) getSelectedNodetypes().clear(); } public void setSelectedNodetypes(List<String> selectedNodetypes) { this.selectedNodetypes = selectedNodetypes; } public List<String> getSelectedNodetypes() { return selectedNodetypes; } public static class SearchNodeTypeActionListener extends EventListener<UINodeTypeSelector> { public void execute(Event<UINodeTypeSelector> event) throws Exception { UINodeTypeSelector uiNodeTypeSelect = event.getSource(); UIFormStringInput uiInputNodeType = (UIFormStringInput)uiNodeTypeSelect.findComponentById("NodeTypeText"); String nodeTypeName = uiInputNodeType.getValue(); if (nodeTypeName == null || nodeTypeName.length() == 0) return; if (nodeTypeName.contains("*") && !nodeTypeName.contains(".*")) { nodeTypeName = nodeTypeName.replace("*", ".*"); } Pattern p = Pattern.compile(".*".concat(nodeTypeName.trim()).concat(".*"), Pattern.CASE_INSENSITIVE); if (uiNodeTypeSelect.lstNodetype == null) { uiNodeTypeSelect.lstNodetype = uiNodeTypeSelect.getAllNodeTypes(); } List<NodeTypeBean> lstNodetype = new ArrayList<NodeTypeBean>(); for (NodeTypeBean nodeType : uiNodeTypeSelect.lstNodetype) { if (p.matcher(nodeType.getName()).find()) { lstNodetype.add(nodeType); } } uiNodeTypeSelect.init(1, uiNodeTypeSelect.getSelectedNodetypes(), lstNodetype); UIPopupWindow uiPopup = event.getSource().getAncestorOfType(UIPopupWindow.class); uiPopup.setShowMask(true); event.getRequestContext().addUIComponentToUpdateByAjax(uiPopup); } } public static class SaveActionListener extends EventListener<UINodeTypeSelector> { public void execute(Event<UINodeTypeSelector> event) throws Exception { UINodeTypeSelector uiNodeTypeSelect = event.getSource(); List<String> selectedNodetypes = uiNodeTypeSelect.getSelectedNodetypes(); String returnField = uiNodeTypeSelect.getReturnFieldName(); if (selectedNodetypes.contains(ALL_DOCUMENT_TYPES)) { selectedNodetypes.remove(ALL_DOCUMENT_TYPES); for (String docNodeType : uiNodeTypeSelect.getDocumentNodetypes()) { if (!selectedNodetypes.contains(docNodeType) && ((UICheckBoxInput) uiNodeTypeSelect.findComponentById(docNodeType)).isChecked()) { selectedNodetypes.add(docNodeType); } } } ((UISelectable)(uiNodeTypeSelect).getSourceComponent()).doSelect(returnField, selectedNodetypes); selectedNodetypes.clear(); UIPopupWindow uiPopup = event.getSource().getAncestorOfType(UIPopupWindow.class); if (uiPopup != null) { uiPopup.setShow(false); uiPopup.setRendered(false); } UIComponent component = event.getSource().getSourceComponent().getParent(); if (component != null) { event.getRequestContext().addUIComponentToUpdateByAjax(component); } } } public static class ShowPageActionListener extends EventListener<UIPageIterator> { public void execute(Event<UIPageIterator> event) throws Exception { UINodeTypeSelector uiNodeTypeSelect = event.getSource().getAncestorOfType(UINodeTypeSelector.class); List<String> selectedNodetypes = uiNodeTypeSelect.getSelectedNodetypes(); List<UICheckBoxInput> listCheckbox = new ArrayList<UICheckBoxInput>(); uiNodeTypeSelect.findComponentOfType(listCheckbox, UICheckBoxInput.class); for (UICheckBoxInput uiCheckBox : listCheckbox) { if (selectedNodetypes.contains(uiCheckBox.getName().toString())) { uiCheckBox.setChecked(true); } else { uiCheckBox.setChecked(false); } } } } public static class OnChangeActionListener extends EventListener<UINodeTypeSelector> { private void updateCheckBox(List<String> selectedNodetypes, UICheckBoxInput uiCheckBox) { if (uiCheckBox.isChecked()) { if (!selectedNodetypes.contains(uiCheckBox.getName().toString())) selectedNodetypes.add(uiCheckBox.getName().toString()); } else { selectedNodetypes.remove(uiCheckBox.getName().toString()); } } public void execute(Event<UINodeTypeSelector> event) throws Exception { UINodeTypeSelector uiNodeTypeSelect = event.getSource(); List<String> selectedNodetypes = uiNodeTypeSelect.getSelectedNodetypes(); List<String> preSelectedNodetypes = new ArrayList<String>(); preSelectedNodetypes.addAll(selectedNodetypes); List<NodeTypeBean> lstNodeType = uiNodeTypeSelect.getNodeTypeList(); UICheckBoxInput uiCheckBox = (UICheckBoxInput)uiNodeTypeSelect.getChildById(ALL_DOCUMENT_TYPES); updateCheckBox(selectedNodetypes, uiCheckBox); for (NodeTypeBean nodetype : lstNodeType) { uiCheckBox = (UICheckBoxInput) uiNodeTypeSelect.getChildById(nodetype.getName()); updateCheckBox(selectedNodetypes, uiCheckBox); } // if at this times, check box 'ALL_DOCUMENT_TYPES' change if (selectedNodetypes.contains(ALL_DOCUMENT_TYPES) && !preSelectedNodetypes.contains(ALL_DOCUMENT_TYPES)) { for(String nodeTypeName : uiNodeTypeSelect.getDocumentNodetypes()) { ((UICheckBoxInput) uiNodeTypeSelect.getChildById(nodeTypeName)).setChecked(true); if (!selectedNodetypes.contains(nodeTypeName)) selectedNodetypes.add(nodeTypeName); } } else if (!selectedNodetypes.contains(ALL_DOCUMENT_TYPES) && preSelectedNodetypes.contains(ALL_DOCUMENT_TYPES)) { if (selectedNodetypes.containsAll(uiNodeTypeSelect.getDocumentNodetypes())) for (String nodeTypeName : uiNodeTypeSelect.getDocumentNodetypes()) { ((UICheckBoxInput) uiNodeTypeSelect.getChildById(nodeTypeName)).setChecked(false); selectedNodetypes.remove(nodeTypeName); } } UIPopupWindow uiPopup = event.getSource().getAncestorOfType(UIPopupWindow.class); uiPopup.setShowMask(true); event.getRequestContext().addUIComponentToUpdateByAjax(uiPopup); } } public static class CloseActionListener extends EventListener<UINodeTypeSelector> { public void execute(Event<UINodeTypeSelector> event) throws Exception { UIPopupWindow uiPopup = event.getSource().getAncestorOfType(UIPopupWindow.class); uiPopup.setShow(false); uiPopup.setRendered(false); event.getRequestContext().addUIComponentToUpdateByAjax(uiPopup); } } public static class RefreshActionListener extends EventListener<UINodeTypeSelector> { public void execute(Event<UINodeTypeSelector> event) throws Exception { UINodeTypeSelector uiNodeTypeSelect = event.getSource(); List<UICheckBoxInput> listCheckbox = new ArrayList<UICheckBoxInput>(); uiNodeTypeSelect.findComponentOfType(listCheckbox, UICheckBoxInput.class); for (int i = 0; i < listCheckbox.size(); i++) { listCheckbox.get(i).setChecked(false); uiNodeTypeSelect.getSelectedNodetypes().clear(); } UIPopupWindow uiPopup = event.getSource().getAncestorOfType(UIPopupWindow.class); uiPopup.setShowMask(true); event.getRequestContext().addUIComponentToUpdateByAjax(uiPopup); } } public static class NodeTypeBean { private String nodeTypeName_; private boolean isMixin_; public NodeTypeBean(NodeType nodeType) { this.nodeTypeName_ = nodeType.getName(); this.isMixin_ = nodeType.isMixin(); } public String getName() { return nodeTypeName_; } public void setName(String nodeTypeName) { nodeTypeName_ = nodeTypeName; } public boolean isMixin() { return isMixin_; } public void setMixin(boolean isMixin) { isMixin_ = isMixin; } } static public class NodeTypeNameComparator implements Comparator<NodeTypeBean> { public int compare(NodeTypeBean n1, NodeTypeBean n2) throws ClassCastException { String name1 = n1.getName(); String name2 = n2.getName(); return name1.compareToIgnoreCase(name2); } } }
16,952
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIECMPageIterator.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/core/UIECMPageIterator.java
/* * Copyright (C) 2003-2011 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.core; import java.util.Arrays; import org.exoplatform.commons.serialization.api.annotations.Serialized; import org.exoplatform.commons.utils.PageList; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.config.annotation.EventConfig; import org.exoplatform.webui.core.UIComponent; import org.exoplatform.webui.core.UIPageIterator; import org.exoplatform.webui.event.Event; import org.exoplatform.webui.event.EventListener; /** * Created by The eXo Platform SAS * Author : Dang Viet Ha * hadv@exoplatform.com * 19-05-2011 */ /** * A component that allows pagination, with an iterator to change pages * */ @ComponentConfig(template = "classpath:groovy/ecm/webui/core/UIPageIterator.gtmpl", events = { @EventConfig(listeners = UIECMPageIterator.ShowPageActionListener.class), @EventConfig(listeners = UIECMPageIterator.ChangeMaxSizePageActionListener.class) }) @Serialized public class UIECMPageIterator extends UIPageIterator { /** * The list of pages */ private int itemsPerPage_ = 0; private int totalItems = 0; private boolean useMaxSizeSetting_ = false; public static final int[] MAX_ITEMS_PER_PAGE = new int[] { 5, 10, 15, 20, 30, 60, 100 }; private boolean justPaginated_ = false; public boolean isJustPaginated() { return justPaginated_; } public void setJustPaginated(boolean value) { justPaginated_ = value; } public UIECMPageIterator() { } public int[] getMaxItemPerPageList() { int pageSize = this.getItemsPerPage(); if (isPageSizeInList(pageSize)) { return MAX_ITEMS_PER_PAGE; } else { int length = MAX_ITEMS_PER_PAGE.length + 1; int[] pageSizeList = new int[length]; System.arraycopy(MAX_ITEMS_PER_PAGE, 0, pageSizeList, 0, MAX_ITEMS_PER_PAGE.length); pageSizeList[pageSizeList.length - 1] = pageSize; Arrays.sort(pageSizeList); return pageSizeList; } } public int getItemsPerPage() { if (itemsPerPage_ <= 0) { itemsPerPage_ = 10; } return itemsPerPage_; } public void setItemsPerPage(int itemsPerPage) { this.itemsPerPage_ = itemsPerPage; } public int getTotalItems() { return totalItems; } public void setTotalItems(int totalItems) { this.totalItems = totalItems; } /** * @param useMaxSizeSetting_ the useMaxSizeSetting_ to set */ public void setUseMaxSizeSetting(boolean useMaxSizeSetting_) { this.useMaxSizeSetting_ = useMaxSizeSetting_; } /** * @return the useMaxSizeSetting_ */ public boolean isUseMaxSizeSetting() { return useMaxSizeSetting_; } public void setPageList(PageList pageList) { super.setPageList(pageList); this.itemsPerPage_ = pageList.getPageSize(); } private boolean isPageSizeInList(int pageSize) { for (int size : MAX_ITEMS_PER_PAGE) { if (size == pageSize) { return true; } } return false; } static public class ShowPageActionListener extends EventListener<UIECMPageIterator> { public void execute(Event<UIECMPageIterator> event) throws Exception { UIECMPageIterator uiPageIterator = event.getSource(); int page = Integer.parseInt(event.getRequestContext().getRequestParameter(OBJECTID)); uiPageIterator.setCurrentPage(page); uiPageIterator.setJustPaginated(true); UIComponent parent = uiPageIterator.getParent(); if (parent == null) return; event.getRequestContext().addUIComponentToUpdateByAjax(parent); parent.broadcast(event, event.getExecutionPhase()); } } static public class ChangeMaxSizePageActionListener extends EventListener<UIECMPageIterator>{ public void execute(Event<UIECMPageIterator> event) throws Exception { UIECMPageIterator uiPageIterator = event.getSource(); int itemsPerPage = Integer.parseInt(event.getRequestContext().getRequestParameter(OBJECTID)); uiPageIterator.setItemsPerPage(itemsPerPage); UIComponent parent = uiPageIterator.getParent(); if (parent == null) return; if (parent instanceof UIPagingGrid ) { ((UIPagingGrid)parent).refresh(uiPageIterator.getCurrentPage()); } else if (parent instanceof UIPagingGridDecorator) { ((UIPagingGridDecorator)parent).refresh(uiPageIterator.getCurrentPage()); } event.getRequestContext().addUIComponentToUpdateByAjax(parent); } } }
5,202
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIPagingGridDecorator.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/core/UIPagingGridDecorator.java
/* * Copyright (C) 2003-2011 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.core; import org.exoplatform.webui.core.UIComponentDecorator; /** * Created by The eXo Platform SAS * Author : Dang Viet Ha * hadv@exoplatform.com * 31-05-2011 */ public abstract class UIPagingGridDecorator extends UIComponentDecorator { /** The page iterator */ protected UIECMPageIterator uiIterator_; public UIPagingGridDecorator() throws Exception { uiIterator_ = createUIComponent(UIECMPageIterator.class, null, null); setUIComponent(uiIterator_); } public UIECMPageIterator getUIPageIterator() { return uiIterator_; } public abstract void refresh(int currentPage) throws Exception; }
1,391
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIPagingGrid.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/core/UIPagingGrid.java
/* * Copyright (C) 2003-2011 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.core; import java.util.List; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.core.UIComponent; import org.exoplatform.webui.core.UIGrid; /** * Created by The eXo Platform SAS * Author : Dang Viet Ha * hadv@exoplatform.com * 30-05-2011 */ @ComponentConfig(template = "classpath:groovy/ecm/webui/core/UIGrid.gtmpl") public abstract class UIPagingGrid extends UIGrid { /** The page iterator */ protected UIECMPageIterator uiPageIterator_; public UIPagingGrid() throws Exception { uiPageIterator_ = createUIComponent(UIECMPageIterator.class, null, null); uiPageIterator_.setParent(this); } public abstract void refresh(int currentPage) throws Exception; public UIECMPageIterator getUIPageIterator() { return uiPageIterator_; } public List<?> getBeans() throws Exception { return uiPageIterator_.getCurrentPageData(); } public UIComponent findComponentById(String lookupId) { if (uiPageIterator_.getId().equals(lookupId)) { return uiPageIterator_; } return super.findComponentById(lookupId); } }
1,883
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIPermissionInfoBase.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/core/UIPermissionInfoBase.java
/* * Copyright (C) 2003-2007 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.core; import java.security.AccessControlException; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; import javax.jcr.AccessDeniedException; import javax.jcr.Node; import javax.jcr.RepositoryException; import org.exoplatform.commons.utils.LazyPageList; import org.exoplatform.commons.utils.ListAccess; import org.exoplatform.commons.utils.ListAccessImpl; import org.exoplatform.ecm.webui.core.bean.PermissionBean; import org.exoplatform.ecm.webui.utils.PermissionUtil; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.services.jcr.access.AccessControlEntry; import org.exoplatform.services.jcr.access.PermissionType; import org.exoplatform.services.jcr.core.ExtendedNode; import org.exoplatform.services.security.IdentityConstants; import org.exoplatform.web.application.ApplicationMessage; import org.exoplatform.webui.application.WebuiRequestContext; import org.exoplatform.webui.core.UIApplication; import org.exoplatform.webui.core.UIContainer; import org.exoplatform.webui.core.UIGrid; import org.exoplatform.webui.event.Event; import org.exoplatform.webui.event.EventListener; public abstract class UIPermissionInfoBase extends UIContainer { protected static final String FIELD_NAME = "fieldName"; protected static final String FIELD_VALUE = "fieldValue"; protected static final String EDIT_ACTION = "Edit"; private static final String PERMISSION_ADD_NODE_ACTION = "addNode"; public static String[] PERMISSION_BEAN_FIELD = {"usersOrGroups", PermissionType.READ, PERMISSION_ADD_NODE_ACTION, PermissionType.REMOVE}; private static String[] PERMISSION_ACTION = {"Delete"} ; private int sizeOfListPermission = 0; public UIPermissionInfoBase() throws Exception { UIGrid uiGrid = createUIComponent(UIPermissionInfoGrid.class, null, "PermissionInfo") ; addChild(uiGrid) ; uiGrid.getUIPageIterator().setId("PermissionInfoIterator"); uiGrid.configure("usersOrGroups", PERMISSION_BEAN_FIELD, PERMISSION_ACTION) ; } public abstract Node getCurrentNode() throws Exception; public int getSizeOfListPermission() { return sizeOfListPermission; } public void setSizeOfListPermission(int sizeOfListPermission) { this.sizeOfListPermission = sizeOfListPermission; } public void updateGrid(int currentPage) throws Exception { List<PermissionBean> permBeans = new ArrayList<>(); ExtendedNode node = (ExtendedNode) this.getCurrentNode(); Map<String, List<String>> permsMap = this.getPermissionsMap(node); Set<String> keys = permsMap.keySet(); Iterator<String> keysIter = keys.iterator() ; int iSystemOwner = 0; //TODO Utils.getExoOwner(node) has exception return SystemIdentity.SYSTEM String owner = IdentityConstants.SYSTEM ; if(getExoOwner(node) != null) owner = getExoOwner(node); if (owner.equals(IdentityConstants.SYSTEM)) iSystemOwner = -1; PermissionBean permOwnerBean = new PermissionBean(); if(!permsMap.containsKey(owner)) { permOwnerBean.setUsersOrGroups(owner); permOwnerBean.setRead(true) ; permOwnerBean.setAddNode(true) ; permOwnerBean.setRemove(true) ; permBeans.add(permOwnerBean); } while (keysIter.hasNext()) { String userOrGroup = keysIter.next(); PermissionBean permBean = new PermissionBean(); permBean.setUsersOrGroups(userOrGroup); // owner always has full right even if it has been modified in GUI if (owner.equals(userOrGroup)) { permBean.setRead(true); permBean.setAddNode(true); permBean.setRemove(true); } else { List<String> permissions = permsMap.get(userOrGroup); for (String perm : permissions) { if (PermissionType.READ.equals(perm)) permBean.setRead(true); else if (PermissionType.ADD_NODE.equals(perm)) permBean.setAddNode(true); else if (PermissionType.REMOVE.equals(perm)) permBean.setRemove(true); } } permBeans.add(permBean); sizeOfListPermission = permBeans.size() + iSystemOwner; } UIGrid uiGrid = findFirstComponentOfType(UIGrid.class); // Sort by user/group Collections.sort(permBeans, new PermissionBeanComparator()); ListAccess<PermissionBean> permList = new ListAccessImpl<>(PermissionBean.class, permBeans); LazyPageList<PermissionBean> dataPageList = new LazyPageList<>(permList, 10); uiGrid.getUIPageIterator().setPageList(dataPageList); if (currentPage > uiGrid.getUIPageIterator().getAvailablePage()) uiGrid.getUIPageIterator().setCurrentPage(uiGrid.getUIPageIterator().getAvailablePage()); else uiGrid.getUIPageIterator().setCurrentPage(currentPage); } protected String getExoOwner(Node node) throws Exception { return Utils.getNodeOwner(node) ; } /** * Get permission Map of specific node. * * @param node * @return * @throws RepositoryException */ private Map<String, List<String>> getPermissionsMap(ExtendedNode node) throws RepositoryException { Map<String, List<String>> permsMap = new HashMap<>(); Iterator<AccessControlEntry> permissionEntriesIter = node.getACL().getPermissionEntries().iterator(); while(permissionEntriesIter.hasNext()) { AccessControlEntry accessControlEntry = permissionEntriesIter.next(); String currentIdentity = accessControlEntry.getIdentity(); String currentPermission = accessControlEntry.getPermission(); List<String> currentPermissionsList = permsMap.get(currentIdentity); if(!permsMap.containsKey(currentIdentity)) { permsMap.put(currentIdentity, null) ; } if(currentPermissionsList == null) currentPermissionsList = new ArrayList<>() ; if(!currentPermissionsList.contains(currentPermission)) { currentPermissionsList.add(currentPermission) ; } permsMap.put(currentIdentity, currentPermissionsList) ; } return permsMap; } public List<PermissionBean> getPermBeans() { return new ArrayList<>(); } public static class EditActionListener extends EventListener<UIPermissionInfoBase> { public void execute(Event<UIPermissionInfoBase> event) throws Exception { UIPermissionInfoBase uiPermissionInfo = event.getSource(); UIApplication uiApp = uiPermissionInfo.getAncestorOfType(UIApplication.class); WebuiRequestContext requestContext = event.getRequestContext(); ExtendedNode node = (ExtendedNode)uiPermissionInfo.getCurrentNode(); // Get selected user/Group String userOrGroupId = requestContext.getRequestParameter(OBJECTID); // Changed permission value String selectedPermission = requestContext.getRequestParameter(FIELD_NAME); String selectedPermissionValue = requestContext.getRequestParameter(FIELD_VALUE); if (node == null) { List<PermissionBean> perBeans = uiPermissionInfo.getPermBeans(); for (PermissionBean perm : perBeans) { if (perm.getUsersOrGroups().equals(userOrGroupId)) { if (PermissionType.READ.equals(selectedPermission) && !perm.isAddNode() && !perm.isRemove()) { if (Boolean.FALSE.toString().equals(selectedPermissionValue)) { uiApp.addMessage(new ApplicationMessage("UIPermissionForm.msg.checkbox-require", null, ApplicationMessage.WARNING)); return; } perm.setRead("true".equals(selectedPermissionValue)); } else if (PERMISSION_ADD_NODE_ACTION.equals(selectedPermission) || PermissionType.SET_PROPERTY.equals(selectedPermission)) { perm.setAddNode("true".equals(selectedPermissionValue)); if (perm.isAddNode()) perm.setRead(true); } else if (PermissionType.REMOVE.equals(selectedPermission)) { perm.setRemove("true".equals(selectedPermissionValue)); if (perm.isRemove()) perm.setRead(true); } } } event.getRequestContext().addUIComponentToUpdateByAjax(uiPermissionInfo); return; } if (!node.isCheckedOut()) { uiApp.addMessage(new ApplicationMessage("UIActionBar.msg.node-checkedin", null, ApplicationMessage.WARNING)); return; } // Current node permissions Map<String, List<String>> permsMap = uiPermissionInfo.getPermissionsMap(node); // Current user/group permissions List<String> identityPermissions = permsMap.get(userOrGroupId); // org.exoplatform.wcm.webui.Utils.addLockToken(node); try { // Change permission if (PermissionUtil.canChangePermission(node)) { if (node.canAddMixin("exo:privilegeable")){ node.addMixin("exo:privilegeable"); node.setPermission(Utils.getNodeOwner(node),PermissionType.ALL); } if (Boolean.valueOf(selectedPermissionValue)) { if (PERMISSION_ADD_NODE_ACTION.equals(selectedPermission)) { identityPermissions.add(PermissionType.SET_PROPERTY); identityPermissions.add(PermissionType.ADD_NODE); } else { identityPermissions.add(selectedPermission); } } else { // Do not allow remove when only one permission type exist if (identityPermissions.size() == 1) { uiApp.addMessage(new ApplicationMessage("UIPermissionForm.msg.checkbox-require", null, ApplicationMessage.WARNING)); return; } if (PERMISSION_ADD_NODE_ACTION.equals(selectedPermission)) { identityPermissions.remove(PermissionType.SET_PROPERTY); identityPermissions.remove(PermissionType.ADD_NODE); } else if (PermissionType.REMOVE.equals(selectedPermission)) { identityPermissions.remove(selectedPermission); } } node.setPermission(userOrGroupId, identityPermissions.toArray(new String[identityPermissions.size()])); } UIPermissionFormBase uiPermissionForm = uiPermissionInfo.getAncestorOfType(UIPermissionManagerBase.class).getChild(UIPermissionFormBase.class); uiPermissionForm.updateSymlinks(node); node.getSession().save(); uiPermissionInfo.updateGrid(uiPermissionInfo.getChild(UIGrid.class).getUIPageIterator().getCurrentPage()); event.getRequestContext().addUIComponentToUpdateByAjax(uiPermissionInfo); } catch (AccessDeniedException | AccessControlException e) { uiApp.addMessage(new ApplicationMessage("UIPermissionForm.msg.access-denied", null, ApplicationMessage.WARNING)); } } } public class PermissionBeanComparator implements Comparator<PermissionBean> { public int compare(PermissionBean o1, PermissionBean o2) throws ClassCastException { try { String name1 = o1.getUsersOrGroups(); String name2 = o2.getUsersOrGroups(); return name1.compareToIgnoreCase(name2); } catch(Exception e) { return 0; } } } }
12,461
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIPermissionInfoGrid.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/core/UIPermissionInfoGrid.java
/* * Copyright (C) 2003-2013 eXo Platform SAS. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program 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 Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.core; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.core.UIGrid; /** * Created by The eXo Platform SAS * Author : eXoPlatform * exo@exoplatform.com * Apr 8, 2013 */ @ComponentConfig(template = "classpath:groovy/wcm/webui/core/UIPermissionInfoGrid.gtmpl") public class UIPermissionInfoGrid extends UIGrid { public UIPermissionInfoGrid() throws Exception { super(); } }
1,197
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIPermissionFormBase.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/core/UIPermissionFormBase.java
/* * Copyright (C) 2003-2007 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.core; import java.util.Iterator; import java.util.List; import javax.jcr.Node; import org.exoplatform.ecm.permission.info.UIPermissionInputSet; import org.exoplatform.ecm.webui.selector.UIGroupMemberSelector; import org.exoplatform.ecm.webui.selector.UISelectable; import org.exoplatform.ecm.webui.utils.PermissionUtil; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.services.cms.link.LinkManager; import org.exoplatform.services.jcr.access.AccessControlEntry; import org.exoplatform.services.jcr.access.PermissionType; import org.exoplatform.services.jcr.core.ExtendedNode; import org.exoplatform.services.log.ExoLogger; import org.exoplatform.services.log.Log; import org.exoplatform.services.security.IdentityConstants; import org.exoplatform.services.wcm.core.NodetypeConstant; import org.exoplatform.services.wcm.utils.WCMCoreUtils; import org.exoplatform.webui.core.UIPopupContainer; import org.exoplatform.webui.event.Event; import org.exoplatform.webui.event.EventListener; import org.exoplatform.webui.form.UIForm; public abstract class UIPermissionFormBase extends UIForm implements UISelectable { public static final String PERMISSION = "permission"; public static final String POPUP_SELECT = "SelectUserOrGroup"; public static final String SYMLINK = "exo:symlink"; private static final String[] PERMISSION_TYPES = {PermissionType.READ, PermissionType.ADD_NODE, PermissionType.REMOVE}; protected static final Log LOG = ExoLogger.getLogger(UIPermissionFormBase.class.getName()); public UIPermissionFormBase() throws Exception { addChild(new UIPermissionInputSet(PERMISSION)); setActions(new String[] { "Save", "Reset", "Close" }); } public abstract Node getCurrentNode() throws Exception; public void fillForm(String user, ExtendedNode node) throws Exception { UIPermissionInputSet uiInputSet = getChildById(PERMISSION); refresh(); uiInputSet.getUIStringInput(UIPermissionInputSet.FIELD_USERORGROUP).setValue(user); if(user.equals(Utils.getNodeOwner(node))) { for (String perm : PERMISSION_TYPES) { uiInputSet.getUICheckBoxInput(perm).setChecked(true); } } else { List<AccessControlEntry> permsList = node.getACL().getPermissionEntries(); Iterator<AccessControlEntry> perIter = permsList.iterator(); StringBuilder userPermission = new StringBuilder(); while(perIter.hasNext()) { AccessControlEntry accessControlEntry = perIter.next(); if(user.equals(accessControlEntry.getIdentity())) { userPermission.append(accessControlEntry.getPermission()).append(" "); } } for (String perm : PERMISSION_TYPES) { boolean isCheck = userPermission.toString().contains(perm); uiInputSet.getUICheckBoxInput(perm).setChecked(isCheck); } } } public void updateSymlinks(Node node) throws Exception { if(node.isNodeType(NodetypeConstant.MIX_REFERENCEABLE)){ LinkManager linkManager = WCMCoreUtils.getService(LinkManager.class); List<Node> symlinks = linkManager.getAllLinks(node, SYMLINK); for (Node symlink : symlinks) { try { linkManager.updateLink(symlink, node); } catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn(e.getMessage()); } } } } } protected void lockForm(boolean isLock) { UIPermissionInputSet uiInputSet = getChildById(PERMISSION); if(isLock) { uiInputSet.setButtonActions(new String[] {"Reset" }); } else { uiInputSet.setButtonActions(new String[] {"Save", "Reset" }); } for (String perm : PERMISSION_TYPES) { uiInputSet.getUICheckBoxInput(perm).setDisabled(isLock); } } protected boolean isEditable(Node node) throws Exception { return PermissionUtil.canChangePermission(node); } protected void refresh() { reset(); checkAll(false); } protected void checkAll(boolean check) { UIPermissionInputSet uiInputSet = getChildById(PERMISSION); for (String perm : PERMISSION_TYPES) { uiInputSet.getUICheckBoxInput(perm).setChecked(check); } } protected String getExoOwner(Node node) throws Exception { return Utils.getNodeOwner(node); } static public class ResetActionListener extends EventListener<UIPermissionFormBase> { public void execute(Event<UIPermissionFormBase> event) throws Exception { UIPermissionFormBase uiForm = event.getSource(); uiForm.lockForm(false); uiForm.refresh(); event.getRequestContext().addUIComponentToUpdateByAjax(uiForm); } } static public class SelectUserActionListener extends EventListener<UIPermissionFormBase> { public void execute(Event<UIPermissionFormBase> event) throws Exception { UIPermissionFormBase uiForm = event.getSource(); ((UIPermissionManagerBase)uiForm.getParent()).initUserSelector(); UIPopupContainer popupContainer = uiForm.getAncestorOfType(UIPopupContainer.class); if (popupContainer != null) { event.getRequestContext().addUIComponentToUpdateByAjax(popupContainer); } else { event.getRequestContext().addUIComponentToUpdateByAjax(uiForm.getParent()); } } } static public class AddAnyActionListener extends EventListener<UIPermissionFormBase> { public void execute(Event<UIPermissionFormBase> event) throws Exception { UIPermissionFormBase uiForm = event.getSource(); UIPermissionInputSet uiInputSet = uiForm.getChildById(UIPermissionFormBase.PERMISSION); uiInputSet.getUIStringInput(UIPermissionInputSet.FIELD_USERORGROUP).setValue(IdentityConstants.ANY); uiForm.checkAll(false); uiInputSet.getUICheckBoxInput(PermissionType.READ).setChecked(true); UIPopupContainer popupContainer = uiForm.getAncestorOfType(UIPopupContainer.class); if (popupContainer != null) { event.getRequestContext().addUIComponentToUpdateByAjax(popupContainer); } else { event.getRequestContext().addUIComponentToUpdateByAjax(uiForm.getParent()); } } } static public class SelectMemberActionListener extends EventListener<UIPermissionFormBase> { public void execute(Event<UIPermissionFormBase> event) throws Exception { UIPermissionFormBase uiForm = event.getSource(); UIGroupMemberSelector uiGroupMemberSelector = uiForm.createUIComponent(UIGroupMemberSelector.class, null, null); uiGroupMemberSelector.setSourceComponent(uiForm, new String[] { UIPermissionInputSet.FIELD_USERORGROUP }); uiForm.getAncestorOfType(UIPermissionManagerBase.class).initPopupPermission(uiGroupMemberSelector); UIPopupContainer popupContainer = uiForm.getAncestorOfType(UIPopupContainer.class); if (popupContainer != null) { event.getRequestContext().addUIComponentToUpdateByAjax(popupContainer); } else { event.getRequestContext().addUIComponentToUpdateByAjax(uiForm.getParent()); } } } }
7,900
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIPermissionManagerBase.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/core/UIPermissionManagerBase.java
/* * Copyright (C) 2003-2007 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.core; import javax.jcr.Node; import org.exoplatform.ecm.permission.info.UIPermissionInputSet; import org.exoplatform.ecm.utils.lock.LockUtil; import org.exoplatform.ecm.webui.utils.PermissionUtil; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.services.log.ExoLogger; import org.exoplatform.services.log.Log; import org.exoplatform.webui.core.UIComponent; import org.exoplatform.webui.core.UIContainer; import org.exoplatform.webui.core.UIGrid; import org.exoplatform.webui.core.UIPopupComponent; import org.exoplatform.webui.core.UIPopupWindow; import org.exoplatform.webui.event.Event; import org.exoplatform.webui.event.EventListener; import org.exoplatform.webui.organization.account.UIUserSelector; public abstract class UIPermissionManagerBase extends UIContainer implements UIPopupComponent{ private static final Log LOG = ExoLogger.getLogger(UIPermissionManagerBase.class.getName()); public void initPopupPermission(UIComponent uiSelector) throws Exception { UIPopupWindow uiPopup = getChildById(UIPermissionFormBase.POPUP_SELECT); if(uiPopup == null) { uiPopup = addChild(UIPopupWindow.class, null, UIPermissionFormBase.POPUP_SELECT); uiPopup.setWindowSize(560, 345); uiPopup.setShowMask(true); } else { uiPopup.setShowMask(true); uiPopup.setRendered(true); } uiPopup.setUIComponent(uiSelector); uiPopup.setShow(true); uiPopup.setResizable(true); } public void initUserSelector() throws Exception { UIPopupWindow uiPopup = getChildById("PopupUserSelector"); if(uiPopup == null) { uiPopup = addChild(UIPopupWindow.class, null, "PopupUserSelector"); } uiPopup.setWindowSize(790, 400); UIUserContainer uiUserContainer = this.createUIComponent(UIUserContainer.class, null, null); uiPopup.setUIComponent(uiUserContainer); uiPopup.setShow(true); uiPopup.setShowMask(true); uiPopup.setResizable(true); } public void activate() { try { getChild(UIPermissionInfoBase.class).updateGrid(1); } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error("Unexpected error!", e.getMessage()); } } } public void checkPermissonInfo(Node node) throws Exception { if (node.isLocked()) { String lockToken = LockUtil.getLockToken(node); if (lockToken != null) node.getSession().addLockToken(lockToken); if (!Utils.isLockTokenHolder(node)) { getChild(UIPermissionInfoBase.class).getChild(UIGrid.class) .configure("usersOrGroups", UIPermissionInfoBase.PERMISSION_BEAN_FIELD, new String[] {}); getChild(UIPermissionFormBase.class).setRendered(false); } } else { if (!PermissionUtil.canChangePermission(node)) { getChild(UIPermissionInfoBase.class).getChild(UIGrid.class) .configure("usersOrGroups", UIPermissionInfoBase.PERMISSION_BEAN_FIELD, new String[] {}); getChild(UIPermissionFormBase.class).setRendered(false); } } } public void deActivate() { } static public class AddUserActionListener extends EventListener<UIUserSelector> { public void execute(Event<UIUserSelector> event) throws Exception { UIUserSelector uiForm = event.getSource(); UIPermissionManagerBase uiParent = uiForm.getAncestorOfType(UIPermissionManagerBase.class); UIPermissionFormBase uiPermissionForm = uiParent.getChild(UIPermissionFormBase.class); uiPermissionForm.doSelect(UIPermissionInputSet.FIELD_USERORGROUP, uiForm.getSelectedUsers()); UIPopupWindow uiPopup = uiParent.getChild(UIPopupWindow.class); uiPopup.setUIComponent(null); uiPopup.setShow(false); event.getRequestContext().addUIComponentToUpdateByAjax(uiParent); } } }
4,782
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIUserContainer.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/core/UIUserContainer.java
/*************************************************************************** * Copyright 2001-2008 The eXo Platform SARL All rights reserved. * * Please look at license.txt in info directory for more license detail. * **************************************************************************/ package org.exoplatform.ecm.webui.core; import org.exoplatform.ecm.permission.info.UIPermissionInputSet; import org.exoplatform.webui.core.UIPopupComponent; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.config.annotation.EventConfig; import org.exoplatform.webui.core.UIContainer; import org.exoplatform.webui.core.UIPopupWindow; import org.exoplatform.webui.core.lifecycle.UIContainerLifecycle; import org.exoplatform.webui.event.Event; import org.exoplatform.webui.event.EventListener; import org.exoplatform.webui.organization.account.UIUserSelector; /** * Created by The eXo Platform SARL * Author : Hoang Van Hung * hunghvit@gmail.com * Dec 3, 2008 */ @ComponentConfig( lifecycle = UIContainerLifecycle.class, events = {@EventConfig(listeners = UIUserContainer.AddUserActionListener.class)} ) public class UIUserContainer extends UIContainer implements UIPopupComponent { public UIUserContainer() throws Exception { UIUserSelector uiUserSelector = getChild(UIUserSelector.class); if (uiUserSelector == null) { uiUserSelector = addChild(UIUserSelector.class, null, null); } uiUserSelector.setMulti(false); uiUserSelector.setShowSearchUser(true); uiUserSelector.setShowSearch(true); } public void activate() { } public void deActivate() { } static public class AddUserActionListener extends EventListener<UIUserContainer> { public void execute(Event<UIUserContainer> event) throws Exception { UIUserContainer uiUserContainer = event.getSource(); UIUserSelector uiUserSelector = uiUserContainer.getChild(UIUserSelector.class); UIPermissionManagerBase uiParent = uiUserContainer.getAncestorOfType(UIPermissionManagerBase.class); UIPermissionFormBase uiPermissionForm = uiParent.getChild(UIPermissionFormBase.class); uiPermissionForm.doSelect(UIPermissionInputSet.FIELD_USERORGROUP, uiUserSelector.getSelectedUsers()); UIPopupWindow uiPopup = uiParent.findComponentById("PopupUserSelector"); uiPopup.setShow(false); event.getRequestContext().addUIComponentToUpdateByAjax(uiParent); } } }
2,541
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
PermissionBean.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/core/bean/PermissionBean.java
/* * Copyright (C) 2003-2013 eXo Platform SAS. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program 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 Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.core.bean; import org.exoplatform.services.jcr.access.PermissionType; /** * Created by The eXo Platform SAS * Author : eXoPlatform * vuna@exoplatform.com * Mar 23, 2013 */ public class PermissionBean { private String usersOrGroups ; private boolean read ; private boolean addNode ; private boolean remove ; public String getUsersOrGroups() { return usersOrGroups ; } public void setUsersOrGroups(String s) { usersOrGroups = s ; } public boolean isAddNode() { return addNode ; } public void setAddNode(boolean b) { addNode = b ; } public boolean isRead() { return read ; } public void setRead(boolean b) { read = b ; } public boolean isRemove() { return remove ; } public void setRemove(boolean b) { remove = b ; } /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object obj) { // TODO Auto-generated method stub return this.usersOrGroups.equals(((PermissionBean)obj).usersOrGroups); } public void setPermissions(String[] permArray) { if (permArray == null) return; for (String entry : permArray) { if (PermissionType.READ.equals(entry)) this.setRead(true); if (PermissionType.REMOVE.equals(entry)) this.setRemove(true); if (PermissionType.ADD_NODE.equals(entry)) this.setAddNode(true); } } @Override public int hashCode() { return this.usersOrGroups.hashCode(); } }
2,195
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
FCKConfigService.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/core/fckconfig/FCKConfigService.java
/* * Copyright (C) 2003-2008 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.core.fckconfig; import java.util.ArrayList; import java.util.List; import org.exoplatform.container.component.ComponentPlugin; import org.exoplatform.webui.form.wysiwyg.FCKEditorConfig; /** * Created by The eXo Platform SAS. * * @author : Hoa.Pham hoa.pham@exoplatform.com Jun 23, 2008 */ public class FCKConfigService { private List<FCKConfigPlugin> fckConfigPlugins = new ArrayList<FCKConfigPlugin>(); public FCKConfigService() { } /** * Adds the FCKConfigPlugin. * * @param plugin the FCKConfigPlugin */ public void addPlugin(ComponentPlugin plugin) { if(plugin instanceof FCKConfigPlugin) { fckConfigPlugins.add(FCKConfigPlugin.class.cast(plugin)); } } /** * Use to configure the fckeditoConfig by via FCKConfigPlugin. * * @param editorConfig the FCKEditorConfig * @throws Exception the exception */ public void processFCKEditorConfig(final FCKEditorConfig editorConfig, final FCKEditorContext context) throws Exception{ for(FCKConfigPlugin plugin: fckConfigPlugins) { plugin.addParameters(editorConfig,context); } } }
1,903
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
FCKEditorContext.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/core/fckconfig/FCKEditorContext.java
/* * Copyright (C) 2003-2008 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.core.fckconfig; import java.util.HashMap; /** * Created by The eXo Platform SAS * @author : Hoa.Pham * hoa.pham@exoplatform.com * Jun 23, 2008 */ @SuppressWarnings({ "hiding", "serial" }) public class FCKEditorContext extends HashMap<String, Object> { public String getPortalName() { return (String)this.get("portalName"); } public void setPortalName(String portalName) { this.put("portalName",portalName); } public String getSkinName() {return (String)this.get("skinName"); } public void setSkinName(String skinName) { this.put("skinName",skinName);} public String getRepository() { return (String)this.get("repository"); } public void setRepository(String repository) { this.put("repository",repository); } public String getWorkspace() {return (String)this.get("workspace"); } public void setWorkspace(String worksapce) { this.put("workspace",worksapce); } public String getCurrentNodePath() { return (String) this.get("jcrPath"); } public void setCurrentNodePath(String path) { this.put("jcrPath",path); } }
1,837
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
FCKDynamicSkinPlugin.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/core/fckconfig/FCKDynamicSkinPlugin.java
/* * Copyright (C) 2003-2008 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.core.fckconfig; import java.util.Collection; import org.exoplatform.portal.resource.SkinConfig; import org.exoplatform.portal.resource.SkinService; import org.exoplatform.services.wcm.utils.WCMCoreUtils; import org.exoplatform.webui.form.wysiwyg.FCKEditorConfig; /** * Created by The eXo Platform SAS * Author : Phan Le Thanh Chuong * chuong_phan@exoplatform.com, phan.le.thanh.chuong@gmail.com * Aug 28, 2008 */ public class FCKDynamicSkinPlugin extends FCKConfigPlugin { /* * (non-Javadoc) * @see * org.exoplatform.services.ecm.fckconfig.FCKConfigPlugin#addParameters(org * .exoplatform.webui.form.wysiwyg.FCKEditorConfig, * org.exoplatform.services.ecm.fckconfig.FCKEditorContext) */ public void addParameters(FCKEditorConfig editorConfig, FCKEditorContext editorContext) throws Exception { StringBuffer cssMergedBuffer = new StringBuffer(); SkinService skinService = WCMCoreUtils.getService(SkinService.class); Collection<SkinConfig> collecionSkin = skinService.getPortalSkins(editorContext.getSkinName()); for (SkinConfig skinConfig : collecionSkin) { cssMergedBuffer = cssMergedBuffer.append(skinConfig.getCSSPath()).append(","); } SkinConfig skinConfig = skinService.getSkin(editorContext.getPortalName(), editorContext.getSkinName()); if (skinConfig != null) { cssMergedBuffer = cssMergedBuffer.append(skinConfig.getCSSPath()); } String cssMerged = cssMergedBuffer.toString(); if (cssMerged.endsWith(",")) cssMerged = cssMerged.substring(0, cssMerged.length() - 1); editorConfig.put("EditorAreaCSS", cssMerged); } }
2,418
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
FCKConfigPlugin.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/webui/core/fckconfig/FCKConfigPlugin.java
/* * Copyright (C) 2003-2008 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.core.fckconfig; import org.exoplatform.container.component.BaseComponentPlugin; import org.exoplatform.webui.form.wysiwyg.FCKEditorConfig; /** * Created by The eXo Platform SAS. * * @author : Hoa.Pham hoa.pham@exoplatform.com Jun 23, 2008 */ public abstract class FCKConfigPlugin extends BaseComponentPlugin { /** * This method is used to add/override some variables in fckconfig.js * * @param config the config * @throws Exception the exception */ public abstract void addParameters(final FCKEditorConfig config, final FCKEditorContext context) throws Exception; }
1,368
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
RepeatIntervalValidator.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/jcr/RepeatIntervalValidator.java
/* * Copyright (C) 2003-2007 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.jcr; import org.exoplatform.web.application.ApplicationMessage; import org.exoplatform.webui.exception.MessageException; import org.exoplatform.webui.form.UIFormInput; import org.exoplatform.webui.form.validator.Validator; import org.quartz.impl.triggers.SimpleTriggerImpl; /** * Created by The eXo Platform SARL * Author : Dang Van Minh * minh.dang@exoplatform.com * Aug 21, 2007 6:25:58 PM */ public class RepeatIntervalValidator implements Validator { public void validate(UIFormInput uiInput) throws Exception { try { long timeInterval = Long.parseLong(uiInput.getValue().toString()) ; new SimpleTriggerImpl().setRepeatInterval(timeInterval) ; } catch(Exception e) { throw new MessageException( new ApplicationMessage("RepeatIntervalValidator.msg.invalid-value", null, ApplicationMessage.WARNING)) ; } } }
1,626
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
CronExpressionValidator.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/jcr/CronExpressionValidator.java
/* * Copyright (C) 2003-2007 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.jcr; import org.exoplatform.web.application.ApplicationMessage; import org.exoplatform.webui.exception.MessageException; import org.exoplatform.webui.form.UIFormInput; import org.exoplatform.webui.form.validator.Validator; import org.quartz.impl.triggers.CronTriggerImpl; /** * Created by The eXo Platform SAS * Author : Hoa Pham * hoa.pham@exoplatform.com * Aug 13, 2007 */ public class CronExpressionValidator implements Validator { public void validate(UIFormInput uiInput) throws Exception { try { new CronTriggerImpl().setCronExpression((String) uiInput.getValue()); } catch (Exception e) { throw new MessageException(new ApplicationMessage("CronExpressionValidator.invalid-input", null, ApplicationMessage.WARNING)); } } }
1,632
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
RssServlet.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/jcr/RssServlet.java
/* * Copyright (C) 2003-2007 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.jcr; import java.io.IOException; import java.io.InputStream; import java.util.List; import javax.jcr.Node; import javax.jcr.Property; import javax.jcr.Session; import org.exoplatform.container.PortalContainer; import org.exoplatform.container.RootContainer; import org.exoplatform.services.cms.templates.TemplateService; import org.exoplatform.services.jcr.RepositoryService; import org.exoplatform.services.log.ExoLogger; import org.exoplatform.services.log.Log; import jakarta.servlet.RequestDispatcher; import jakarta.servlet.ServletConfig; import jakarta.servlet.ServletException; import jakarta.servlet.ServletOutputStream; import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; @SuppressWarnings({"serial","unused"}) public class RssServlet extends HttpServlet { private static final Log LOG = ExoLogger.getLogger(RssServlet.class.getName()); public void init(ServletConfig config) throws ServletException {} public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setHeader("Cache-Control", "private max-age=600, s-maxage=120"); String wsName = null ; String path = null ; String portalName = null ; String pathInfo = request.getPathInfo() ; portalName = pathInfo.substring(1, pathInfo.indexOf("/", 1)) ; wsName = pathInfo.substring(portalName.length() + 2, pathInfo.indexOf("/", portalName.length() + 2)) ; path = pathInfo.substring(pathInfo.indexOf(wsName)+ wsName.length() + 1); PortalContainer pcontainer = RootContainer.getInstance().getPortalContainer(portalName); PortalContainer.setInstance(pcontainer) ; RepositoryService repositoryService = (RepositoryService)pcontainer.getComponentInstanceOfType(RepositoryService.class); TemplateService tservice = (TemplateService)pcontainer.getComponentInstanceOfType(TemplateService.class); Session session = null ; try{ session = repositoryService.getCurrentRepository().getSystemSession(wsName) ; String repositoryName = repositoryService.getCurrentRepository().getConfiguration().getName(); Node rootNode = session.getRootNode() ; Node file = null ; if(rootNode.hasNode(path)) file = rootNode.getNode(path) ; else if(rootNode.hasNode(path.substring(0, path.lastIndexOf("/")))){ Node parentNode = rootNode.getNode(path.substring(0, path.lastIndexOf("/"))) ; String name = path.substring(path.lastIndexOf("/") + 1) ; if(name.indexOf(".") > -1 && parentNode.hasNode(name.substring(0, name.indexOf(".")))) file = parentNode.getNode(name.substring(0, name.indexOf("."))) ; } if (file == null) throw new Exception("Node " + path + " not found. "); Node content; if(file.isNodeType("nt:file")) { content = file.getNode("jcr:content"); Property data = content.getProperty("jcr:data"); String mimeType = content.getProperty("jcr:mimeType").getString(); response.setContentType(mimeType) ; InputStream is = data.getStream(); byte[] buf = new byte[is.available()]; is.read(buf); ServletOutputStream os = response.getOutputStream(); os.write(buf); } else if (file.isNodeType("exo:rss-enable")){ List documentNodeType = tservice.getDocumentTemplates() ; String nodeType = file.getPrimaryNodeType().getName() ; if(documentNodeType.contains(nodeType)){ String templateName = tservice.getTemplatePath(false, nodeType, "view1") ; request.setAttribute("portalName", portalName) ; request.setAttribute("wsName", wsName) ; request.setAttribute("templateName", "jcr:"+templateName) ; request.setAttribute("curNode", file) ; RequestDispatcher rd = request.getRequestDispatcher("/viewcontent"); rd.forward(request, response); }else { throw new Exception("This node type is not document node"); } } else throw new Exception("Invalid node type, expected nt:file or exo:rss-enable type"); }catch(Exception e) { if (LOG.isErrorEnabled()) { LOG.error("Unexpected error", e); } throw new ServletException(e) ; }finally{ if(session != null) { session.logout() ; } } } }
5,147
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
SimpleSearchValidator.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/jcr/SimpleSearchValidator.java
/* * Copyright (C) 2003-2008 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.jcr; import org.exoplatform.web.application.ApplicationMessage; import org.exoplatform.webui.exception.MessageException; import org.exoplatform.webui.form.UIFormInput; import org.exoplatform.webui.form.validator.Validator; /** * @author hai_lethanh * */ public class SimpleSearchValidator implements Validator { @Override public void validate(UIFormInput uiInput) throws Exception { String inputValue = ((String) uiInput.getValue()); if (inputValue == null || inputValue.trim().length() == 0) { throw new MessageException(new ApplicationMessage("SearchValidator.msg.empty-input", new Object[] { uiInput.getName() }, ApplicationMessage.WARNING)); } } }
1,567
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
TypeNodeComparator.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/jcr/TypeNodeComparator.java
/* * Copyright (C) 2003-2007 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.jcr; import java.util.Comparator; import java.util.StringTokenizer; import javax.jcr.Node; import org.exoplatform.ecm.jcr.model.Preference; import org.exoplatform.ecm.webui.utils.Utils; public class TypeNodeComparator implements Comparator<javax.jcr.Node> { private String order_; public TypeNodeComparator(String pOrder) { order_ = pOrder ; } public int compareOld(Object o1, Object o2) throws ClassCastException { StringTokenizer key1 = new StringTokenizer((String) o1, "//") ; StringTokenizer key2 = new StringTokenizer((String) o2, "//") ; String type1 = key1.nextToken() ; String type2 = key2.nextToken() ; int res = 0 ; if ("folder".equals(type1) && "folder".equals(type2)) { // mime type key1.nextToken() ; key2.nextToken() ; // sort by name res = key1.nextToken().compareToIgnoreCase(key2.nextToken()); if(Preference.ASCENDING_ORDER.equals(order_)) return res ; return -res ; } else if ("file".equals(type1) && "file".equals(type2)) { String mimeType1 = key1.nextToken() ; String mimeType2 = key2.nextToken() ; // sort by mime type res = mimeType1.compareToIgnoreCase(mimeType2) ; if (res == 0) return key1.nextToken().compareToIgnoreCase(key2.nextToken()) ; // same mime type -> sort by name else if(Preference.ASCENDING_ORDER.equals(order_)) return res ; else return -res ; } else { if(Preference.ASCENDING_ORDER.equals(order_)) res = 1 ; else res = -1 ; // folder before file in ascending order if ("folder".equals(type1)) return -res ; return res ; } } public int compare(Node node1, Node node2) { try{ String nodeType1 = node1.getPrimaryNodeType().getName(); String nodeType2 = node2.getPrimaryNodeType().getName(); if("nt:file".equals(nodeType1) && "nt:file".equals(nodeType2)) { String mimeType1 = node1.getNode(Utils.JCR_CONTENT).getProperty(Utils.JCR_MIMETYPE).getString(); String mimeType2 = node2.getNode(Utils.JCR_CONTENT).getProperty(Utils.JCR_MIMETYPE).getString(); if(Preference.ASCENDING_ORDER.equals(order_)) { return mimeType1.compareToIgnoreCase(mimeType2); } return mimeType2.compareToIgnoreCase(mimeType1); } if(Preference.ASCENDING_ORDER.equals(order_)) { return nodeType1.compareToIgnoreCase(nodeType2) ; } return nodeType2.compareToIgnoreCase(nodeType1) ; }catch (Exception e) { return 0; } } }
3,324
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
SearchValidator.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/jcr/SearchValidator.java
/* * Copyright (C) 2003-2008 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.jcr; import org.exoplatform.web.application.ApplicationMessage; import org.exoplatform.webui.exception.MessageException; import org.exoplatform.webui.form.UIFormInput; import org.exoplatform.webui.form.validator.Validator; /** * Created by The eXo Platform SAS * Author : Ly Dinh Quang * quang.ly@exoplatform.com * xxx5669@yahoo.com * Jul 9, 2008 */ public class SearchValidator implements Validator { public void validate(UIFormInput uiInput) throws Exception { String inputValue = ((String)uiInput.getValue()); if (inputValue == null || inputValue.trim().length() == 0) { throwException("SearchValidator.msg.empty-input", uiInput); } inputValue = inputValue.trim(); switch (inputValue.length()) { case 1: checkOneChar(inputValue, uiInput); break; case 2: checkTwoChars(inputValue, uiInput); break; default: checkMoreChars(inputValue, uiInput); break; } } private void checkOneChar(String s, UIFormInput uiInput) throws MessageException { String[] arrFilterChars = {"+", "-", "&", "|", "!", "(", ")", "{", "}", "[", "]", "^", "\"", "~", "*", "?", ":", "\\", "'"}; if (checkArr(s, arrFilterChars)) { throwException("SearchValidator.msg.Invalid-char", uiInput); } } private void checkTwoChars(String s, UIFormInput uiInput) throws MessageException { String s2 = ""; if (s.startsWith("+") || s.startsWith("-") || s.startsWith("!")) { s2 = s.substring(1, 2); checkOneChar(s2, uiInput); } else if (s.endsWith("~") || s.endsWith("?") || s.endsWith("*")) { s2 = s.substring(0, 1); String[] arrFilterChars1 = {"+", "-", "&", "|", "!", "(", ")", "{", "}", "[", "]", "^", "\"", ":", "\\", "'"}; if (checkArr(s2, arrFilterChars1)) { throwException("SearchValidator.msg.Invalid-char", uiInput); } } else { String s3 = s.substring(0, 1); String s4 = s.substring(1, 2); String[] arrFilterChars2 = {"+", "-", "&", "|", "!", "(", ")", "{", "}", "[", "]", "^", "\"", "~", "*", "?", ":", "\\", "'"}; if (checkArr(s3, arrFilterChars2)) { throwException("SearchValidator.msg.Invalid-char", uiInput); } if (checkArr(s4, arrFilterChars2)) { throwException("SearchValidator.msg.Invalid-char", uiInput); } } } private void checkMoreChars(String s, UIFormInput uiInput) throws MessageException { String[] arrFilterChars = {"-", "&&", "||", "!", "(", ")", "}", "]", "^", ":", "&", "|", "'"}; for (String filter : arrFilterChars) { if (s.startsWith(filter)) { throwException("SearchValidator.msg.Invalid-char", uiInput); } } String[] arrFilterChars2 = {"+", "-", "&&", "||", "!", "(", ")", "{", "}", "[", "]", "^", "\"", "~", "*", "?", ":", "\\", "&", "|", "'"}; for (String filter : arrFilterChars2) { int index = s.indexOf(filter); if (index > -1 && !checkBackSlash(s, index)) { //Check FuzzySearch if (filter.equals("~")) { if (index == 0) { String regex = "~\\w+"; if (!s.matches(regex)) { throwException("SearchValidator.msg.Invalid-char", uiInput); } } else { if (checkChar(s, index, -1, " ") || checkChar(s, index, +1, " ")) { throwException("SearchValidator.msg.Invalid-char4", uiInput); } else if (checkChar(s, index, -1, "\"")) { int x = s.indexOf("\""); if (x > -1 && x != index - 1) { try { String subString = concatSpace(s.substring(index + 1, s.length())); Double.parseDouble(subString); } catch (Exception e) { throwException("SearchValidator.msg.Invalid-char2", uiInput); } } else { throwException("SearchValidator.msg.Invalid-char", uiInput); } } else { String subString = concatSpace(s.substring(index + 1, s.length())); double numberAt = 0; try { numberAt = Double.parseDouble(subString); } catch (NumberFormatException e) { throwException("SearchValidator.msg.Invalid-char2", uiInput); } if (numberAt >= 1 || numberAt < 0) { throwException("SearchValidator.msg.Invalid-char1", uiInput); } } } } else if (filter.equals("^")) { if (checkChar(s, index, -1, " ") || checkChar(s, index, +1, " ")) { throwException("SearchValidator.msg.Invalid-char5", uiInput); } else { String subString = concatSpace(s.substring(index + 1, s.length())); try { Double.parseDouble(subString); } catch (NumberFormatException e) { throwException("SearchValidator.msg.Invalid-char3", uiInput); } } } else { if (filter.equals("*") || filter.equals("?")) { return; } throwException("SearchValidator.msg.Invalid-char", uiInput); // } else if (filter.equals("[") || filter.equals("]")) { // String regex = "\\w*\\[\\w+ [Tt][Oo] \\w+\\]\\w*"; // if (!s.matches(regex)) { // throwException("SearchValidator.msg.Invalid-char", uiInput); // } } } } } private boolean checkChar(String s, int index, int forward, String c) { if (index == 0 || (index + forward == s.length())) { return false; } String charToString = String.valueOf(s.charAt(index + forward)); if (charToString.equals(c)) { return true; } return false; } private boolean checkBackSlash(String s, int index) { if (index == 0) { return false; } String charToString = String.valueOf(s.charAt(index - 1)); if (charToString.equalsIgnoreCase("\\")) { return true; } return false; } private boolean checkArr(String s, String[] arrFilterChars) { for (String filter : arrFilterChars) { if (s.equals(filter)) { return true; } } return false; } private String concatSpace(String s) { char[] arrayChar = s.toCharArray(); int index = 0; for (int i = 0; i < arrayChar.length; i++) { if (String.valueOf(arrayChar[i]).equals(" ")) { index = i; break; } } if (index != 0) { return s.substring(0, index); } return s; } private void throwException(String s, UIFormInput uiInput) throws MessageException { Object[] args = { uiInput.getName() }; throw new MessageException(new ApplicationMessage(s, args, ApplicationMessage.WARNING)); } }
7,662
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
PropertiesComparator.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/jcr/PropertiesComparator.java
/* * Copyright (C) 2003-2007 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.jcr; import java.util.Comparator; import org.exoplatform.ecm.jcr.model.Preference; public class PropertiesComparator implements Comparator { private String order_; public PropertiesComparator(String pOrder) { order_ = pOrder ; } public int compare(Object o1, Object o2) throws ClassCastException { if(Preference.ASCENDING_ORDER.equals(order_)) { return ((String) o1).compareToIgnoreCase((String) o2) ; } return -1 * ((String) o1).compareToIgnoreCase((String) o2) ; } }
1,262
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
RepeatCountValidator.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/jcr/RepeatCountValidator.java
/* * Copyright (C) 2003-2007 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.jcr; import org.exoplatform.web.application.ApplicationMessage; import org.exoplatform.webui.exception.MessageException; import org.exoplatform.webui.form.UIFormInput; import org.exoplatform.webui.form.validator.Validator; import org.quartz.impl.triggers.SimpleTriggerImpl; /** * Created by The eXo Platform SARL * Author : Dang Van Minh * minh.dang@exoplatform.com * Aug 21, 2007 3:38:21 PM */ public class RepeatCountValidator implements Validator { public void validate(UIFormInput uiInput) throws Exception { try { int repeatCount = Integer.parseInt(uiInput.getValue().toString()) ; new SimpleTriggerImpl().setRepeatCount(repeatCount) ; } catch(Exception e) { throw new MessageException( new ApplicationMessage("RepeatCountValidator.msg.invalid-value", null, ApplicationMessage.WARNING)) ; } } }
1,620
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
VersionNode.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/jcr/model/VersionNode.java
/* * Copyright (C) 2003-2007 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.jcr.model; import java.util.*; import javax.jcr.*; import javax.jcr.version.Version; import javax.jcr.version.VersionIterator; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.services.cms.documents.VersionHistoryUtils; import org.exoplatform.services.cms.impl.DMSConfiguration; import org.exoplatform.services.jcr.core.ManageableRepository; import org.exoplatform.services.jcr.ext.common.SessionProvider; import org.exoplatform.services.log.ExoLogger; import org.exoplatform.services.log.Log; import org.exoplatform.services.wcm.utils.WCMCoreUtils; public class VersionNode { private static final String EXO_LAST_MODIFIED_DATE = "exo:lastModifiedDate"; private boolean isExpanded = true; private List<VersionNode> children_ = new ArrayList<VersionNode>(); private static final Log LOG = ExoLogger.getLogger(VersionNode.class.getName()); private Calendar createdTime_; private String name_ = ""; private String displayName = ""; private String path_ = ""; private String ws_ = ""; private String uuid_; private String[] versionLabels_ = new String[] {}; private String author_ = ""; public VersionNode(Node node, Session session) { Version version = node instanceof Version ? (Version) node : null; try { Property property = getProperty(node, EXO_LAST_MODIFIED_DATE); if (property != null) { createdTime_ = property.getDate(); } name_ = version == null ? "" : version.getName(); path_ = node.getPath(); ws_ = node.getSession().getWorkspace().getName(); uuid_ = node.getUUID(); Property prop = getProperty(node, Utils.EXO_LASTMODIFIER); author_ = prop == null ? null : prop.getString(); if (version == null) { if (node.isNodeType(Utils.MIX_VERSIONABLE)) { addVersions(node, session); } } else { addVersions(node, session); } } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error("Unexpected error", e); } } } /** * Add versions of the given node as children with the right name and display name, and set * the name dan display name of the current version. * If the node has a property exo:maxVersion, it means some versions have been removed and * we must use this value as the current version. * If the node has a property exo:versionList, it means some versions have been removed then * some others have been created. Since the display name of the versions does not follow the sequential numbering * anymore (for example 1,3,4 if version 2 has been removed), the property exo:versionList maps the * version name with the correct display name. * To be noted : display name is always decremented by 1 from the version index of offset since * we want the display name to start from 0 * @param node JCR node * @param session JCR session * @throws RepositoryException */ private void addVersions(Node node, Session session) throws RepositoryException { if(node instanceof Version) { Version version = (Version) node; versionLabels_ = version.getContainingHistory().getVersionLabels(version); } else { int maxVersion = 0; Map<String, String> mapVersionName = new HashMap<>(); if(node.isNodeType(VersionHistoryUtils.MIX_DISPLAY_VERSION_NAME)){ //maxVersion of root version if(node.hasProperty(VersionHistoryUtils.MAX_VERSION_PROPERTY)){ maxVersion = (int) node.getProperty(VersionHistoryUtils.MAX_VERSION_PROPERTY).getLong(); } //list of version name entries (jcrID, display version) if(node.hasProperty(VersionHistoryUtils.LIST_VERSION_PROPERTY)){ Value[] values = node.getProperty(VersionHistoryUtils.LIST_VERSION_PROPERTY).getValues(); for (Value value : values){ mapVersionName.put(value.getString().split(VersionHistoryUtils.VERSION_SEPARATOR)[0], value.getString().split(VersionHistoryUtils.VERSION_SEPARATOR)[1]); } } } Version rootVersion = node.getVersionHistory().getRootVersion(); VersionIterator allVersions = node.getVersionHistory().getAllVersions(); int maxIndex = 0; while (allVersions.hasNext()) { Version version = allVersions.nextVersion(); if(version.getUUID().equals(rootVersion.getUUID())) { continue; } int versionIndex = Integer.parseInt(version.getName()); maxIndex = Math.max(maxIndex , versionIndex); String versionOffset = mapVersionName.get(version.getName()); VersionNode versionNode = new VersionNode(version, session); if(versionOffset != null) { versionNode.setDisplayName(String.valueOf(Integer.parseInt(versionOffset) - 1)); } else { versionNode.setDisplayName(String.valueOf(versionIndex - 1)); } children_.add(versionNode); } name_ = String.valueOf(maxIndex + 1); displayName = maxVersion > 0 ? String.valueOf(maxVersion - 1) : String.valueOf(maxIndex); versionLabels_ = node.getVersionHistory().getVersionLabels(rootVersion); } } private Property getProperty(Node node, String propName) throws RepositoryException { Property property = null; if (node.hasProperty(propName)) { property = node.getProperty(propName); } else if (node.hasNode(Utils.JCR_FROZEN) && node.getNode(Utils.JCR_FROZEN).hasProperty(propName)) { property = node.getNode(Utils.JCR_FROZEN).getProperty(propName); } return property; } public boolean isExpanded() { return isExpanded; } public void setExpanded(boolean isExpanded) { this.isExpanded = isExpanded; } public String getName() { return name_; } public String getDisplayName() { return displayName; } public void setDisplayName(String displayName_) { this.displayName = displayName_; } public String getWs() { return ws_; } public String getPath() { return path_; } public int getChildrenSize() { return children_.size(); } public List<VersionNode> getChildren() { return children_; } public Calendar getCreatedTime() { return createdTime_; } public String getAuthor() { return author_; } public String[] getVersionLabels() { return versionLabels_; } public Node getNode(String nodeName) throws RepositoryException { DMSConfiguration dmsConf = WCMCoreUtils.getService(DMSConfiguration.class); String systemWS = dmsConf.getConfig().getSystemWorkspace(); ManageableRepository repo = WCMCoreUtils.getRepository(); SessionProvider provider = systemWS.equals(ws_) ? WCMCoreUtils.getSystemSessionProvider() : WCMCoreUtils.getUserSessionProvider(); return ((Node) provider.getSession(ws_, repo).getItem(path_)).getNode(nodeName); } public boolean hasNode(String nodeName) throws Exception { DMSConfiguration dmsConf = WCMCoreUtils.getService(DMSConfiguration.class); String systemWS = dmsConf.getConfig().getSystemWorkspace(); ManageableRepository repo = WCMCoreUtils.getRepository(); SessionProvider provider = systemWS.equals(ws_) ? WCMCoreUtils.getSystemSessionProvider() : WCMCoreUtils.getUserSessionProvider(); return ((Node) provider.getSession(ws_, repo).getItem(path_)).hasNode(nodeName); } public String getUUID() { return uuid_; } public VersionNode findVersionNode(String path) throws RepositoryException { if (path_.equals(path)) return this; VersionNode node = null; Iterator<VersionNode> iter = children_.iterator(); while (iter.hasNext()) { VersionNode child = (VersionNode) iter.next(); node = child.findVersionNode(path); if (node != null) return node; } return null; } public void removeVersionInChild(VersionNode versionNode1, VersionNode versionNodeRemove) throws RepositoryException { if (versionNode1.getChildren().contains(versionNodeRemove)) versionNode1.getChildren().remove(versionNodeRemove); else { for (VersionNode vsN : versionNode1.getChildren()) { removeVersionInChild(vsN, versionNodeRemove); } } } }
9,200
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
Preference.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/jcr/model/Preference.java
/* * Copyright (C) 2003-2007 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.jcr.model; public class Preference { public static final String SORT_BY_NODENAME = "Alphabetic" ; public static final String SORT_BY_NODETYPE= "Type" ; public static final String SORT_BY_NODESIZE= "Size" ; public static final String SORT_BY_CREATED_DATE= "CreatedDate" ; public static final String SORT_BY_DATE= "Date" ; public static final String SORT_BY_MODIFIED_DATE= "ModifiedDate" ; public static final String PROPERTY_SORT = "Property" ; public static final String SORT_BY_OWNER = "Owner"; public static final String SORT_BY_VERSIONABLE = "Versionable"; public static final String SORT_BY_AUDITING = "Auditing"; public static final String SHOW_OWNED_BY_USER_DOC = "OwnedByMe"; public static final String ENABLE_DRAG_AND_DROP = "EnableDragAndDrop"; public static final String SHOW_FAVOURITE_DOC = "Favourites"; public static final String SHOW_HIDDEN_DOC = "Hidden"; public static final String[] SORT_BY_SINGLEVALUE_PROPERTY = {"SingleValueProperty"}; public static final String SHOW_NON_DOCUMENTTYPE = "showNonDocumentType" ; public static final String ASCENDING_ORDER = "Ascending" ; public static final String DESCENDING_ORDER = "Descending" ; public static final String SQL_QUERY = "SQL"; public static final String XPATH_QUERY = "XPATH"; public static final String BLUE_DOWN_ARROW = "Down" ; public static final String BLUE_UP_ARROW = "Up" ; public static final String NODES_PER_PAGE = "nbPerPage"; public static final String PREFERENCE_ORDER_BY = "preferenceOrderBy"; public static final String PREFERENCE_SORT_BY = "preferenceSortBy"; public static final String PREFERENCE_QUERY_TYPE = "preferenceQueryType"; public static final String PREFERENCE_ENABLESTRUCTURE = "enableStructure"; public static final String PREFERENCE_SHOWSIDEBAR = "showSideBar"; public static final String PREFERENCE_SHOWREFDOCUMENTS = "showRefDocuments"; public static final String PREFERENCE_SHOW_ITEMS_BY_USER = "showItemsByUserInTimeline"; public static final String PREFERENCE_SHOW_HIDDEN_NODE = "isShowHiddenNode"; private String sortType = SORT_BY_NODENAME ; private String order = ASCENDING_ORDER ; private String allowCreateFoder = "" ; private boolean jcrEnable = false; private boolean showSideBar = false ; private boolean isShowNonDocumentType = false ; private boolean isShowPreferenceDocuments = false ; private boolean isShowHiddenNode = false ; private boolean isShowOwnedByUserDoc = true; private boolean isEnableDragAndDrop = true; private boolean isShowFavouriteDoc = true; private boolean isShowHiddenDoc = true; private boolean isShowTrashDoc = true; private boolean isShowItemsByUser = true; private String queryType = "SQL"; private int nodesPerPage = 20; public boolean isJcrEnable() { return jcrEnable ; } public void setJcrEnable(boolean b) { jcrEnable = b ; } public String getSortType() { return sortType ; } public void setSortType(String s) { sortType = s ; } public String getOrder() { return order ; } public void setOrder(String s) { order = s ; } public boolean isShowSideBar() { return showSideBar ; } public void setShowSideBar(boolean b) { showSideBar = b ; } public boolean isShowNonDocumentType() { return isShowNonDocumentType ; } public void setShowNonDocumentType( boolean b) { isShowNonDocumentType = b ; } public boolean isShowPreferenceDocuments() { return isShowPreferenceDocuments ; } public void setShowPreferenceDocuments(boolean b) { isShowPreferenceDocuments = b ; } public boolean isShowHiddenNode() { return isShowHiddenNode ; } public void setShowHiddenNode(boolean b) { isShowHiddenNode = b ; } public boolean isShowOwnedByUserDoc() { return isShowOwnedByUserDoc; } public void setShowOwnedByUserDoc(boolean b) { isShowOwnedByUserDoc = b; } public boolean isEnableDragAndDrop() { return isEnableDragAndDrop; } public void setEnableDragAndDrop(boolean b) { isEnableDragAndDrop = b; } public boolean isShowFavouriteDoc() { return isShowFavouriteDoc; } public void setShowFavouriteDoc(boolean b) { isShowFavouriteDoc = b; } public boolean isShowHiddenDoc() { return isShowHiddenDoc; } public void setShowHiddenDoc(boolean b) { isShowHiddenDoc = b; } public boolean isShowItemsByUser() { return isShowItemsByUser; } public void setShowItemsByUser(boolean b) { this.isShowItemsByUser = b; } public String getAllowCreateFoder() { return allowCreateFoder ; } public void setAllowCreateFoder(String s) { allowCreateFoder = s ; } public int getNodesPerPage(){return nodesPerPage ; } public void setNodesPerPage(int number) { this.nodesPerPage = number ; } public String getQueryType(){return queryType; } public void setQueryType(String query) { this.queryType = query; } }
5,516
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
PermissionBean.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/permission/PermissionBean.java
/*************************************************************************** * Copyright (C) 2003-2009 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. * **************************************************************************/ package org.exoplatform.ecm.permission; import java.util.Objects; /** * Created by The eXo Platform SARL * Author : Hoang Van Hung hunghvit@gmail.com * Apr 17, 2009 */ public class PermissionBean { private String usersOrGroups; private boolean read; private boolean addNode; private boolean setProperty; private boolean remove; public String getUsersOrGroups() { return usersOrGroups; } public void setUsersOrGroups(String s) { usersOrGroups = s; } public boolean isAddNode() { return addNode; } public void setAddNode(boolean b) { addNode = b; } public boolean isRead() { return read; } public void setRead(boolean b) { read = b; } public boolean isRemove() { return remove; } public void setRemove(boolean b) { remove = b; } public boolean isSetProperty() { return setProperty; } public void setSetProperty(boolean b) { setProperty = b; } public boolean equals(Object arg0) { if (arg0 instanceof PermissionBean) { PermissionBean permBean = (PermissionBean) arg0; return this.getUsersOrGroups().equals(permBean.getUsersOrGroups()); } return false; } @Override public int hashCode() { return Objects.hash(usersOrGroups); } }
2,224
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIPermissionInputSet.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui/src/main/java/org/exoplatform/ecm/permission/info/UIPermissionInputSet.java
/* * Copyright (C) 2003-2007 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.permission.info; import org.exoplatform.ecm.webui.form.UIFormInputSetWithAction; import org.exoplatform.services.jcr.access.PermissionType; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.event.Event; import org.exoplatform.webui.event.EventListener; import org.exoplatform.webui.form.UIForm; import org.exoplatform.webui.form.UIFormStringInput; import org.exoplatform.webui.form.input.UICheckBoxInput; /** * Created by The eXo Platform SARL * Author : Tran The Trong * trongtt@gmail.com * Jun 28, 2006 */ @ComponentConfig(template = "classpath:groovy/ecm/webui/form/UIPermissionInputSet.gtmpl") public class UIPermissionInputSet extends UIFormInputSetWithAction { final static public String FIELD_USERORGROUP = "userOrGroup"; private String[] buttonActions_ = {"Save", "Reset"}; private String primaryBtn_ = "Save"; public UIPermissionInputSet(String name) throws Exception { super(name); initComponent(true); } private void initComponent(boolean hasPermissionCheckbox) throws Exception{ setComponentConfig(getClass(), null); UIFormStringInput userGroup = new UIFormStringInput(FIELD_USERORGROUP, FIELD_USERORGROUP, null); userGroup.setReadOnly(true); addUIFormInput(userGroup); if (hasPermissionCheckbox) { for (String perm : new String[] { PermissionType.READ, PermissionType.ADD_NODE, PermissionType.REMOVE }) { UICheckBoxInput checkBoxInput = new UICheckBoxInput(perm, perm, false); addUIFormInput(checkBoxInput); checkBoxInput.setOnChange("OnChange"); } } setActionInfo(FIELD_USERORGROUP, new String[] {"SelectUser", "SelectMember", "AddAny"}); } public UIPermissionInputSet(String name, boolean hasPermissionCheckbox) throws Exception { super(name); initComponent(hasPermissionCheckbox); } public String[] getButtonActions() { return buttonActions_; } public void setButtonActions(String[] actions) { buttonActions_ = actions; } public String getPrimaryButtonAction() { return primaryBtn_; } public void setPrimaryButtonAction(String primaryBtn) { primaryBtn_ = primaryBtn; } static public class OnChangeActionListener extends EventListener<UIForm> { public void execute(Event<UIForm> event) throws Exception { UIForm permissionForm = event.getSource(); UICheckBoxInput readCheckBox = permissionForm.getUICheckBoxInput(PermissionType.READ); boolean isAddNodeCheckBoxChecked = permissionForm.getUICheckBoxInput(PermissionType.ADD_NODE).isChecked(); boolean isRemoveCheckBoxChecked = permissionForm.getUICheckBoxInput(PermissionType.REMOVE).isChecked(); if (isAddNodeCheckBoxChecked || isRemoveCheckBoxChecked) { readCheckBox.setChecked(true); } event.getRequestContext().addUIComponentToUpdateByAjax(permissionForm); } } }
3,647
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
BaseConnectActionComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/viewer/src/main/java/org/exoplatform/ecm/webui/BaseConnectActionComponent.java
/* * Copyright (C) 2003-2016 eXo Platform SAS. * * This 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 software 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 software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.exoplatform.ecm.webui; import org.exoplatform.ecm.webui.clouddrives.CloudDriveContext; import org.exoplatform.services.cms.clouddrives.CloudDriveService; import org.exoplatform.services.cms.clouddrives.CloudProvider; import org.exoplatform.services.cms.clouddrives.ProviderNotAvailableException; import org.exoplatform.services.log.ExoLogger; import org.exoplatform.services.log.Log; import org.exoplatform.services.wcm.utils.WCMCoreUtils; import org.exoplatform.web.application.Parameter; import org.exoplatform.webui.application.WebuiRequestContext; import org.exoplatform.webui.ext.manager.UIAbstractManager; import org.exoplatform.webui.ext.manager.UIAbstractManagerComponent; /** * The Class BaseConnectActionComponent. */ public abstract class BaseConnectActionComponent extends UIAbstractManagerComponent implements CloudDriveUIMenuAction { /** The Constant LOG. */ protected static final Log LOG = ExoLogger.getLogger(BaseConnectActionComponent.class); /** * Cloud Drive provider id of this connect component. * * @return String */ protected abstract String getProviderId(); /** * Render event URL. * * @param ajax the ajax * @param name the name * @param beanId the bean id * @param params the params * @return the string * @throws Exception the exception */ @Override public String renderEventURL(boolean ajax, String name, String beanId, Parameter[] params) throws Exception { // this action hasn't a template, so we initialize request context on // rendering phase CloudDriveService drivesService = WCMCoreUtils.getService(CloudDriveService.class); if (drivesService != null) { try { CloudProvider provider = drivesService.getProvider(getProviderId()); CloudDriveContext.init(this); // XXX do workaround here, need point an id of the provider for this // Connect component // this could be better to do by HTML attribute, but we cannot do this // for the moment return "javascript:void(0);//" + provider.getId() + "//objectId"; } catch (ProviderNotAvailableException e) { // if no such provider, cannot do anything - default link LOG.error("Error rendering Connect to " + getProviderId() + " component: " + e.getMessage()); return super.renderEventURL(ajax, name, beanId, params); } } else { LOG.error("CloudDriveService not registred in the container."); return super.renderEventURL(ajax, name, beanId, params); } } /** * Gets the name. * * @return the name */ @Override public String getName() { // Name used in UI String connectYour = WebuiRequestContext.getCurrentInstance() .getApplicationResourceBundle() .getString("UIPopupWindow.title.ConnectYour"); if (connectYour == null || connectYour.length() == 0) { connectYour = "Connect your"; } CloudDriveService drivesService = WCMCoreUtils.getService(CloudDriveService.class); if (drivesService != null) { try { CloudProvider provider = drivesService.getProvider(getProviderId()); return connectYour + " " + provider.getName(); } catch (ProviderNotAvailableException e) { // if no such provider, cannot do anything - default name will be LOG.error("Error rendering Connect to " + getProviderId() + " component: " + e.getMessage()); } } else { LOG.error("CloudDriveService not registred in the container."); } return connectYour + " " + getProviderId(); } @Override public Class<? extends UIAbstractManager> getUIAbstractManagerClass() { return null; } }
4,576
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
CloudDriveUIMenuAction.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/viewer/src/main/java/org/exoplatform/ecm/webui/CloudDriveUIMenuAction.java
/* * Copyright (C) 2003-2016 eXo Platform SAS. * * This 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 software 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 software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.exoplatform.ecm.webui; /** * Action in ECMS menu action bar for Cloud Drive UI. Created by The eXo * Platform SAS * * @author <a href="mailto:pnedonosko@exoplatform.com">Peter Nedonosko</a> * @version $Id: CloudDriveUIAction.java 00000 Feb 28, 2014 pnedonosko $ */ public interface CloudDriveUIMenuAction { /** * Action name. * * @return String */ String getName(); }
1,236
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
CloudFileViewer.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/viewer/src/main/java/org/exoplatform/ecm/webui/viewer/CloudFileViewer.java
/* * Copyright (C) 2003-2016 eXo Platform SAS. * * This 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 software 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 software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.exoplatform.ecm.webui.viewer; import org.exoplatform.services.cms.clouddrives.CloudDrive; import org.exoplatform.services.cms.clouddrives.CloudFile; /** * Support for file viewers to show Cloud Drive files preview embedded in ECMS * Documents.<br> * Created by The eXo Platform SAS. * * @author <a href="mailto:pnedonosko@exoplatform.com">Peter Nedonosko</a> * @version $Id: CloudFileViewer.java 00000 Nov 18, 2014 pnedonosko $ */ public interface CloudFileViewer { /** * Initialize UI component to represent the given cloud file. * * @param drive {@link CloudDrive} * @param file {@link CloudFile} * @throws Exception the exception */ void initFile(CloudDrive drive, CloudFile file) throws Exception; }
1,579
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
HTML5VideoViewer.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/viewer/src/main/java/org/exoplatform/ecm/webui/viewer/HTML5VideoViewer.java
/* * Copyright (C) 2003-2008 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.viewer; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.core.UIComponent; /** * Created by The eXo Platform SARL * Author : Dang Van Minh * minh.dang@exoplatform.com * Aug 18, 2009 * 3:49:41 AM */ @ComponentConfig( template = "classpath:resources/templates/HTML5VideoViewer.gtmpl" ) public class HTML5VideoViewer extends UIComponent { public HTML5VideoViewer() throws Exception { } }
1,195
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
ImageViewer.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/viewer/src/main/java/org/exoplatform/ecm/webui/viewer/ImageViewer.java
/* * Copyright (C) 2003-2008 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.viewer; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.core.UIComponent; /** * Created by The eXo Platform SARL * Author : Dang Van Minh * minh.dang@exoplatform.com * Aug 18, 2009 * 3:49:41 AM */ @ComponentConfig( template = "classpath:resources/templates/ImageViewer.gtmpl" ) public class ImageViewer extends UIComponent { public ImageViewer() throws Exception { } }
1,216
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
MpegVideoViewer.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/viewer/src/main/java/org/exoplatform/ecm/webui/viewer/MpegVideoViewer.java
/* * Copyright (C) 2003-2008 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.viewer; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.core.UIComponent; /** * Created by The eXo Platform SARL * Author : Dang Van Minh * minh.dang@exoplatform.com * Aug 18, 2009 * 3:49:41 AM */ @ComponentConfig( template = "classpath:resources/templates/MpegVideoViewer.gtmpl" ) public class MpegVideoViewer extends UIComponent { public MpegVideoViewer() throws Exception { } }
1,228
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
AbstractCloudFileViewer.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/viewer/src/main/java/org/exoplatform/ecm/webui/viewer/AbstractCloudFileViewer.java
/* * Copyright (C) 2003-2016 eXo Platform SAS. * * This 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 software 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 software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.exoplatform.ecm.webui.viewer; import java.util.Locale; import java.util.ResourceBundle; import javax.ws.rs.core.MediaType; import org.exoplatform.ecm.webui.clouddrives.CloudDriveContext; import org.exoplatform.portal.webui.util.Util; import org.exoplatform.portal.webui.workspace.UIPortalApplication; import org.exoplatform.services.cms.clouddrives.CloudDrive; import org.exoplatform.services.cms.clouddrives.CloudFile; import org.exoplatform.services.resources.ResourceBundleService; import org.exoplatform.services.wcm.utils.WCMCoreUtils; import org.exoplatform.webui.application.WebuiRequestContext; import org.exoplatform.webui.ext.manager.UIAbstractManager; import org.exoplatform.webui.ext.manager.UIAbstractManagerComponent; /** * Base class for Cloud Drive file viewers. */ public abstract class AbstractCloudFileViewer extends UIAbstractManagerComponent implements CloudFileViewer { /** The drive. */ protected CloudDrive drive; /** The file. */ protected CloudFile file; /** The viewable max size. */ protected final long viewableMaxSize; /** * Instantiates a new abstract file viewer. * * @param viewableMaxSize the viewable max size */ protected AbstractCloudFileViewer(long viewableMaxSize) { this.viewableMaxSize = viewableMaxSize; } /** * Instantiates a new abstract file viewer. */ protected AbstractCloudFileViewer() { this(Long.MAX_VALUE); } /** * {@inheritDoc} */ @Override public void processRender(WebuiRequestContext context) throws Exception { CloudDriveContext.init(this); Object obj = context.getAttribute(CloudDrive.class); if (obj != null) { CloudDrive drive = (CloudDrive) obj; obj = context.getAttribute(CloudFile.class); if (obj != null) { initFile(drive, (CloudFile) obj); } } super.processRender(context); } /** * {@inheritDoc} */ @Override public void initFile(CloudDrive drive, CloudFile file) { this.drive = drive; this.file = file; } /** * Gets the drive. * * @return the drive */ public CloudDrive getDrive() { return drive; } /** * Gets the file. * * @return the file */ public CloudFile getFile() { return file; } /** * Checks if is viewable. * * @return true, if is viewable */ public boolean isViewable() { String mimeType = file.getType(); return file.getSize() <= viewableMaxSize && !mimeType.startsWith(MediaType.APPLICATION_OCTET_STREAM); } /** * Gets the resource bundle. * * @param key the key * @return the resource bundle */ public String appRes(String key) { Locale locale = Util.getUIPortal().getAncestorOfType(UIPortalApplication.class).getLocale(); ResourceBundleService resourceBundleService = WCMCoreUtils.getService(ResourceBundleService.class); ResourceBundle resourceBundle = resourceBundleService.getResourceBundle( new String[] { "locale.clouddrive.CloudDrive", "locale.ecm.views" }, locale, this.getClass().getClassLoader()); return resourceBundle.getString(key); } @Override public Class<? extends UIAbstractManager> getUIAbstractManagerClass() { return null; } }
4,351
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
FlashViewer.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/viewer/src/main/java/org/exoplatform/ecm/webui/viewer/FlashViewer.java
/* * Copyright (C) 2003-2008 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.viewer; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.core.UIComponent; /** * Created by The eXo Platform SARL * Author : Dang Van Minh * minh.dang@exoplatform.com * Aug 18, 2009 * 3:49:41 AM */ @ComponentConfig( template = "classpath:resources/templates/FlashViewer.gtmpl" ) public class FlashViewer extends UIComponent { public FlashViewer() throws Exception { } }
1,216
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
NotViewableCloudViewer.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/viewer/src/main/java/org/exoplatform/ecm/webui/viewer/NotViewableCloudViewer.java
/* * Copyright (C) 2003-2016 eXo Platform SAS. * * This 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 software 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 software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.exoplatform.ecm.webui.viewer; import org.exoplatform.webui.config.annotation.ComponentConfig; /** * Viewer showing no preview form. Created by The eXo Platform SAS * * @author <a href="mailto:pnedonosko@exoplatform.com">Peter Nedonosko</a> * @version $Id: LargeFilesViewer.java 00000 Jul 27, 2015 pnedonosko $ */ @ComponentConfig(template = "classpath:resources/templates/DefaultCloudFileViewer.gtmpl") public class NotViewableCloudViewer extends DefaultCloudFileViewer { /** * {@inheritDoc} */ @Override public boolean isViewable() { return false; } }
1,421
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
DefaultCloudFileViewer.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/viewer/src/main/java/org/exoplatform/ecm/webui/viewer/DefaultCloudFileViewer.java
/* * Copyright (C) 2003-2016 eXo Platform SAS. * * This 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 software 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 software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.exoplatform.ecm.webui.viewer; import java.util.Arrays; import java.util.List; import org.exoplatform.ecm.webui.clouddrives.CloudDriveContext; import org.exoplatform.ecm.webui.filters.CloudFileFilter; import org.exoplatform.services.log.ExoLogger; import org.exoplatform.services.log.Log; import org.exoplatform.web.application.Parameter; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.ext.filter.UIExtensionFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilters; import org.exoplatform.webui.ext.manager.UIAbstractManager; /** * Default WebUI component for Cloud Drive files. It shows content of remote * file by its URL in iframe on file page in eXo Documents.<br> * Created by The eXo Platform SAS. * * @author <a href="mailto:pnedonosko@exoplatform.com">Peter Nedonosko</a> * @version $Id: DefaultFileViewer.java 00000 Nov 1, 2012 pnedonosko $ */ @ComponentConfig(template = "classpath:resources/templates/DefaultCloudFileViewer.gtmpl") public class DefaultCloudFileViewer extends AbstractCloudFileViewer { /** The Constant LOG. */ protected static final Log LOG = ExoLogger.getLogger(DefaultCloudFileViewer.class); /** The Constant EVENT_NAME. */ public static final String EVENT_NAME = "ShowCloudFile"; /** The Constant FILTERS. */ protected static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[] { new CloudFileFilter() }); /** * Instantiates a new default file viewer. */ public DefaultCloudFileViewer() { super(); } /** * Instantiates a new default file viewer. * * @param viewableMaxSize the viewable max size */ protected DefaultCloudFileViewer(long viewableMaxSize) { super(viewableMaxSize); } /** * Gets the filters. * * @return the filters */ @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } /** * {@inheritDoc} */ @Override public String renderEventURL(boolean ajax, String name, String beanId, Parameter[] params) throws Exception { if (EVENT_NAME.equals(name)) { CloudDriveContext.init(this); return "javascript:void(0);//objectId"; } return super.renderEventURL(ajax, name, beanId, params); } @Override public Class<? extends UIAbstractManager> getUIAbstractManagerClass() { return null; } }
3,263
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
PDFViewer.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/viewer/src/main/java/org/exoplatform/ecm/webui/viewer/PDFViewer.java
/* * Copyright (C) 2003-2008 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.viewer; import org.exoplatform.download.DownloadService; import org.exoplatform.download.InputStreamDownloadResource; import org.exoplatform.portal.webui.util.Util; import org.exoplatform.portal.webui.workspace.UIPortalApplication; import org.exoplatform.services.cms.mimetype.DMSMimeTypeResolver; import org.exoplatform.services.log.ExoLogger; import org.exoplatform.services.log.Log; import org.exoplatform.services.pdfviewer.PDFViewerService; import org.exoplatform.services.resources.ResourceBundleService; import org.exoplatform.services.wcm.utils.WCMCoreUtils; import org.exoplatform.web.application.RequireJS; import org.exoplatform.webui.application.portlet.PortletRequestContext; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.config.annotation.EventConfig; import org.exoplatform.webui.core.UIComponent; import org.exoplatform.webui.core.lifecycle.UIFormLifecycle; import org.exoplatform.webui.core.model.SelectItemOption; import org.exoplatform.webui.event.Event; import org.exoplatform.webui.event.Event.Phase; import org.exoplatform.webui.event.EventListener; import org.exoplatform.webui.form.UIForm; import org.exoplatform.webui.form.UIFormSelectBox; import org.exoplatform.webui.form.UIFormStringInput; import org.icepdf.core.pobjects.Document; import org.icepdf.core.pobjects.PInfo; import javax.jcr.Node; import javax.jcr.NodeIterator; import javax.jcr.RepositoryException; import javax.portlet.PortletRequest; import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.MissingResourceException; import java.util.ResourceBundle; /** * Created by The eXo Platform SARL * Author : Dang Van Minh * minh.dang@exoplatform.com * Aug 18, 2009 * 3:49:41 AM */ @ComponentConfig( lifecycle = UIFormLifecycle.class, template = "classpath:resources/templates/PDFJSViewer.gtmpl", events = { @EventConfig(listeners = PDFViewer.NextPageActionListener.class, phase = Phase.DECODE), @EventConfig(listeners = PDFViewer.PreviousPageActionListener.class, phase = Phase.DECODE), @EventConfig(listeners = PDFViewer.GotoPageActionListener.class, phase = Phase.DECODE), @EventConfig(listeners = PDFViewer.RotateRightPageActionListener.class, phase = Phase.DECODE), @EventConfig(listeners = PDFViewer.RotateLeftPageActionListener.class, phase = Phase.DECODE), @EventConfig(listeners = PDFViewer.ScalePageActionListener.class, phase = Phase.DECODE), @EventConfig(listeners = PDFViewer.DownloadFileActionListener.class, phase = Phase.DECODE), @EventConfig(listeners = PDFViewer.ZoomInPageActionListener.class, phase = Phase.DECODE), @EventConfig(listeners = PDFViewer.ZoomOutPageActionListener.class, phase = Phase.DECODE) } ) /** * PDF Viewer component which will be used to display PDF file on web browser */ public class PDFViewer extends UIForm { private static final Log LOG = ExoLogger.getExoLogger(PDFViewer.class); final static private String PAGE_NUMBER = "pageNumber"; final static private String SCALE_PAGE = "scalePage"; final private String localeFile = "locale.portlet.viewer.PDFViewer"; private String sharedResourcesBundleNames[]; private ResourceBundle sharedResourceBundle=null; private static final int MIN_IE_SUPPORTED_BROWSER_VERSION = 9; private static final int MIN_FF_SUPPORTED_BROWSER_VERSION = 20; private static final int MIN_CHROME_SUPPORTED_BROWSER_VERSION = 20; private int currentPageNumber_ = 1; private int maximumOfPage_ = 0; private float currentRotation_ = 0.0f; private float currentScale_ = 1.0f; private Map<String, String> metadatas = new HashMap<String, String>(); public PDFViewer() throws Exception { addUIFormInput(new UIFormStringInput(PAGE_NUMBER, PAGE_NUMBER, "1")); UIFormSelectBox uiScaleBox = new UIFormSelectBox(SCALE_PAGE, SCALE_PAGE, initScaleOptions()); uiScaleBox.setOnChange("ScalePage"); addUIFormInput(uiScaleBox); uiScaleBox.setValue("1.0f"); } public Method getMethod(UIComponent uiComponent, String name) throws NoSuchMethodException { return uiComponent.getClass().getMethod(name, new Class[0]); } public void initDatas() throws Exception { UIComponent uiParent = getParent(); Method method = getMethod(uiParent, "getOriginalNode"); Node originalNode = null; if(method != null) originalNode = (Node) method.invoke(uiParent, (Object[]) null); if(originalNode != null) { Document document = getDocument(originalNode); if (document != null) { maximumOfPage_ = document.getNumberOfPages(); metadatas.clear(); putDocumentInfo(document.getInfo()); document.dispose(); } else maximumOfPage_ = -1; } } public Map getMetadataExtraction() { return metadatas; } public int getMaximumOfPage() throws Exception { if(maximumOfPage_ == 0) { initDatas(); } return maximumOfPage_; } public float getCurrentRotation() { return currentRotation_; } public void setRotation(float rotation) { currentRotation_ = rotation; } public float getCurrentScale() { return currentScale_; } public void setScale(float scale) { currentScale_ = scale; } public int getPageNumber() { return currentPageNumber_; } public void setPageNumber(int pageNum) { currentPageNumber_ = pageNum; }; public String getResourceBundle(String key) { try { Locale locale = Util.getUIPortal().getAncestorOfType(UIPortalApplication.class).getLocale(); ResourceBundleService resourceBundleService = WCMCoreUtils.getService(ResourceBundleService.class); ResourceBundle resourceBundle = resourceBundleService.getResourceBundle(localeFile, locale, this.getClass().getClassLoader()); return resourceBundle.getString(key); } catch (MissingResourceException e) { return key; } } public String getResource(String key) { try { Locale locale = Util.getUIPortal().getAncestorOfType(UIPortalApplication.class).getLocale(); ResourceBundleService resourceBundleService = WCMCoreUtils.getService(ResourceBundleService.class); sharedResourcesBundleNames = resourceBundleService.getSharedResourceBundleNames(); sharedResourceBundle = resourceBundleService.getResourceBundle(sharedResourcesBundleNames, locale); return sharedResourceBundle.getString(key); } catch (MissingResourceException e) { return key; } } private Document getDocument(Node node) throws RepositoryException, Exception { PDFViewerService pdfViewerService = getApplicationComponent(PDFViewerService.class); String repository = (String) getMethod(this.getParent(), "getRepository").invoke(this.getParent(), (Object[]) null); return pdfViewerService.initDocument(node, repository); } private void putDocumentInfo(PInfo documentInfo) { if (documentInfo != null) { if(documentInfo.getTitle() != null && documentInfo.getTitle().length() > 0) { metadatas.put("title", documentInfo.getTitle()); } if(documentInfo.getAuthor() != null && documentInfo.getAuthor().length() > 0) { metadatas.put("author", documentInfo.getAuthor()); } if(documentInfo.getSubject() != null && documentInfo.getSubject().length() > 0) { metadatas.put("subject", documentInfo.getSubject()); } if(documentInfo.getKeywords() != null && documentInfo.getKeywords().length() > 0) { metadatas.put("keyWords", documentInfo.getKeywords()); } if(documentInfo.getCreator() != null && documentInfo.getCreator().length() > 0) { metadatas.put("creator", documentInfo.getCreator()); } if(documentInfo.getProducer() != null && documentInfo.getProducer().length() > 0) { metadatas.put("producer", documentInfo.getProducer()); } try { if(documentInfo.getCreationDate() != null) { metadatas.put("creationDate", documentInfo.getCreationDate().toString()); } } catch (Exception e) { LOG.debug("Error when getting creation date.", e); } try { if(documentInfo.getModDate() != null) { metadatas.put("modDate", documentInfo.getModDate().toString()); } } catch (Exception e) { LOG.debug("Exception when getting modification date.", e); } } } private List<SelectItemOption<String>> initScaleOptions() { List<SelectItemOption<String>> scaleOptions = new ArrayList<SelectItemOption<String>>(); scaleOptions.add(new SelectItemOption<String>("5%", "0.05f")); scaleOptions.add(new SelectItemOption<String>("10%", "0.1f")); scaleOptions.add(new SelectItemOption<String>("25%", "0.25f")); scaleOptions.add(new SelectItemOption<String>("50%", "0.5f")); scaleOptions.add(new SelectItemOption<String>("75%", "0.75f")); scaleOptions.add(new SelectItemOption<String>("100%", "1.0f")); scaleOptions.add(new SelectItemOption<String>("125%", "1.25f")); scaleOptions.add(new SelectItemOption<String>("150%", "1.5f")); scaleOptions.add(new SelectItemOption<String>("200%", "2.0f")); scaleOptions.add(new SelectItemOption<String>("300%", "3.0f")); return scaleOptions; } /** * Check if client has modern browser (IE9+, FF20+, Chrome 20+). */ private boolean isNotModernBrowser() { PortletRequestContext requestContext = PortletRequestContext.getCurrentInstance(); PortletRequest portletRequest = requestContext.getRequest(); String userAgent = portletRequest.getProperty("user-agent"); boolean isChrome = (userAgent.indexOf("Chrome/") != -1); boolean isMSIE = (userAgent.indexOf("MSIE") != -1); boolean isFirefox = (userAgent.indexOf("Firefox/") != -1); String version = "1"; if (isFirefox) { // Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:13.0) Gecko/20100101 Firefox/13.0 version = userAgent.replaceAll("^.*?Firefox/", "").replaceAll("\\.\\d+", ""); } else if (isChrome) { // Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.52 Safari/536.5 version = userAgent.replaceAll("^.*?Chrome/(\\d+)\\..*$", "$1"); } else if (isMSIE) { // Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E) version = userAgent.replaceAll("^.*?MSIE\\s+(\\d+).*$", "$1"); } boolean unsupportedBrowser = (isFirefox && Integer.parseInt(version) < MIN_FF_SUPPORTED_BROWSER_VERSION) || (isChrome && Integer.parseInt(version) < MIN_CHROME_SUPPORTED_BROWSER_VERSION) || (isMSIE && Integer.parseInt(version) < MIN_IE_SUPPORTED_BROWSER_VERSION); return unsupportedBrowser; } static public class PreviousPageActionListener extends EventListener<PDFViewer> { public void execute(Event<PDFViewer> event) throws Exception { PDFViewer pdfViewer = event.getSource(); if(pdfViewer.currentPageNumber_ == 1) { pdfViewer.getUIStringInput(PAGE_NUMBER).setValue( Integer.toString((pdfViewer.currentPageNumber_))); } else { pdfViewer.getUIStringInput(PAGE_NUMBER).setValue( Integer.toString((pdfViewer.currentPageNumber_ -1))); pdfViewer.setPageNumber(pdfViewer.currentPageNumber_ - 1); } event.getRequestContext().addUIComponentToUpdateByAjax(pdfViewer); } } static public class NextPageActionListener extends EventListener<PDFViewer> { public void execute(Event<PDFViewer> event) throws Exception { PDFViewer pdfViewer = event.getSource(); if(pdfViewer.currentPageNumber_ == pdfViewer.maximumOfPage_) { pdfViewer.getUIStringInput(PAGE_NUMBER).setValue( Integer.toString((pdfViewer.currentPageNumber_))); } else { pdfViewer.getUIStringInput(PAGE_NUMBER).setValue( Integer.toString((pdfViewer.currentPageNumber_ + 1))); pdfViewer.setPageNumber(pdfViewer.currentPageNumber_ + 1); } event.getRequestContext().addUIComponentToUpdateByAjax(pdfViewer); } } static public class GotoPageActionListener extends EventListener<PDFViewer> { public void execute(Event<PDFViewer> event) throws Exception { PDFViewer pdfViewer = event.getSource(); String pageStr = pdfViewer.getUIStringInput(PAGE_NUMBER).getValue(); int pageNumber = 1; try { pageNumber = Integer.parseInt(pageStr); } catch(NumberFormatException e) { pageNumber = pdfViewer.currentPageNumber_; } if(pageNumber >= pdfViewer.maximumOfPage_) pageNumber = pdfViewer.maximumOfPage_; else if(pageNumber < 1) pageNumber = 1; pdfViewer.getUIStringInput(PAGE_NUMBER).setValue(Integer.toString((pageNumber))); pdfViewer.setPageNumber(pageNumber); event.getRequestContext().addUIComponentToUpdateByAjax(pdfViewer); } } static public class RotateRightPageActionListener extends EventListener<PDFViewer> { public void execute(Event<PDFViewer> event) throws Exception { PDFViewer pdfViewer = event.getSource(); pdfViewer.setRotation(pdfViewer.currentRotation_ + 270.0f); event.getRequestContext().addUIComponentToUpdateByAjax(pdfViewer); } } static public class RotateLeftPageActionListener extends EventListener<PDFViewer> { public void execute(Event<PDFViewer> event) throws Exception { PDFViewer pdfViewer = event.getSource(); pdfViewer.setRotation(pdfViewer.currentRotation_ + 90.0f); event.getRequestContext().addUIComponentToUpdateByAjax(pdfViewer); } } static public class ScalePageActionListener extends EventListener<PDFViewer> { public void execute(Event<PDFViewer> event) throws Exception { PDFViewer pdfViewer = event.getSource(); String scale = pdfViewer.getUIFormSelectBox(SCALE_PAGE).getValue(); pdfViewer.setScale(Float.parseFloat(scale)); event.getRequestContext().addUIComponentToUpdateByAjax(pdfViewer); } } static public class DownloadFileActionListener extends EventListener<PDFViewer> { public void execute(Event<PDFViewer> event) throws Exception { PDFViewer pdfViewer = event.getSource(); UIComponent uiParent = pdfViewer.getParent(); Method methodGetNode = pdfViewer.getMethod(uiParent, "getNode"); Node node = (Node)methodGetNode.invoke(uiParent, (Object[]) null); node = getFileLangNode(node); String repository = (String) pdfViewer.getMethod(uiParent, "getRepository").invoke(uiParent, (Object[]) null); PDFViewerService pdfViewerService = pdfViewer.getApplicationComponent(PDFViewerService.class); File file = pdfViewerService.getPDFDocumentFile(node, repository); String fileName = node.getName(); int index = fileName.lastIndexOf('.'); if (index < 0) { fileName += ".pdf"; } else if (index == fileName.length() - 1) { fileName += "pdf"; } else { String extension = fileName.substring(index + 1); fileName = fileName.replace(extension, "pdf"); } DownloadService dservice = pdfViewer.getApplicationComponent(DownloadService.class) ; InputStreamDownloadResource dresource = new InputStreamDownloadResource( new BufferedInputStream(new FileInputStream(file)), DMSMimeTypeResolver.getInstance().getMimeType(".pdf")); dresource.setDownloadName(fileName) ; String downloadLink = dservice.getDownloadLink(dservice.addDownloadResource(dresource)) ; RequireJS requireJS = event.getRequestContext().getJavascriptManager().getRequireJS(); requireJS.require("SHARED/ecm-utils", "ecmutil").addScripts("ecmutil.ECMUtils.ajaxRedirect('" + downloadLink + "');"); event.getRequestContext().addUIComponentToUpdateByAjax(pdfViewer); } } static public class ZoomInPageActionListener extends EventListener<PDFViewer> { public void execute(Event<PDFViewer> event) throws Exception { PDFViewer pdfViewer = event.getSource(); String[] arrValue = {"0.05f", "0.1f", "0.25f", "0.5f", "0.75f", "1.0f", "1.25f", "1.5f", "2.0f", "3.0f"}; String scale = pdfViewer.getUIFormSelectBox(SCALE_PAGE).getValue(); if(scale.equals(arrValue[arrValue.length - 1])) return; for(int i = 0; i < arrValue.length - 1; i++) { if(scale.equals(arrValue[i])) { pdfViewer.setScale(Float.parseFloat(arrValue[i + 1])); pdfViewer.getUIFormSelectBox(SCALE_PAGE).setValue(arrValue[i + 1]); break; } } event.getRequestContext().addUIComponentToUpdateByAjax(pdfViewer); } } static public class ZoomOutPageActionListener extends EventListener<PDFViewer> { public void execute(Event<PDFViewer> event) throws Exception { PDFViewer pdfViewer = event.getSource(); String scale = pdfViewer.getUIFormSelectBox(SCALE_PAGE).getValue(); String[] arrValue = {"0.05f", "0.1f", "0.25f", "0.5f", "0.75f", "1.0f", "1.25f", "1.5f", "2.0f", "3.0f"}; if(scale.equals(arrValue[0])) return; for(int i = 0; i < arrValue.length - 1; i++) { if(scale.equals(arrValue[i])) { pdfViewer.setScale(Float.parseFloat(arrValue[i - 1])); pdfViewer.getUIFormSelectBox(SCALE_PAGE).setValue(arrValue[i - 1]); break; } } event.getRequestContext().addUIComponentToUpdateByAjax(pdfViewer); } } static public Node getFileLangNode(Node currentNode) throws Exception { if(currentNode.isNodeType("nt:unstructured")) { if(currentNode.getNodes().getSize() > 0) { NodeIterator nodeIter = currentNode.getNodes() ; while(nodeIter.hasNext()) { Node ntFile = nodeIter.nextNode() ; if(ntFile.isNodeType("nt:file")) { return ntFile ; } } return currentNode ; } } return currentNode ; } public String getActionOpenDocInDesktop() { UIComponent uiParent = getParent(); String ret = ""; try { Method method = getMethod(uiParent, "getActionOpenDocInDesktop"); if(method != null) ret = (String) method.invoke(uiParent, (Object[]) null); } catch (NoSuchMethodException| IllegalArgumentException| IllegalAccessException| InvocationTargetException e) { ret = ""; } return ret; } }
19,762
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
VideoAudioViewer.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/viewer/src/main/java/org/exoplatform/ecm/webui/viewer/VideoAudioViewer.java
/*************************************************************************** * Copyright (C) 2003-2009 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. * **************************************************************************/ package org.exoplatform.ecm.webui.viewer; import java.util.ArrayList; import java.util.List; import javax.jcr.Node; import javax.jcr.NodeIterator; import org.exoplatform.container.xml.PortalContainerInfo; import org.exoplatform.services.cms.impl.Utils; import org.exoplatform.services.wcm.core.NodeLocation; import org.exoplatform.services.wcm.utils.WCMCoreUtils; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.core.UIComponent; /** * Created by The eXo Platform SARL * Author : Hoang Van Hung * hunghvit@gmail.com * Oct 29, 2009 */ @ComponentConfig( template = "classpath:resources/templates/VideoAudioViewer.gtmpl" ) public class VideoAudioViewer extends UIComponent { private List<NodeLocation> presentNodes = new ArrayList<NodeLocation>(); private String repository; public VideoAudioViewer() throws Exception { } public List<Node> getPresentNodes() { List<Node> result = new ArrayList<Node>(); result.addAll(NodeLocation.getNodeListByLocationList(presentNodes)); return result; } public void setPresentNodes(List<Node> presentNodes) { this.presentNodes = NodeLocation.getLocationsByNodeList(presentNodes); } public void setRepository(String repository) { this.repository = repository; } public String getRepository() { return repository; } public String getPortalName() { PortalContainerInfo containerInfo = WCMCoreUtils.getService(PortalContainerInfo.class) ; return containerInfo.getContainerName() ; } public Node getFileLangNode(Node currentNode) throws Exception { if(currentNode.isNodeType("nt:unstructured")) { if(currentNode.getNodes().getSize() > 0) { NodeIterator nodeIter = currentNode.getNodes() ; while(nodeIter.hasNext()) { Node ntFile = nodeIter.nextNode() ; if(ntFile.isNodeType("nt:file")) { return ntFile ; } } return currentNode ; } } return currentNode ; } public Node getChildNode(Node parent, String childType) throws Exception { return Utils.getChildOfType(parent, childType); } }
3,116
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
TextViewer.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/viewer/src/main/java/org/exoplatform/ecm/webui/viewer/TextViewer.java
/* * Copyright (C) 2003-2008 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.ecm.webui.viewer; import org.exoplatform.portal.webui.util.Util; import org.exoplatform.portal.webui.workspace.UIPortalApplication; import org.exoplatform.services.resources.ResourceBundleService; import org.exoplatform.services.wcm.utils.WCMCoreUtils; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.core.UIComponent; import java.util.Locale; import java.util.MissingResourceException; import java.util.ResourceBundle; /** * Created by The eXo Platform SARL * Author : Dang Van Minh * minh.dang@exoplatform.com * Aug 18, 2009 * 3:49:41 AM */ @ComponentConfig( template = "classpath:resources/templates/TextViewer.gtmpl" ) public class TextViewer extends UIComponent { private String sharedResourcesBundleNames[]; private ResourceBundle sharedResourceBundle=null; public TextViewer() throws Exception { } public String getResource(String key) { try { Locale locale = Util.getUIPortal().getAncestorOfType(UIPortalApplication.class).getLocale(); ResourceBundleService resourceBundleService = WCMCoreUtils.getService(ResourceBundleService.class); sharedResourcesBundleNames = resourceBundleService.getSharedResourceBundleNames(); sharedResourceBundle = resourceBundleService.getResourceBundle(sharedResourcesBundleNames, locale); return sharedResourceBundle.getString(key); } catch (MissingResourceException e) { return key; } } }
2,247
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
CloudFileFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/viewer/src/main/java/org/exoplatform/ecm/webui/filters/CloudFileFilter.java
/* * Copyright (C) 2003-2016 eXo Platform SAS. * * This 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 software 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 software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.exoplatform.ecm.webui.filters; import java.util.List; import javax.jcr.Node; import javax.jcr.RepositoryException; import org.exoplatform.services.cms.clouddrives.CloudDrive; import org.exoplatform.services.cms.clouddrives.CloudDriveService; import org.exoplatform.services.cms.clouddrives.CloudFile; import org.exoplatform.services.cms.clouddrives.DriveRemovedException; import org.exoplatform.services.cms.clouddrives.NotCloudDriveException; import org.exoplatform.services.cms.clouddrives.NotCloudFileException; import org.exoplatform.services.cms.clouddrives.NotYetCloudFileException; import org.exoplatform.services.log.ExoLogger; import org.exoplatform.services.log.Log; import org.exoplatform.services.wcm.utils.WCMCoreUtils; import org.exoplatform.webui.application.WebuiRequestContext; /** * Filter for cloud files. * * @author <a href="mailto:pnedonosko@exoplatform.com">Peter Nedonosko</a> * @version $Id: CloudFileFilter.java 00000 Nov 5, 2012 pnedonosko $ */ public class CloudFileFilter extends AbstractCloudDriveNodeFilter { /** The Constant LOG. */ protected static final Log LOG = ExoLogger.getLogger(CloudFileFilter.class); /** * Instantiates a new cloud file filter. */ public CloudFileFilter() { super(); } /** * Instantiates a new cloud file filter. * * @param providers the providers */ public CloudFileFilter(List<String> providers) { super(providers); } /** * Instantiates a new cloud file filter. * * @param providers the providers * @param minSize the min size * @param maxSize the max size */ public CloudFileFilter(List<String> providers, long minSize, long maxSize) { super(providers, minSize, maxSize); } /** * Instantiates a new cloud file filter. * * @param minSize the min size * @param maxSize the max size */ public CloudFileFilter(long minSize, long maxSize) { super(minSize, maxSize); } /** * {@inheritDoc} */ @Override protected boolean accept(Node node) throws RepositoryException { if (node != null) { CloudDriveService driveService = WCMCoreUtils.getService(CloudDriveService.class); CloudDrive drive = driveService.findDrive(node); if (drive != null) { try { if (acceptProvider(drive.getUser().getProvider())) { CloudFile file = drive.getFile(node.getPath()); long size = file.getSize(); if (size >= minSize && size <= maxSize) { // attribute used in CloudFile viewer(s) WebuiRequestContext rcontext = WebuiRequestContext.getCurrentInstance(); rcontext.setAttribute(CloudDrive.class, drive); rcontext.setAttribute(CloudFile.class, file); return true; } } } catch (DriveRemovedException e) { // doesn't accept } catch (NotYetCloudFileException e) { // doesn't accept } catch (NotCloudFileException e) { // doesn't accept } catch (NotCloudDriveException e) { // doesn't accept } } } return false; } }
3,968
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
AbstractCloudDriveNodeFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/viewer/src/main/java/org/exoplatform/ecm/webui/filters/AbstractCloudDriveNodeFilter.java
/* * Copyright (C) 2003-2018 eXo Platform SAS. * * This 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 software 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 software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.exoplatform.ecm.webui.filters; import java.util.Collections; import java.util.List; import java.util.Map; import javax.jcr.AccessDeniedException; import javax.jcr.ItemNotFoundException; import javax.jcr.Node; import javax.jcr.RepositoryException; import org.exoplatform.portal.application.PortalRequestContext; import org.exoplatform.services.cms.clouddrives.CloudProvider; import org.exoplatform.services.jcr.RepositoryService; import org.exoplatform.services.jcr.ext.common.SessionProvider; import org.exoplatform.services.log.ExoLogger; import org.exoplatform.services.log.Log; import org.exoplatform.services.wcm.utils.WCMCoreUtils; //import org.exoplatform.social.webui.activity.UIActivitiesContainer; //import org.exoplatform.social.webui.composer.PopupContainer; import org.exoplatform.webui.application.WebuiRequestContext; import org.exoplatform.webui.core.UIApplication; import org.exoplatform.webui.ext.filter.UIExtensionFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * Filter for cloud files. * * @author <a href="mailto:pnedonosko@exoplatform.com">Peter Nedonosko</a> * @version $Id: CloudDriveFiler.java 00000 Nov 5, 2012 pnedonosko $ */ public abstract class AbstractCloudDriveNodeFilter implements UIExtensionFilter { protected static final Log LOG = ExoLogger.getLogger(AbstractCloudDriveNodeFilter.class); /** The Constant CONTENTVIEWER_REST_PATH. */ protected static final String CONTENTVIEWER_REST_PATH = "/contentviewer/"; /** The constant UIJCREXPLORER_CONTEXT_NODE. */ public static final String UIJCREXPLORER_CONTEXT_NODE = "UIJCRExplorer.contextNode"; /** The min size. */ protected long minSize; /** The max size. */ protected long maxSize; /** The providers. */ protected List<String> providers; /** * Instantiates a new abstract cloud drive node filter. */ public AbstractCloudDriveNodeFilter() { this(Collections.<String> emptyList()); } /** * Instantiates a new abstract cloud drive node filter. * * @param providers the providers */ public AbstractCloudDriveNodeFilter(List<String> providers) { this(providers, 0, Long.MAX_VALUE); } /** * Instantiates a new abstract cloud drive node filter. * * @param minSize the min size * @param maxSize the max size */ public AbstractCloudDriveNodeFilter(long minSize, long maxSize) { this(Collections.<String> emptyList(), minSize, maxSize); } /** * Instantiates a new abstract cloud drive node filter. * * @param providers the providers * @param minSize the min size * @param maxSize the max size */ public AbstractCloudDriveNodeFilter(List<String> providers, long minSize, long maxSize) { this.providers = providers; this.minSize = minSize >= 0 ? minSize : 0; this.maxSize = maxSize; } /** * {@inheritDoc} */ public boolean accept(Map<String, Object> context) throws Exception { if (context == null) { return true; } else { boolean accepted = false; Node contextNode = (Node) context.get(Node.class.getName()); if (contextNode == null) { WebuiRequestContext reqContext = WebuiRequestContext.getCurrentInstance(); contextNode = (Node) reqContext.getAttribute(UIJCREXPLORER_CONTEXT_NODE); // case of file preview in Social activity stream if (contextNode == null) { contextNode = (Node) reqContext.getAttribute("UIDocumentPreviewNode"); } // case of ContentViewerRESTService (actual for PLF 4.4 and PLF 5.0) if (contextNode == null && PortalRequestContext.class.isAssignableFrom(reqContext.getClass())) { try { PortalRequestContext portalReqContext = PortalRequestContext.class.cast(reqContext); String reqPathInfo = portalReqContext.getControllerContext().getRequest().getPathInfo(); if (reqPathInfo.startsWith(CONTENTVIEWER_REST_PATH)) { // It's string of content like: // /contentviewer/repository/collaboration/4e6a36fcc0a8016529a3148700beecec String[] reqParams = reqPathInfo.substring(CONTENTVIEWER_REST_PATH.length()).split("/"); if (reqParams.length >= 3) { String repository = reqParams[0]; String workspace = reqParams[1]; String uuid = reqParams[2]; RepositoryService repositoryService = WCMCoreUtils.getService(RepositoryService.class); SessionProvider sp = WCMCoreUtils.getUserSessionProvider(); contextNode = sp.getSession(workspace, repositoryService.getRepository(repository)).getNodeByUUID(uuid); } } } catch (AccessDeniedException e) { // no access for current user } catch (ItemNotFoundException e) { // such item not found } catch (Throwable e) { // ignore and assume we don't have a context node if (LOG.isDebugEnabled()) { LOG.debug("Cannot find context node in the request: " + e.getMessage()); } } } } if (contextNode != null) { accepted = accept(contextNode); } return accepted; } } /** * {@inheritDoc} */ public UIExtensionFilterType getType() { return UIExtensionFilterType.MANDATORY; } /** * {@inheritDoc} */ public void onDeny(Map<String, Object> context) throws Exception { } // ****************** internals ****************** /** * Accept provider. * * @param provider the provider * @return true, if successful */ protected boolean acceptProvider(CloudProvider provider) { if (providers.size() > 0) { boolean accepted = providers.contains(provider.getId()); if (accepted) { return true; } else { // TODO compare by class inheritance return false; } } else { return true; } } /** * Accept. * * @param node the node * @return true, if successful * @throws RepositoryException the repository exception */ protected abstract boolean accept(Node node) throws RepositoryException; }
7,086
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIFCCConstant.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-fcc/src/main/java/org/exoplatform/wcm/webui/fastcontentcreator/UIFCCConstant.java
/* * Copyright (C) 2003-2009 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.wcm.webui.fastcontentcreator; /** * Created by The eXo Platform SAS * Author : eXoPlatform * chuong.phan@exoplatform.com, phan.le.thanh.chuong@gmail.com * Jun 25, 2009 */ public class UIFCCConstant { /** The Constant PREFERENCE_MODE. */ public static final String PREFERENCE_MODE = "mode"; /** The Constant PREFERENCE_IS_NEEDED_ACTION. */ public static final String PREFERENCE_IS_ACTION_NEEDED = "isActionNeeded"; /** The Constant PREFERENCE_REPOSITORY. */ public static final String PREFERENCE_REPOSITORY = "repository"; /** The Constant PREFERENCE_WORKSPACE. */ public static final String PREFERENCE_WORKSPACE = "workspace"; /** The Constant PREFERENCE_PATH. */ public static final String PREFERENCE_PATH = "path"; /** The Constant PREFERENCE_TYPE. */ public static final String PREFERENCE_TYPE = "type"; /** The Constant PREFERENCE_SAVE_BUTTON. */ public static final String PREFERENCE_SAVE_BUTTON = "saveButton"; /** The Constant PREFERENCE_SAVE_MESSAGE. */ public static final String PREFERENCE_SAVE_MESSAGE = "saveMessage"; /** The Constant PREFERENCE_IS_REDIRECT. */ public static final String PREFERENCE_IS_REDIRECT = "isRedirect"; /** The Constant PREFERENCE_REDIRECT_PATH. */ public static final String PREFERENCE_REDIRECT_PATH = "redirectPath"; /** The Constant TAXONOMY_POPUP_WINDOW. */ public static final String TAXONOMY_POPUP_WINDOW = "UIFCCTaxonomyPopupWindow"; /** The Constant SELECTOR_POPUP_WINDOW. */ public static final String SELECTOR_POPUP_WINDOW = "UIFCCSelectorPopupWindow"; /** The Constant SAVE_LOCATION_FIELD. */ public static final String SAVE_LOCATION_FIELD = "UIFCCSaveLocationField"; /** The Constant REPOSITORY_FORM_SELECTBOX. */ public static final String REPOSITORY_FORM_SELECTBOX = "UIFCCRepositoryFormSelectBox" ; /** The Constant WORKSPACE_FORM_SELECTBOX. */ public static final String WORKSPACE_FORM_SELECTBOX = "UIFCCWorkspaceFormSelectBox" ; /** The Constant LOCATION_FORM_INPUT_ACTION. */ public static final String LOCATION_FORM_INPUT_ACTION = "UIFCCLocationFormInputAction" ; /** The Constant LOCATION_FORM_STRING_INPUT. */ public static final String LOCATION_FORM_STRING_INPUT = "UIFCCLocationFormStringInput" ; /** The Constant TEMPLATE_FIELD. */ public static final String TEMPLATE_FIELD = "UIFCCTemplateField"; /** The Constant TEMPLATE_FORM_SELECTBOX. */ public static final String TEMPLATE_FORM_SELECTBOX = "UIFCCTemplateFormSelectBox" ; /** The Constant SAVE_FORM_STRING_INPUT. */ public static final String SAVE_FORM_STRING_INPUT = "UIFCCSaveFormStringInput"; /** The Constant MESSAGE_FORM_TEXTAREA_INPUT. */ public static final String MESSAGE_FORM_TEXTAREA_INPUT = "UIFCCMessageFormTextareaInput"; /** The Constant REDIRECT_FORM_CHECKBOX_INPUT. */ public static final String REDIRECT_FORM_CHECKBOX_INPUT = "UIFCCRedirectFormCheckboxInput"; /** The Constant REDIRECT_PATH_FORM_STRING_INPUT. */ public static final String REDIRECT_PATH_FORM_STRING_INPUT = "UIFCCRedirectPathFormStringInput"; /** The Constant ACTION_FIELD. */ public static final String ACTION_FIELD = "UIFCCActionField"; /** The Constant ACTION_GRID. */ public static final String ACTION_GRID = "UIFCCActionGrid"; /** The Constant ACTION_POPUP_WINDOW. */ public static final String ACTION_POPUP_WINDOW = "UIFCCActionPopupWindow"; /** The Constant ACTION_TYPE_SELECTBOX. */ public static final String ACTION_TYPE_SELECTBOX = "UIFCCActionTypeSelectBox"; }
4,536
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIFCCUtils.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-fcc/src/main/java/org/exoplatform/wcm/webui/fastcontentcreator/UIFCCUtils.java
/* * Copyright (C) 2003-2009 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.wcm.webui.fastcontentcreator; import org.exoplatform.webui.application.WebuiRequestContext; import org.exoplatform.webui.application.portlet.PortletRequestContext; import javax.portlet.PortletPreferences; import javax.portlet.PortletRequest; /** * Created by The eXo Platform SAS * Author : eXoPlatform * chuong.phan@exoplatform.com, phan.le.thanh.chuong@gmail.com * Jun 25, 2009 */ public class UIFCCUtils { /** * Gets the portlet preferences. * * @return the portlet preferences */ public static PortletPreferences getPortletPreferences() { PortletRequestContext portletRequestContext = WebuiRequestContext.getCurrentInstance(); PortletRequest request = portletRequestContext.getRequest(); return request.getPreferences(); } /** * Gets the preference repository. * * @return the preference repository */ public static String getPreferenceRepository() { return getPortletPreferences().getValue(UIFCCConstant.PREFERENCE_REPOSITORY, ""); } /** * Gets the preference workspace. * * @return the preference workspace */ public static String getPreferenceWorkspace() { return getPortletPreferences().getValue(UIFCCConstant.PREFERENCE_WORKSPACE, ""); } /** * Gets the preference type. * * @return the preference type */ public static String getPreferenceType() { return getPortletPreferences().getValue(UIFCCConstant.PREFERENCE_TYPE, ""); } /** * Gets the preference path. * * @return the preference path */ public static String getPreferencePath() { return getPortletPreferences().getValue(UIFCCConstant.PREFERENCE_PATH, ""); } /** * Gets the preference save message. * * @return the preference save message */ public static String getPreferenceSaveMessage() { return getPortletPreferences().getValue(UIFCCConstant.PREFERENCE_SAVE_MESSAGE, ""); } }
2,628
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIFCCForm.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-fcc/src/main/java/org/exoplatform/wcm/webui/fastcontentcreator/UIFCCForm.java
/* * Copyright (C) 2003-2007 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.wcm.webui.fastcontentcreator; import org.exoplatform.ecm.resolver.JCRResourceResolver; import org.exoplatform.ecm.webui.form.UIDialogForm; import org.exoplatform.ecm.webui.selector.ComponentSelector; import org.exoplatform.ecm.webui.selector.UISelectable; import org.exoplatform.ecm.webui.tree.selectone.UIOneNodePathSelector; import org.exoplatform.ecm.webui.tree.selectone.UIOneTaxonomySelector; import org.exoplatform.ecm.webui.utils.DialogFormUtil; import org.exoplatform.portal.webui.util.Util; import org.exoplatform.resolver.ResourceResolver; import org.exoplatform.services.cms.BasePath; import org.exoplatform.services.cms.CmsService; import org.exoplatform.services.cms.impl.DMSConfiguration; import org.exoplatform.services.cms.taxonomy.TaxonomyService; import org.exoplatform.services.cms.templates.TemplateService; import org.exoplatform.services.jcr.RepositoryService; import org.exoplatform.services.jcr.ext.common.SessionProvider; import org.exoplatform.services.jcr.ext.hierarchy.NodeHierarchyCreator; import org.exoplatform.services.wcm.utils.WCMCoreUtils; import org.exoplatform.upload.UploadService; import org.exoplatform.wcm.webui.Utils; import org.exoplatform.web.application.ApplicationMessage; import org.exoplatform.web.application.RequireJS; import org.exoplatform.webui.application.WebuiRequestContext; import org.exoplatform.webui.application.portlet.PortletRequestContext; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.config.annotation.ComponentConfigs; import org.exoplatform.webui.config.annotation.EventConfig; import org.exoplatform.webui.core.UIApplication; import org.exoplatform.webui.core.UIComponent; import org.exoplatform.webui.core.lifecycle.UIFormLifecycle; import org.exoplatform.webui.event.Event; import org.exoplatform.webui.event.Event.Phase; import org.exoplatform.webui.event.EventListener; import org.exoplatform.webui.form.UIFormInput; import org.exoplatform.webui.form.UIFormInputBase; import org.exoplatform.webui.form.UIFormMultiValueInputSet; import org.exoplatform.webui.form.UIFormStringInput; import org.exoplatform.webui.form.input.UIUploadInput; import javax.jcr.AccessDeniedException; import javax.jcr.ItemExistsException; import javax.jcr.Node; import javax.jcr.NodeIterator; import javax.jcr.PathNotFoundException; import javax.jcr.Session; import javax.jcr.Value; import javax.jcr.lock.LockException; import javax.jcr.version.VersionException; import javax.portlet.PortletPreferences; import java.security.AccessControlException; import java.util.ArrayList; import java.util.List; import java.util.Map; /** * Created by The eXo Platform SAS * Author : eXoPlatform * chuong.phan@exoplatform.com, phan.le.thanh.chuong@gmail.com * Jun 25, 2009 */ @ComponentConfigs( { @ComponentConfig(type = UIFormMultiValueInputSet.class, id = "WYSIWYGRichTextMultipleInputset", events = { @EventConfig(listeners = UIDialogForm.AddActionListener.class, phase = Phase.DECODE), @EventConfig(listeners = UIFormMultiValueInputSet.RemoveActionListener.class, phase = Phase.DECODE) }), @ComponentConfig(lifecycle = UIFormLifecycle.class, events = { @EventConfig(listeners = UIFCCForm.SaveActionListener.class), @EventConfig(listeners = UIFCCForm.AddActionListener.class, phase = Phase.DECODE), @EventConfig(listeners = UIFCCForm.RemoveActionListener.class, phase = Phase.DECODE), @EventConfig(listeners = UIFCCForm.ShowComponentActionListener.class, phase = Phase.DECODE), @EventConfig(listeners = UIFCCForm.RemoveReferenceActionListener.class, confirm = "DialogFormField.msg.confirm-delete", phase = Phase.DECODE) }) }) public class UIFCCForm extends UIDialogForm implements UISelectable { /** The Constant FIELD_TAXONOMY. */ final static public String FIELD_TAXONOMY = "categories"; /** The Constant POPUP_TAXONOMY. */ final static public String POPUP_TAXONOMY = "UIPopupTaxonomy"; /** The list taxonomy. */ private List<String> listTaxonomy = new ArrayList<String>(); /** The list taxonomy name. */ private List<String> listTaxonomyName = new ArrayList<String>(); /** The document type_. */ private String documentType_ ; /** The jcr template resource resolver_. */ private JCRResourceResolver jcrTemplateResourceResolver_ ; /** * Instantiates a new uIFCC form. * * @throws Exception the exception */ public UIFCCForm() throws Exception { PortletPreferences preferences = UIFCCUtils.getPortletPreferences() ; String custom_save_button = preferences.getValue(UIFCCConstant.PREFERENCE_SAVE_BUTTON, ""); setActions(new String[]{custom_save_button}) ; } public String event(String name) throws Exception { StringBuilder b = new StringBuilder(); b.append("javascript:eXo.webui.UIForm.submitForm('").append(getFormId()).append("','"); b.append("Save").append("',true)"); return b.toString(); } private String getFormId() { WebuiRequestContext context = WebuiRequestContext.getCurrentInstance(); if (context instanceof PortletRequestContext) { return ((PortletRequestContext)context).getWindowId() + "#" + getId(); } return getId(); } /** * Gets the list taxonomy. * * @return the list taxonomy */ public List<String> getListTaxonomy() { return listTaxonomy; } /** * Gets the list taxonomy name. * * @return the list taxonomy name */ public List<String> getlistTaxonomyName() { return listTaxonomyName; } /** * Sets the list taxonomy. * * @param listTaxonomyNew the new list taxonomy */ public void setListTaxonomy(List<String> listTaxonomyNew) { listTaxonomy = listTaxonomyNew; } /** * Sets the list taxonomy name. * * @param listTaxonomyNameNew the new list taxonomy name */ public void setListTaxonomyName(List<String> listTaxonomyNameNew) { listTaxonomyName = listTaxonomyNameNew; } /* (non-Javadoc) * @see org.exoplatform.ecm.webui.form.UIDialogForm#getTemplate() */ public String getTemplate() { TemplateService templateService = getApplicationComponent(TemplateService.class) ; String userName = Util.getPortalRequestContext().getRemoteUser() ; try { if(userName == null) { return templateService.getTemplatePathByAnonymous(true, documentType_); } return templateService.getTemplatePathByUser(true, documentType_, userName) ; } catch (Exception e) { UIApplication uiApp = getAncestorOfType(UIApplication.class) ; Object[] arg = { documentType_ } ; uiApp.addMessage(new ApplicationMessage("UIFCCForm.msg.not-support", arg, ApplicationMessage.ERROR)) ; return null ; } } /* (non-Javadoc) * @see org.exoplatform.ecm.webui.selector.UISelectable#doSelect(java.lang.String, java.lang.Object) */ @SuppressWarnings("unchecked") public void doSelect(String selectField, Object value) throws Exception { this.isUpdateSelect = true; UIFormInput formInput = getUIInput(selectField); if(formInput instanceof UIFormInputBase) { ((UIFormInputBase)formInput).setValue(value.toString()); }else if(formInput instanceof UIFormMultiValueInputSet) { UIFormMultiValueInputSet inputSet = (UIFormMultiValueInputSet) formInput; String valueTaxonomy = String.valueOf(value).trim(); List taxonomylist = inputSet.getValue(); if (!taxonomylist.contains(valueTaxonomy)) { listTaxonomy.add(valueTaxonomy); listTaxonomyName.add(valueTaxonomy); taxonomylist.add(valueTaxonomy); } inputSet.setValue(taxonomylist); } UIFCCPortlet uiContainer = getParent(); uiContainer.removeChildById("PopupComponent"); } /** * Gets the current node. * * @return the current node * * @throws Exception the exception */ public Node getCurrentNode() throws Exception { RepositoryService repositoryService = getApplicationComponent(RepositoryService.class) ; PortletPreferences preferences = UIFCCUtils.getPortletPreferences() ; Session session = WCMCoreUtils.getUserSessionProvider() .getSession(preferences.getValue(UIFCCConstant.PREFERENCE_WORKSPACE, ""), repositoryService.getCurrentRepository()); return (Node) session.getItem(preferences.getValue("path", "")); } /** * Sets the template node. * * @param type the new template node */ public void setTemplateNode(String type) { documentType_ = type ; } /* (non-Javadoc) * @see org.exoplatform.ecm.webui.form.UIDialogForm#isEditing() */ public boolean isEditing() { return false ; } /* * (non-Javadoc) * @see * org.exoplatform.webui.core.UIComponent#getTemplateResourceResolver(org. * exoplatform.webui.application.WebuiRequestContext, java.lang.String) */ public ResourceResolver getTemplateResourceResolver(WebuiRequestContext context, String template) { if(jcrTemplateResourceResolver_ == null) newJCRTemplateResourceResolver() ; return jcrTemplateResourceResolver_; } /** * New jcr template resource resolver. */ public void newJCRTemplateResourceResolver() { try { jcrTemplateResourceResolver_ = new JCRResourceResolver(getDMSWorkspace()) ; } catch(Exception e) { Utils.createPopupMessage(this, "UIFCCForm.msg.new-jcr-template", null, ApplicationMessage.ERROR); } } /** * Gets the dMS workspace. * * @return the dMS workspace */ private String getDMSWorkspace() { DMSConfiguration dmsConfiguration = getApplicationComponent(DMSConfiguration.class); return dmsConfiguration.getConfig().getSystemWorkspace(); } @Override public void processRender(WebuiRequestContext context) throws Exception { context.getJavascriptManager().loadScriptResource("wcm-webui-extension"); context.getJavascriptManager().addCustomizedOnLoadScript("changeWarning();"); super.processRender(context); } /** * The listener interface for receiving saveAction events. * The class that is interested in processing a saveAction * event implements this interface, and the object created * with that class is registered with a component using the * component's <code>addSaveActionListener</code> method. When * the saveAction event occurs, that object's appropriate * method is invoked. */ static public class SaveActionListener extends EventListener<UIFCCForm> { /* (non-Javadoc) * @see org.exoplatform.webui.event.EventListener#execute(org.exoplatform.webui.event.Event) */ public void execute(Event<UIFCCForm> event) throws Exception { UIFCCForm fastContentCreatorForm = event.getSource() ; UIApplication uiApp = fastContentCreatorForm.getAncestorOfType(UIApplication.class); PortletPreferences preferences = UIFCCUtils.getPortletPreferences(); String preferencePath = preferences.getValue(UIFCCConstant.PREFERENCE_PATH, "") ; String preferenceType = preferences.getValue(UIFCCConstant.PREFERENCE_TYPE, "") ; String preferenceWorkspace = preferences.getValue(UIFCCConstant.PREFERENCE_WORKSPACE, "") ; RepositoryService repositoryService = fastContentCreatorForm.getApplicationComponent(RepositoryService.class); SessionProvider sessionProvider = WCMCoreUtils.getUserSessionProvider(); Session session = sessionProvider.getSession(preferenceWorkspace, repositoryService.getCurrentRepository()); CmsService cmsService = fastContentCreatorForm.getApplicationComponent(CmsService.class) ; TaxonomyService taxonomyService = fastContentCreatorForm.getApplicationComponent(TaxonomyService.class); boolean hasCategories = false; StringBuffer sb = new StringBuffer(); String categoriesPath = ""; String[] categoriesPathList = null; List inputs = fastContentCreatorForm.getChildren(); for (int i = 0; i < inputs.size(); i++) { UIFormInput input = (UIFormInput) inputs.get(i); if((input.getName() != null) && input.getName().equals("name")) { String valueName = input.getValue().toString().trim(); if (!org.exoplatform.ecm.webui.utils.Utils.isNameValid(valueName, org.exoplatform.ecm.webui.utils.Utils.SPECIALCHARACTER)) { uiApp.addMessage(new ApplicationMessage("UIFCCForm.msg.name-not-allowed", null, ApplicationMessage.WARNING)); return; } } } if(fastContentCreatorForm.isReference) { UIFormMultiValueInputSet uiSet = fastContentCreatorForm.getChild(UIFormMultiValueInputSet.class); if((uiSet != null) && (uiSet.getName() != null) && uiSet.getName().equals("categories")) { hasCategories = true; List<UIComponent> listChildren = uiSet.getChildren(); for (UIComponent component : listChildren) { UIFormStringInput uiStringInput = (UIFormStringInput)component; if(uiStringInput.getValue() != null) { String value = uiStringInput.getValue().trim(); sb.append(value).append(","); } } categoriesPath = sb.toString(); if (categoriesPath.endsWith(",")) categoriesPath = categoriesPath.substring(0, categoriesPath.length()-1).trim(); categoriesPathList = categoriesPath.split(","); if ((categoriesPathList == null) || (categoriesPathList.length == 0)) { uiApp.addMessage(new ApplicationMessage("UISelectedCategoriesGrid.msg.non-categories", null, ApplicationMessage.WARNING)); return; } for(String categoryPath : categoriesPathList) { if((categoryPath != null) && (categoryPath.trim().length() > 0)){ if (categoryPath.indexOf("/") == -1) { uiApp.addMessage(new ApplicationMessage("UISelectedCategoriesGrid.msg.non-categories", null, ApplicationMessage.WARNING)); return; } } } } } Map inputProperties = DialogFormUtil.prepareMap(fastContentCreatorForm.getChildren(), fastContentCreatorForm.getInputProperties(), fastContentCreatorForm.getInputOptions()); Node homeNode = null; Node newNode = null ; try { homeNode = (Node) session.getItem(preferencePath); } catch (AccessDeniedException ade){ Object[] args = { preferencePath } ; uiApp.addMessage(new ApplicationMessage("UIFCCForm.msg.access-denied", args, ApplicationMessage.WARNING)) ; return; } catch(PathNotFoundException pnfe) { Object[] args = { preferencePath } ; uiApp.addMessage(new ApplicationMessage("UIFCCForm.msg.path-not-found", args, ApplicationMessage.WARNING)) ; return; } try { String addedPath = cmsService.storeNode(preferenceType, homeNode, inputProperties, true); homeNode.getSession().save() ; int index = 0; if(homeNode.hasNode(addedPath.substring(addedPath.lastIndexOf("/") + 1))) { newNode = homeNode.getNode(addedPath.substring(addedPath.lastIndexOf("/") + 1)); if (hasCategories && (newNode != null) && ((categoriesPath != null) && (categoriesPath.length() > 0))){ for(String categoryPath : categoriesPathList) { index = categoryPath.indexOf("/"); taxonomyService.addCategory(newNode, categoryPath.substring(0, index), categoryPath.substring(index + 1)); } } event.getRequestContext().setAttribute("nodePath", newNode.getPath()); } fastContentCreatorForm.reset() ; fastContentCreatorForm.setIsResetForm(true) ; for(UIComponent uiChild : fastContentCreatorForm.getChildren()) { if(uiChild instanceof UIFormMultiValueInputSet) { ((UIFormMultiValueInputSet)uiChild).setValue(new ArrayList<Value>()) ; } else if(uiChild instanceof UIUploadInput) { UploadService uploadService = fastContentCreatorForm.getApplicationComponent(UploadService.class) ; uploadService.removeUploadResource(((UIUploadInput)uiChild).getUploadIds()[0]) ; } } session.save() ; session.refresh(false) ; homeNode.getSession().refresh(false) ; boolean preferenceIsRedirect = Boolean.parseBoolean(preferences.getValue(UIFCCConstant.PREFERENCE_IS_REDIRECT, "")) ; String preferenceRedirectPath = preferences.getValue(UIFCCConstant.PREFERENCE_REDIRECT_PATH, "") ; if (preferenceIsRedirect && preferenceRedirectPath != null) { RequireJS requireJS = event.getRequestContext().getJavascriptManager().getRequireJS(); requireJS.require("SHARED/ecm-utils", "ecmutil").addScripts("ecmutil.ECMUtils.ajaxRedirect('" + preferenceRedirectPath + "');"); } else { String saveMessage = preferences.getValue(UIFCCConstant.PREFERENCE_SAVE_MESSAGE, "") ; if (saveMessage == null) saveMessage = "saved-successfully"; Object[] args = { saveMessage } ; ApplicationMessage appMessage = new ApplicationMessage("UIFCCForm.msg.saved-successfully", args); appMessage.setArgsLocalized(false); uiApp.addMessage(appMessage) ; } event.getRequestContext().addUIComponentToUpdateByAjax(fastContentCreatorForm.getParent()) ; } catch (AccessControlException ace) { throw new AccessDeniedException(ace.getMessage()); } catch(VersionException ve) { uiApp.addMessage(new ApplicationMessage("UIFCCForm.msg.in-versioning", null, ApplicationMessage.WARNING)) ; return; } catch(AccessDeniedException e) { Object[] args = { preferencePath } ; String key = "UIFCCForm.msg.access-denied" ; uiApp.addMessage(new ApplicationMessage(key, args, ApplicationMessage.WARNING)) ; return; } catch(LockException lock) { Object[] args = { preferencePath } ; String key = "UIFCCForm.msg.node-locked" ; uiApp.addMessage(new ApplicationMessage(key, args, ApplicationMessage.WARNING)) ; return; } catch(ItemExistsException item) { Object[] args = { preferencePath } ; String key = "UIFCCForm.msg.node-isExist" ; uiApp.addMessage(new ApplicationMessage(key, args, ApplicationMessage.WARNING)) ; } } } /** * The listener interface for receiving showComponentAction events. * The class that is interested in processing a showComponentAction * event implements this interface, and the object created * with that class is registered with a component using the * component's <code>addShowComponentActionListener</code> method. When * the showComponentAction event occurs, that object's appropriate * method is invoked. */ @SuppressWarnings("unchecked") static public class ShowComponentActionListener extends EventListener<UIFCCForm> { /* (non-Javadoc) * @see org.exoplatform.webui.event.EventListener#execute(org.exoplatform.webui.event.Event) */ public void execute(Event<UIFCCForm> event) throws Exception { UIFCCForm fastContentCreatorForm = event.getSource() ; UIFCCPortlet fastContentCreatorPortlet = fastContentCreatorForm.getParent() ; fastContentCreatorForm.isShowingComponent = true; String fieldName = event.getRequestContext().getRequestParameter(OBJECTID) ; Map fieldPropertiesMap = fastContentCreatorForm.componentSelectors.get(fieldName) ; String classPath = (String)fieldPropertiesMap.get("selectorClass") ; String rootPath = (String)fieldPropertiesMap.get("rootPath") ; ClassLoader cl = Thread.currentThread().getContextClassLoader() ; Class clazz = Class.forName(classPath, true, cl) ; UIComponent component = fastContentCreatorPortlet.createUIComponent(clazz, null, null); NodeHierarchyCreator nodeHierarchyCreator = fastContentCreatorForm.getApplicationComponent(NodeHierarchyCreator.class); SessionProvider sessionProvider = WCMCoreUtils.getUserSessionProvider(); String selectorParams = (String)fieldPropertiesMap.get("selectorParams") ; if(component instanceof UIOneNodePathSelector) { String repositoryName = UIFCCUtils.getPreferenceRepository() ; String wsFieldName = (String)fieldPropertiesMap.get("workspaceField") ; String wsName = ""; if(wsFieldName != null && wsFieldName.length() > 0) { wsName = (String)fastContentCreatorForm.<UIFormInputBase>getUIInput(wsFieldName).getValue() ; ((UIOneNodePathSelector)component).setIsDisable(wsName, true) ; } if(selectorParams != null) { String[] arrParams = selectorParams.split(",") ; if(arrParams.length == 4) { ((UIOneNodePathSelector)component).setAcceptedNodeTypesInPathPanel(new String[] {"nt:file"}) ; wsName = arrParams[1]; rootPath = arrParams[2]; ((UIOneNodePathSelector)component).setIsDisable(wsName, true) ; if(arrParams[3].indexOf(";") > -1) { ((UIOneNodePathSelector)component).setAcceptedMimeTypes(arrParams[3].split(";")) ; } else { ((UIOneNodePathSelector)component).setAcceptedMimeTypes(new String[] {arrParams[3]}) ; } } } if(rootPath == null) rootPath = "/"; ((UIOneNodePathSelector)component).setRootNodeLocation(repositoryName, wsName, rootPath) ; ((UIOneNodePathSelector)component).setShowRootPathSelect(true); ((UIOneNodePathSelector)component).init(sessionProvider); } else if (component instanceof UIOneTaxonomySelector) { String workspaceName = fastContentCreatorForm.getDMSWorkspace(); ((UIOneTaxonomySelector)component).setIsDisable(workspaceName, false); String rootTreePath = nodeHierarchyCreator.getJcrPath(BasePath.TAXONOMIES_TREE_STORAGE_PATH); RepositoryService repositoryService = fastContentCreatorForm.getApplicationComponent(RepositoryService.class); Session session = sessionProvider.getSession(workspaceName, repositoryService.getCurrentRepository()); Node rootTree = (Node) session.getItem(rootTreePath); NodeIterator childrenIterator = rootTree.getNodes(); while (childrenIterator.hasNext()) { Node childNode = childrenIterator.nextNode(); rootTreePath = childNode.getPath(); break; } ((UIOneTaxonomySelector) component).setRootNodeLocation(fastContentCreatorForm.repositoryName, workspaceName, rootTreePath); ((UIOneTaxonomySelector)component).init(sessionProvider); } Utils.createPopupWindow(fastContentCreatorForm, component, UIFCCConstant.TAXONOMY_POPUP_WINDOW, 640); String param = "returnField=" + fieldName ; String[] params = selectorParams == null ? new String[] { param } : new String[] { param, "selectorParams=" + selectorParams }; ((ComponentSelector)component).setSourceComponent(fastContentCreatorForm, params) ; event.getRequestContext().addUIComponentToUpdateByAjax(fastContentCreatorPortlet) ; } } /** * The listener interface for receiving removeReferenceAction events. * The class that is interested in processing a removeReferenceAction * event implements this interface, and the object created * with that class is registered with a component using the * component's <code>addRemoveReferenceActionListener</code> method. When * the removeReferenceAction event occurs, that object's appropriate * method is invoked. */ static public class RemoveReferenceActionListener extends EventListener<UIFCCForm> { /* (non-Javadoc) * @see org.exoplatform.webui.event.EventListener#execute(org.exoplatform.webui.event.Event) */ public void execute(Event<UIFCCForm> event) throws Exception { UIFCCForm fastContentCreatorForm = event.getSource() ; fastContentCreatorForm.isRemovePreference = true; String fieldName = event.getRequestContext().getRequestParameter(OBJECTID) ; fastContentCreatorForm.getUIStringInput(fieldName).setValue(null) ; event.getRequestContext().addUIComponentToUpdateByAjax(fastContentCreatorForm.getParent()) ; } } /** * The listener interface for receiving addAction events. * The class that is interested in processing a addAction * event implements this interface, and the object created * with that class is registered with a component using the * component's <code>addAddActionListener</code> method. When * the addAction event occurs, that object's appropriate * method is invoked. */ static public class AddActionListener extends EventListener<UIFCCForm> { /* (non-Javadoc) * @see org.exoplatform.webui.event.EventListener#execute(org.exoplatform.webui.event.Event) */ public void execute(Event<UIFCCForm> event) throws Exception { UIFCCForm uiFCCForm = event.getSource(); UIFCCPortlet fastContentCreatorPortlet = uiFCCForm.getParent(); String clickedField = event.getRequestContext().getRequestParameter(OBJECTID); if (uiFCCForm.isReference) { UIFormMultiValueInputSet uiSet = uiFCCForm.getChildById(FIELD_TAXONOMY); if((uiSet != null) && (uiSet.getName() != null) && uiSet.getName().equals(FIELD_TAXONOMY)) { if ((clickedField != null) && (clickedField.equals(FIELD_TAXONOMY))){ NodeHierarchyCreator nodeHierarchyCreator = uiFCCForm.getApplicationComponent(NodeHierarchyCreator.class); if(uiSet.getValue().size() == 0) uiSet.setValue(new ArrayList<Value>()); String workspaceName = uiFCCForm.getDMSWorkspace(); UIOneTaxonomySelector uiOneTaxonomySelector = uiFCCForm.createUIComponent(UIOneTaxonomySelector.class, null, null); uiOneTaxonomySelector.setIsDisable(workspaceName, false); String rootTreePath = nodeHierarchyCreator.getJcrPath(BasePath.TAXONOMIES_TREE_STORAGE_PATH); RepositoryService repositoryService = uiFCCForm.getApplicationComponent(RepositoryService.class); SessionProvider sessionProvider = WCMCoreUtils.getUserSessionProvider(); Session session = sessionProvider.getSession(workspaceName, repositoryService.getCurrentRepository()); Node rootTree = (Node) session.getItem(rootTreePath); NodeIterator childrenIterator = rootTree.getNodes(); while (childrenIterator.hasNext()) { Node childNode = childrenIterator.nextNode(); rootTreePath = childNode.getPath(); break; } uiOneTaxonomySelector.setRootNodeLocation(uiFCCForm.repositoryName, workspaceName, rootTreePath); uiOneTaxonomySelector.init(WCMCoreUtils.getUserSessionProvider()); String param = "returnField=" + FIELD_TAXONOMY; uiOneTaxonomySelector.setSourceComponent(uiFCCForm, new String[]{param}); Utils.createPopupWindow(uiFCCForm, uiOneTaxonomySelector, UIFCCConstant.TAXONOMY_POPUP_WINDOW, 640); } } event.getRequestContext().addUIComponentToUpdateByAjax(fastContentCreatorPortlet); } else { event.getRequestContext().addUIComponentToUpdateByAjax(uiFCCForm.getParent()); } } } /** * The listener interface for receiving removeAction events. * The class that is interested in processing a removeAction * event implements this interface, and the object created * with that class is registered with a component using the * component's <code>addRemoveActionListener</code> method. When * the removeAction event occurs, that object's appropriate * method is invoked. */ static public class RemoveActionListener extends EventListener<UIFCCForm> { /* (non-Javadoc) * @see org.exoplatform.webui.event.EventListener#execute(org.exoplatform.webui.event.Event) */ public void execute(Event<UIFCCForm> event) throws Exception { event.getRequestContext().addUIComponentToUpdateByAjax(event.getSource().getParent()) ; } } }
29,720
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIFCCPortlet.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-fcc/src/main/java/org/exoplatform/wcm/webui/fastcontentcreator/UIFCCPortlet.java
/* * Copyright (C) 2003-2007 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.wcm.webui.fastcontentcreator; import org.exoplatform.services.jcr.RepositoryService; import org.exoplatform.wcm.webui.fastcontentcreator.config.UIFCCConfig; import org.exoplatform.webui.application.WebuiApplication; import org.exoplatform.webui.application.WebuiRequestContext; import org.exoplatform.webui.application.portlet.PortletRequestContext; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.core.UIPopupContainer; import org.exoplatform.webui.core.UIPortletApplication; import org.exoplatform.webui.core.lifecycle.UIApplicationLifecycle; import javax.portlet.PortletMode; import javax.portlet.PortletPreferences; /** * Created by The eXo Platform SAS * Author : eXoPlatform * chuong.phan@exoplatform.com, phan.le.thanh.chuong@gmail.com * Jun 25, 2009 */ @ComponentConfig( lifecycle = UIApplicationLifecycle.class ) public class UIFCCPortlet extends UIPortletApplication { /** * Instantiates a new uIFCC portlet. * * @throws Exception the exception */ public UIFCCPortlet() throws Exception { addChild(UIPopupContainer.class, null, null); } /* * (non-Javadoc) * @see * org.exoplatform.webui.core.UIPortletApplication#processRender(org.exoplatform * .webui.application.WebuiApplication, * org.exoplatform.webui.application.WebuiRequestContext) */ public void processRender(WebuiApplication app, WebuiRequestContext context) throws Exception { // context.getJavascriptManager().importJavascript("eXo.ecm.ECMUtils", // "/ecm-wcm-extension/javascript/"); context.getJavascriptManager().require("SHARED/ecm-utils", "ecmutil"). addScripts("ecmutil.ECMUtils.init('UIFastContentCreatorPortlet');"); PortletRequestContext portletRequestContext = (PortletRequestContext) context; if (portletRequestContext.getApplicationMode() == PortletMode.VIEW) { if (getChild(UIFCCConfig.class) != null) { removeChild(UIFCCConfig.class); } if (getChild(UIFCCForm.class) == null) { UIFCCForm fastContentCreatorForm = addChild(UIFCCForm.class, null, null); PortletPreferences preferences = UIFCCUtils.getPortletPreferences(); fastContentCreatorForm.setTemplateNode(preferences.getValue(UIFCCConstant.PREFERENCE_TYPE, "")); fastContentCreatorForm.setWorkspace(preferences.getValue(UIFCCConstant.PREFERENCE_WORKSPACE, "")); fastContentCreatorForm.setStoredPath(preferences.getValue(UIFCCConstant.PREFERENCE_PATH, "")); fastContentCreatorForm.setRepositoryName(getApplicationComponent(RepositoryService.class).getCurrentRepository() .getConfiguration() .getName()); } } else if (portletRequestContext.getApplicationMode() == PortletMode.EDIT) { if (getChild(UIFCCForm.class) != null) { removeChild(UIFCCForm.class); } if (getChild(UIFCCConfig.class) == null) { UIFCCConfig fastContentCreatorConfig = addChild(UIFCCConfig.class, null, null); fastContentCreatorConfig.initEditMode(); } } super.processRender(app, context) ; } }
4,184
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIFCCConfig.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-fcc/src/main/java/org/exoplatform/wcm/webui/fastcontentcreator/config/UIFCCConfig.java
/* * Copyright (C) 2003-2007 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.wcm.webui.fastcontentcreator.config; import org.exoplatform.ecm.webui.selector.UISelectable; import org.exoplatform.ecm.webui.tree.selectone.UIOneNodePathSelector; import org.exoplatform.services.cms.templates.TemplateService; import org.exoplatform.services.jcr.config.RepositoryConfigurationException; import org.exoplatform.services.jcr.core.ManageableRepository; import org.exoplatform.services.log.ExoLogger; import org.exoplatform.services.log.Log; import org.exoplatform.services.wcm.core.NodeLocation; import org.exoplatform.services.wcm.utils.WCMCoreUtils; import org.exoplatform.wcm.webui.Utils; import org.exoplatform.wcm.webui.container.UIFormFieldSet; import org.exoplatform.wcm.webui.fastcontentcreator.UIFCCUtils; import org.exoplatform.wcm.webui.fastcontentcreator.config.action.UIFCCActionList; import org.exoplatform.wcm.webui.fastcontentcreator.UIFCCConstant; import org.exoplatform.web.application.ApplicationMessage; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.config.annotation.EventConfig; import org.exoplatform.webui.core.UIApplication; import org.exoplatform.webui.core.UIGrid; import org.exoplatform.webui.core.lifecycle.UIFormLifecycle; import org.exoplatform.webui.core.model.SelectItemOption; import org.exoplatform.webui.event.Event; import org.exoplatform.webui.event.Event.Phase; import org.exoplatform.webui.event.EventListener; import org.exoplatform.webui.form.UIFormInputSet; import org.exoplatform.webui.form.UIFormSelectBox; import org.exoplatform.webui.form.UIFormStringInput; import org.exoplatform.webui.form.UIFormTabPane; import org.exoplatform.webui.form.UIFormTextAreaInput; import org.exoplatform.webui.form.ext.UIFormInputSetWithAction; import org.exoplatform.webui.form.input.UICheckBoxInput; import javax.jcr.Node; import javax.jcr.PathNotFoundException; import javax.jcr.RepositoryException; import javax.jcr.Session; import javax.jcr.nodetype.NodeDefinition; import javax.jcr.nodetype.NodeType; import javax.jcr.nodetype.NodeTypeManager; import javax.portlet.PortletPreferences; import java.util.ArrayList; import java.util.List; /** * Created by The eXo Platform SAS * Author : eXoPlatform * chuong.phan@exoplatform.com, phan.le.thanh.chuong@gmail.com * Jun 25, 2009 */ @ComponentConfig( lifecycle = UIFormLifecycle.class, template = "system:/groovy/FastContentCreatorPortlet/UIFormWithFieldSet.gtmpl", events = { @EventConfig(listeners = UIFCCConfig.SaveActionListener.class), @EventConfig(listeners = UIFCCConfig.SelectPathActionListener.class, phase=Phase.DECODE), @EventConfig(listeners = UIFCCConfig.ChangeWorkspaceActionListener.class, phase=Phase.DECODE) } ) public class UIFCCConfig extends UIFormTabPane implements UISelectable { /** The log. */ private static final Log LOG = ExoLogger.getLogger(UIFCCConfig.class.getName()); /** Basic Mode */ private static final String BASIC_MODE = "basic"; /** The saved location node. */ private NodeLocation savedLocationNode; /** * Instantiates a new uIFCC config. * * @throws Exception the exception */ public UIFCCConfig() throws Exception { super("UIFCCConfig"); PortletPreferences portletPreferences = UIFCCUtils.getPortletPreferences(); String preferenceMode = portletPreferences.getValue(UIFCCConstant.PREFERENCE_MODE, ""); String preferenceWorkspace = portletPreferences.getValue(UIFCCConstant.PREFERENCE_WORKSPACE, ""); String preferencePath = portletPreferences.getValue(UIFCCConstant.PREFERENCE_PATH, ""); List<SelectItemOption<String>> options = new ArrayList<SelectItemOption<String>>() ; UIFormInputSetWithAction saveLocationField = new UIFormInputSetWithAction(UIFCCConstant.SAVE_LOCATION_FIELD); if (!BASIC_MODE.equals(preferenceMode)) { UIFormSelectBox workspaceSelectBox = new UIFormSelectBox(UIFCCConstant.WORKSPACE_FORM_SELECTBOX, UIFCCConstant.WORKSPACE_FORM_SELECTBOX, options); workspaceSelectBox.setOnChange("ChangeWorkspace") ; saveLocationField.addChild(workspaceSelectBox) ; } UIFormInputSetWithAction folderSelectorInput = new UIFormInputSetWithAction(UIFCCConstant.LOCATION_FORM_INPUT_ACTION); folderSelectorInput.addUIFormInput(new UIFormStringInput(UIFCCConstant.LOCATION_FORM_STRING_INPUT, UIFCCConstant.LOCATION_FORM_STRING_INPUT, null).setReadOnly(true)); folderSelectorInput.setActionInfo(UIFCCConstant.LOCATION_FORM_STRING_INPUT, new String[] {"SelectPath"}) ; saveLocationField.addUIFormInput((UIFormInputSet)folderSelectorInput); addChild(saveLocationField); setSelectedTab(UIFCCConstant.SAVE_LOCATION_FIELD); UIFormInputSetWithAction templateField = new UIFormInputSetWithAction(UIFCCConstant.TEMPLATE_FIELD); templateField.addChild(new UIFormSelectBox(UIFCCConstant.TEMPLATE_FORM_SELECTBOX, UIFCCConstant.TEMPLATE_FORM_SELECTBOX, options)); templateField.addChild(new UIFormStringInput(UIFCCConstant.SAVE_FORM_STRING_INPUT, UIFCCConstant.SAVE_FORM_STRING_INPUT, null)); templateField.addChild(new UIFormTextAreaInput(UIFCCConstant.MESSAGE_FORM_TEXTAREA_INPUT, UIFCCConstant.MESSAGE_FORM_TEXTAREA_INPUT, null)); templateField.addChild(new UICheckBoxInput(UIFCCConstant.REDIRECT_FORM_CHECKBOX_INPUT, UIFCCConstant.REDIRECT_FORM_CHECKBOX_INPUT, false)); templateField.addChild(new UIFormStringInput(UIFCCConstant.REDIRECT_PATH_FORM_STRING_INPUT, UIFCCConstant.REDIRECT_PATH_FORM_STRING_INPUT, null)); addChild(templateField); if (!BASIC_MODE.equals(preferenceMode)) { UIFormInputSetWithAction actionField = new UIFormInputSetWithAction(UIFCCConstant.ACTION_FIELD); UIFCCActionList fastContentCreatorActionList = actionField.addChild(UIFCCActionList.class, null, "UIFCCActionList"); fastContentCreatorActionList.init(preferenceMode); Session session = WCMCoreUtils.getUserSessionProvider().getSession(preferenceWorkspace, WCMCoreUtils.getRepository()); fastContentCreatorActionList.updateGrid((Node) session.getItem(preferencePath), fastContentCreatorActionList.getChild(UIGrid.class) .getUIPageIterator() .getCurrentPage()); addChild(actionField); } setActions(new String[] {"Save"}) ; } /** * Inits the edit mode. * * @throws Exception the exception */ public void initEditMode() throws Exception { PortletPreferences preferences = UIFCCUtils.getPortletPreferences(); String preferenceMode = preferences.getValue(UIFCCConstant.PREFERENCE_MODE, ""); String preferenceWorkspace = preferences.getValue(UIFCCConstant.PREFERENCE_WORKSPACE, "") ; String preferencePath = preferences.getValue(UIFCCConstant.PREFERENCE_PATH, "") ; boolean isDefaultWorkspace = false ; if (!BASIC_MODE.equals(preferenceMode)) { ManageableRepository repository = WCMCoreUtils.getRepository(); String[] workspaceNames = repository.getWorkspaceNames(); String systemWsName = repository.getConfiguration().getSystemWorkspaceName(); List<SelectItemOption<String>> workspace = new ArrayList<SelectItemOption<String>>(); for (String workspaceName : workspaceNames) { if (!workspaceName.equals(systemWsName)) { if (workspaceName.equals(preferenceWorkspace)) isDefaultWorkspace = true; workspace.add(new SelectItemOption<String>(workspaceName)); } } UIFormSelectBox uiWorkspaceList = getUIFormSelectBox(UIFCCConstant.WORKSPACE_FORM_SELECTBOX); uiWorkspaceList.setOptions(workspace); if (isDefaultWorkspace) { uiWorkspaceList.setValue(preferenceWorkspace); } else if (workspace.size() > 0) { uiWorkspaceList.setValue(workspace.get(0).getValue()); } } getUIStringInput(UIFCCConstant.LOCATION_FORM_STRING_INPUT).setValue(preferencePath) ; setTemplateOptions(preferencePath, preferenceWorkspace) ; getUIStringInput(UIFCCConstant.SAVE_FORM_STRING_INPUT).setValue(preferences. getValue(UIFCCConstant.PREFERENCE_SAVE_BUTTON, "")); getUIFormTextAreaInput(UIFCCConstant.MESSAGE_FORM_TEXTAREA_INPUT).setValue(preferences. getValue(UIFCCConstant.PREFERENCE_SAVE_MESSAGE, "")); getUICheckBoxInput(UIFCCConstant.REDIRECT_FORM_CHECKBOX_INPUT). setChecked(Boolean.parseBoolean(preferences.getValue(UIFCCConstant.PREFERENCE_IS_REDIRECT, ""))); getUIStringInput(UIFCCConstant.REDIRECT_PATH_FORM_STRING_INPUT).setValue(preferences. getValue(UIFCCConstant.PREFERENCE_REDIRECT_PATH, "")); } /** * Sets the template options. * * @param nodePath the node path * @param workspaceName the workspace name * * @throws Exception the exception */ private void setTemplateOptions(String nodePath, String workspaceName) throws Exception { try { Session session = WCMCoreUtils.getUserSessionProvider().getSession(workspaceName, WCMCoreUtils.getRepository()); Node currentNode = null ; UIFormSelectBox uiSelectTemplate = getUIFormSelectBox(UIFCCConstant.TEMPLATE_FORM_SELECTBOX); List<SelectItemOption<String>> options = new ArrayList<SelectItemOption<String>>(); boolean hasDefaultDoc = false ; String defaultValue = UIFCCUtils.getPreferenceType(); try { currentNode = (Node)session.getItem(nodePath) ; setSavedLocationNode(currentNode); } catch(PathNotFoundException ex) { UIApplication uiApp = getAncestorOfType(UIApplication.class) ; uiApp.addMessage(new ApplicationMessage("UIFCCConfig.msg.item-not-found", null, ApplicationMessage.WARNING)); return ; } NodeTypeManager ntManager = session.getWorkspace().getNodeTypeManager() ; NodeType currentNodeType = currentNode.getPrimaryNodeType() ; NodeDefinition[] childDefs = currentNodeType.getChildNodeDefinitions() ; TemplateService templateService = getApplicationComponent(TemplateService.class) ; List<String> templates = templateService.getDocumentTemplates() ; List<String> labels = new ArrayList<String>() ; try { for(int i = 0; i < templates.size(); i ++){ String nodeTypeName = templates.get(i).toString() ; NodeType nodeType = ntManager.getNodeType(nodeTypeName) ; NodeType[] superTypes = nodeType.getSupertypes() ; boolean isCanCreateDocument = false ; for(NodeDefinition childDef : childDefs){ NodeType[] requiredChilds = childDef.getRequiredPrimaryTypes() ; for(NodeType requiredChild : requiredChilds) { if(nodeTypeName.equals(requiredChild.getName())){ isCanCreateDocument = true ; break ; } } if(nodeTypeName.equals(childDef.getName()) || isCanCreateDocument) { if(!hasDefaultDoc && nodeTypeName.equals(defaultValue)) hasDefaultDoc = true ; String label = templateService.getTemplateLabel(nodeTypeName) ; if(!labels.contains(label)) { options.add(new SelectItemOption<String>(label, nodeTypeName)); } labels.add(label) ; isCanCreateDocument = true ; } } if(!isCanCreateDocument){ for(NodeType superType:superTypes) { for(NodeDefinition childDef : childDefs){ for(NodeType requiredType : childDef.getRequiredPrimaryTypes()) { if (superType.getName().equals(requiredType.getName())) { if(!hasDefaultDoc && nodeTypeName.equals(defaultValue)) { hasDefaultDoc = true ; } String label = templateService.getTemplateLabel(nodeTypeName) ; if(!labels.contains(label)) { options.add(new SelectItemOption<String>(label, nodeTypeName)); } labels.add(label) ; isCanCreateDocument = true ; break; } } if(isCanCreateDocument) break ; } if(isCanCreateDocument) break ; } } } uiSelectTemplate.setOptions(options) ; if(hasDefaultDoc) { uiSelectTemplate.setValue(defaultValue); } else if(options.size() > 0) { defaultValue = options.get(0).getValue() ; uiSelectTemplate.setValue(defaultValue); } } catch(Exception e) { Utils.createPopupMessage(this, "UIFCCConfig.msg.get-template", null, ApplicationMessage.ERROR); } } catch(Exception ex) { Utils.createPopupMessage(this, "UIFCCConfig.msg.set-template-option", null, ApplicationMessage.ERROR); } } /* (non-Javadoc) * @see org.exoplatform.ecm.webui.selector.UISelectable#doSelect(java.lang.String, java.lang.Object) */ public void doSelect(String selectField, Object value) { getUIStringInput(selectField).setValue(value.toString()) ; PortletPreferences preferences = UIFCCUtils.getPortletPreferences(); String preferenceMode = preferences.getValue(UIFCCConstant.PREFERENCE_MODE, ""); String preferenceWorkspace = preferences.getValue(UIFCCConstant.PREFERENCE_WORKSPACE, "") ; if (!BASIC_MODE.equals(preferenceMode)) { preferenceWorkspace = getUIFormSelectBox(UIFCCConstant.WORKSPACE_FORM_SELECTBOX).getValue() ; } String savedLocationPath = value.toString(); try { setTemplateOptions(savedLocationPath, preferenceWorkspace) ; } catch(Exception ex) { Utils.createPopupMessage(this, "UIFCCConfig.msg.do-select", null, ApplicationMessage.ERROR); } try { Session session = WCMCoreUtils.getUserSessionProvider().getSession(preferenceWorkspace, WCMCoreUtils.getRepository()); UIFCCActionList uiFCCActionList = ((UIFormFieldSet) getChildById("UIFCCActionField")).getChild(UIFCCActionList.class); uiFCCActionList.updateGrid((Node) session.getItem(savedLocationPath), uiFCCActionList.getChild(UIGrid.class) .getUIPageIterator() .getCurrentPage()); } catch (RepositoryConfigurationException e) { if (LOG.isWarnEnabled()) { LOG.warn(e.getMessage()); } } catch (RepositoryException e) { if (LOG.isWarnEnabled()) { LOG.warn(e.getMessage()); } } catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn(e.getMessage()); } } Utils.closePopupWindow(this, UIFCCConstant.SELECTOR_POPUP_WINDOW); } /** * Gets the saved location node. * * @return the saved location node */ public Node getSavedLocationNode() { return NodeLocation.getNodeByLocation(savedLocationNode); } /** * Sets the saved location node. * * @param savedLocationNode the new saved location node */ public void setSavedLocationNode(Node savedLocationNode) { this.savedLocationNode = NodeLocation.getNodeLocationByNode(savedLocationNode); } /** * Get PREFERENCE_MODE. * * @return */ public String getPreferenceMode() { PortletPreferences portletPreferences = UIFCCUtils.getPortletPreferences(); return portletPreferences.getValue(UIFCCConstant.PREFERENCE_MODE, ""); } /** * The listener interface for receiving selectPathAction events. * The class that is interested in processing a selectPathAction * event implements this interface, and the object created * with that class is registered with a component using the * component's <code>addSelectPathActionListener</code> method. When * the selectPathAction event occurs, that object's appropriate * method is invoked. */ static public class SelectPathActionListener extends EventListener<UIFCCConfig> { /* (non-Javadoc) * @see org.exoplatform.webui.event.EventListener#execute(org.exoplatform.webui.event.Event) */ public void execute(Event<UIFCCConfig> event) throws Exception { UIFCCConfig fastContentCreatorConfig = event.getSource() ; PortletPreferences preferences = UIFCCUtils.getPortletPreferences(); String preferenceMode = preferences.getValue(UIFCCConstant.PREFERENCE_MODE, ""); String preferenceRepository = WCMCoreUtils.getRepository().getConfiguration().getName(); String preferenceWorkspace = preferences.getValue(UIFCCConstant.PREFERENCE_WORKSPACE, "") ; if (!BASIC_MODE.equals(preferenceMode)) { preferenceWorkspace = fastContentCreatorConfig.getUIFormSelectBox(UIFCCConstant.WORKSPACE_FORM_SELECTBOX) .getValue(); } UIOneNodePathSelector uiOneNodePathSelector = fastContentCreatorConfig.createUIComponent(UIOneNodePathSelector.class, null, null); uiOneNodePathSelector.setIsDisable(preferenceWorkspace, true) ; uiOneNodePathSelector.setShowRootPathSelect(true) ; uiOneNodePathSelector.setRootNodeLocation(preferenceRepository, preferenceWorkspace, "/"); uiOneNodePathSelector.init(WCMCoreUtils.getUserSessionProvider()) ; uiOneNodePathSelector.setSourceComponent(fastContentCreatorConfig, new String[] { UIFCCConstant.LOCATION_FORM_STRING_INPUT }); Utils.createPopupWindow(fastContentCreatorConfig, uiOneNodePathSelector, UIFCCConstant.SELECTOR_POPUP_WINDOW, 610); fastContentCreatorConfig.setSelectedTab(UIFCCConstant.SAVE_LOCATION_FIELD); } } /** * The listener interface for receiving changeWorkspaceAction events. * The class that is interested in processing a changeWorkspaceAction * event implements this interface, and the object created * with that class is registered with a component using the * component's <code>addChangeWorkspaceActionListener</code> method. When * the changeWorkspaceAction event occurs, that object's appropriate * method is invoked. */ static public class ChangeWorkspaceActionListener extends EventListener<UIFCCConfig> { /* (non-Javadoc) * @see org.exoplatform.webui.event.EventListener#execute(org.exoplatform.webui.event.Event) */ public void execute(Event<UIFCCConfig> event) throws Exception { UIFCCConfig uiFCCConfig = event.getSource(); uiFCCConfig.getUIStringInput(UIFCCConstant.LOCATION_FORM_STRING_INPUT).setValue("/"); String wsName = uiFCCConfig.getUIFormSelectBox(UIFCCConstant.WORKSPACE_FORM_SELECTBOX).getValue(); uiFCCConfig.setTemplateOptions(uiFCCConfig.getUIStringInput(UIFCCConstant.LOCATION_FORM_STRING_INPUT) .getValue(), wsName); event.getRequestContext().addUIComponentToUpdateByAjax(uiFCCConfig); } } /** * The listener interface for receiving saveAction events. * The class that is interested in processing a saveAction * event implements this interface, and the object created * with that class is registered with a component using the * component's <code>addSaveActionListener</code> method. When * the saveAction event occurs, that object's appropriate * method is invoked. */ static public class SaveActionListener extends EventListener<UIFCCConfig> { /* (non-Javadoc) * @see org.exoplatform.webui.event.EventListener#execute(org.exoplatform.webui.event.Event) */ public void execute(Event<UIFCCConfig> event) throws Exception { UIFCCConfig fastContentCreatorConfig = event.getSource() ; UIApplication uiApp = fastContentCreatorConfig.getAncestorOfType(UIApplication.class) ; PortletPreferences portletPreferences = UIFCCUtils.getPortletPreferences(); String preferenceMode = portletPreferences.getValue(UIFCCConstant.PREFERENCE_MODE, ""); boolean preferenceIsActionNeeded = Boolean.parseBoolean(portletPreferences. getValue(UIFCCConstant.PREFERENCE_IS_ACTION_NEEDED, "false")); String type = fastContentCreatorConfig.getUIFormSelectBox(UIFCCConstant.TEMPLATE_FORM_SELECTBOX) .getValue(); String path = fastContentCreatorConfig.getUIStringInput(UIFCCConstant.LOCATION_FORM_STRING_INPUT) .getValue(); String saveButton = fastContentCreatorConfig.getUIStringInput(UIFCCConstant.SAVE_FORM_STRING_INPUT) .getValue(); String saveMessage = fastContentCreatorConfig.getUIFormTextAreaInput(UIFCCConstant.MESSAGE_FORM_TEXTAREA_INPUT) .getValue(); String isRedirect = String.valueOf(fastContentCreatorConfig. getUICheckBoxInput(UIFCCConstant.REDIRECT_FORM_CHECKBOX_INPUT) .isChecked()); String redirectPath = fastContentCreatorConfig.getUIStringInput(UIFCCConstant.REDIRECT_PATH_FORM_STRING_INPUT) .getValue(); if (("false".equals(isRedirect) || redirectPath == null) && saveMessage == null) { Utils.createPopupMessage(fastContentCreatorConfig, "UIFCCConfig.msg.message-empty", null, ApplicationMessage.WARNING); } String workspaceName = null; if (BASIC_MODE.equals(preferenceMode) && preferenceIsActionNeeded) workspaceName = portletPreferences.getValue(UIFCCConstant.PREFERENCE_WORKSPACE, ""); else workspaceName = fastContentCreatorConfig.getUIFormSelectBox(UIFCCConstant.WORKSPACE_FORM_SELECTBOX) .getValue(); if (workspaceName == null || workspaceName.trim().length() == 0) { uiApp.addMessage(new ApplicationMessage("UIFCCConfig.msg.ws-empty", null, ApplicationMessage.WARNING)); return; } if (type == null || type.trim().length() == 0) { uiApp.addMessage(new ApplicationMessage("UIFCCConfig.msg.fileType-empty", null, ApplicationMessage.WARNING)); return; } portletPreferences.setValue(UIFCCConstant.PREFERENCE_WORKSPACE, workspaceName); portletPreferences.setValue(UIFCCConstant.PREFERENCE_PATH, path); portletPreferences.setValue(UIFCCConstant.PREFERENCE_TYPE, type); portletPreferences.setValue(UIFCCConstant.PREFERENCE_SAVE_BUTTON, saveButton); portletPreferences.setValue(UIFCCConstant.PREFERENCE_SAVE_MESSAGE, saveMessage); portletPreferences.setValue(UIFCCConstant.PREFERENCE_IS_REDIRECT, isRedirect); portletPreferences.setValue(UIFCCConstant.PREFERENCE_REDIRECT_PATH, redirectPath); portletPreferences.store(); uiApp.addMessage(new ApplicationMessage("UIFCCConfig.msg.save-successfully", null)); } } }
25,675
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIFCCActionTypeForm.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-fcc/src/main/java/org/exoplatform/wcm/webui/fastcontentcreator/config/action/UIFCCActionTypeForm.java
/* * Copyright (C) 2003-2009 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.wcm.webui.fastcontentcreator.config.action; import org.exoplatform.portal.webui.util.Util; import org.exoplatform.services.cms.actions.ActionServiceContainer; import org.exoplatform.services.cms.templates.TemplateService; import org.exoplatform.wcm.webui.fastcontentcreator.UIFCCPortlet; import org.exoplatform.wcm.webui.fastcontentcreator.UIFCCUtils; import org.exoplatform.wcm.webui.fastcontentcreator.config.UIFCCConfig; import org.exoplatform.web.application.ApplicationMessage; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.config.annotation.EventConfig; import org.exoplatform.webui.core.UIApplication; import org.exoplatform.webui.core.lifecycle.UIFormLifecycle; import org.exoplatform.webui.core.model.SelectItemOption; import org.exoplatform.webui.event.Event; import org.exoplatform.webui.event.EventListener; import org.exoplatform.webui.form.UIForm; import org.exoplatform.webui.form.UIFormSelectBox; import javax.jcr.Node; import javax.jcr.PathNotFoundException; import javax.jcr.RepositoryException; import javax.jcr.nodetype.NodeType; import java.util.ArrayList; import java.util.Iterator; import java.util.List; /** * Created by The eXo Platform SAS * Author : eXoPlatform * chuong.phan@exoplatform.com, phan.le.thanh.chuong@gmail.com * Jun 25, 2009 */ @ComponentConfig( lifecycle = UIFormLifecycle.class, template = "system:/groovy/FastContentCreatorPortlet/UIFCCActionTypeForm.gtmpl", events = { @EventConfig(listeners = UIFCCActionTypeForm.ChangeActionTypeActionListener.class) } ) public class UIFCCActionTypeForm extends UIForm { /** The Constant ACTION_TYPE. */ final static public String ACTION_TYPE = "actionType" ; /** The Constant CHANGE_ACTION. */ final static public String CHANGE_ACTION = "ChangeActionType" ; /** The type list_. */ private List<SelectItemOption<String>> typeList_ ; /** The node path. */ private String nodePath = null; /** The default action type_. */ public String defaultActionType_ ; /** * Instantiates a new uIFCC action type form. * * @throws Exception the exception */ public UIFCCActionTypeForm() throws Exception { typeList_ = new ArrayList<SelectItemOption<String>>() ; UIFormSelectBox uiSelectBox = new UIFormSelectBox(ACTION_TYPE, ACTION_TYPE, new ArrayList<SelectItemOption<String>>()); uiSelectBox.setOnChange(CHANGE_ACTION) ; addUIFormInput(uiSelectBox) ; } /** * Gets the created action types. * * @return the created action types * * @throws Exception the exception */ private Iterator<NodeType> getCreatedActionTypes() throws Exception { ActionServiceContainer actionService = getApplicationComponent(ActionServiceContainer.class) ; return actionService.getCreatedActionTypes(UIFCCUtils.getPreferenceRepository()).iterator(); } /** * Sets the default action type. * * @throws Exception the exception */ public void setDefaultActionType() throws Exception{ boolean isNews = true; UIFCCPortlet fastContentCreatorPortlet = getAncestorOfType(UIFCCPortlet.class); UIFCCConfig fastContentCreatorConfig = fastContentCreatorPortlet.getChild(UIFCCConfig.class); Node savedLocationNode = fastContentCreatorConfig.getSavedLocationNode() ; UIFCCActionContainer fastContentCreatorActionContainer = getParent() ; UIFCCActionForm fastContentCreatorActionForm = fastContentCreatorActionContainer.getChild(UIFCCActionForm.class); if(defaultActionType_ == null) { defaultActionType_ = "exo:addMetadataAction"; isNews = true; }else{ isNews = false; } fastContentCreatorActionForm.setNodePath(nodePath) ; getUIFormSelectBox(ACTION_TYPE).setValue(defaultActionType_).setDisabled(!isNews); fastContentCreatorActionForm.createNewAction(savedLocationNode, defaultActionType_, isNews); fastContentCreatorActionForm.setWorkspace(savedLocationNode.getSession() .getWorkspace() .getName()); fastContentCreatorActionForm.setStoredPath(savedLocationNode.getPath()); } /** * Update. * * @throws Exception the exception */ public void update() throws Exception { Iterator<NodeType> actions = getCreatedActionTypes(); while(actions.hasNext()){ String action = actions.next().getName(); typeList_.add(new SelectItemOption<String>(action, action)); } getUIFormSelectBox(ACTION_TYPE).setOptions(typeList_) ; setDefaultActionType() ; } /** * Inits the. * * @param nodePath the node path * @param actionType the action type * * @throws RepositoryException the repository exception */ public void init(String nodePath, String actionType) throws RepositoryException { this.nodePath = nodePath; this.defaultActionType_ = actionType; } /** * The listener interface for receiving changeActionTypeAction events. * The class that is interested in processing a changeActionTypeAction * event implements this interface, and the object created * with that class is registered with a component using the * component's <code>addChangeActionTypeActionListener</code> method. When * the changeActionTypeAction event occurs, that object's appropriate * method is invoked. */ static public class ChangeActionTypeActionListener extends EventListener<UIFCCActionTypeForm> { /* (non-Javadoc) * @see org.exoplatform.webui.event.EventListener#execute(org.exoplatform.webui.event.Event) */ public void execute(Event<UIFCCActionTypeForm> event) throws Exception { UIFCCActionTypeForm fastContentCreatorActionTypeForm = event.getSource() ; UIFCCPortlet fastContentCreatorPortlet = fastContentCreatorActionTypeForm.getAncestorOfType(UIFCCPortlet.class); UIFCCConfig fastContentCreatorConfig = fastContentCreatorPortlet.getChild(UIFCCConfig.class); Node currentNode = fastContentCreatorConfig.getSavedLocationNode() ; String actionType = fastContentCreatorActionTypeForm.getUIFormSelectBox(ACTION_TYPE).getValue() ; TemplateService templateService = fastContentCreatorActionTypeForm.getApplicationComponent(TemplateService.class) ; String userName = Util.getPortalRequestContext().getRemoteUser() ; UIApplication uiApp = fastContentCreatorActionTypeForm.getAncestorOfType(UIApplication.class) ; try { String templatePath = templateService.getTemplatePathByUser(true, actionType, userName) ; if (templatePath == null) { Object[] arg = { actionType }; uiApp.addMessage(new ApplicationMessage("UIFastContentCreatorActionTypeForm.msg.access-denied", arg, ApplicationMessage.WARNING)); actionType = "exo:addMetadataAction" ; fastContentCreatorActionTypeForm.getUIFormSelectBox(UIFCCActionTypeForm.ACTION_TYPE).setValue(actionType) ; UIFCCActionContainer fastContentCreatorActionContainer = fastContentCreatorActionTypeForm. getAncestorOfType(UIFCCActionContainer.class); UIFCCActionForm fastContentCreatorActionForm = fastContentCreatorActionContainer.getChild(UIFCCActionForm.class); fastContentCreatorActionForm.createNewAction(currentNode, actionType, true); event.getRequestContext().addUIComponentToUpdateByAjax(fastContentCreatorActionContainer); return ; } } catch (PathNotFoundException path) { Object[] arg = { actionType } ; uiApp.addMessage(new ApplicationMessage("UIFastContentCreatorActionTypeForm.msg.not-support", arg, ApplicationMessage.WARNING)); actionType = "exo:addMetadataAction" ; fastContentCreatorActionTypeForm.getUIFormSelectBox(UIFCCActionTypeForm.ACTION_TYPE).setValue(actionType) ; UIFCCActionContainer fastContentCreatorActionContainer = fastContentCreatorActionTypeForm. getAncestorOfType(UIFCCActionContainer.class); UIFCCActionForm fastContentCreatorActionForm = fastContentCreatorActionContainer.getChild(UIFCCActionForm.class); fastContentCreatorActionForm.createNewAction(currentNode, actionType, true); event.getRequestContext().addUIComponentToUpdateByAjax(fastContentCreatorActionContainer); } UIFCCActionContainer fastContentCreatorActionContainer = fastContentCreatorActionTypeForm.getParent(); UIFCCActionForm uiActionForm = fastContentCreatorActionContainer.getChild(UIFCCActionForm.class); uiActionForm.createNewAction(currentNode, actionType, true); event.getRequestContext().addUIComponentToUpdateByAjax(fastContentCreatorActionContainer); } } }
9,768
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIFCCActionContainer.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-fcc/src/main/java/org/exoplatform/wcm/webui/fastcontentcreator/config/action/UIFCCActionContainer.java
/* * Copyright (C) 2003-2009 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.wcm.webui.fastcontentcreator.config.action; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.core.UIContainer; import org.exoplatform.webui.core.lifecycle.UIContainerLifecycle; /** * Created by The eXo Platform SAS * Author : eXoPlatform * chuong.phan@exoplatform.com, phan.le.thanh.chuong@gmail.com * Jun 25, 2009 */ @ComponentConfig( lifecycle = UIContainerLifecycle.class ) public class UIFCCActionContainer extends UIContainer { /** * Instantiates a new uIFCC action container. * * @throws Exception the exception */ public UIFCCActionContainer() throws Exception { addChild(UIFCCActionTypeForm.class, null, null); addChild(UIFCCActionForm.class, null, null); } }
1,480
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIFCCActionForm.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-fcc/src/main/java/org/exoplatform/wcm/webui/fastcontentcreator/config/action/UIFCCActionForm.java
/* * Copyright (C) 2003-2009 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.wcm.webui.fastcontentcreator.config.action; import org.exoplatform.ecm.resolver.JCRResourceResolver; import org.exoplatform.ecm.utils.lock.LockUtil; import org.exoplatform.ecm.webui.form.UIDialogForm; import org.exoplatform.ecm.webui.nodetype.selector.UINodeTypeSelector; import org.exoplatform.ecm.webui.selector.ComponentSelector; import org.exoplatform.ecm.webui.selector.UISelectable; import org.exoplatform.ecm.webui.tree.selectone.UIOneNodePathSelector; import org.exoplatform.ecm.webui.utils.DialogFormUtil; import org.exoplatform.ecm.webui.utils.PermissionUtil; import org.exoplatform.portal.webui.util.Util; import org.exoplatform.resolver.ResourceResolver; import org.exoplatform.services.cms.CmsService; import org.exoplatform.services.cms.JcrInputProperty; import org.exoplatform.services.cms.actions.ActionServiceContainer; import org.exoplatform.services.cms.impl.DMSConfiguration; import org.exoplatform.services.cms.impl.DMSRepositoryConfiguration; import org.exoplatform.services.cms.templates.TemplateService; import org.exoplatform.services.wcm.utils.WCMCoreUtils; import org.exoplatform.wcm.webui.Utils; import org.exoplatform.wcm.webui.fastcontentcreator.UIFCCConstant; import org.exoplatform.wcm.webui.fastcontentcreator.UIFCCPortlet; import org.exoplatform.wcm.webui.fastcontentcreator.UIFCCUtils; import org.exoplatform.wcm.webui.fastcontentcreator.config.UIFCCConfig; import org.exoplatform.web.application.ApplicationMessage; import org.exoplatform.webui.application.WebuiRequestContext; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.config.annotation.EventConfig; import org.exoplatform.webui.core.UIApplication; import org.exoplatform.webui.core.UIComponent; import org.exoplatform.webui.core.UIContainer; import org.exoplatform.webui.core.UIGrid; import org.exoplatform.webui.core.lifecycle.UIFormLifecycle; import org.exoplatform.webui.event.Event; import org.exoplatform.webui.event.Event.Phase; import org.exoplatform.webui.event.EventListener; import org.exoplatform.webui.form.UIFormInputBase; import org.exoplatform.webui.form.UIFormMultiValueInputSet; import org.exoplatform.webui.form.UIFormStringInput; import javax.jcr.Node; import javax.jcr.RepositoryException; import java.util.ArrayList; import java.util.List; import java.util.Map; /** * Created by The eXo Platform SAS * Author : eXoPlatform * chuong.phan@exoplatform.com, phan.le.thanh.chuong@gmail.com * Jun 25, 2009 */ @ComponentConfig(lifecycle = UIFormLifecycle.class, events = { @EventConfig(listeners = UIFCCActionForm.SaveActionListener.class), @EventConfig(listeners = UIDialogForm.OnchangeActionListener.class, phase = Phase.DECODE), @EventConfig(listeners = UIFCCActionForm.CloseActionListener.class, phase = Phase.DECODE), @EventConfig(listeners = UIFCCActionForm.ShowComponentActionListener.class, phase = Phase.DECODE), @EventConfig(listeners = UIFCCActionForm.RemoveReferenceActionListener.class, confirm = "DialogFormField.msg.confirm-delete", phase = Phase.DECODE) }) public class UIFCCActionForm extends UIDialogForm implements UISelectable { /** The parent path_. */ private String parentPath_ ; /** The node type name_. */ private String nodeTypeName_ = null ; /** The script path_. */ private String scriptPath_ = null ; /** The root path_. */ private String rootPath_ = null; /** The is add new. */ private boolean isAddNew = false; /** The Constant EXO_ACTIONS. */ private static final String EXO_ACTIONS = "exo:actions"; /** * Instantiates a new uIFCC action form. * * @throws Exception the exception */ public UIFCCActionForm() throws Exception {setActions(new String[]{"Save","Close"}) ;} /** * Creates the new action. * * @param parentNode the parent node * @param actionType the action type * @param isAddNew the is add new * * @throws Exception the exception */ public void createNewAction(Node parentNode, String actionType, boolean isAddNew) throws Exception { reset() ; parentPath_ = parentNode.getPath() ; nodeTypeName_ = actionType; componentSelectors.clear() ; properties.clear() ; this.isAddNew = isAddNew; getChildren().clear() ; } /** * Gets the parent node. * * @return the parent node * * @throws Exception the exception */ private Node getParentNode(Node node) throws Exception{ return (Node) node.getSession().getItem(parentPath_) ; } /* (non-Javadoc) * @see org.exoplatform.ecm.webui.form.UIDialogForm#renderField(java.lang.String) */ public void renderField(String name) throws Exception { UIComponent uiInput = findComponentById(name); if ("homePath".equals(name)) { String homPath = UIFCCUtils.getPreferenceWorkspace() + ":" + parentPath_; if (homPath.endsWith("/")) homPath = homPath.substring(0, homPath.length() - 1); ((UIFormStringInput) uiInput).setValue(homPath); } if ("targetPath".equals(name) && (isOnchange()) && !isUpdateSelect) { ((UIFormStringInput) uiInput).reset(); } super.renderField(name); } /* (non-Javadoc) * @see org.exoplatform.ecm.webui.selector.UISelectable#doSelect(java.lang.String, java.lang.Object) */ public void doSelect(String selectField, Object value) throws Exception { isUpdateSelect = true ; //getUIStringInput(selectField).setValue(value.toString()) ; UIComponent uicomponent = getChildById(selectField); if (UIFormStringInput.class.isInstance(uicomponent)) ((UIFormStringInput)uicomponent).setValue(value.toString()); else if (UIFormMultiValueInputSet.class.isInstance(uicomponent)) { ((UIFormMultiValueInputSet)uicomponent).setValue((ArrayList<String>)value); } } /** * Gets the current path. * * @return the current path * * @throws Exception the exception */ public String getCurrentPath() throws Exception { UIFCCPortlet fastContentCreatorPortlet = getAncestorOfType(UIFCCPortlet.class); UIFCCConfig fastContentCreatorConfig = fastContentCreatorPortlet.getChild(UIFCCConfig.class); return fastContentCreatorConfig.getSavedLocationNode().getPath(); } /* * (non-Javadoc) * @see * org.exoplatform.webui.core.UIComponent#getTemplateResourceResolver(org. * exoplatform.webui.application.WebuiRequestContext, java.lang.String) */ public ResourceResolver getTemplateResourceResolver(WebuiRequestContext context, String template) { DMSConfiguration dmsConfiguration = getApplicationComponent(DMSConfiguration.class); DMSRepositoryConfiguration repositoryConfiguration = dmsConfiguration.getConfig(); return new JCRResourceResolver(repositoryConfiguration.getSystemWorkspace()); } /* (non-Javadoc) * @see org.exoplatform.ecm.webui.form.UIDialogForm#getTemplate() */ public String getTemplate() { return getDialogPath() ; } /** * Gets the dialog path. * * @return the dialog path */ public String getDialogPath() { repositoryName = UIFCCUtils.getPreferenceRepository() ; TemplateService templateService = getApplicationComponent(TemplateService.class) ; String userName = Util.getPortalRequestContext().getRemoteUser() ; String dialogPath = null ; if (nodeTypeName_ != null) { try { dialogPath = templateService.getTemplatePathByUser(true, nodeTypeName_, userName); } catch (Exception e){ Utils.createPopupMessage(this, "UIFCCForm.msg.get-dialog-path", null, ApplicationMessage.ERROR); } } return dialogPath ; } /** * Gets the repository name. * * @return the repository name */ public String getRepositoryName() { return repositoryName; } /** * Gets the template node type. * * @return the template node type */ public String getTemplateNodeType() { return nodeTypeName_ ; } /** * Gets the path. * * @return the path */ public String getPath() { return scriptPath_ ; } /** * Sets the root path. * * @param rootPath the new root path */ public void setRootPath(String rootPath){ rootPath_ = rootPath; } /** * Gets the root path. * * @return the root path */ public String getRootPath(){return rootPath_;} /* (non-Javadoc) * @see org.exoplatform.ecm.webui.form.UIDialogForm#onchange(org.exoplatform.webui.event.Event) */ public void onchange(Event<?> event) throws Exception { if(!isAddNew){ event.getRequestContext().addUIComponentToUpdateByAjax(getParent()) ; return; } } /** * The listener interface for receiving saveAction events. * The class that is interested in processing a saveAction * event implements this interface, and the object created * with that class is registered with a component using the * component's <code>addSaveActionListener</code> method. When * the saveAction event occurs, that object's appropriate * method is invoked. */ static public class SaveActionListener extends EventListener<UIFCCActionForm> { /* (non-Javadoc) * @see org.exoplatform.webui.event.EventListener#execute(org.exoplatform.webui.event.Event) */ public void execute(Event<UIFCCActionForm> event) throws Exception { UIFCCActionForm fccActionForm = event.getSource(); UIApplication uiApp = fccActionForm.getAncestorOfType(UIApplication.class) ; // Get current node UIFCCPortlet fastContentCreatorPortlet = fccActionForm.getAncestorOfType(UIFCCPortlet.class); UIFCCConfig fastContentCreatorConfig = fastContentCreatorPortlet.getChild(UIFCCConfig.class) ; Node currentNode = fastContentCreatorConfig.getSavedLocationNode(); // Check permission for current node if (!PermissionUtil.canAddNode(currentNode) || !PermissionUtil.canSetProperty(currentNode)) { uiApp.addMessage(new ApplicationMessage("UIFastContentCreatorActionForm.msg.no-permission-add", null)); return; } UIFCCActionList fastContentCreatorActionList = null; Map<String, JcrInputProperty> sortedInputs = DialogFormUtil.prepareMap(fccActionForm.getChildren(), fccActionForm.getInputProperties(), fccActionForm.getInputOptions()); // Update action node: if(!fccActionForm.isAddNew) { CmsService cmsService = fccActionForm.getApplicationComponent(CmsService.class) ; Node storedHomeNode = fccActionForm.getParentNode(currentNode).getNode("exo:actions"); cmsService.storeNode(fccActionForm.nodeTypeName_, storedHomeNode, sortedInputs, false) ; storedHomeNode.getSession().save(); } else { // Add lock token if node is locked if (currentNode.isLocked()) { String lockToken = LockUtil.getLockToken(currentNode); if(lockToken != null) { currentNode.getSession().addLockToken(lockToken); } } try{ JcrInputProperty rootProp = sortedInputs.get("/node"); if(rootProp == null) { rootProp = new JcrInputProperty(); rootProp.setJcrPath("/node"); rootProp.setValue((sortedInputs.get("/node/exo:name")).getValue()) ; sortedInputs.put("/node", rootProp) ; } else { rootProp.setValue((sortedInputs.get("/node/exo:name")).getValue()); } String actionName = (String)(sortedInputs.get("/node/exo:name")).getValue() ; Node parentNode = fccActionForm.getParentNode(currentNode); // Check if action existed if (parentNode.hasNode(EXO_ACTIONS)) { if (parentNode.getNode(EXO_ACTIONS).hasNode(actionName)) { Object[] args = { actionName }; uiApp.addMessage(new ApplicationMessage("UIFastContentCreatorActionForm.msg.existed-action", args, ApplicationMessage.WARNING)); return; } } // Check parent node if(parentNode.isNew()) { String[] args = {parentNode.getPath()} ; uiApp.addMessage(new ApplicationMessage("UIFastContentCreatorActionForm.msg.unable-add-action",args)) ; return; } // Save to database ActionServiceContainer actionServiceContainer = fccActionForm.getApplicationComponent(ActionServiceContainer.class); actionServiceContainer.addAction(parentNode, fccActionForm.nodeTypeName_, sortedInputs); fccActionForm.setIsOnchange(false) ; parentNode.getSession().save() ; // Create action fccActionForm.createNewAction(fastContentCreatorConfig.getSavedLocationNode(), fccActionForm.nodeTypeName_, true); fastContentCreatorActionList = fastContentCreatorConfig.findFirstComponentOfType(UIFCCActionList.class); fastContentCreatorActionList.updateGrid(parentNode, fastContentCreatorActionList.getChild(UIGrid.class) .getUIPageIterator() .getCurrentPage()); fccActionForm.reset() ; } catch(RepositoryException repo) { String key = "UIFastContentCreatorActionForm.msg.repository-exception" ; uiApp.addMessage(new ApplicationMessage(key, null, ApplicationMessage.WARNING)) ; return; } catch(NumberFormatException nume) { String key = "UIFastContentCreatorActionForm.msg.numberformat-exception" ; uiApp.addMessage(new ApplicationMessage(key, null, ApplicationMessage.WARNING)) ; return; } catch (NullPointerException nullPointerException) { uiApp.addMessage(new ApplicationMessage("UIFastContentCreatorActionForm.msg.unable-add", null, ApplicationMessage.WARNING)); return; } catch (Exception e) { uiApp.addMessage(new ApplicationMessage("UIFastContentCreatorActionForm.msg.unable-add", null, ApplicationMessage.WARNING)); return; } } Utils.closePopupWindow(fccActionForm, UIFCCConstant.ACTION_POPUP_WINDOW); } } /** * The listener interface for receiving closeAction events. * The class that is interested in processing a closeAction * event implements this interface, and the object created * with that class is registered with a component using the * component's <code>addCloseActionListener</code> method. When * the closeAction event occurs, that object's appropriate * method is invoked. */ static public class CloseActionListener extends EventListener<UIFCCActionForm> { /* (non-Javadoc) * @see org.exoplatform.webui.event.EventListener#execute(org.exoplatform.webui.event.Event) */ public void execute(Event<UIFCCActionForm> event) throws Exception { UIFCCActionForm fastContentCreatorActionForm = event.getSource(); Utils.closePopupWindow(fastContentCreatorActionForm, UIFCCConstant.ACTION_POPUP_WINDOW); } } /** * The listener interface for receiving removeReferenceAction events. * The class that is interested in processing a removeReferenceAction * event implements this interface, and the object created * with that class is registered with a component using the * component's <code>addRemoveReferenceActionListener</code> method. When * the removeReferenceAction event occurs, that object's appropriate * method is invoked. */ static public class RemoveReferenceActionListener extends EventListener<UIFCCActionForm> { /* (non-Javadoc) * @see org.exoplatform.webui.event.EventListener#execute(org.exoplatform.webui.event.Event) */ public void execute(Event<UIFCCActionForm> event) throws Exception { UIFCCActionForm fastContentCreatorActionForm = event.getSource(); fastContentCreatorActionForm.isRemovePreference = true; String fieldName = event.getRequestContext().getRequestParameter(OBJECTID); fastContentCreatorActionForm.getUIStringInput(fieldName).setValue(null); event.getRequestContext() .addUIComponentToUpdateByAjax(fastContentCreatorActionForm.getParent()); } } /** * The listener interface for receiving showComponentAction events. * The class that is interested in processing a showComponentAction * event implements this interface, and the object created * with that class is registered with a component using the * component's <code>addShowComponentActionListener</code> method. When * the showComponentAction event occurs, that object's appropriate * method is invoked. */ @SuppressWarnings("unchecked") static public class ShowComponentActionListener extends EventListener<UIFCCActionForm> { /* (non-Javadoc) * @see org.exoplatform.webui.event.EventListener#execute(org.exoplatform.webui.event.Event) */ public void execute(Event<UIFCCActionForm> event) throws Exception { UIFCCActionForm fastContentCreatorActionForm = event.getSource() ; UIContainer uiContainer = fastContentCreatorActionForm.getParent() ; fastContentCreatorActionForm.isShowingComponent = true; String fieldName = event.getRequestContext().getRequestParameter(OBJECTID) ; Map fieldPropertiesMap = fastContentCreatorActionForm.componentSelectors.get(fieldName) ; String classPath = (String)fieldPropertiesMap.get("selectorClass") ; String rootPath = (String)fieldPropertiesMap.get("rootPath") ; ClassLoader cl = Thread.currentThread().getContextClassLoader() ; Class clazz = Class.forName(classPath, true, cl) ; UIComponent uiComp = uiContainer.createUIComponent(clazz, null, null); String repositoryName = fastContentCreatorActionForm.getRepositoryName(); String selectorParams = (String) fieldPropertiesMap.get("selectorParams"); if (uiComp instanceof UIOneNodePathSelector) { String wsFieldName = (String) fieldPropertiesMap.get("workspaceField"); String wsName = ""; if (wsFieldName != null && wsFieldName.length() > 0) { wsName = (String) fastContentCreatorActionForm.<UIFormInputBase> getUIInput(wsFieldName) .getValue(); ((UIOneNodePathSelector) uiComp).setIsDisable(wsName, true); } if(selectorParams != null) { String[] arrParams = selectorParams.split(",") ; if(arrParams.length == 4) { ((UIOneNodePathSelector)uiComp).setAcceptedNodeTypesInPathPanel(new String[] {"nt:file"}) ; wsName = arrParams[1]; rootPath = arrParams[2]; ((UIOneNodePathSelector)uiComp).setIsDisable(wsName, true) ; if(arrParams[3].indexOf(";") > -1) { ((UIOneNodePathSelector)uiComp).setAcceptedMimeTypes(arrParams[3].split(";")) ; } else { ((UIOneNodePathSelector)uiComp).setAcceptedMimeTypes(new String[] {arrParams[3]}) ; } } } if (rootPath == null) rootPath = "/"; ((UIOneNodePathSelector) uiComp).setRootNodeLocation(UIFCCUtils.getPreferenceRepository(), wsName, rootPath); ((UIOneNodePathSelector) uiComp).setShowRootPathSelect(true); ((UIOneNodePathSelector) uiComp).init(WCMCoreUtils.getUserSessionProvider()); } else if (uiComp instanceof UINodeTypeSelector) { ((UINodeTypeSelector)uiComp).setRepositoryName(repositoryName); UIFormMultiValueInputSet uiFormMultiValueInputSet = fastContentCreatorActionForm.getChildById(fieldName); List values = uiFormMultiValueInputSet.getValue(); ((UINodeTypeSelector)uiComp).init(1, values); } Utils.createPopupWindow(fastContentCreatorActionForm, uiComp, UIFCCConstant.SELECTOR_POPUP_WINDOW, 640); String param = "returnField=" + fieldName ; String[] params = selectorParams == null ? new String[] { param } : new String[] { param, "selectorParams=" + selectorParams }; ((ComponentSelector)uiComp).setSourceComponent(fastContentCreatorActionForm, params); if(fastContentCreatorActionForm.isAddNew){ uiContainer.setRendered(true); } event.getRequestContext().addUIComponentToUpdateByAjax(uiContainer) ; } } }
21,818
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIFCCActionList.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-fcc/src/main/java/org/exoplatform/wcm/webui/fastcontentcreator/config/action/UIFCCActionList.java
/* * Copyright (C) 2003-2009 eXo Platform SAS. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. */ package org.exoplatform.wcm.webui.fastcontentcreator.config.action; import org.exoplatform.commons.utils.LazyPageList; import org.exoplatform.commons.utils.ListAccess; import org.exoplatform.commons.utils.ListAccessImpl; import org.exoplatform.services.cms.actions.ActionServiceContainer; import org.exoplatform.services.wcm.core.NodeLocation; import org.exoplatform.wcm.webui.Utils; import org.exoplatform.wcm.webui.fastcontentcreator.UIFCCPortlet; import org.exoplatform.wcm.webui.fastcontentcreator.UIFCCConstant; import org.exoplatform.wcm.webui.fastcontentcreator.UIFCCUtils; import org.exoplatform.wcm.webui.fastcontentcreator.config.UIFCCConfig; import org.exoplatform.web.application.ApplicationMessage; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.config.annotation.EventConfig; import org.exoplatform.webui.core.UIApplication; import org.exoplatform.webui.core.UIContainer; import org.exoplatform.webui.core.UIGrid; import org.exoplatform.webui.core.UIPageIterator; import org.exoplatform.webui.core.UIPopupContainer; import org.exoplatform.webui.core.UIPopupWindow; import org.exoplatform.webui.core.lifecycle.Lifecycle; import org.exoplatform.webui.event.Event; import org.exoplatform.webui.event.EventListener; import javax.jcr.AccessDeniedException; import javax.jcr.Node; import java.util.ArrayList; import java.util.List; /** * Created by The eXo Platform SAS * Author : eXoPlatform * chuong.phan@exoplatform.com, phan.le.thanh.chuong@gmail.com * Jun 25, 2009 */ @ComponentConfig( lifecycle = Lifecycle.class, template = "system:/groovy/FastContentCreatorPortlet/UIFCCActionList.gtmpl", events = { @EventConfig(listeners = UIFCCActionList.AddActionListener.class), @EventConfig(listeners = UIFCCActionList.EditActionListener.class), @EventConfig(listeners = UIFCCActionList.DeleteActionListener.class, confirm = "UIFCCActionList.msg.confirm-delete-action") } ) public class UIFCCActionList extends UIContainer { /** The Constant HEADERS. */ private static final String[] HEADERS = {"name", "description", "instanceOf"}; /** The Constant ACTIONS. */ private String[] ACTIONS = {"Edit", "Delete"}; private String mode = null; /** * Instantiates a new uIFCC action list. * * @throws Exception the exception */ public UIFCCActionList() throws Exception { } public void init(String mode) throws Exception { this.mode = mode; UIGrid grid = addChild(UIGrid.class, null, null); if ("basic".equals(mode)) { ACTIONS = new String[]{"Edit"}; } grid.configure(UIFCCConstant.ACTION_GRID, HEADERS , ACTIONS ); } /** * Update grid. * * @param node the node * @param currentPage the current page * * @throws Exception the exception */ @SuppressWarnings("unchecked") public void updateGrid(Node node, int currentPage) throws Exception { UIPageIterator uiIterator = getChild(UIGrid.class).getUIPageIterator(); ListAccess<Object> actionNodeList = new ListAccessImpl<Object>(Object.class, NodeLocation.getLocationsByNodeList(getAllActions(node))); LazyPageList<Object> dataPageList = new LazyPageList<Object>(actionNodeList, 10); uiIterator.setPageList(dataPageList); if (currentPage > uiIterator.getAvailablePage()) uiIterator.setCurrentPage(uiIterator.getAvailablePage()); else uiIterator.setCurrentPage(currentPage); } /** * Gets the actions. * * @return the actions */ public String[] getActions() { return ACTIONS ; } /** * Checks for actions. * * @return true, if successful */ public boolean hasActions() { UIFCCConfig fastContentCreatorConfig = getAncestorOfType(UIFCCConfig.class) ; ActionServiceContainer actionService = getApplicationComponent(ActionServiceContainer.class) ; try { return actionService.hasActions(fastContentCreatorConfig.getSavedLocationNode()); } catch (Exception e) { return false; } } /** * Gets the all actions. * * @param node the node * * @return the all actions */ public List<Node> getAllActions(Node node) { ActionServiceContainer actionService = getApplicationComponent(ActionServiceContainer.class) ; try { return actionService.getActions(node); } catch(Exception e){ return new ArrayList<Node>() ; } } /** * Gets the list actions. * * @return the list actions * * @throws Exception the exception */ @SuppressWarnings("unchecked") public List getListActions() throws Exception { UIPageIterator uiIterator = getChild(UIGrid.class).getUIPageIterator(); return NodeLocation.getNodeListByLocationList(uiIterator.getCurrentPageData()); } public String getMode() { return mode; } /** * The listener interface for receiving addAction events. * The class that is interested in processing a addAction * event implements this interface, and the object created * with that class is registered with a component using the * component's <code>addAddActionListener</code> method. When * the addAction event occurs, that object's appropriate * method is invoked. */ public static class AddActionListener extends EventListener<UIFCCActionList> { /* (non-Javadoc) * @see org.exoplatform.webui.event.EventListener#execute(org.exoplatform.webui.event.Event) */ public void execute(Event<UIFCCActionList> event) throws Exception { UIFCCActionList fastContentCreatorActionList = event.getSource(); UIFCCActionContainer fastContentCreatorActionContainer = fastContentCreatorActionList. createUIComponent(UIFCCActionContainer.class, null, null); Utils.createPopupWindow(fastContentCreatorActionList, fastContentCreatorActionContainer, UIFCCConstant.ACTION_POPUP_WINDOW, 550); fastContentCreatorActionContainer.getChild(UIFCCActionTypeForm.class).update(); } } /** * The listener interface for receiving editAction events. * The class that is interested in processing a editAction * event implements this interface, and the object created * with that class is registered with a component using the * component's <code>addEditActionListener</code> method. When * the editAction event occurs, that object's appropriate * method is invoked. */ public static class EditActionListener extends EventListener<UIFCCActionList> { /* (non-Javadoc) * @see org.exoplatform.webui.event.EventListener#execute(org.exoplatform.webui.event.Event) */ public void execute(Event<UIFCCActionList> event) throws Exception { UIFCCActionList fastContentCreatorActionList = event.getSource(); String actionName = event.getRequestContext().getRequestParameter(OBJECTID); UIFCCActionContainer fccActionContainer = fastContentCreatorActionList.createUIComponent(UIFCCActionContainer.class, null, null); Utils.createPopupWindow(fastContentCreatorActionList, fccActionContainer, UIFCCConstant.ACTION_POPUP_WINDOW, 550); UIFCCActionTypeForm fccActionTypeForm = fccActionContainer.getChild(UIFCCActionTypeForm.class); ActionServiceContainer actionService = fastContentCreatorActionList.getApplicationComponent(ActionServiceContainer.class); UIFCCConfig fastContentCreatorConfig = fastContentCreatorActionList.getAncestorOfType(UIFCCConfig.class) ; Node parentNode = fastContentCreatorConfig.getSavedLocationNode(); Node actionNode= actionService.getAction(parentNode, actionName); fccActionTypeForm.init(actionNode.getPath(), actionNode.getPrimaryNodeType().getName()); fccActionTypeForm.update(); } } /** * The listener interface for receiving deleteAction events. * The class that is interested in processing a deleteAction * event implements this interface, and the object created * with that class is registered with a component using the * component's <code>addDeleteActionListener</code> method. When * the deleteAction event occurs, that object's appropriate * method is invoked. */ public static class DeleteActionListener extends EventListener<UIFCCActionList> { /* (non-Javadoc) * @see org.exoplatform.webui.event.EventListener#execute(org.exoplatform.webui.event.Event) */ public void execute(Event<UIFCCActionList> event) throws Exception { UIFCCActionList fastContentCreatorActionList = event.getSource() ; UIFCCConfig fastContentCreatorConfig = fastContentCreatorActionList.getAncestorOfType(UIFCCConfig.class) ; ActionServiceContainer actionService = fastContentCreatorActionList.getApplicationComponent(ActionServiceContainer.class) ; String actionName = event.getRequestContext().getRequestParameter(OBJECTID) ; UIPopupContainer popupContainer = fastContentCreatorActionList.getAncestorOfType(UIFCCPortlet.class) .getChild(UIPopupContainer.class); UIPopupWindow uiPopup = popupContainer.getChildById(UIFCCConstant.ACTION_POPUP_WINDOW) ; UIApplication uiApp = fastContentCreatorActionList.getAncestorOfType(UIApplication.class) ; if(uiPopup != null && uiPopup.isShow()) { uiPopup.setShowMask(true); uiApp.addMessage(new ApplicationMessage("UIActionList.msg.remove-popup-first", null, ApplicationMessage.WARNING)); return ; } if (uiPopup != null && uiPopup.isRendered()) popupContainer.removeChildById(UIFCCConstant.ACTION_POPUP_WINDOW); try { actionService.removeAction(fastContentCreatorConfig.getSavedLocationNode(), actionName, UIFCCUtils.getPreferenceRepository()); } catch(AccessDeniedException ace) { uiApp.addMessage(new ApplicationMessage("UIActionList.msg.access-denied", null, ApplicationMessage.WARNING)); return ; } fastContentCreatorActionList.updateGrid(fastContentCreatorConfig.getSavedLocationNode(), fastContentCreatorActionList.getChild(UIGrid.class) .getUIPageIterator() .getCurrentPage()); event.getRequestContext().addUIComponentToUpdateByAjax(fastContentCreatorConfig) ; } } }
11,854
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
OpenCloudFileManagerComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-clouddrives/src/main/java/org/exoplatform/services/cms/clouddrives/webui/OpenCloudFileManagerComponent.java
/* * Copyright (C) 2003-2016 eXo Platform SAS. * * This 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 software 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 software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.exoplatform.services.cms.clouddrives.webui; import java.util.Arrays; import java.util.List; import org.exoplatform.ecm.webui.clouddrives.CloudDriveContext; import org.exoplatform.ecm.webui.filters.CloudFileFilter; import org.exoplatform.services.log.ExoLogger; import org.exoplatform.services.log.Log; import org.exoplatform.web.application.Parameter; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.core.lifecycle.UIContainerLifecycle; import org.exoplatform.webui.ext.filter.UIExtensionFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilters; import org.exoplatform.webui.ext.manager.UIAbstractManager; import org.exoplatform.webui.ext.manager.UIAbstractManagerComponent; /** * Created by The eXo Platform SAS. * * @author <a href="mailto:pnedonosko@exoplatform.com">Peter Nedonosko</a> * @version $Id: OpenCloudFileManagerComponent.java 00000 Sep 26, 2012 * pnedonosko $ */ @ComponentConfig(lifecycle = UIContainerLifecycle.class) public class OpenCloudFileManagerComponent extends UIAbstractManagerComponent { /** The Constant LOG. */ protected static final Log LOG = ExoLogger.getLogger(OpenCloudFileManagerComponent.class); /** The Constant EVENT_NAME. */ public static final String EVENT_NAME = "OpenCloudFile"; /** The Constant FILTERS. */ protected static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[] { new CloudFileFilter() }); /** * Gets the filters. * * @return the filters */ @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } /** * {@inheritDoc} */ @Override public String renderEventURL(boolean ajax, String name, String beanId, Parameter[] params) throws Exception { if (EVENT_NAME.equals(name)) { CloudDriveContext.init(this); return "javascript:void(0);//objectId"; } return super.renderEventURL(ajax, name, beanId, params); } @Override public Class<? extends UIAbstractManager> getUIAbstractManagerClass() { return null; } }
2,964
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
ConnectCloudDriveForm.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-clouddrives/src/main/java/org/exoplatform/services/cms/clouddrives/webui/ConnectCloudDriveForm.java
/* * Copyright (C) 2003-2016 eXo Platform SAS. * * This 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 software 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 software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.exoplatform.services.cms.clouddrives.webui; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.config.annotation.EventConfig; import org.exoplatform.webui.core.lifecycle.UIFormLifecycle; import org.exoplatform.webui.event.Event; import org.exoplatform.webui.event.Event.Phase; import org.exoplatform.webui.event.EventListener; /** * The Class ConnectCloudDriveForm. */ @ComponentConfig(lifecycle = UIFormLifecycle.class, template = "classpath:groovy/templates/CloudDriveConnectDialog.gtmpl", events = { @EventConfig(listeners = ConnectCloudDriveForm.ConnectActionListener.class), @EventConfig(listeners = ConnectCloudDriveForm.CancelActionListener.class, phase = Phase.DECODE) }) public class ConnectCloudDriveForm extends BaseCloudDriveForm { /** * The listener interface for receiving cancelAction events. The class that is * interested in processing a cancelAction event implements this interface, * and the object created with that class is registered with a component using * the component's <code>addCancelActionListener</code> method. When the * cancelAction event occurs, that object's appropriate method is invoked. */ public static class CancelActionListener extends EventListener<ConnectCloudDriveForm> { /** * {@inheritDoc} */ public void execute(Event<ConnectCloudDriveForm> event) throws Exception { UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); uiExplorer.cancelAction(); } } /** * The listener interface for receiving connectAction events. The class that * is interested in processing a connectAction event implements this * interface, and the object created with that class is registered with a * component using the component's <code>addConnectActionListener</code> * method. When the connectAction event occurs, that object's appropriate * method is invoked. */ public static class ConnectActionListener extends EventListener<ConnectCloudDriveForm> { /** * {@inheritDoc} */ public void execute(Event<ConnectCloudDriveForm> event) throws Exception { UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); uiExplorer.updateAjax(event); } } }
3,212
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z