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
ViewPermissionsActionComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/action/ViewPermissionsActionComponent.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.component.explorer.control.action; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIActionBarActionListener; import org.exoplatform.ecm.webui.component.explorer.popup.info.UIPermissionManager; import org.exoplatform.ecm.webui.core.UIPermissionManagerBase; 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.UIPopupContainer; import org.exoplatform.webui.event.Event; /** * Created by The eXo Platform SAS * Author : eXoPlatform * nicolas.filotto@exoplatform.com * 6 mai 2009 */ @ComponentConfig( events = { @EventConfig(listeners = ViewPermissionsActionComponent.ViewPermissionsActionListener.class) } ) public class ViewPermissionsActionComponent extends UIComponent { public static class ViewPermissionsActionListener extends UIActionBarActionListener<ViewPermissionsActionComponent> { public void processEvent(Event<ViewPermissionsActionComponent> event) throws Exception { UIJCRExplorer uiJCRExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); UIPopupContainer UIPopupContainer = uiJCRExplorer.getChild(UIPopupContainer.class); UIPermissionManagerBase uiPerMan = UIPopupContainer.activate(UIPermissionManager.class, 700); uiPerMan.checkPermissonInfo(uiJCRExplorer.getCurrentNode()); event.getRequestContext().addUIComponentToUpdateByAjax(UIPopupContainer); } } }
2,395
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
ManageHiddenActionComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/action/ManageHiddenActionComponent.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.component.explorer.control.action; import java.util.Arrays; import java.util.List; import javax.jcr.Node; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.control.UIActionBar; import org.exoplatform.ecm.webui.component.explorer.control.filter.CanSetPropertyFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsCheckedOutFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotLockedFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotRootNodeFilter; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIActionBarActionRealNodeListener; import org.exoplatform.ecm.webui.utils.Utils; 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.UIComponent; import org.exoplatform.webui.event.Event; import org.exoplatform.webui.ext.filter.UIExtensionFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilters; /** * Created by The eXo Platform SAS * Author : eXoPlatform * nicolas.filotto@exoplatform.com * 6 mai 2009 */ @ComponentConfig( events = { @EventConfig(listeners = ManageHiddenActionComponent.ManageHiddenActionListener.class) } ) public class ManageHiddenActionComponent extends UIComponent { private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[]{new IsNotRootNodeFilter(), new CanSetPropertyFilter(), new IsNotLockedFilter(), new IsCheckedOutFilter()}); @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } public static class ManageHiddenActionListener extends UIActionBarActionRealNodeListener<ManageHiddenActionComponent> { public void processEvent(Event<ManageHiddenActionComponent> event) throws Exception { UIActionBar uiActionBar = event.getSource().getAncestorOfType(UIActionBar.class); UIJCRExplorer uiExplorer = uiActionBar.getAncestorOfType(UIJCRExplorer.class); Node selectedNode = uiExplorer.getRealCurrentNode(); UIApplication uiApp = uiActionBar.getAncestorOfType(UIApplication.class); if(selectedNode.isNodeType(Utils.EXO_HIDDENABLE)) { selectedNode.removeMixin(Utils.EXO_HIDDENABLE); selectedNode.save(); uiApp.addMessage(new ApplicationMessage("UIActionBar.msg.removed-hidden-mixin", null)); uiExplorer.updateAjax(event); } else if(selectedNode.canAddMixin(Utils.EXO_HIDDENABLE)){ selectedNode.addMixin(Utils.EXO_HIDDENABLE); selectedNode.save(); uiApp.addMessage(new ApplicationMessage("UIActionBar.msg.added-hidden-mixin", null)); uiExplorer.updateAjax(event); } } } }
3,763
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
ShowJCRStructureActionComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/action/ShowJCRStructureActionComponent.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.component.explorer.control.action; import java.util.Arrays; import java.util.List; import org.exoplatform.ecm.jcr.model.Preference; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotEditingDocumentFilter; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIActionBarActionListener; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.config.annotation.EventConfig; import org.exoplatform.webui.core.UIComponent; import org.exoplatform.webui.event.Event; import org.exoplatform.webui.ext.filter.UIExtensionFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilters; /** * Created by The eXo Platform SAS * Author : eXoPlatform * nicolas.filotto@exoplatform.com * 6 mai 2009 */ @ComponentConfig( events = { @EventConfig(listeners = ShowJCRStructureActionComponent.ShowJCRStructureActionListener.class) } ) public class ShowJCRStructureActionComponent extends UIComponent { private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[]{new IsNotEditingDocumentFilter()}); @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } public static class ShowJCRStructureActionListener extends UIActionBarActionListener<ShowJCRStructureActionComponent> { public void processEvent(Event<ShowJCRStructureActionComponent> event) throws Exception { UIJCRExplorer uiJCRExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); Preference pref = uiJCRExplorer.getPreference(); if(uiJCRExplorer.getPreference().isJcrEnable()) pref.setJcrEnable(false); else pref.setJcrEnable(true); uiJCRExplorer.refreshExplorer(); } } }
2,625
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
AddFolderActionComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/action/AddFolderActionComponent.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.component.explorer.control.action; import java.util.Arrays; import java.util.List; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.control.filter.CanAddNodeFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.HasAllowedFolderTypeFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsCheckedOutFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotCategoryFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotEditingDocumentFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotInTrashFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotLockedFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotNtFileFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotTrashHomeNodeFilter; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIActionBarActionListener; import org.exoplatform.ecm.webui.component.explorer.popup.actions.UIFolderForm; 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.UIPopupContainer; import org.exoplatform.webui.event.Event; 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 : eXoPlatform * nicolas.filotto@exoplatform.com * 5 mai 2009 */ @ComponentConfig( events = { @EventConfig(listeners = AddFolderActionComponent.AddFolderActionListener.class) } ) public class AddFolderActionComponent extends UIAbstractManagerComponent { private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[]{new IsNotNtFileFilter(), new CanAddNodeFilter(), new IsNotCategoryFilter(), new IsNotLockedFilter(), new IsCheckedOutFilter(), new IsNotTrashHomeNodeFilter(), new IsNotInTrashFilter(), new IsNotEditingDocumentFilter(), new HasAllowedFolderTypeFilter()}); @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } public static void addFolder(Event<? extends UIComponent> event, UIJCRExplorer uiExplorer) throws Exception { UIPopupContainer UIPopupContainer = uiExplorer.getChild(UIPopupContainer.class); UIFolderForm folderForm = uiExplorer.createUIComponent(UIFolderForm.class, null, null); UIPopupContainer.activate(folderForm, 420, 220, false); event.getRequestContext().addUIComponentToUpdateByAjax(UIPopupContainer); } public static class AddFolderActionListener extends UIActionBarActionListener<AddFolderActionComponent> { public void processEvent(Event<AddFolderActionComponent> event) throws Exception { UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); addFolder(event, uiExplorer); } } @Override public Class<? extends UIAbstractManager> getUIAbstractManagerClass() { return null; } }
4,486
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
AddCategoryActionComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/action/AddCategoryActionComponent.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.component.explorer.control.action; import java.util.Arrays; import java.util.List; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.control.filter.CanAddCategoryFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.CanAddNodeFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsCheckedOutFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotEditingDocumentFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotLockedFilter; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIActionBarActionListener; import org.exoplatform.ecm.webui.component.explorer.popup.actions.UICategoryForm; 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.UIPopupContainer; import org.exoplatform.webui.event.Event; import org.exoplatform.webui.ext.filter.UIExtensionFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilters; /** * Created by The eXo Platform SARL * Author : Hoang Van Hung * hunghvit@gmail.com * Nov 18, 2009 */ @ComponentConfig( events = { @EventConfig(listeners = AddCategoryActionComponent.AddCategoryActionListener.class) } ) public class AddCategoryActionComponent extends UIComponent { private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[] { new CanAddNodeFilter(), new IsNotLockedFilter(), new IsCheckedOutFilter(), new CanAddCategoryFilter(), new IsNotEditingDocumentFilter() }); @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } public static void addFolder(Event<? extends UIComponent> event, UIJCRExplorer uiExplorer) throws Exception { UIPopupContainer UIPopupContainer = uiExplorer.getChild(UIPopupContainer.class); UIPopupContainer.activate(UICategoryForm.class, 600); event.getRequestContext().addUIComponentToUpdateByAjax(UIPopupContainer); } public static class AddCategoryActionListener extends UIActionBarActionListener<AddCategoryActionComponent> { @Override protected void processEvent(Event<AddCategoryActionComponent> event) throws Exception { UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); addFolder(event, uiExplorer); } } }
3,479
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
ViewRelationsActionComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/action/ViewRelationsActionComponent.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.component.explorer.control.action; import java.util.Arrays; import java.util.List; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.UIWorkingArea; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotRootNodeFilter; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIActionBarActionListener; import org.exoplatform.ecm.webui.component.explorer.sidebar.UISideBar; import org.exoplatform.ecm.webui.component.explorer.sidebar.UITreeExplorer; import org.exoplatform.ecm.webui.component.explorer.sidebar.UIViewRelationList; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.config.annotation.EventConfig; import org.exoplatform.webui.core.UIComponent; import org.exoplatform.webui.event.Event; import org.exoplatform.webui.ext.filter.UIExtensionFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilters; /** * Created by The eXo Platform SAS * Author : eXoPlatform * nicolas.filotto@exoplatform.com * 6 mai 2009 */ @ComponentConfig( events = { @EventConfig(listeners = ViewRelationsActionComponent.ViewRelationsActionListener.class) } ) public class ViewRelationsActionComponent extends UIComponent { private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[]{new IsNotRootNodeFilter()}); @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } public static class ViewRelationsActionListener extends UIActionBarActionListener<ViewRelationsActionComponent> { public void processEvent(Event<ViewRelationsActionComponent> event) throws Exception { UIJCRExplorer uiJCRExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); UIWorkingArea uiWorkingArea = uiJCRExplorer.getChild(UIWorkingArea.class); UISideBar uiSideBar = uiWorkingArea.getChild(UISideBar.class); if(uiJCRExplorer.getPreference().isShowSideBar()) { if(uiSideBar.getCurrentComp().equals(uiSideBar.getChild(UIViewRelationList.class).getId())) { UITreeExplorer treeExplorer = uiSideBar.getChild(UITreeExplorer.class); treeExplorer.buildTree(); uiSideBar.setRenderedChild(UITreeExplorer.class); uiSideBar.setCurrentComp(uiSideBar.getChild(UITreeExplorer.class).getId()); event.getRequestContext().addUIComponentToUpdateByAjax(uiSideBar.getParent()); } else { uiSideBar.setCurrentComp(uiSideBar.getChild(UIViewRelationList.class).getId()); event.getRequestContext().addUIComponentToUpdateByAjax(uiSideBar.getParent()); } } else { uiJCRExplorer.getPreference().setShowSideBar(true); uiSideBar.setRenderedChild(UIViewRelationList.class); } event.getRequestContext().addUIComponentToUpdateByAjax(uiWorkingArea); } } }
3,736
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
ImportNodeActionComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/action/ImportNodeActionComponent.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.component.explorer.control.action; import java.util.Arrays; import java.util.List; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.control.filter.CanAddNodeFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsCheckedOutFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotEditingDocumentFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotLockedFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotNtFileFilter; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIActionBarActionListener; import org.exoplatform.ecm.webui.component.explorer.popup.admin.UIImportNode; 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.UIPopupContainer; import org.exoplatform.webui.event.Event; import org.exoplatform.webui.ext.filter.UIExtensionFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilters; /** * Created by The eXo Platform SAS * Author : eXoPlatform * nicolas.filotto@exoplatform.com * 6 mai 2009 */ @ComponentConfig( events = { @EventConfig(listeners = ImportNodeActionComponent.ImportNodeActionListener.class) } ) public class ImportNodeActionComponent extends UIComponent { private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[] {new IsNotNtFileFilter(), new CanAddNodeFilter(), new IsNotLockedFilter(), new IsCheckedOutFilter(), new IsNotEditingDocumentFilter() }); @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } public static class ImportNodeActionListener extends UIActionBarActionListener<ImportNodeActionComponent> { public void processEvent(Event<ImportNodeActionComponent> event) throws Exception { UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); UIPopupContainer UIPopupContainer = uiExplorer.getChild(UIPopupContainer.class); UIPopupContainer.activate(UIImportNode.class, 610); event.getRequestContext().addUIComponentToUpdateByAjax(UIPopupContainer); } } }
3,360
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
ManageVersionsActionComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/action/ManageVersionsActionComponent.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.component.explorer.control.action; import org.exoplatform.ecm.webui.component.explorer.UIDocumentWorkspace; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.UIWorkingArea; import org.exoplatform.ecm.webui.component.explorer.control.filter.*; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIActionBarActionListener; import org.exoplatform.ecm.webui.component.explorer.versions.UIActivateVersion; import org.exoplatform.ecm.webui.component.explorer.versions.UIVersionInfo; import org.exoplatform.ecm.webui.utils.Utils; 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.UIPopupContainer; import org.exoplatform.webui.event.Event; import org.exoplatform.webui.ext.filter.UIExtensionFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilters; import javax.jcr.Node; import java.util.Arrays; import java.util.List; /** * Created by The eXo Platform SAS * Author : eXoPlatform * nicolas.filotto@exoplatform.com * 6 mai 2009 */ @ComponentConfig( events = { @EventConfig(listeners = ManageVersionsActionComponent.ManageVersionsActionListener.class) } ) public class ManageVersionsActionComponent extends UIComponent { private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[] { new IsNotRootNodeFilter("UIActionBar.msg.cannot-enable-version-rootnode"), new CanSetPropertyFilter(), new IsNotLockedFilter(), new CanEnableVersionFilter(), new IsNotEditingDocumentFilter(), new IsNotFolderFilter(), new IsNotIgnoreVersionNodeFilter() } ); @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } public static class ManageVersionsActionListener extends UIActionBarActionListener<ManageVersionsActionComponent> { public void processEvent(Event<ManageVersionsActionComponent> event) throws Exception { UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); UIPopupContainer UIPopupContainer = uiExplorer.getChild(UIPopupContainer.class); Node currentNode = uiExplorer.getCurrentNode(); uiExplorer.setIsHidePopup(false); if (currentNode.canAddMixin(Utils.MIX_VERSIONABLE)) { UIPopupContainer.activate(UIActivateVersion.class, 400); event.getRequestContext().addUIComponentToUpdateByAjax(UIPopupContainer); } else if (currentNode.isNodeType(Utils.MIX_VERSIONABLE)) { UIWorkingArea uiWorkingArea = uiExplorer.getChild(UIWorkingArea.class); UIDocumentWorkspace uiDocumentWorkspace = uiWorkingArea.getChild(UIDocumentWorkspace.class); UIVersionInfo uiVersionInfo = uiDocumentWorkspace.getChild(UIVersionInfo.class); uiVersionInfo.setCurrentNode(currentNode); uiVersionInfo.setRootOwner(currentNode.getProperty("exo:lastModifier").getString()); uiVersionInfo.activate(); uiDocumentWorkspace.setRenderedChild(UIVersionInfo.class); event.getRequestContext().addUIComponentToUpdateByAjax(uiDocumentWorkspace); } } } }
4,077
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
ViewReferencesActionComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/action/ViewReferencesActionComponent.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.component.explorer.control.action; import java.util.Arrays; import java.util.List; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotRootNodeFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsReferenceableNodeFilter; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIActionBarActionListener; import org.exoplatform.ecm.webui.component.explorer.popup.info.UIReferencesList; 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.UIPopupContainer; import org.exoplatform.webui.event.Event; import org.exoplatform.webui.ext.filter.UIExtensionFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilters; /** * Created by The eXo Platform SAS * Author : eXoPlatform * nicolas.filotto@exoplatform.com * 6 mai 2009 */ @ComponentConfig( events = { @EventConfig(listeners = ViewReferencesActionComponent.ViewReferencesActionListener.class) } ) public class ViewReferencesActionComponent extends UIComponent { private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[] { new IsReferenceableNodeFilter(), new IsNotRootNodeFilter() }); @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } public static class ViewReferencesActionListener extends UIActionBarActionListener<ViewReferencesActionComponent> { public void processEvent(Event<ViewReferencesActionComponent> event) throws Exception { UIJCRExplorer uiJCRExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); UIPopupContainer UIPopupContainer = uiJCRExplorer.getChild(UIPopupContainer.class); UIPopupContainer.activate(UIReferencesList.class, 600); event.getRequestContext().addUIComponentToUpdateByAjax(UIPopupContainer); } } }
2,843
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
ManageCategoriesActionComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/action/ManageCategoriesActionComponent.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.component.explorer.control.action; import java.util.Arrays; import java.util.List; import javax.jcr.Node; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.control.UIActionBar; import org.exoplatform.ecm.webui.component.explorer.control.filter.CanSetPropertyFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsCheckedOutFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsDocumentFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotLockedFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotRootNodeFilter; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIActionBarActionListener; import org.exoplatform.ecm.webui.component.explorer.popup.admin.UICategoriesAddedList; import org.exoplatform.ecm.webui.component.explorer.popup.admin.UICategoryManager; import org.exoplatform.ecm.webui.tree.selectone.UIOneTaxonomySelector; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.services.cms.taxonomy.TaxonomyService; 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.UIComponent; import org.exoplatform.webui.core.UIPopupContainer; import org.exoplatform.webui.event.Event; import org.exoplatform.webui.ext.filter.UIExtensionFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilters; /** * Created by The eXo Platform SAS * Author : eXoPlatform * nicolas.filotto@exoplatform.com * 6 mai 2009 */ @ComponentConfig( events = { @EventConfig(listeners = ManageCategoriesActionComponent.ManageCategoriesActionListener.class) } ) public class ManageCategoriesActionComponent extends UIComponent { private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[] { new IsNotRootNodeFilter(), new IsCheckedOutFilter(), new CanSetPropertyFilter(), new IsNotLockedFilter(), new IsDocumentFilter() }); @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } public static class ManageCategoriesActionListener extends UIActionBarActionListener<ManageCategoriesActionComponent> { public void processEvent(Event<ManageCategoriesActionComponent> event) throws Exception { UIActionBar uiActionBar = event.getSource().getAncestorOfType(UIActionBar.class); UIJCRExplorer uiExplorer = uiActionBar.getAncestorOfType(UIJCRExplorer.class); String repository = uiExplorer.getRepositoryName(); String workspaceName = null; uiExplorer.setIsHidePopup(true); UICategoryManager uiManager = uiExplorer.createUIComponent(UICategoryManager.class, null, null); UIOneTaxonomySelector uiOneTaxonomySelector = uiManager.getChild(UIOneTaxonomySelector.class); TaxonomyService taxonomyService = uiActionBar.getApplicationComponent(TaxonomyService.class); UIApplication uiApp = uiActionBar.getAncestorOfType(UIApplication.class); List<Node> lstNode = taxonomyService.getAllTaxonomyTrees(); if (lstNode != null && lstNode.size() > 0) { uiOneTaxonomySelector.setRootTaxonomyName(lstNode.get(0).getName()); workspaceName = lstNode.get(0).getSession().getWorkspace().getName(); uiOneTaxonomySelector.setRootNodeLocation(repository, workspaceName, lstNode.get(0).getPath()); uiOneTaxonomySelector.setIsDisable(workspaceName, false); uiOneTaxonomySelector.setExceptedNodeTypesInPathPanel(new String[] {Utils.EXO_SYMLINK}); uiOneTaxonomySelector.init(uiExplorer.getSessionProvider()); UICategoriesAddedList uiCateAddedList = uiManager.getChild(UICategoriesAddedList.class); uiOneTaxonomySelector.setSourceComponent(uiCateAddedList, null); UIPopupContainer UIPopupContainer = uiExplorer.getChild(UIPopupContainer.class); UIPopupContainer.activate(uiManager, 650, 500); event.getRequestContext().addUIComponentToUpdateByAjax(UIPopupContainer); } else { uiApp.addMessage(new ApplicationMessage("UIActionBar.msg.not-exist-categories", null)); uiExplorer.updateAjax(event); } } } }
5,227
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
ExportNodeActionComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/action/ExportNodeActionComponent.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.component.explorer.control.action; import java.util.Arrays; import java.util.List; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotEditingDocumentFilter; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIActionBarActionListener; import org.exoplatform.ecm.webui.component.explorer.popup.admin.UIExportNode; 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.UIPopupContainer; import org.exoplatform.webui.event.Event; import org.exoplatform.webui.ext.filter.UIExtensionFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilters; /** * Created by The eXo Platform SAS Author : eXoPlatform * nicolas.filotto@exoplatform.com 6 mai 2009 */ @ComponentConfig(events = { @EventConfig(listeners = ExportNodeActionComponent.ExportNodeActionListener.class) }) public class ExportNodeActionComponent extends UIComponent { private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[] { new IsNotEditingDocumentFilter() }); @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } public static class ExportNodeActionListener extends UIActionBarActionListener<ExportNodeActionComponent> { public void processEvent(Event<ExportNodeActionComponent> event) throws Exception { UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); UIPopupContainer UIPopupContainer = uiExplorer.getChild(UIPopupContainer.class); UIPopupContainer.activate(UIExportNode.class, 610); event.getRequestContext().addUIComponentToUpdateByAjax(UIPopupContainer); } } }
2,698
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
AddLocalizationLinkActionComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/action/AddLocalizationLinkActionComponent.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.component.explorer.control.action; import java.util.Arrays; import java.util.List; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.control.filter.CanAddNodeFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsCheckedOutFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotInTrashFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotLockedFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotSymlinkFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotTrashHomeNodeFilter; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIActionBarActionListener; import org.exoplatform.ecm.webui.component.explorer.symlink.UIAddTranslationManager; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.config.annotation.EventConfig; import org.exoplatform.webui.core.UIPopupContainer; import org.exoplatform.webui.event.Event; 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 : eXoPlatform * nicolas.filotto@exoplatform.com * 6 mai 2009 */ @ComponentConfig( events = { @EventConfig(listeners = AddLocalizationLinkActionComponent.AddLocalizationLinkActionListener.class) } ) public class AddLocalizationLinkActionComponent extends UIAbstractManagerComponent { private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[]{new CanAddNodeFilter(), new IsNotLockedFilter(), new IsCheckedOutFilter(), new IsNotSymlinkFilter(), new IsNotTrashHomeNodeFilter(), new IsNotInTrashFilter()}); @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } public static class AddLocalizationLinkActionListener extends UIActionBarActionListener<AddLocalizationLinkActionComponent> { public void processEvent(Event<AddLocalizationLinkActionComponent> event) throws Exception { UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); UIPopupContainer UIPopupContainer = uiExplorer.getChild(UIPopupContainer.class); UIAddTranslationManager uiAddTranslationManager = event.getSource().createUIComponent(UIAddTranslationManager.class, null, null); UIPopupContainer.activate(uiAddTranslationManager, 600, 155); event.getRequestContext().addUIComponentToUpdateByAjax(UIPopupContainer); } } @Override public Class<? extends UIAbstractManager> getUIAbstractManagerClass() { return null; } }
3,884
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
ManageAuditingActionComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/action/ManageAuditingActionComponent.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.component.explorer.control.action; import java.util.Arrays; import java.util.List; import javax.jcr.Node; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.auditing.UIActivateAuditing; import org.exoplatform.ecm.webui.component.explorer.auditing.UIAuditingInfo; import org.exoplatform.ecm.webui.component.explorer.control.filter.CanSetPropertyFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsCheckedOutFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotLockedFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotRootNodeFilter; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIActionBarActionListener; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.config.annotation.EventConfig; import org.exoplatform.webui.core.UIPopupContainer; import org.exoplatform.webui.event.Event; 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 : eXoPlatform * nicolas.filotto@exoplatform.com * 6 mai 2009 */ @ComponentConfig( events = { @EventConfig(listeners = ManageAuditingActionComponent.ManageAuditingActionListener.class) } ) public class ManageAuditingActionComponent extends UIAbstractManagerComponent { private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[]{new IsNotRootNodeFilter(), new CanSetPropertyFilter(), new IsNotLockedFilter(), new IsCheckedOutFilter()}); @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } public static class ManageAuditingActionListener extends UIActionBarActionListener<ManageAuditingActionComponent> { public void processEvent(Event<ManageAuditingActionComponent> event) throws Exception { UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); UIPopupContainer UIPopupContainer = uiExplorer.getChild(UIPopupContainer.class); Node currentNode = uiExplorer.getCurrentNode(); if (!currentNode.isNodeType(Utils.EXO_AUDITABLE)) { UIPopupContainer.activate(UIActivateAuditing.class, 400); event.getRequestContext().addUIComponentToUpdateByAjax(UIPopupContainer); return; } UIAuditingInfo uiAuditingInfo = uiExplorer.createUIComponent(UIAuditingInfo.class, null, null); UIPopupContainer.activate(uiAuditingInfo, 700, 500); uiAuditingInfo.updateGrid(); event.getRequestContext().addUIComponentToUpdateByAjax(UIPopupContainer); } } @Override public Class<? extends UIAbstractManager> getUIAbstractManagerClass() { return null; } }
3,838
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
TaggingDocumentActionComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/action/TaggingDocumentActionComponent.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.component.explorer.control.action; import java.util.Arrays; import java.util.List; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.control.filter.CanSetPropertyFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsCheckedOutFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsDocumentFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotLockedFilter; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIActionBarActionListener; import org.exoplatform.ecm.webui.component.explorer.popup.actions.UITaggingFormContainer; 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.UIPopupContainer; import org.exoplatform.webui.event.Event; import org.exoplatform.webui.ext.filter.UIExtensionFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilters; /** * Created by The eXo Platform SAS * Author : eXoPlatform * nicolas.filotto@exoplatform.com * 6 mai 2009 */ @ComponentConfig( events = { @EventConfig(listeners = TaggingDocumentActionComponent.TaggingDocumentActionListener.class) } ) public class TaggingDocumentActionComponent extends UIComponent { private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[] { new CanSetPropertyFilter(), new IsNotLockedFilter(), new IsDocumentFilter("UIActionBar.msg.unsupported-tagging"), new IsCheckedOutFilter("UIActionBar.msg.tagnode-checkedin") }); @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } public static class TaggingDocumentActionListener extends UIActionBarActionListener<TaggingDocumentActionComponent> { public void processEvent(Event<TaggingDocumentActionComponent> event) throws Exception { UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); UIPopupContainer UIPopupContainer = uiExplorer.getChild(UIPopupContainer.class); UIPopupContainer.activate(UITaggingFormContainer.class, 600); event.getRequestContext().addUIComponentToUpdateByAjax(UIPopupContainer); } } }
3,154
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
OverloadThumbnailActionComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/action/OverloadThumbnailActionComponent.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.component.explorer.control.action; import java.util.Arrays; import java.util.List; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsCheckedOutFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotEditingDocumentFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotRootNodeFilter; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIActionBarActionRealNodeListener; import org.exoplatform.ecm.webui.component.explorer.thumbnail.UIThumbnailForm; 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.UIPopupContainer; import org.exoplatform.webui.event.Event; import org.exoplatform.webui.ext.filter.UIExtensionFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilters; /** * Created by The eXo Platform SAS * Author : eXoPlatform * nicolas.filotto@exoplatform.com * 6 mai 2009 */ @ComponentConfig( events = { @EventConfig(listeners = OverloadThumbnailActionComponent.OverloadThumbnailActionListener.class) } ) public class OverloadThumbnailActionComponent extends UIComponent { private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[] { new IsNotRootNodeFilter(), new IsNotEditingDocumentFilter(), new IsCheckedOutFilter() }); @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } public static class OverloadThumbnailActionListener extends UIActionBarActionRealNodeListener<OverloadThumbnailActionComponent> { public void processEvent(Event<OverloadThumbnailActionComponent> event) throws Exception { UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); UIThumbnailForm uiThumbnailForm = uiExplorer.createUIComponent(UIThumbnailForm.class, null, null); UIPopupContainer UIPopupContainer = uiExplorer.getChild(UIPopupContainer.class); UIPopupContainer.activate(uiThumbnailForm, 500, 0); event.getRequestContext().addUIComponentToUpdateByAjax(UIPopupContainer); } } }
3,204
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
WatchDocumentActionComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/action/WatchDocumentActionComponent.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.component.explorer.control.action; import java.util.Arrays; import java.util.List; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.control.filter.CanSetPropertyFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsCheckedOutFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsDocumentFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotLockedFilter; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIActionBarActionListener; import org.exoplatform.ecm.webui.component.explorer.popup.actions.UIWatchDocumentForm; 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.UIPopupContainer; import org.exoplatform.webui.event.Event; import org.exoplatform.webui.ext.filter.UIExtensionFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilters; /** * Created by The eXo Platform SAS * Author : eXoPlatform * nicolas.filotto@exoplatform.com * 6 mai 2009 */ @ComponentConfig( events = { @EventConfig(listeners = WatchDocumentActionComponent.WatchDocumentActionListener.class) } ) public class WatchDocumentActionComponent extends UIComponent { private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[] { new IsNotLockedFilter(), new CanSetPropertyFilter(), new IsDocumentFilter("UIActionBar.msg.unsupported-watch"), new IsCheckedOutFilter("UIActionBar.msg.watch-checkedin") }); @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } public static class WatchDocumentActionListener extends UIActionBarActionListener<WatchDocumentActionComponent> { public void processEvent(Event<WatchDocumentActionComponent> event) throws Exception { UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); UIPopupContainer UIPopupContainer = uiExplorer.getChild(UIPopupContainer.class); UIWatchDocumentForm wathDocumentForm = UIPopupContainer.createUIComponent(UIWatchDocumentForm.class, null, null); UIPopupContainer.activate(wathDocumentForm, 420, 0, false); event.getRequestContext().addUIComponentToUpdateByAjax(UIPopupContainer); } } }
3,254
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
AddDocumentActionComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/action/AddDocumentActionComponent.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.component.explorer.control.action; import java.util.Arrays; import java.util.List; import org.exoplatform.ecm.webui.component.explorer.UIDocumentContainer; import org.exoplatform.ecm.webui.component.explorer.UIDocumentWorkspace; import org.exoplatform.ecm.webui.component.explorer.UIDrivesArea; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.UIWorkingArea; import org.exoplatform.ecm.webui.component.explorer.control.filter.CanAddNodeFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsCheckedOutFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotEditingDocumentFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotInTrashFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotLockedFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotNtFileFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotTrashHomeNodeFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotDocumentFilter; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIActionBarActionListener; import org.exoplatform.ecm.webui.component.explorer.popup.actions.UIDocumentForm; import org.exoplatform.ecm.webui.component.explorer.popup.actions.UIDocumentFormController; import org.exoplatform.ecm.webui.component.explorer.search.UISearchResult; 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.event.Event; 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 : eXoPlatform * nicolas.filotto@exoplatform.com * 6 mai 2009 */ @ComponentConfig( events = { @EventConfig(listeners = AddDocumentActionComponent.AddDocumentActionListener.class) } ) public class AddDocumentActionComponent extends UIAbstractManagerComponent { private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[]{new IsNotNtFileFilter(), new CanAddNodeFilter(), new IsNotDocumentFilter(), new IsNotLockedFilter(), new IsCheckedOutFilter(), new IsNotTrashHomeNodeFilter(), new IsNotInTrashFilter(), new IsNotEditingDocumentFilter()}); @UIExtensionFilters public static List<UIExtensionFilter> getFilters() { return FILTERS; } public static void addDocument(Event<? extends UIComponent> event, UIJCRExplorer uiExplorer, UIApplication uiApp, UIComponent uiComp, WebuiRequestContext context) throws Exception { if (event != null) context = event.getRequestContext(); UIDocumentFormController uiController = uiComp.createUIComponent(UIDocumentFormController.class, null, null); uiController.setCurrentNode(uiExplorer.getCurrentNode()); uiController.setRepository(uiExplorer.getRepositoryName()); if(uiController.getListFileType().isEmpty()) { uiApp.addMessage(new ApplicationMessage("UIActionBar.msg.empty-file-type", null, ApplicationMessage.WARNING)); return; } // uiExplorer.setPathBeforeEditing(uiExplorer.getCurrentPath()); uiController.init(); UIWorkingArea uiWorkingArea = uiExplorer.getChild(UIWorkingArea.class); UIDocumentWorkspace uiDocumentWorkspace = uiWorkingArea.getChild(UIDocumentWorkspace.class); if(!uiDocumentWorkspace.isRendered()) { uiWorkingArea.getChild(UIDrivesArea.class).setRendered(false); uiWorkingArea.getChild(UIDocumentWorkspace.class).setRendered(true); } uiDocumentWorkspace.getChild(UIDocumentContainer.class).setRendered(false); uiDocumentWorkspace.getChild(UISearchResult.class).setRendered(false); UIDocumentFormController controller = uiDocumentWorkspace.removeChild(UIDocumentFormController.class); if (controller != null) { controller.getChild(UIDocumentForm.class).releaseLock(); controller.getChild(UIDocumentForm.class).clearRemovedNode(); } uiDocumentWorkspace.addChild(uiController); uiController.bindContentType(); uiController.setRendered(true); context.addUIComponentToUpdateByAjax(uiWorkingArea); if (event != null) uiExplorer.updateAjax(event); } public static class AddDocumentActionListener extends UIActionBarActionListener<AddDocumentActionComponent> { public void processEvent(Event<AddDocumentActionComponent> event) throws Exception { UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); UIApplication uiApp = event.getSource().getAncestorOfType(UIApplication.class); addDocument(event, uiExplorer, uiApp, event.getSource(), null); } } @Override public Class<? extends UIAbstractManager> getUIAbstractManagerClass() { return null; } }
6,571
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIWorkingAreaActionListener.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/listener/UIWorkingAreaActionListener.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.component.explorer.control.listener; import java.util.HashMap; import java.util.Map; import java.util.regex.Matcher; import javax.jcr.Node; import javax.jcr.PathNotFoundException; import javax.jcr.Session; import javax.portlet.PortletPreferences; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.UIWorkingArea; import org.exoplatform.ecm.webui.utils.Utils; 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.application.portlet.PortletRequestContext; import org.exoplatform.webui.core.UIApplication; import org.exoplatform.webui.core.UIComponent; import org.exoplatform.webui.event.Event; import org.exoplatform.webui.exception.MessageException; import org.exoplatform.webui.ext.UIExtensionEventListener; import org.exoplatform.webui.ext.UIExtensionManager; /** * Created by The eXo Platform SARL * Author : Hoang Van Hung * hunghvit@gmail.com * Aug 5, 2009 */ public abstract class UIWorkingAreaActionListener <T extends UIComponent> extends UIExtensionEventListener<T> { private static final Log LOG = ExoLogger.getLogger(UIWorkingAreaActionListener.class.getName()); private Node getNodeByPath(String nodePath, UIJCRExplorer uiExplorer, boolean giveTarget) throws Exception { nodePath = uiExplorer.getCurrentWorkspace() + ":" + nodePath; Matcher matcher = UIWorkingArea.FILE_EXPLORER_URL_SYNTAX.matcher(nodePath); String wsName = null; if (matcher.find()) { wsName = matcher.group(1); nodePath = matcher.group(2); } else { wsName = uiExplorer.getCurrentWorkspace(); } Session session = uiExplorer.getSessionByWorkspace(wsName); return uiExplorer.getNodeByPath(nodePath, session, giveTarget); } private Node getNodeByPath(String nodePath, UIJCRExplorer uiExplorer) throws Exception { return getNodeByPath(nodePath, uiExplorer, true); } private boolean inTrash(String nodePath) { PortletRequestContext pcontext = (PortletRequestContext)WebuiRequestContext.getCurrentInstance(); PortletPreferences portletPref = pcontext.getRequest().getPreferences(); String trashHomeNodePath = portletPref.getValue(Utils.TRASH_HOME_NODE_PATH, ""); if (nodePath.startsWith(trashHomeNodePath)) return true; Matcher matcher = UIWorkingArea.FILE_EXPLORER_URL_SYNTAX.matcher(nodePath); if (matcher.find()) { return matcher.group(2).startsWith(trashHomeNodePath); } else { return false; } } public boolean acceptForMultiNode(Event<T> event, String path) { Map<String, Object> context = new HashMap<String, Object>(); UIWorkingArea uiWorkingArea = event.getSource().getAncestorOfType(UIWorkingArea.class); UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); WebuiRequestContext requestContext = event.getRequestContext(); UIApplication uiApp = requestContext.getUIApplication(); try { context.put(UIWorkingArea.class.getName(), uiWorkingArea); context.put(UIJCRExplorer.class.getName(), uiExplorer); context.put(UIApplication.class.getName(), uiApp); context.put(Node.class.getName(), getNodeByPath(path, uiExplorer)); context.put(WebuiRequestContext.class.getName(), requestContext); UIExtensionManager manager = event.getSource().getApplicationComponent(UIExtensionManager.class); return manager.accept(getExtensionType(), event.getName(), context); } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error("an unexpected error occurs while filter the node", e); } } return false; } @Override protected Map<String, Object> createContext(Event<T> event) throws Exception { Map<String, Object> context = new HashMap<String, Object>(); UIWorkingArea uiWorkingArea = event.getSource().getAncestorOfType(UIWorkingArea.class); UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); String nodePath = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID); if (nodePath == null || nodePath.length() == 0 || nodePath.contains(";")) return null; // Use the method getNodeByPath because it is link aware try { Node currentNode = getNodeByPath(nodePath, uiExplorer, !inTrash(nodePath) && !("Delete".equals(event.getName()) || "Cut".equals(event.getName()))); WebuiRequestContext requestContext = event.getRequestContext(); UIApplication uiApp = requestContext.getUIApplication(); context.put(UIWorkingArea.class.getName(), uiWorkingArea); context.put(UIJCRExplorer.class.getName(), uiExplorer); context.put(UIApplication.class.getName(), uiApp); context.put(Node.class.getName(), currentNode); context.put(WebuiRequestContext.class.getName(), requestContext); } catch(PathNotFoundException pte) { throw new MessageException(new ApplicationMessage("UIPopupMenu.msg.path-not-found", null, ApplicationMessage.WARNING)) ; } catch(Exception e) { if (LOG.isErrorEnabled()) { LOG.error("Unexpected problem occurs", e); } } return context; } @Override public void execute(Event<T> event) throws Exception { String nodePath = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID); if (nodePath == null || !nodePath.contains(";")) { super.execute(event); return; } processEvent(event); } @Override protected String getExtensionType() { return UIWorkingArea.EXTENSION_TYPE; } }
6,752
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIActionBarActionRealNodeListener.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/listener/UIActionBarActionRealNodeListener.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.component.explorer.control.listener; import java.util.Map; import javax.jcr.Node; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.webui.core.UIComponent; import org.exoplatform.webui.event.Event; /** * Created by The eXo Platform SAS * Author : eXoPlatform * nicolas.filotto@exoplatform.com * 6 mai 2009 */ public abstract class UIActionBarActionRealNodeListener<T extends UIComponent> extends UIActionBarActionListener<T> { /** * {@inheritDoc} */ protected Map<String, Object> createContext(Event<T> event) throws Exception { Map<String, Object> context = super.createContext(event); UIJCRExplorer uiExplorer = (UIJCRExplorer) context.get(UIJCRExplorer.class.getName()); Node currentNode = uiExplorer.getRealCurrentNode(); context.put(Node.class.getName(), currentNode); return context; } }
1,670
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UIActionBarActionListener.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/listener/UIActionBarActionListener.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.component.explorer.control.listener; import java.util.HashMap; import java.util.Map; import java.util.regex.Matcher; import javax.jcr.Node; import javax.jcr.PathNotFoundException; import javax.jcr.Session; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.UIWorkingArea; import org.exoplatform.ecm.webui.component.explorer.control.UIActionBar; import org.exoplatform.services.cms.views.ManageViewService; 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.core.UIApplication; import org.exoplatform.webui.core.UIComponent; import org.exoplatform.webui.event.Event; import org.exoplatform.webui.exception.MessageException; import org.exoplatform.webui.ext.UIExtensionEventListener; /** * Created by The eXo Platform SAS * Author : eXoPlatform * nicolas.filotto@exoplatform.com * 6 mai 2009 */ public abstract class UIActionBarActionListener<T extends UIComponent> extends UIExtensionEventListener<T> { private static final Log LOG = ExoLogger.getLogger(UIActionBarActionListener.class.getName()); /** * {@inheritDoc} */ @Override protected Map<String, Object> createContext(Event<T> event) throws Exception { Map<String, Object> context = new HashMap<String, Object>(); UIActionBar uiActionBar = event.getSource().getAncestorOfType(UIActionBar.class); UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); String nodePath = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID); try { Node currentNode; if (nodePath != null && nodePath.length() != 0 && !nodePath.contains(";")) { Matcher matcher = UIWorkingArea.FILE_EXPLORER_URL_SYNTAX.matcher(nodePath); String wsName = null; if (matcher.find()) { wsName = matcher.group(1); nodePath = matcher.group(2); } else { throw new IllegalArgumentException("The ObjectId is invalid '" + nodePath + "'"); } Session session = uiExplorer.getSessionByWorkspace(wsName); // Use the method getNodeByPath because it is link aware currentNode = uiExplorer.getNodeByPath(nodePath, session); } else { currentNode = uiExplorer.getCurrentNode(); } WebuiRequestContext requestContext = event.getRequestContext(); UIApplication uiApp = requestContext.getUIApplication(); context.put(UIActionBar.class.getName(), uiActionBar); context.put(UIJCRExplorer.class.getName(), uiExplorer); context.put(UIApplication.class.getName(), uiApp); context.put(Node.class.getName(), currentNode); context.put(WebuiRequestContext.class.getName(), requestContext); } catch(PathNotFoundException pne) { throw new MessageException(new ApplicationMessage("UIPopupMenu.msg.path-not-found", null, ApplicationMessage.WARNING)) ; } catch(Exception e) { if (LOG.isErrorEnabled()) { LOG.error("Unexpected problem occurs", e); } } return context; } /** * {@inheritDoc} */ @Override protected String getExtensionType() { return ManageViewService.EXTENSION_TYPE; } }
4,204
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsLockForSymlink.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsLockForSymlink.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.component.explorer.control.filter; import java.util.Map; import javax.jcr.Node; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * Created by The eXo Platform SAS * Author : Nguyen The Vinh From ECM Of eXoPlatform * vinh_nguyen@exoplatform.com * 7 Mar 2013 */ public class IsLockForSymlink extends UIExtensionAbstractFilter{ public IsLockForSymlink() { this(null); } public IsLockForSymlink(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } @Override public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node currentNode = (Node) context.get(Node.class.getName()); return (!currentNode.isLocked()) ; } @Override public void onDeny(Map<String, Object> context) throws Exception { if (context == null) return; Node currentNode = (Node) context.get(Node.class.getName()); Object[] arg = { currentNode.getPath() }; createUIPopupMessages(context, "UIPopupMenu.msg.node-locked", arg); } }
1,882
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsNotFolderFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsNotFolderFilter.java
package org.exoplatform.ecm.webui.component.explorer.control.filter; import java.util.Map; import javax.jcr.Node; import java.util.List; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.services.cms.templates.TemplateService; import org.exoplatform.services.wcm.utils.WCMCoreUtils; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * Created by The eXo Platform SARL * Author : Nguyen The Vinh * nguyenthevinhbk@gmail.com * Oct 07, 2011 * Filter if node is folder type but not document */ public class IsNotFolderFilter extends UIExtensionAbstractFilter{ @Override public UIExtensionFilterType getType() { return UIExtensionFilterType.MANDATORY; } public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node currentNode = (Node) context.get(Node.class.getName()); TemplateService templateService = WCMCoreUtils.getService(TemplateService.class); List<String> dmsDocumentListTmp = templateService.getAllDocumentNodeTypes(); if (currentNode.isNodeType(Utils.NT_UNSTRUCTURED) || currentNode.isNodeType(Utils.NT_FOLDER)) { for (String documentType : dmsDocumentListTmp) { if (currentNode.getPrimaryNodeType().isNodeType(documentType) ){ return true; } } return false; } return true; } public void onDeny(Map<String, Object> context) throws Exception { } }
1,517
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsFavouriteFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsFavouriteFilter.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.component.explorer.control.filter; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.services.cms.documents.FavoriteService; import org.exoplatform.services.wcm.utils.WCMCoreUtils; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; import javax.jcr.Node; import java.util.Map; /** * Created by The eXo Platform SARL * Author : Nguyen Anh Vu * anhvurz90@gmail.com * Oct 16, 2009 * 10:20:29 AM */ public class IsFavouriteFilter extends UIExtensionAbstractFilter { public IsFavouriteFilter() { this(null); } public IsFavouriteFilter(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } public static boolean isFavourite(Node node, UIJCRExplorer uiExplorer) throws Exception { FavoriteService favoriteService = WCMCoreUtils.getService(FavoriteService.class); return favoriteService.isFavoriter(WCMCoreUtils.getRemoteUser(), node); } public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node currentNode = (Node) context.get(Node.class.getName()); UIJCRExplorer uiExplorer = (UIJCRExplorer)context.get(UIJCRExplorer.class.getName()); return isFavourite(currentNode, uiExplorer); } public void onDeny(Map<String, Object> context) throws Exception { } }
2,161
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsNotSystemWorkspaceFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsNotSystemWorkspaceFilter.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.component.explorer.control.filter; import java.util.Map; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * Created by The eXo Platform SAS * Author : eXoPlatform * ha.dangviet@exoplatform.com * Nov 22, 2010 */ public class IsNotSystemWorkspaceFilter extends UIExtensionAbstractFilter { @Override public boolean accept(Map<String, Object> context) throws Exception { if (context == null) { return false; } UIJCRExplorer uiJCRExplorer = (UIJCRExplorer) context.get(UIJCRExplorer.class.getName()); return !uiJCRExplorer.isSystemWorkspace(); } @Override public void onDeny(Map<String, Object> context) throws Exception { } /** * This is the type of the filter */ public UIExtensionFilterType getType() { return UIExtensionFilterType.MANDATORY; } }
1,710
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
ShareDocumentFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/ShareDocumentFilter.java
/*************************************************************************** * Copyright (C) 2003-2021 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.component.explorer.control.filter; import org.exoplatform.commons.api.settings.SettingService; import org.exoplatform.commons.api.settings.SettingValue; import org.exoplatform.commons.api.settings.data.Context; import org.exoplatform.commons.api.settings.data.Scope; import org.exoplatform.commons.utils.CommonsUtils; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; import java.util.Map; public class ShareDocumentFilter extends UIExtensionAbstractFilter { public ShareDocumentFilter() { this("UIPopupMenu.msg.share-document"); } public ShareDocumentFilter(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; SettingService settingService = CommonsUtils.getService(SettingService.class); SettingValue<?> settingValue = settingService.get(Context.GLOBAL.id("sharedDocumentStatus"), Scope.APPLICATION.id("sharedDocumentStatus"), "exo:sharedDocumentStatus"); return !(settingValue != null && !settingValue.getValue().toString().isEmpty() ? Boolean.valueOf(settingValue.getValue().toString()) : false); } public void onDeny(Map<String, Object> context) throws Exception { createUIPopupMessages(context, "UIPopupMenu.msg.share-document"); } }
2,343
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsEditableFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsEditableFilter.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.component.explorer.control.filter; import java.security.AccessControlException; import java.util.Map; import javax.jcr.Node; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.portal.webui.util.Util; import org.exoplatform.services.cms.templates.TemplateService; import org.exoplatform.services.wcm.utils.WCMCoreUtils; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * Created by The eXo Platform SARL * Author : Hoang Van Hung * hunghvit@gmail.com * Aug 6, 2009 */ public class IsEditableFilter extends UIExtensionAbstractFilter { public IsEditableFilter() { this("UIActionBar.msg.not-support"); } public IsEditableFilter(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node currentNode = (Node) context.get(Node.class.getName()); String nodeType; if(currentNode.hasProperty("exo:presentationType")) { nodeType = currentNode.getProperty("exo:presentationType").getString(); }else { nodeType = currentNode.getPrimaryNodeType().getName(); } for(String type:Utils.NON_EDITABLE_NODETYPES) { if(type.equalsIgnoreCase(nodeType)) return false; } String userName = Util.getPortalRequestContext().getRemoteUser(); try{ TemplateService templateService = WCMCoreUtils.getService(TemplateService.class); templateService.getTemplatePathByUser(true, nodeType, userName); }catch(AccessControlException e){ return false; } return true; } public void onDeny(Map<String, Object> context) throws Exception { if (context == null) return; Node currentNode = (Node) context.get(Node.class.getName()); Object[] arg = { currentNode.getPath() }; createUIPopupMessages(context, messageKey, arg); } }
2,930
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
CanAddCategoryFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/CanAddCategoryFilter.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.component.explorer.control.filter; import java.util.Map; import javax.jcr.Node; import org.exoplatform.webui.ext.filter.UIExtensionFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * Created by The eXo Platform SARL * Author : Hoang Van Hung * hunghvit@gmail.com * Nov 18, 2009 */ public class CanAddCategoryFilter implements UIExtensionFilter { /** * This method checks if the current node is of the right type */ public boolean accept(Map<String, Object> context) throws Exception { Node currentNode = (Node) context.get(Node.class.getName()); return currentNode.isNodeType("exo:taxonomy"); } /** * This is the type of the filter */ public UIExtensionFilterType getType() { return UIExtensionFilterType.MANDATORY; } /** * This is called when the filter has failed */ public void onDeny(Map<String, Object> context) throws Exception {} }
1,877
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsNotLockedFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsNotLockedFilter.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.component.explorer.control.filter; import org.exoplatform.ecm.utils.lock.LockUtil; import org.exoplatform.services.wcm.utils.WCMCoreUtils; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; import javax.jcr.Node; import java.util.Map; /** * Created by The eXo Platform SAS * Author : eXoPlatform * nicolas.filotto@exoplatform.com * 5 mai 2009 */ public class IsNotLockedFilter extends UIExtensionAbstractFilter { private boolean checkGroup = false; private boolean checkOwner = false; public IsNotLockedFilter() { this(null); } public IsNotLockedFilter(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } public IsNotLockedFilter(boolean checkGroup) { this(null); this.checkGroup = checkGroup; } public IsNotLockedFilter(boolean checkGroup, boolean checkOwner) { this(null); this.checkGroup = checkGroup; this.checkOwner = checkOwner; } public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node currentNode = (Node) context.get(Node.class.getName()); String remoteUser = WCMCoreUtils.getRemoteUser(); String superUser = WCMCoreUtils.getSuperUser(); if (remoteUser.equalsIgnoreCase(superUser)) { return true; } if(!currentNode.isLocked()) return true; if (checkOwner && currentNode.isLocked()) { String lockOwner = currentNode.getLock().getLockOwner(); if (lockOwner.equals(remoteUser)) return true; } String lockToken = checkGroup ? LockUtil.getLockToken(currentNode): LockUtil.getLockTokenOfUser(currentNode); if(lockToken != null) { currentNode.getSession().addLockToken(LockUtil.getLockToken(currentNode)); return true; } return false; } public void onDeny(Map<String, Object> context) throws Exception { if (context == null) return; Node currentNode = (Node) context.get(Node.class.getName()); Object[] arg = { currentNode.getPath() }; createUIPopupMessages(context, "UIPopupMenu.msg.node-locked", arg); } }
2,969
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsMixVotable.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsMixVotable.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.component.explorer.control.filter; import java.util.Map; import javax.jcr.Node; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * Created by The eXo Platform SAS * Author : eXoPlatform * nicolas.filotto@exoplatform.com * 7 mai 2009 */ public class IsMixVotable extends UIExtensionAbstractFilter { public IsMixVotable() { this("UIVoteForm.msg.not-support"); } public IsMixVotable(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } public boolean accept(Map<String, Object> context) throws Exception { Node currentNode = (Node) context.get(Node.class.getName()); return currentNode.isNodeType(Utils.MIX_VOTABLE); } public void onDeny(Map<String, Object> context) throws Exception { createUIPopupMessages(context, messageKey); } }
1,733
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
HasRemovePermissionFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/HasRemovePermissionFilter.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.component.explorer.control.filter; import java.util.Map; import javax.jcr.Node; import org.exoplatform.ecm.webui.utils.PermissionUtil; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * Created by The eXo Platform SARL * Author : Nguyen Anh Vu * anhvurz90@gmail.com * Nov 2, 2009 * 2:06:49 PM */ public class HasRemovePermissionFilter extends UIExtensionAbstractFilter { public HasRemovePermissionFilter() { this(null); } public HasRemovePermissionFilter(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } public static boolean hasRemovePermission(Node node) throws Exception { try { return PermissionUtil.canRemoveNode(node); } catch (Exception ex) { return true; } } public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node currentNode = (Node) context.get(Node.class.getName()); return hasRemovePermission(currentNode); } public void onDeny(Map<String, Object> context) throws Exception { } }
1,890
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsContainBinaryFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsContainBinaryFilter.java
package org.exoplatform.ecm.webui.component.explorer.control.filter; import org.exoplatform.services.wcm.core.NodetypeConstant; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; import javax.jcr.Node; import javax.jcr.RepositoryException; import java.util.Map; /** * Created by The eXo Platform SEA * Author : eXoPlatform * toannh@exoplatform.com * On 8/7/15 * Filter for Edit button * Edit content for content type * Edit property for nt:file */ public class IsContainBinaryFilter extends UIExtensionAbstractFilter { public IsContainBinaryFilter() { this("UIActionBar.msg.node-checkedin"); } public IsContainBinaryFilter(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node currentNode = (Node) context.get(Node.class.getName()); if(NodetypeConstant.NT_FILE.equals(currentNode.getPrimaryNodeType().getName())) { try { String mimeType = currentNode.getNode(NodetypeConstant.JCR_CONTENT) .getProperty(NodetypeConstant.JCR_MIME_TYPE).getString(); if (mimeType != null && !(mimeType.startsWith("text") || mimeType.indexOf("groovy") >= 0)) { return true; } } catch (RepositoryException re) { return false; } } return false; } public void onDeny(Map<String, Object> context) throws Exception {} }
1,537
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsNotMandatoryChildNode.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsNotMandatoryChildNode.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.component.explorer.control.filter; import java.util.Map; import javax.jcr.Node; import javax.jcr.nodetype.NodeDefinition; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * Created by The eXo Platform SAS * Author : eXoPlatform * tanhq@exoplatform.com * Oct 18, 2013 */ public class IsNotMandatoryChildNode extends UIExtensionAbstractFilter { public IsNotMandatoryChildNode() { this(null); } public IsNotMandatoryChildNode(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node currentNode = (Node) context.get(Node.class.getName()); Node parentNode = currentNode.getParent(); String deletedNodeType; try { deletedNodeType = currentNode.getDefinition().getDeclaringNodeType().getName(); } catch (Exception e) { return true; } NodeDefinition[] nodeDefinitions = parentNode.getPrimaryNodeType().getDeclaredChildNodeDefinitions(); for (NodeDefinition nodeDefinition : nodeDefinitions) { String childNodeType = nodeDefinition.getDeclaringNodeType().getName(); if(deletedNodeType.equals(childNodeType) && nodeDefinition.getName().equals(currentNode.getName()) && nodeDefinition.isMandatory()) { return false; } } return true; } public void onDeny(Map<String, Object> context) throws Exception {} }
2,308
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsVersionableOrAncestorFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsVersionableOrAncestorFilter.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.component.explorer.control.filter; import java.util.Map; import javax.jcr.AccessDeniedException; import javax.jcr.Node; import javax.jcr.RepositoryException; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * Created by The eXo Platform SARL * Author : Hoang Van Hung * hunghvit@gmail.com * Aug 6, 2009 */ public class IsVersionableOrAncestorFilter extends UIExtensionAbstractFilter { public IsVersionableOrAncestorFilter() { this(null); } public IsVersionableOrAncestorFilter(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } public static boolean isAncestorVersionable(Node node) throws RepositoryException { int depth = node.getDepth() - 1; if (depth < 1) return false; Node parent = null; try { parent = (Node) node.getAncestor(depth); } catch (ClassCastException ex) { parent = (Node) node.getAncestor(--depth); } catch (AccessDeniedException ade){ return false; } while (true) { if (parent.isNodeType(Utils.MIX_VERSIONABLE)) return true; if (--depth == 0) return false; try { parent = (Node) node.getAncestor(depth); } catch(RepositoryException re){ return false; } if (parent == null) return false; } } public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node currentNode = (Node) context.get(Node.class.getName()); if (Utils.isVersionable(currentNode) || isAncestorVersionable(currentNode)) return true; return false; } public void onDeny(Map<String, Object> context) throws Exception {} }
2,745
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
CanDeleteNodeFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/CanDeleteNodeFilter.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.component.explorer.control.filter; import java.util.Map; import javax.jcr.Node; import org.exoplatform.ecm.webui.utils.PermissionUtil; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * Created by The eXo Platform SARL * Author : Hoang Van Hung * hunghvit@gmail.com * Aug 6, 2009 */ public class CanDeleteNodeFilter extends UIExtensionAbstractFilter { public CanDeleteNodeFilter() { this("UIActionBar.msg.node-checkedin"); } public CanDeleteNodeFilter(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } public boolean accept(Map<String, Object> context) throws Exception { if (context==null) return true; Node currentNode = (Node) context.get(Node.class.getName()); // in case exo:actions are in checked items in Trash. return false. if (Utils.EXO_ACTIONS.equals(currentNode.getName()) && Utils.isInTrash(currentNode)) { return false; } else { return (PermissionUtil.canRemoveNode(currentNode))&& (!isVersionableOrAncestor(currentNode) || (isVersionableOrAncestor(currentNode) && IsCheckedOutFilter.isCheckedOut(currentNode))); } } public void onDeny(Map<String, Object> context) throws Exception { } private boolean isVersionableOrAncestor(Node node) throws Exception { return Utils.isVersionable(node) || IsVersionableOrAncestorFilter.isAncestorVersionable(node); } }
2,551
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsTrashHomeNodeFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsTrashHomeNodeFilter.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.component.explorer.control.filter; import java.util.Map; import javax.jcr.Node; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * Created by The eXo Platform SARL * Author : Nguyen Anh Vu * anhvurz90@gmail.com * Nov 13, 2009 * 5:14:29 PM */ public class IsTrashHomeNodeFilter extends UIExtensionAbstractFilter { public IsTrashHomeNodeFilter() { this(null); } public IsTrashHomeNodeFilter(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node currentNode = (Node) context.get(Node.class.getName()); return Utils.isTrashHomeNode(currentNode); } public void onDeny(Map<String, Object> context) throws Exception { } }
1,675
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
CanEditDocFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/CanEditDocFilter.java
package org.exoplatform.ecm.webui.component.explorer.control.filter; import org.exoplatform.ecm.webui.utils.PermissionUtil; import org.exoplatform.services.wcm.utils.WCMCoreUtils; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; import javax.jcr.Node; import java.util.Map; /** * Check parent node modify permission for Open Document In Office feature */ public class CanEditDocFilter extends UIExtensionAbstractFilter { public CanEditDocFilter() { this("UIActionBar.msg.unsupported-action"); } public CanEditDocFilter(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } /* (non-Javadoc) * @see org.exoplatform.webui.ext.filter.UIExtensionFilter#accept(java.util.Map) */ @Override public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node currentNode = (Node) context.get(Node.class.getName()); if(!WCMCoreUtils.canAccessParentNode(currentNode)) return false; return PermissionUtil.canAddNode(currentNode.getParent()); } /* (non-Javadoc) * @see org.exoplatform.webui.ext.filter.UIExtensionFilter#onDeny(java.util.Map) */ @Override public void onDeny(Map<String, Object> context) throws Exception { } }
1,325
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsInTrashFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsInTrashFilter.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.component.explorer.control.filter; import java.util.Map; import javax.jcr.Node; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * Created by The eXo Platform SARL * Author : Nguyen Anh Vu * anhvurz90@gmail.com * Oct 16, 2009 * 10:48:40 AM */ public class IsInTrashFilter extends UIExtensionAbstractFilter { public IsInTrashFilter() { this(null); } public IsInTrashFilter(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node currentNode = (Node) context.get(Node.class.getName()); return Utils.isInTrash(currentNode); } public void onDeny(Map<String, Object> context) throws Exception { } }
1,652
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsNotSymlinkFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsNotSymlinkFilter.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.component.explorer.control.filter; import java.util.Map; import javax.jcr.Node; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * Created by The eXo Platform SAS * Author : eXoPlatform * nicolas.filotto@exoplatform.com * 6 mai 2009 */ public class IsNotSymlinkFilter extends UIExtensionAbstractFilter { public IsNotSymlinkFilter() { this(null); } public IsNotSymlinkFilter(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node currentNode = (Node) context.get(Node.class.getName()); return !currentNode.isNodeType(Utils.EXO_SYMLINK); } public void onDeny(Map<String, Object> context) throws Exception { if (context == null) return; Node currentNode = (Node) context.get(Node.class.getName()); Object[] arg = { currentNode.getPath() }; createUIPopupMessages(context, "UIWorkingArea.msg.selected-is-link", arg); } }
1,945
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsNtFileFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsNtFileFilter.java
package org.exoplatform.ecm.webui.component.explorer.control.filter; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; import javax.jcr.Node; import java.util.Map; public class IsNtFileFilter extends UIExtensionAbstractFilter { public IsNtFileFilter() { this("UIActionBar.msg.unsupported-action"); } public IsNtFileFilter(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } /* (non-Javadoc) * @see org.exoplatform.webui.ext.filter.UIExtensionFilter#accept(java.util.Map) */ @Override public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node currentNode = (Node) context.get(Node.class.getName()); return currentNode.isNodeType(Utils.NT_FILE); } /* (non-Javadoc) * @see org.exoplatform.webui.ext.filter.UIExtensionFilter#onDeny(java.util.Map) */ @Override public void onDeny(Map<String, Object> context) throws Exception { } }
1,089
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsNotSameNameSiblingFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsNotSameNameSiblingFilter.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.component.explorer.control.filter; import java.util.Map; import javax.jcr.Node; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * Created by The eXo Platform SARL * Author : Hoang Van Hung * hunghvit@gmail.com * Aug 6, 2009 */ public class IsNotSameNameSiblingFilter extends UIExtensionAbstractFilter { public IsNotSameNameSiblingFilter() { this(null); } public IsNotSameNameSiblingFilter(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } public static boolean isNotSameNameSibling(Node node) throws Exception { return node.getIndex() <= 1; } public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node currentNode = (Node) context.get(Node.class.getName()); return isNotSameNameSibling(currentNode); } public void onDeny(Map<String, Object> context) throws Exception { } }
1,944
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
HasPublicationLifecycleFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/HasPublicationLifecycleFilter.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.component.explorer.control.filter; import java.util.Map; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.services.ecm.publication.PublicationService; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; /** * Created by The eXo Platform SAS * Author : eXoPlatform * nicolas.filotto@exoplatform.com * 6 mai 2009 */ public class HasPublicationLifecycleFilter extends UIExtensionAbstractFilter { public boolean accept(Map<String, Object> context) throws Exception { UIJCRExplorer uiExplorer = (UIJCRExplorer) context.get(UIJCRExplorer.class.getName()); PublicationService publicationService = uiExplorer.getApplicationComponent(PublicationService.class); return !publicationService.getPublicationPlugins().isEmpty(); } public void onDeny(Map<String, Object> context) throws Exception { createUIPopupMessages(context, "UIActionBar.msg.manage-publication.no-publication-lifecycle"); } }
1,763
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsPasteableFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsPasteableFilter.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.component.explorer.control.filter; import java.util.Map; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.services.cms.clipboard.ClipboardService; import org.exoplatform.services.security.ConversationState; import org.exoplatform.services.wcm.utils.WCMCoreUtils; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * Created by The eXo Platform SARL * Author : Hoang Van Hung * hunghvit@gmail.com * Aug 6, 2009 */ public class IsPasteableFilter extends UIExtensionAbstractFilter { public IsPasteableFilter() { this(null); } public IsPasteableFilter(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } public boolean accept(Map<String, Object> context) throws Exception { if (context==null) return true; UIJCRExplorer uiExplorer = (UIJCRExplorer) context.get(UIJCRExplorer.class.getName()); ClipboardService clipboardService = WCMCoreUtils.getService(ClipboardService.class); String userId = ConversationState.getCurrent().getIdentity().getUserId(); return !clipboardService.getClipboardList(userId, false).isEmpty(); } public void onDeny(Map<String, Object> context) throws Exception { if (context == null) return; createUIPopupMessages(context, "UIPopupMenu.msg.no-node"); } }
2,352
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
CanAddNodeFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/CanAddNodeFilter.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.component.explorer.control.filter; import java.util.Map; import javax.jcr.Node; import org.exoplatform.ecm.webui.utils.PermissionUtil; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * Created by The eXo Platform SAS * Author : eXoPlatform * nicolas.filotto@exoplatform.com * 6 mai 2009 */ public class CanAddNodeFilter extends UIExtensionAbstractFilter { public CanAddNodeFilter() { this(null); } public CanAddNodeFilter(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node currentNode = (Node) context.get(Node.class.getName()); return PermissionUtil.canAddNode(currentNode); } public void onDeny(Map<String, Object> context) throws Exception { createUIPopupMessages(context, "UIPopupMenu.msg.has-not-add-permission"); } }
1,800
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsReferenceableNodeFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsReferenceableNodeFilter.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.component.explorer.control.filter; import java.util.Map; import javax.jcr.Node; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; /** * Created by The eXo Platform SAS * Author : eXoPlatform * nicolas.filotto@exoplatform.com * 6 mai 2009 */ public class IsReferenceableNodeFilter extends UIExtensionAbstractFilter { public boolean accept(Map<String, Object> context) throws Exception { Node currentNode = (Node) context.get(Node.class.getName()); UIJCRExplorer uiExplorer = (UIJCRExplorer) context.get(UIJCRExplorer.class.getName()); return uiExplorer.isReferenceableNode(currentNode); } public void onDeny(Map<String, Object> context) throws Exception { Node currentNode = (Node) context.get(Node.class.getName()); Object[] args = { currentNode.getPath() }; createUIPopupMessages(context, "UIActionBar.msg.is-not-referenable", args); } }
1,760
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsNotParentLockedWhenRenameFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsNotParentLockedWhenRenameFilter.java
package org.exoplatform.ecm.webui.component.explorer.control.filter; import org.exoplatform.services.cms.lock.LockService; import org.exoplatform.services.wcm.utils.WCMCoreUtils; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; import javax.jcr.Node; import java.util.Map; /** * User: dongpd * * Date: 11/22/13 * Time: 4:57 PM */ public class IsNotParentLockedWhenRenameFilter extends UIExtensionAbstractFilter { @Override public UIExtensionFilterType getType() { return UIExtensionFilterType.MANDATORY; } @Override public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node parentNode = ((Node) context.get(Node.class.getName())).getParent(); LockService lockService = WCMCoreUtils.getService(LockService.class); if (parentNode.isLocked() && lockService.getLockToken(parentNode) == null) { return false; } else { return true; } } @Override public void onDeny(Map<String, Object> context) throws Exception { } }
1,114
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsNotDocumentFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsNotDocumentFilter.java
package org.exoplatform.ecm.webui.component.explorer.control.filter; import java.util.Map; import javax.jcr.Node; import javax.jcr.nodetype.NodeType; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.services.cms.templates.TemplateService; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; import static org.exoplatform.services.cms.impl.Utils.isDocument; public class IsNotDocumentFilter extends UIExtensionAbstractFilter { public IsNotDocumentFilter() { this("UIActionBar.msg.not-supported"); } public IsNotDocumentFilter(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node currentNode = (Node) context.get(Node.class.getName()); if (isDocument(currentNode)) { return false; } return true; } public void onDeny(Map<String, Object> context) throws Exception { if (context == null) return; createUIPopupMessages(context, messageKey); } }
1,169
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsNotNtFileFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsNotNtFileFilter.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.component.explorer.control.filter; import java.util.Map; import javax.jcr.Node; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * Created by The eXo Platform SAS * Author : eXoPlatform * dongpd@exoplatform.com * phamdong@gmail.com * Nov 24, 2011 */ public class IsNotNtFileFilter extends UIExtensionAbstractFilter{ public IsNotNtFileFilter() { this("UIActionBar.msg.unsupported-action"); } public IsNotNtFileFilter(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } /* (non-Javadoc) * @see org.exoplatform.webui.ext.filter.UIExtensionFilter#accept(java.util.Map) */ @Override public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node currentNode = (Node) context.get(Node.class.getName()); return !currentNode.isNodeType(Utils.NT_FILE); } /* (non-Javadoc) * @see org.exoplatform.webui.ext.filter.UIExtensionFilter#onDeny(java.util.Map) */ @Override public void onDeny(Map<String, Object> context) throws Exception { } }
1,972
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
CanSetPropertyFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/CanSetPropertyFilter.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.component.explorer.control.filter; import java.util.Map; import javax.jcr.Node; import org.exoplatform.ecm.webui.utils.PermissionUtil; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * Created by The eXo Platform SAS * Author : eXoPlatform * nicolas.filotto@exoplatform.com * 6 mai 2009 */ public class CanSetPropertyFilter extends UIExtensionAbstractFilter { public CanSetPropertyFilter() { this("UIPopupMenu.msg.has-not-edit-permission"); } public CanSetPropertyFilter(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node currentNode = (Node) context.get(Node.class.getName()); return PermissionUtil.canSetProperty(currentNode); } public void onDeny(Map<String, Object> context) throws Exception { if (context == null) return; createUIPopupMessages(context, messageKey); } }
1,853
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsNotContainBinaryFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsNotContainBinaryFilter.java
package org.exoplatform.ecm.webui.component.explorer.control.filter; import org.exoplatform.services.wcm.core.NodetypeConstant; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; import javax.jcr.Node; import javax.jcr.RepositoryException; import java.util.Map; /** * Created by The eXo Platform SEA * Author : eXoPlatform * toannh@exoplatform.com * On 8/7/15 * Filter for Edit button * Edit content for content type * Edit property for nt:file */ public class IsNotContainBinaryFilter extends UIExtensionAbstractFilter { public IsNotContainBinaryFilter() { this("UIActionBar.msg.node-checkedin"); } public IsNotContainBinaryFilter(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node currentNode = (Node) context.get(Node.class.getName()); if(NodetypeConstant.NT_FILE.equals(currentNode.getPrimaryNodeType().getName())) { try { String mimeType = currentNode.getNode(NodetypeConstant.JCR_CONTENT) .getProperty(NodetypeConstant.JCR_MIME_TYPE).getString(); if (mimeType != null && (mimeType.startsWith("text") || mimeType.indexOf("groovy") >= 0)) { return true; } return false; } catch (RepositoryException re) { return false; } } return true; } public void onDeny(Map<String, Object> context) throws Exception {} }
1,566
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsNotFavouriteFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsNotFavouriteFilter.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.component.explorer.control.filter; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.services.cms.documents.FavoriteService; import org.exoplatform.services.wcm.utils.WCMCoreUtils; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; import javax.jcr.Node; import java.util.Map; /** * Created by The eXo Platform SARL * Author : Nguyen Anh Vu * anhvurz90@gmail.com * Oct 16, 2009 * 10:34:12 AM */ public class IsNotFavouriteFilter extends UIExtensionAbstractFilter { public IsNotFavouriteFilter() { this(null); } public IsNotFavouriteFilter(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } public static boolean isNotFavourite(Node node, UIJCRExplorer uiExplorer) throws Exception { FavoriteService favoriteService = WCMCoreUtils.getService(FavoriteService.class); return !favoriteService.isFavoriter(WCMCoreUtils.getRemoteUser(), node); } public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node currentNode = (Node) context.get(Node.class.getName()); UIJCRExplorer uiExplorer = (UIJCRExplorer)context.get(UIJCRExplorer.class.getName()); return isNotFavourite(currentNode, uiExplorer); } public void onDeny(Map<String, Object> context) throws Exception { } }
2,178
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsHoldsLockFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsHoldsLockFilter.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.component.explorer.control.filter; import java.util.Map; import javax.jcr.Node; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * Created by The eXo Platform SARL * Author : Hoang Van Hung * hunghvit@gmail.com * Aug 6, 2009 */ public class IsHoldsLockFilter extends UIExtensionAbstractFilter { public IsHoldsLockFilter() { this(null); } public IsHoldsLockFilter(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node currentNode = (Node) context.get(Node.class.getName()); return currentNode.holdsLock(); } public void onDeny(Map<String, Object> context) throws Exception { } }
1,796
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
CanCutNodeFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/CanCutNodeFilter.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.component.explorer.control.filter; import java.util.Map; import javax.jcr.Node; import org.exoplatform.ecm.webui.utils.PermissionUtil; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * Created by The eXo Platform SARL * Author : Hoang Van Hung * hunghvit@gmail.com * Aug 6, 2009 */ public class CanCutNodeFilter extends UIExtensionAbstractFilter { public CanCutNodeFilter() { this("UIPopupMenu.msg.can-not-cut-node"); } public CanCutNodeFilter(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node currentNode = (Node) context.get(Node.class.getName()); return PermissionUtil.canRemoveNode(currentNode) && (!IsVersionableOrAncestorFilter.isAncestorVersionable(currentNode) || (IsVersionableOrAncestorFilter.isAncestorVersionable(currentNode) && IsCheckedOutFilter.isCheckedOut(currentNode))); } public void onDeny(Map<String, Object> context) throws Exception { createUIPopupMessages(context, "UIPopupMenu.msg.can-not-cut-node"); } }
2,170
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsDocumentFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsDocumentFilter.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.component.explorer.control.filter; import java.util.Map; import javax.jcr.Node; import javax.jcr.nodetype.NodeType; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.services.cms.templates.TemplateService; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * Created by The eXo Platform SAS * Author : eXoPlatform * nicolas.filotto@exoplatform.com * 6 mai 2009 */ public class IsDocumentFilter extends UIExtensionAbstractFilter { public IsDocumentFilter() { this("UIActionBar.msg.not-supported"); } public IsDocumentFilter(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node currentNode = (Node) context.get(Node.class.getName()); UIJCRExplorer uiExplorer = (UIJCRExplorer) context.get(UIJCRExplorer.class.getName()); TemplateService templateService = uiExplorer.getApplicationComponent(TemplateService.class); NodeType nodeType = currentNode.getPrimaryNodeType(); return templateService.getDocumentTemplates().contains(nodeType.getName()); } public void onDeny(Map<String, Object> context) throws Exception { if (context == null) return; createUIPopupMessages(context, messageKey); } }
2,218
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
CanAddSymlinkFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/CanAddSymlinkFilter.java
package org.exoplatform.ecm.webui.component.explorer.control.filter; import java.util.Map; import javax.jcr.Node; import javax.jcr.nodetype.NodeType; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.services.cms.impl.Utils; import org.exoplatform.webui.ext.filter.UIExtensionFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * Created by The eXo Platform SAS * Author : Ha Quang Tan * tanhq@exoplatform.com * September 24, 2012 */ public class CanAddSymlinkFilter implements UIExtensionFilter { public boolean accept(Map<String, Object> context) throws Exception { if(context == null) return true; UIJCRExplorer uiExplorer = (UIJCRExplorer) context.get(UIJCRExplorer.class.getName()); if(uiExplorer == null) return true; Node currentNode = uiExplorer.getCurrentNode(); if (currentNode.getPrimaryNodeType().canAddChildNode(String.valueOf(System.currentTimeMillis()), Utils.EXO_SYMLINK)) { return true; } NodeType[] declaredSuperTypes = currentNode.getPrimaryNodeType().getSupertypes(); for (NodeType nodeType : declaredSuperTypes) { if(nodeType.canAddChildNode(String.valueOf(System.currentTimeMillis()), Utils.EXO_SYMLINK)) return true; } NodeType[] declaredSuperTypesOfMixs = currentNode.getMixinNodeTypes(); for (NodeType mixin : declaredSuperTypesOfMixs) { NodeType[] superTypes = mixin.getSupertypes(); if (mixin.canAddChildNode(String.valueOf(System.currentTimeMillis()), Utils.EXO_SYMLINK)) return true; for (NodeType nodeType : superTypes) { if(nodeType.canAddChildNode(String.valueOf(System.currentTimeMillis()), Utils.EXO_SYMLINK)) return true; } } return false; } public UIExtensionFilterType getType() { return UIExtensionFilterType.MANDATORY; } public void onDeny(Map<String, Object> context) throws Exception { } }
1,934
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
CanEnableVersionFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/CanEnableVersionFilter.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.component.explorer.control.filter; import java.util.Map; import javax.jcr.Node; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; /** * Created by The eXo Platform SAS * Author : eXoPlatform * nicolas.filotto@exoplatform.com * 6 mai 2009 */ public class CanEnableVersionFilter extends UIExtensionAbstractFilter { public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node currentNode = (Node) context.get(Node.class.getName()); return currentNode.canAddMixin(Utils.MIX_VERSIONABLE) || currentNode.isNodeType(Utils.MIX_VERSIONABLE); } public void onDeny(Map<String, Object> context) throws Exception { createUIPopupMessages(context, "UIActionBar.msg.cannot-enable-version"); } }
1,618
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsNotSimpleLockedFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsNotSimpleLockedFilter.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.component.explorer.control.filter; import java.util.Map; import javax.jcr.Node; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * Created by The eXo Platform SARL * Author : Hoang Van Hung * hunghvit@gmail.com * Aug 10, 2009 */ public class IsNotSimpleLockedFilter extends UIExtensionAbstractFilter { public IsNotSimpleLockedFilter() { this(null); } public IsNotSimpleLockedFilter(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node currentNode = (Node) context.get(Node.class.getName()); return !currentNode.isLocked(); } public void onDeny(Map<String, Object> context) throws Exception { if (context == null) return; Node currentNode = (Node) context.get(Node.class.getName()); Object[] arg = { currentNode.getPath() }; createUIPopupMessages(context, "UIPopupMenu.msg.node-locked", arg); } }
2,031
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsNotEditingDocumentFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsNotEditingDocumentFilter.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.component.explorer.control.filter; import java.util.Map; import javax.jcr.Node; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * Created by The eXo Platform SAS * Author : Nguyen Anh Vu * anhvurz90@gmail.com * July 26, 2010 */ public class IsNotEditingDocumentFilter extends UIExtensionAbstractFilter { public IsNotEditingDocumentFilter() { this(null); } public IsNotEditingDocumentFilter(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node currentNode = (Node) context.get(Node.class.getName()); UIJCRExplorer uiExplorer = (UIJCRExplorer)context.get(UIJCRExplorer.class.getName()); if (currentNode == null) return !uiExplorer.isEditingDocument(); return !uiExplorer.isEditingDocument() || !currentNode.getSession().getWorkspace().getName().equals(uiExplorer.getCurrentDriveWorkspace()) || !currentNode.getPath().equals(uiExplorer.getCurrentNode().getPath()); } public void onDeny(Map<String, Object> context) throws Exception { } }
2,206
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
HasAllowedFolderTypeFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/HasAllowedFolderTypeFilter.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 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.component.explorer.control.filter; import java.util.List; import java.util.Map; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * Created by The eXo Platform SAS * Author : eXoPlatform * dongpd@exoplatform.com * Jan 07, 2013 */ public class HasAllowedFolderTypeFilter extends UIExtensionAbstractFilter { public HasAllowedFolderTypeFilter() { this("UIActionBar.msg.unsupported-action"); } public HasAllowedFolderTypeFilter(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } @Override public void onDeny(Map<String, Object> context) throws Exception { } @Override public boolean accept(Map<String, Object> context) throws Exception { if (context == null) { return true; } UIJCRExplorer uiExplorer = (UIJCRExplorer) context.get(UIJCRExplorer.class.getName()); List<String> allowedFolderTypes = Utils.getAllowedFolderTypesInCurrentPath(uiExplorer.getCurrentNode(), uiExplorer.getDriveData()); return (allowedFolderTypes.size() != 0); } }
2,051
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
DownloadDocumentFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/DownloadDocumentFilter.java
/*************************************************************************** * Copyright (C) 2003-2021 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.component.explorer.control.filter; import org.exoplatform.commons.api.settings.SettingService; import org.exoplatform.commons.api.settings.SettingValue; import org.exoplatform.commons.api.settings.data.Context; import org.exoplatform.commons.api.settings.data.Scope; import org.exoplatform.commons.utils.CommonsUtils; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; import java.util.Map; public class DownloadDocumentFilter extends UIExtensionAbstractFilter { public DownloadDocumentFilter() { this("UIPopupMenu.msg.download-document"); } public DownloadDocumentFilter(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; SettingService settingService = CommonsUtils.getService(SettingService.class); SettingValue<?> settingValue = settingService.get(Context.GLOBAL.id("downloadDocumentStatus"), Scope.APPLICATION.id("downloadDocumentStatus"), "exo:downloadDocumentStatus"); return !(settingValue != null && !settingValue.getValue().toString().isEmpty() ? Boolean.valueOf(settingValue.getValue().toString()) : false); } public void onDeny(Map<String, Object> context) throws Exception { createUIPopupMessages(context, "UIPopupMenu.msg.download-document"); } }
2,364
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsAbleToRestoreFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsAbleToRestoreFilter.java
package org.exoplatform.ecm.webui.component.explorer.control.filter; import java.util.Map; import javax.jcr.Node; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * This filter will be used to check the current user has permission to restore selected document/folder or not. */ public class IsAbleToRestoreFilter extends UIExtensionAbstractFilter { public IsAbleToRestoreFilter() { this(null); } public IsAbleToRestoreFilter(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } @Override public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node currentNode = (Node) context.get(Node.class.getName()); return Utils.isAbleToRestore(currentNode); } @Override public void onDeny(Map<String, Object> context) throws Exception { createUIPopupMessages(context, "UIDocumentInfo.msg.access-denied"); } }
1,103
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsNotRootNodeFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsNotRootNodeFilter.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.component.explorer.control.filter; import java.util.Map; import javax.jcr.Node; import org.exoplatform.services.jcr.impl.core.NodeImpl; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * Created by The eXo Platform SAS * Author : eXoPlatform * nicolas.filotto@exoplatform.com * 6 mai 2009 */ public class IsNotRootNodeFilter extends UIExtensionAbstractFilter { public IsNotRootNodeFilter() { this("UIActionBar.msg.cannot-action-in-rootnode"); } public IsNotRootNodeFilter(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node currentNode = (Node) context.get(Node.class.getName()); return currentNode.getPath().length() != 1; } public void onDeny(Map<String, Object> context) throws Exception { createUIPopupMessages(context, messageKey); } }
1,812
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
HasMetadataTemplatesFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/HasMetadataTemplatesFilter.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.component.explorer.control.filter; import java.util.Hashtable; import java.util.Map; import javax.jcr.Node; import org.exoplatform.services.wcm.utils.WCMCoreUtils; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * Created by The eXo Platform SAS * Author : eXoPlatform * nicolas.filotto@exoplatform.com * 6 mai 2009 */ public class HasMetadataTemplatesFilter extends UIExtensionAbstractFilter { public HasMetadataTemplatesFilter() { super("UIViewMetadataContainer.msg.path-not-found", UIExtensionFilterType.MANDATORY); } public boolean accept(Map<String, Object> context) throws Exception { Node currentNode = (Node) context.get(Node.class.getName()); Hashtable<String, String> metaDataTemp = WCMCoreUtils.getMetadataTemplates(currentNode); return !metaDataTemp.isEmpty(); } public void onDeny(Map<String, Object> context) throws Exception { } }
1,785
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsVersionableFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsVersionableFilter.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.component.explorer.control.filter; import java.util.Map; import javax.jcr.Node; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * Created by The eXo Platform SARL * Author : Hoang Van Hung * hunghvit@gmail.com * Aug 6, 2009 */ public class IsVersionableFilter extends UIExtensionAbstractFilter { public IsVersionableFilter() { this(null); } public IsVersionableFilter(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node currentNode = (Node) context.get(Node.class.getName()); return Utils.isVersionable(currentNode); } public void onDeny(Map<String, Object> context) throws Exception { } }
1,856
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsNotSpecificFolderNodeFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsNotSpecificFolderNodeFilter.java
/* * Copyright (C) 2003-2019 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.component.explorer.control.filter; import java.util.Map; import javax.jcr.Node; import org.exoplatform.services.cms.impl.Utils; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * An extension filter that do not accept extensions on user private nodes which are: * Documents, Favorites, Pictures, Music, videos, Public, Folksonomy and Searches. * */ public class IsNotSpecificFolderNodeFilter extends UIExtensionAbstractFilter { @Override public boolean accept(Map<String, Object> context) throws Exception { if (context == null) { return true; } Node currentNode = (Node) context.get(Node.class.getName()); return !Utils.isPersonalDefaultFolder(currentNode); } @Override public void onDeny(Map<String, Object> context) throws Exception {} public UIExtensionFilterType getType() { return UIExtensionFilterType.MANDATORY; } }
1,698
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsNotInTrashFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsNotInTrashFilter.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.component.explorer.control.filter; import java.util.Map; import javax.jcr.Node; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * Created by The eXo Platform SARL * Author : Nguyen Anh Vu * anhvurz90@gmail.com * Oct 16, 2009 * 10:56:17 AM */ public class IsNotInTrashFilter extends UIExtensionAbstractFilter { public IsNotInTrashFilter() { this(null); } public IsNotInTrashFilter(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node currentNode = (Node) context.get(Node.class.getName()); return !Utils.isInTrash(currentNode); } public void onDeny(Map<String, Object> context) throws Exception { } }
1,669
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsNotCheckedOutFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsNotCheckedOutFilter.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.component.explorer.control.filter; import java.util.Map; import javax.jcr.Node; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * Created by The eXo Platform SARL * Author : Hoang Van Hung * hunghvit@gmail.com * Aug 6, 2009 */ public class IsNotCheckedOutFilter extends UIExtensionAbstractFilter { public IsNotCheckedOutFilter() { this("UIActionBar.msg.node-checkedin"); } public IsNotCheckedOutFilter(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node currentNode = (Node) context.get(Node.class.getName()); return !currentNode.isCheckedOut(); } public void onDeny(Map<String, Object> context) throws Exception {} }
1,834
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsNotIgnoreVersionNodeFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsNotIgnoreVersionNodeFilter.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.component.explorer.control.filter; import org.apache.commons.lang3.StringUtils; import org.exoplatform.services.jcr.core.nodetype.ExtendedNodeTypeManager; import org.exoplatform.services.jcr.impl.core.NodeImpl; import org.exoplatform.services.log.ExoLogger; import org.exoplatform.services.log.Log; import org.exoplatform.services.wcm.utils.WCMCoreUtils; import org.exoplatform.webui.ext.filter.UIExtensionFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; import javax.jcr.AccessDeniedException; import javax.jcr.Node; import javax.jcr.RepositoryException; import javax.jcr.nodetype.NoSuchNodeTypeException; import javax.jcr.nodetype.NodeType; import java.util.ArrayList; import java.util.List; import java.util.Map; /** * This filter excludes all the child nodes of the nodes having a node type defined in "wcm.nodetypes.ignoreversion". * The node types defined in this property must be separated by comas. * The default value is "exo:webContent". * The goal is to not manage versions in child nodes of a complex type. For example a exo:webContent node has some * child nodes which compose the content (html, css, js, images, ...). The versions must be managed at the webContent * level, not on each of these child nodes. */ public class IsNotIgnoreVersionNodeFilter implements UIExtensionFilter { private static final Log LOG = ExoLogger.getLogger(IsNotIgnoreVersionNodeFilter.class); public static final String NODETYPES_IGNOREVERSION_PARAM = "wcm.nodetypes.ignoreversion"; private List<NodeType> ignoredNodetypes = new ArrayList<>(); public IsNotIgnoreVersionNodeFilter() { String nodetypes = System.getProperty(NODETYPES_IGNOREVERSION_PARAM); if(StringUtils.isBlank(nodetypes)) { nodetypes = "exo:webContent"; } String[] arrNodetypes = nodetypes.split(","); for (String nodetype : arrNodetypes) { ExtendedNodeTypeManager ntmanager = WCMCoreUtils.getRepository().getNodeTypeManager(); try { ignoredNodetypes.add(ntmanager.getNodeType(nodetype)); } catch (NoSuchNodeTypeException e) { LOG.warn("Nodetype '{}' configured in wcm.nodetypes.ignoreversion does not exist"); } catch (RepositoryException e) { LOG.error("Error while fetching nodetype '" + nodetype + "'", e); } } } public boolean accept(Map<String, Object> context) throws Exception { if (context == null) { return true; } Node currentNode = (Node) context.get(Node.class.getName()); Node parentNode = currentNode; do { try { parentNode = parentNode.getParent(); } catch(AccessDeniedException ex) { // if we cannot access the parent it means we are not in the content anymore return true; } catch(Exception ex) { LOG.error("Error while getting parent of node " + parentNode.getPath(), ex); return false; } for(NodeType nodetype : ignoredNodetypes) { if (parentNode.isNodeType(nodetype.getName())) { return false; } } } while (!((NodeImpl) parentNode).isRoot()); return true; } public UIExtensionFilterType getType() { return UIExtensionFilterType.MANDATORY; } public void onDeny(Map<String, Object> context) throws Exception { } }
3,994
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsCheckedOutFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsCheckedOutFilter.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.component.explorer.control.filter; import java.util.Map; import javax.jcr.Node; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * Created by The eXo Platform SAS * Author : eXoPlatform * nicolas.filotto@exoplatform.com * 5 mai 2009 */ public class IsCheckedOutFilter extends UIExtensionAbstractFilter { public IsCheckedOutFilter() { this("UIActionBar.msg.node-checkedin"); } public IsCheckedOutFilter(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } public static boolean isCheckedOut(Node node) throws Exception { return node.isCheckedOut(); } public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node currentNode = (Node) context.get(Node.class.getName()); return isCheckedOut(currentNode); } public void onDeny(Map<String, Object> context) throws Exception { if (context == null) return; Node currentNode = (Node) context.get(Node.class.getName()); Object[] arg = { currentNode.getPath() }; createUIPopupMessages(context, messageKey, arg); } }
1,991
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsNotHoldsLockFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsNotHoldsLockFilter.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.component.explorer.control.filter; import java.util.Map; import javax.jcr.Node; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * Created by The eXo Platform SARL * Author : Hoang Van Hung * hunghvit@gmail.com * Aug 10, 2009 */ public class IsNotHoldsLockFilter extends UIExtensionAbstractFilter { public IsNotHoldsLockFilter() { this(null); } public IsNotHoldsLockFilter(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node currentNode = (Node) context.get(Node.class.getName()); return !currentNode.holdsLock(); } public void onDeny(Map<String, Object> context) throws Exception { } }
1,805
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
CanRemoveNodeFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/CanRemoveNodeFilter.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.component.explorer.control.filter; import java.util.Map; import javax.jcr.Node; import org.exoplatform.ecm.webui.utils.PermissionUtil; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; /** * Created by The eXo Platform SAS * Author : eXoPlatform * nicolas.filotto@exoplatform.com * 6 mai 2009 */ public class CanRemoveNodeFilter extends UIExtensionAbstractFilter { public boolean accept(Map<String, Object> context) throws Exception { Node currentNode = (Node) context.get(Node.class.getName()); return PermissionUtil.canRemoveNode(currentNode); } public void onDeny(Map<String, Object> context) throws Exception { createUIPopupMessages(context, "UIActionBar.msg.access-denied"); } }
1,523
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsNotCategoryFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsNotCategoryFilter.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.component.explorer.control.filter; import java.util.Map; import javax.jcr.Node; import org.exoplatform.webui.ext.filter.UIExtensionFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * Created by The eXo Platform SARL * Author : Hoang Van Hung * hunghvit@gmail.com * Nov 18, 2009 */ public class IsNotCategoryFilter implements UIExtensionFilter { /** * This method checks if the current node is of the right type */ public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; Node currentNode = (Node) context.get(Node.class.getName()); return !currentNode.isNodeType("exo:taxonomy"); } /** * This is the type of the filter */ public UIExtensionFilterType getType() { return UIExtensionFilterType.MANDATORY; } /** * This is called when the filter has failed */ public void onDeny(Map<String, Object> context) throws Exception {} }
1,914
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsNotTrashHomeNodeFilter.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsNotTrashHomeNodeFilter.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.component.explorer.control.filter; import java.util.Map; import javax.jcr.Node; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.services.cms.link.LinkManager; import org.exoplatform.services.wcm.utils.WCMCoreUtils; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * Created by The eXo Platform SARL * Author : Nguyen Anh Vu * anhvurz90@gmail.com * Nov 13, 2009 * 4:42:38 PM */ public class IsNotTrashHomeNodeFilter extends UIExtensionAbstractFilter { public IsNotTrashHomeNodeFilter() { this(null); } public IsNotTrashHomeNodeFilter(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } public boolean accept(Map<String, Object> context) throws Exception { if (context == null) return true; LinkManager linkManager = WCMCoreUtils.getService(LinkManager.class); Node currentNode = (Node) context.get(Node.class.getName()); return linkManager.isLink(currentNode) || !Utils.isTrashHomeNode(currentNode); } public void onDeny(Map<String, Object> context) throws Exception { } }
1,904
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
IsMixCommentable.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/control/filter/IsMixCommentable.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.component.explorer.control.filter; import java.util.Map; import javax.jcr.Node; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.webui.ext.filter.UIExtensionAbstractFilter; import org.exoplatform.webui.ext.filter.UIExtensionFilterType; /** * Created by The eXo Platform SAS * Author : eXoPlatform * nicolas.filotto@exoplatform.com * 7 mai 2009 */ public class IsMixCommentable extends UIExtensionAbstractFilter { public IsMixCommentable() { this("UICommentForm.msg.not-support"); } public IsMixCommentable(String messageKey) { super(messageKey, UIExtensionFilterType.MANDATORY); } public boolean accept(Map<String, Object> context) throws Exception { Node currentNode = (Node) context.get(Node.class.getName()); return currentNode.isNodeType(Utils.MIX_COMMENTABLE); } public void onDeny(Map<String, Object> context) throws Exception { createUIPopupMessages(context, messageKey); } }
1,752
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
PlayMediaComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/rightclick/manager/PlayMediaComponent.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.component.explorer.rightclick.manager; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.regex.Matcher; import javax.jcr.Node; import javax.jcr.PathNotFoundException; import org.exoplatform.ecm.webui.component.explorer.UIDocumentWorkspace; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.UIWorkingArea; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotInTrashFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotTrashHomeNodeFilter; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIWorkingAreaActionListener; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.ecm.webui.viewer.VideoAudioViewer; 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.event.Event; import org.exoplatform.webui.ext.UIExtensionManager; 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 SARL * Author : Hoang Van Hung * hunghvit@gmail.com * Oct 30, 2009 */ @ComponentConfig( events = { @EventConfig(listeners = PlayMediaComponent.PlayMediaActionListener.class) } ) public class PlayMediaComponent extends UIAbstractManagerComponent { private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[]{ new IsNotInTrashFilter(), new IsNotTrashHomeNodeFilter() }); @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } private boolean accept(Node node) throws Exception { if (!node.isNodeType(Utils.NT_FILE)) return false; String mimeType = node.getNode(Utils.JCR_CONTENT).getProperty(Utils.JCR_MIMETYPE).getString(); UIExtensionManager manager = getApplicationComponent(UIExtensionManager.class); Map<String, Object> context = new HashMap<String, Object>(); context.put(Utils.MIME_TYPE, mimeType); if (manager.accept(Utils.FILE_VIEWER_EXTENSION_TYPE, "VideoAudio", context)) { return true; } return false; } public static class PlayMediaActionListener extends UIWorkingAreaActionListener<PlayMediaComponent> { public void processEvent(Event<PlayMediaComponent> event) throws Exception { PlayMediaComponent playMedia = event.getSource(); UIJCRExplorer uiExplorer = playMedia.getAncestorOfType(UIJCRExplorer.class); UIWorkingArea uiWorkingArea = playMedia.getParent(); UIDocumentWorkspace uiDocumentWorkspace = uiWorkingArea.getChild(UIDocumentWorkspace.class); UIApplication uiApp = uiWorkingArea.getAncestorOfType(UIApplication.class); uiDocumentWorkspace.removeChildById("PlayMedia"); String srcPath = event.getRequestContext().getRequestParameter(OBJECTID); Matcher matcher = null; String wsName = null; Node tempNode = null; if(srcPath.indexOf(";") > -1) { String[] paths = srcPath.split(";"); List<Node> nodes = new ArrayList<Node>(); for(String path : paths) { matcher = UIWorkingArea.FILE_EXPLORER_URL_SYNTAX.matcher(path); if (matcher.find()) { wsName = matcher.group(1); srcPath = matcher.group(2); } else { throw new IllegalArgumentException("The ObjectId is invalid '"+ srcPath + "'"); } tempNode = uiExplorer.getNodeByPath(srcPath, uiExplorer.getSessionByWorkspace(wsName)); if (playMedia.accept(tempNode)) nodes.add(tempNode); if (nodes.size() == 0) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.unavaiable-supported-media-file", null,ApplicationMessage.WARNING)); return; } } VideoAudioViewer uiViewer = uiDocumentWorkspace.addChild(VideoAudioViewer.class, null, "PlayMedia"); uiViewer.setPresentNodes(nodes); uiViewer.setRepository(uiExplorer.getRepositoryName()); uiDocumentWorkspace.setRenderedChild(VideoAudioViewer.class); } else { matcher = UIWorkingArea.FILE_EXPLORER_URL_SYNTAX.matcher(srcPath); if (matcher.find()) { wsName = matcher.group(1); srcPath = matcher.group(2); } else { throw new IllegalArgumentException("The ObjectId is invalid '"+ srcPath + "'"); } try { // Use the method getNodeByPath because it is link aware uiExplorer.setSelectNode(wsName, srcPath); } catch(PathNotFoundException path) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.path-not-found-exception", null,ApplicationMessage.WARNING)); return; } } event.getRequestContext().addUIComponentToUpdateByAjax(uiDocumentWorkspace); } } @Override public Class<? extends UIAbstractManager> getUIAbstractManagerClass() { return null; } }
6,455
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
MoveNodeManageComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/rightclick/manager/MoveNodeManageComponent.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.component.explorer.rightclick.manager; import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.regex.Matcher; import javax.jcr.*; import javax.jcr.lock.LockException; import javax.jcr.nodetype.ConstraintViolationException; import javax.portlet.PortletPreferences; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.UIWorkingArea; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotTrashHomeNodeFilter; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIWorkingAreaActionListener; import org.exoplatform.ecm.webui.utils.JCRExceptionManager; 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.cms.jcrext.activity.ActivityCommonService; import org.exoplatform.services.cms.thumbnail.ThumbnailService; import org.exoplatform.services.listener.ListenerService; 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.webui.application.WebuiRequestContext; 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.UIApplication; import org.exoplatform.webui.core.UIComponent; import org.exoplatform.webui.event.Event; 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 SARL * Author : Hoang Van Hung * hunghvit@gmail.com * Aug 6, 2009 */ @ComponentConfig( events = { @EventConfig(listeners = MoveNodeManageComponent.MoveNodeActionListener.class, confirm="UIWorkingArea.msg.confirm-move") } ) public class MoveNodeManageComponent extends UIAbstractManagerComponent { private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[]{ new IsNotTrashHomeNodeFilter()} ); @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } private static final Log LOG = ExoLogger.getLogger(MoveNodeManageComponent.class.getName()); private static void processMultipleSelection(String nodePath, String destPath, Event<? extends UIComponent> event) throws Exception { UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); Matcher matcher = UIWorkingArea.FILE_EXPLORER_URL_SYNTAX.matcher(destPath); String wsName = null; if (matcher.find()) { wsName = matcher.group(1); destPath = matcher.group(2); } else { throw new IllegalArgumentException("The ObjectId is invalid '" + destPath + "'"); } Session session = uiExplorer.getSessionByWorkspace(wsName); UIApplication uiApp = event.getSource().getAncestorOfType(UIApplication.class); if (destPath.startsWith(nodePath)) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.bound-move-exception", null, ApplicationMessage.WARNING)); return; } Node destNode; try { // Use the method getNodeByPath because it is link aware destNode = uiExplorer.getNodeByPath(destPath, session); // Reset the path to manage the links that potentially create virtual path destPath = destNode.getPath(); // Reset the session to manage the links that potentially change of // workspace session = destNode.getSession(); } catch (PathNotFoundException path) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.path-not-found-exception", null, ApplicationMessage.WARNING)); return; } catch (Exception e) { JCRExceptionManager.process(uiApp, e); return; } if (!PermissionUtil.canAddNode(destNode)) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.can-not-move-node", null, ApplicationMessage.WARNING)); uiExplorer.updateAjax(event); return; } if (uiExplorer.nodeIsLocked(destNode)) { Object[] arg = { destPath }; uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.node-locked", arg, ApplicationMessage.WARNING)); return; } if (!destNode.isCheckedOut()) { uiApp.addMessage(new ApplicationMessage("UIActionBar.msg.node-checkedin", null)); return; } try { if (nodePath.indexOf(";") > -1) { moveMultiNode(nodePath.split(";"), destNode, event); } else { moveNode(nodePath, null, destNode, event); } session.save(); uiExplorer.updateAjax(event); } catch (AccessDeniedException ace) { Object[] arg = { destPath }; uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.has-not-add-permission", arg, ApplicationMessage.WARNING)); return; } catch (LockException lock) { Object[] arg = { nodePath }; uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.node-locked", arg, ApplicationMessage.WARNING)); return; } catch (ConstraintViolationException constraint) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.move-constraint-exception", null, ApplicationMessage.WARNING)); return; } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error("an unexpected error occurs while selecting the node", e); } JCRExceptionManager.process(uiApp, e); return; } } private static Node getNodeByPath(String srcPath, UIJCRExplorer uiExplorer) throws Exception { Matcher matcher = UIWorkingArea.FILE_EXPLORER_URL_SYNTAX.matcher(srcPath); String wsName = null; if (matcher.find()) { wsName = matcher.group(1); srcPath = matcher.group(2); } else { throw new IllegalArgumentException("The ObjectId is invalid '" + srcPath + "'"); } Session srcSession = uiExplorer.getSessionByWorkspace(wsName); return uiExplorer.getNodeByPath(srcPath, srcSession, false); } private static void moveNode(String srcPath, Node selectedNode, Node destNode, Event<?> event) throws Exception { UIComponent uiComponent = (UIComponent)event.getSource(); UIJCRExplorer uiExplorer = uiComponent.getAncestorOfType(UIJCRExplorer.class); UIApplication uiApp = uiComponent.getAncestorOfType(UIApplication.class); if (srcPath.indexOf(":/") > -1 || (selectedNode != null)) { String[] arrSrcPath = srcPath.split(":/"); if ((srcPath.contains(":/") && ("/" + arrSrcPath[1]).equals(destNode.getPath())) || (selectedNode != null && selectedNode.equals(destNode))) { uiApp.addMessage(new ApplicationMessage("UIWorkingArea.msg.can-not-move-to-itself", null, ApplicationMessage.WARNING)); return; } } if(uiExplorer.isEditingDocument()) { uiApp.addMessage(new ApplicationMessage("UIWorkingArea.msg.is-editing", null, ApplicationMessage.WARNING)); return; } String messagePath = ""; try { if (selectedNode == null) { selectedNode = getNodeByPath(srcPath, uiExplorer); } Session srcSession = selectedNode.getSession(); if (!selectedNode.isCheckedOut()) { uiApp.addMessage(new ApplicationMessage("UIActionBar.msg.node-checkedin", null, ApplicationMessage.WARNING)); return; } uiExplorer.addLockToken(selectedNode); String destPath = destNode.getPath(); messagePath = destPath; // Make destination path without index on final name destPath = destPath.concat("/").concat(selectedNode.getName()); Workspace srcWorkspace = srcSession.getWorkspace(); Workspace destWorkspace = destNode.getSession().getWorkspace(); if (srcPath.indexOf(":/") > -1) srcPath = srcPath.substring(srcPath.indexOf(":/") + 1); // Get thumbnail node if source node ThumbnailService thumbnailService = WCMCoreUtils.getService(ThumbnailService.class); Node srcThumbnailNode = thumbnailService.getThumbnailNode(selectedNode); ListenerService listenerService = WCMCoreUtils.getService(ListenerService.class); ActivityCommonService activityService = WCMCoreUtils.getService(ActivityCommonService.class); Node desNode = null; if (srcWorkspace.equals(destWorkspace)) { srcWorkspace.move(srcPath, destPath); //delete EXO_RESTORE_LOCATION if source is in trash removeMixinEXO_RESTORE_LOCATION(srcSession, destPath); desNode = (Node)srcSession.getItem(destPath); LockUtil.changeLockToken(srcPath, desNode); if (activityService.isAcceptedNode(desNode) || desNode.getPrimaryNodeType().getName().equals(NodetypeConstant.NT_FILE)) { listenerService.broadcast(ActivityCommonService.NODE_MOVED_ACTIVITY, desNode, desNode.getPath()); } srcSession.save(); } else { destWorkspace.clone(srcWorkspace.getName(), srcPath, destPath, false); desNode =(Node) destWorkspace.getSession().getItem(destPath); if (activityService.isAcceptedNode(desNode) || desNode.getPrimaryNodeType().getName().equals(NodetypeConstant.NT_FILE)) { listenerService.broadcast(ActivityCommonService.NODE_MOVED_ACTIVITY, desNode, destPath); } //delete EXO_RESTORE_LOCATION if source is in trash removeMixinEXO_RESTORE_LOCATION(destWorkspace.getSession(), destPath); destWorkspace.getSession().save(); } // Update thumbnail node for destination node thumbnailService.copyThumbnailNode(srcThumbnailNode, desNode); } catch (ItemExistsException iee) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.paste-node-same-name", null, ApplicationMessage.WARNING)); return; } catch (Exception e) { Object[] args = { srcPath, messagePath }; uiApp.addMessage(new ApplicationMessage("UIWorkingArea.msg.move-problem", args, ApplicationMessage.WARNING)); return; } } private static void removeMixinEXO_RESTORE_LOCATION(Session session, String restorePath) throws Exception { Node sameNameNode = ((Node) session.getItem(restorePath)); Node parent = sameNameNode.getParent(); String name = sameNameNode.getName(); NodeIterator nodeIter = parent.getNodes(name); while (nodeIter.hasNext()) { Node node = nodeIter.nextNode(); if (node.isNodeType(Utils.EXO_RESTORELOCATION)) node.removeMixin(Utils.EXO_RESTORELOCATION); } } private static void moveMultiNode(String[] srcPaths, Node destNode, Event<? extends UIComponent> event) throws Exception { Map<String, Node> mapNode = new HashMap <String, Node>(); UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); Node node; for (int i = 0; i < srcPaths.length; i++) { node = getNodeByPath(srcPaths[i], uiExplorer); mapNode.put(node.getPath(), node); } String path = null; Iterator<String> iterator = mapNode.keySet().iterator(); while (iterator.hasNext()) { path = iterator.next(); node = mapNode.get(path); node.refresh(true); moveNode(node.getPath(), node, destNode, event); } } public static class MoveNodeActionListener extends UIWorkingAreaActionListener<MoveNodeManageComponent> { public void processEvent(Event<MoveNodeManageComponent> event) throws Exception { String nodePath = event.getRequestContext().getRequestParameter(OBJECTID); String destPath = event.getRequestContext().getRequestParameter("destInfo"); if (isInTrash(nodePath) && isInTrash(destPath)) return; else if (isInTrash(destPath)) ((UIWorkingArea)event.getSource().getParent()).getChild(DeleteManageComponent.class).doDelete(nodePath, event); else MoveNodeManageComponent.processMultipleSelection(nodePath.trim(), destPath.trim(), event); } private static boolean isInTrash(String path) { PortletRequestContext pcontext = (PortletRequestContext)WebuiRequestContext.getCurrentInstance(); PortletPreferences portletPref = pcontext.getRequest().getPreferences(); String trashHomeNodePath = portletPref.getValue(Utils.TRASH_HOME_NODE_PATH, ""); String trashWorkspace = portletPref.getValue(Utils.TRASH_WORKSPACE, ""); return (path.startsWith(trashHomeNodePath) || path.startsWith(trashWorkspace + ":" + trashHomeNodePath)); } } @Override public Class<? extends UIAbstractManager> getUIAbstractManagerClass() { return null; } }
14,354
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
CustomManageComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/rightclick/manager/CustomManageComponent.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.component.explorer.rightclick.manager; import java.util.Arrays; import java.util.List; import javax.jcr.Node; import javax.jcr.Session; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.UIWorkingArea; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotInTrashFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotTrashHomeNodeFilter; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIWorkingAreaActionListener; import org.exoplatform.ecm.webui.utils.JCRExceptionManager; import org.exoplatform.services.cms.actions.ActionServiceContainer; import org.exoplatform.services.log.ExoLogger; import org.exoplatform.services.log.Log; 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.UIComponent; import org.exoplatform.webui.event.Event; 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 SARL * Author : Hoang Van Hung * hunghvit@gmail.com * Aug 6, 2009 */ @ComponentConfig( events = { @EventConfig(listeners = CustomManageComponent.CustomActionListener.class) } ) public class CustomManageComponent extends UIAbstractManagerComponent { private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[]{new IsNotInTrashFilter(), new IsNotTrashHomeNodeFilter() }); private final static Log LOG = ExoLogger.getLogger(CustomManageComponent.class.getName()); @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } public static void customManage(Event<? extends UIComponent> event, UIJCRExplorer uiExplorer, UIApplication uiApp) throws Exception { UIWorkingArea uicomp = event.getSource().getParent(); String nodePath = event.getRequestContext().getRequestParameter(OBJECTID); String actionName = event.getRequestContext().getRequestParameter("actionName"); String wsName = event.getRequestContext().getRequestParameter(UIWorkingArea.WS_NAME); Session session = uiExplorer.getSessionByWorkspace(wsName); ActionServiceContainer actionService = uicomp.getApplicationComponent(ActionServiceContainer.class); try { Node node = uiExplorer.getNodeByPath(nodePath, session); String userId = event.getRequestContext().getRemoteUser(); actionService.executeAction(userId, node, actionName); Object[] arg = { actionName }; uiApp.addMessage(new ApplicationMessage("UIWorkingArea.msg.execute-successfully", arg)); uiExplorer.updateAjax(event); } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error("an unexpected error occurs while calling custom action on the node", e); } JCRExceptionManager.process(uiApp, e); uiExplorer.updateAjax(event); } } public static class CustomActionListener extends UIWorkingAreaActionListener<CustomManageComponent> { public void processEvent(Event<CustomManageComponent> event) throws Exception { UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); UIApplication uiApp = event.getSource().getAncestorOfType(UIApplication.class); customManage(event, uiExplorer, uiApp); } } @Override public Class<? extends UIAbstractManager> getUIAbstractManagerClass() { return null; } }
4,850
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
CutManageComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/rightclick/manager/CutManageComponent.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.component.explorer.rightclick.manager; import java.util.Arrays; import java.util.List; import java.util.regex.Matcher; import javax.jcr.Node; import javax.jcr.PathNotFoundException; import javax.jcr.Session; import javax.jcr.nodetype.ConstraintViolationException; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.UIWorkingArea; import org.exoplatform.ecm.webui.component.explorer.control.filter.*; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIWorkingAreaActionListener; import org.exoplatform.ecm.webui.utils.JCRExceptionManager; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.services.cms.clipboard.ClipboardService; import org.exoplatform.services.cms.clipboard.jcr.model.ClipboardCommand; import org.exoplatform.services.log.ExoLogger; import org.exoplatform.services.log.Log; import org.exoplatform.services.security.ConversationState; import org.exoplatform.services.wcm.utils.WCMCoreUtils; 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.event.Event; 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 SARL * Author : Hoang Van Hung * hunghvit@gmail.com * Aug 6, 2009 */ @ComponentConfig( events = { @EventConfig(listeners = CutManageComponent.CutActionListener.class) } ) public class CutManageComponent extends UIAbstractManagerComponent { private final static Log LOG = ExoLogger.getLogger(CutManageComponent.class.getName()); private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[] { new IsNotSpecificFolderNodeFilter(), new IsNotInTrashFilter(), new CanCutNodeFilter(), new IsNotLockedFilter(), new IsNotTrashHomeNodeFilter(), new IsNotEditingDocumentFilter()}); @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } private static void processCut(String nodePath, Event<CutManageComponent> event, UIJCRExplorer uiExplorer, boolean isMultiSelect) throws Exception { UIWorkingArea uiWorkingArea = uiExplorer.getChild(UIWorkingArea.class); UIApplication uiApp = event.getSource().getAncestorOfType(UIApplication.class); Matcher matcher = UIWorkingArea.FILE_EXPLORER_URL_SYNTAX.matcher(nodePath); String wsName = null; if (matcher.find()) { wsName = matcher.group(1); nodePath = matcher.group(2); } else { throw new IllegalArgumentException("The ObjectId is invalid '"+ nodePath + "'"); } Session session = uiExplorer.getSessionByWorkspace(wsName); Node selectedNode; try { // Use the method getNodeByPath because it is link aware selectedNode = uiExplorer.getNodeByPath(nodePath, session, false); // Reset the path to manage the links that potentially create virtual path nodePath = selectedNode.getPath(); // Reset the session to manage the links that potentially change of workspace session = selectedNode.getSession(); // Reset the workspace name to manage the links that potentially change of workspace wsName = session.getWorkspace().getName(); } catch(ConstraintViolationException cons) { uiExplorer.getSession().refresh(false); uiExplorer.refreshExplorer(); uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.constraintviolation-exception", null,ApplicationMessage.WARNING)); uiExplorer.updateAjax(event); return; } catch(PathNotFoundException path) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.path-not-found-exception", null,ApplicationMessage.WARNING)); return; } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error("an unexpected error occurs while cuting the node", e); } JCRExceptionManager.process(uiApp, e); return; } try { ClipboardCommand clipboard = new ClipboardCommand(ClipboardCommand.CUT, nodePath, wsName); ClipboardService clipboardService = WCMCoreUtils.getService(ClipboardService.class); String userId = ConversationState.getCurrent().getIdentity().getUserId(); clipboardService.addClipboardCommand(userId, clipboard, false); if (isMultiSelect) { clipboardService.addClipboardCommand(userId, clipboard, true); } } catch (Exception e) { JCRExceptionManager.process(uiApp, e); } } private static void processMultipleCut(String[] nodePaths, Event<CutManageComponent> event, UIJCRExplorer uiExplorer) throws Exception { for(int i=0; i< nodePaths.length; i++) { processCut(nodePaths[i], event, uiExplorer, true); } } public static void cutManage(Event<CutManageComponent> event, UIJCRExplorer uiExplorer) throws Exception { UIWorkingArea uiWorkingArea = event.getSource().getParent(); String nodePath = event.getRequestContext().getRequestParameter(OBJECTID); if(nodePath.indexOf(";") > -1) { ClipboardService clipboardService = WCMCoreUtils.getService(ClipboardService.class); String userId = ConversationState.getCurrent().getIdentity().getUserId(); clipboardService.clearClipboardList(userId, true); processMultipleCut(Utils.removeChildNodes(nodePath), event, uiExplorer); } else { processCut(nodePath, event, uiExplorer, false); } } public static class CutActionListener extends UIWorkingAreaActionListener<CutManageComponent> { public void processEvent(Event<CutManageComponent> event) throws Exception { UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); cutManage(event, uiExplorer); } } @Override public Class<? extends UIAbstractManager> getUIAbstractManagerClass() { return null; } }
7,671
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
CreateNewVersionManageComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/rightclick/manager/CreateNewVersionManageComponent.java
package org.exoplatform.ecm.webui.component.explorer.rightclick.manager; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.UIWorkingArea; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsContainBinaryFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotEditingDocumentFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotInTrashFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotLockedFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsVersionableFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.CanSetPropertyFilter; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIWorkingAreaActionListener; import org.exoplatform.services.cms.documents.AutoVersionService; import org.exoplatform.services.log.ExoLogger; import org.exoplatform.services.log.Log; import org.exoplatform.services.wcm.utils.WCMCoreUtils; import org.exoplatform.wcm.webui.reader.ContentReader; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.config.annotation.EventConfig; import org.exoplatform.webui.event.Event; 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; import javax.jcr.Node; import javax.jcr.Session; import java.util.Arrays; import java.util.List; import java.util.regex.Matcher; /** * Created by The eXo Platform SEA * Author : eXoPlatform * toannh@exoplatform.com * On 8/6/15 * Create a new version of document */ @ComponentConfig( events = { @EventConfig(listeners = CreateNewVersionManageComponent.CreateNewVersionActionListener.class) } ) public class CreateNewVersionManageComponent extends UIAbstractManagerComponent { private static Log log = ExoLogger.getExoLogger(CreateNewVersionManageComponent.class); private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[]{ new IsVersionableFilter(), new IsNotInTrashFilter(), new IsNotEditingDocumentFilter(), new IsNotLockedFilter(), new CanSetPropertyFilter(), new IsContainBinaryFilter()}); @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } @Override public Class<? extends UIAbstractManager> getUIAbstractManagerClass() { return null; } public static class CreateNewVersionActionListener extends UIWorkingAreaActionListener<CreateNewVersionManageComponent> { @Override public void processEvent(Event<CreateNewVersionManageComponent> event) throws Exception { String nodePath = event.getRequestContext().getRequestParameter(OBJECTID); UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); if (nodePath == null) { nodePath = uiExplorer.getCurrentWorkspace() + ':' + uiExplorer.getCurrentPath(); } Matcher matcher = UIWorkingArea.FILE_EXPLORER_URL_SYNTAX.matcher(nodePath); String wsName = null; if (matcher.find()) { wsName = matcher.group(1); nodePath = matcher.group(2); } else { throw new IllegalArgumentException("The ObjectId is invalid '"+ nodePath + "'"); } Session session = uiExplorer.getSessionByWorkspace(wsName); // Use the method getNodeByPath because it is link aware Node node = uiExplorer.getNodeByPath(nodePath, session); AutoVersionService autoVersionService = WCMCoreUtils.getService(AutoVersionService.class); autoVersionService.autoVersion(node); String msg = event.getRequestContext().getApplicationResourceBundle().getString("DocumentAuto.message"); msg = msg.replace("{0}", ContentReader.simpleEscapeHtml("<span style='font-weight:bold;'>" + node.getName() + "</span>")); event.getRequestContext().getJavascriptManager().require("SHARED/wcm-utils", "wcm_utils") .addScripts("eXo.ecm.WCMUtils.showNotice(\""+msg+"\", 'true'); "); } } }
4,273
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
CheckOutManageComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/rightclick/manager/CheckOutManageComponent.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.component.explorer.rightclick.manager; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.GregorianCalendar; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.regex.Matcher; import javax.jcr.Node; import javax.jcr.PathNotFoundException; import javax.jcr.Session; import javax.jcr.Value; import javax.jcr.ValueFactory; import javax.jcr.version.Version; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.UIWorkingArea; import org.exoplatform.ecm.webui.component.explorer.control.filter.CanSetPropertyFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotCheckedOutFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotContainBinaryFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotInTrashFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotLockedFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotTrashHomeNodeFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsVersionableFilter; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIWorkingAreaActionListener; import org.exoplatform.ecm.webui.utils.JCRExceptionManager; import org.exoplatform.portal.webui.util.Util; import org.exoplatform.services.wcm.extensions.publication.lifecycle.authoring.AuthoringPublicationConstant; import org.exoplatform.services.wcm.publication.lifecycle.stageversion.config.VersionData; import org.exoplatform.services.wcm.publication.lifecycle.stageversion.config.VersionLog; 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.UIComponent; import org.exoplatform.webui.event.Event; 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 SARL * Author : Hoang Van Hung * hunghvit@gmail.com * Aug 6, 2009 */ @ComponentConfig( events = { @EventConfig(listeners = CheckOutManageComponent.CheckOutActionListener.class) } ) public class CheckOutManageComponent extends UIAbstractManagerComponent { private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[]{new IsNotInTrashFilter(), new CanSetPropertyFilter(), new IsNotLockedFilter(), new IsNotCheckedOutFilter(), new IsVersionableFilter(), new IsNotTrashHomeNodeFilter(), new IsNotContainBinaryFilter()}); @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } public static void checkOutManage(Event<? extends UIComponent> event, UIJCRExplorer uiExplorer, UIApplication uiApp) throws Exception { String nodePath = event.getRequestContext().getRequestParameter(OBJECTID); if (nodePath == null) { nodePath = uiExplorer.getCurrentWorkspace() + ':' + uiExplorer.getCurrentPath(); } Matcher matcher = UIWorkingArea.FILE_EXPLORER_URL_SYNTAX.matcher(nodePath); String wsName = null; if (matcher.find()) { wsName = matcher.group(1); nodePath = matcher.group(2); } else { throw new IllegalArgumentException("The ObjectId is invalid '"+ nodePath + "'"); } Session session = uiExplorer.getSessionByWorkspace(wsName); // Use the method getNodeByPath because it is link aware Node node = uiExplorer.getNodeByPath(nodePath, session); // Reset the path to manage the links that potentially create virtual path nodePath = node.getPath(); // Reset the session to manage the links that potentially change of workspace session = node.getSession(); // Reset the workspace name to manage the links that potentially change of workspace wsName = session.getWorkspace().getName(); try { String userId = ""; try { userId = Util.getPortalRequestContext().getRemoteUser(); } catch (Exception e) { userId = node.getSession().getUserID(); } Version liveVersion = node.getBaseVersion(); node.checkout(); String currentState = node.getProperty("publication:currentState").getString(); VersionLog versionLog = new VersionLog(liveVersion.getName(),currentState, userId,new GregorianCalendar(),"UIPublicationHistory.create-version"); Map<String, VersionData> revisionsMap = getRevisionData(node); VersionData liveRevisionData = new VersionData(liveVersion.getUUID(),currentState,userId); revisionsMap.put(liveVersion.getUUID(), liveRevisionData); addRevisionData(node, revisionsMap.values()); addLog(node,versionLog); node.save(); } catch(PathNotFoundException path) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.path-not-found-exception", null,ApplicationMessage.WARNING)); return; } catch (Exception e) { JCRExceptionManager.process(uiApp, e); uiExplorer.updateAjax(event); } } public static class CheckOutActionListener extends UIWorkingAreaActionListener<CheckOutManageComponent> { public void processEvent(Event<CheckOutManageComponent> event) throws Exception { UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); UIApplication uiApp = event.getSource().getAncestorOfType(UIApplication.class); checkOutManage(event, uiExplorer, uiApp); } } @Override public Class<? extends UIAbstractManager> getUIAbstractManagerClass() { return null; } /** * Adds the log. * * @param node the node * @param versionLog the version log * @throws Exception the exception */ private static void addLog(Node node, VersionLog versionLog) throws Exception { Value[] values = node.getProperty(AuthoringPublicationConstant.HISTORY).getValues(); ValueFactory valueFactory = node.getSession().getValueFactory(); List<Value> list = new ArrayList<Value>(Arrays.asList(values)); list.add(valueFactory.createValue(versionLog.toString())); node.setProperty(AuthoringPublicationConstant.HISTORY, list.toArray(new Value[] {})); } /** * Gets the revision data. * * @param node the node * @return the revision data * @throws Exception the exception */ private static Map<String, VersionData> getRevisionData(Node node) throws Exception { Map<String, VersionData> map = new HashMap<String, VersionData>(); try { for (Value v : node.getProperty(AuthoringPublicationConstant.REVISION_DATA_PROP).getValues()) { VersionData versionData = VersionData.toVersionData(v.getString()); map.put(versionData.getUUID(), versionData); } } catch (Exception e) { return map; } return map; } /** * Adds the revision data. * * @param node the node * @param list the list * @throws Exception the exception */ private static void addRevisionData(Node node, Collection<VersionData> list) throws Exception { List<Value> valueList = new ArrayList<Value>(); ValueFactory factory = node.getSession().getValueFactory(); for (VersionData versionData : list) { valueList.add(factory.createValue(versionData.toStringValue())); } node.setProperty(AuthoringPublicationConstant.REVISION_DATA_PROP, valueList.toArray(new Value[] {})); } }
9,104
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
EmptyTrashManageComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/rightclick/manager/EmptyTrashManageComponent.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.component.explorer.rightclick.manager; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotInTrashFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsTrashHomeNodeFilter; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIWorkingAreaActionListener; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.services.cms.actions.ActionServiceContainer; import org.exoplatform.services.cms.documents.TrashService; import org.exoplatform.services.cms.taxonomy.TaxonomyService; import org.exoplatform.services.cms.thumbnail.ThumbnailService; import org.exoplatform.services.jcr.core.ManageableRepository; import org.exoplatform.services.wcm.utils.WCMCoreUtils; import org.exoplatform.web.application.ApplicationMessage; 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.EventConfig; import org.exoplatform.webui.core.UIApplication; import org.exoplatform.webui.core.UIComponent; import org.exoplatform.webui.event.Event; 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; import javax.jcr.Node; import javax.jcr.NodeIterator; import javax.jcr.Session; import javax.jcr.nodetype.NodeType; import javax.portlet.PortletPreferences; import java.util.Arrays; import java.util.List; /** * Created by The eXo Platform SARL * Author : Nguyen Anh Vu * anhvurz90@gmail.com * Nov 13, 2009 * 5:19:23 PM */ @ComponentConfig( events = { @EventConfig(listeners = EmptyTrashManageComponent.EmptyTrashActionListener.class, confirm = "EmptyTrashManageComponent.msg.confirm-delete") }) public class EmptyTrashManageComponent extends UIAbstractManagerComponent { private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[] { new IsNotInTrashFilter(), new IsTrashHomeNodeFilter() } ); @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } public static void emptyTrashManage(Event<? extends UIComponent> event, UIJCRExplorer uiExplorer) throws Exception { Node trashHomeNode = getTrashHomeNode(uiExplorer); NodeIterator nodeIter = trashHomeNode.getNodes(); UIApplication uiApp = uiExplorer.getAncestorOfType(UIApplication.class); if (nodeIter.getSize() == 0) { return; } String currentUser = WCMCoreUtils.getRemoteUser(); boolean error = false; while (nodeIter.hasNext()) { try { Node node = nodeIter.nextNode(); if (node.hasProperty(Utils.EXO_LASTMODIFIER)) if (currentUser.equals(node.getProperty(Utils.EXO_LASTMODIFIER).getString())) { deleteNode(node, uiExplorer, event); } } catch (Exception ex) { error = true; } } if (error) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.error-when-emptying-trash", null, ApplicationMessage.WARNING)); } } private static void deleteNode(Node nodeToDelete, UIJCRExplorer uiExplorer, Event<? extends UIComponent> event) throws Exception { PortletRequestContext pcontext = (PortletRequestContext)WebuiRequestContext.getCurrentInstance(); PortletPreferences portletPref = pcontext.getRequest().getPreferences(); String trashWorkspace = portletPref.getValue(Utils.TRASH_WORKSPACE, ""); String nodePath = nodeToDelete.getPath(); // Use the method getNodeByPath because it is link aware Session session = uiExplorer.getSessionByWorkspace(trashWorkspace); // Use the method getNodeByPath because it is link aware Node node = uiExplorer.getNodeByPath(nodePath, session, false); // Reset the session to manage the links that potentially change of // workspace session = node.getSession(); // Reset the workspace name to manage the links that potentially // change of workspace trashWorkspace = session.getWorkspace().getName(); // Use the method getNodeByPath because it is link aware node = uiExplorer.getNodeByPath(nodePath, session, false); // If node has taxonomy TaxonomyService taxonomyService = uiExplorer.getApplicationComponent(TaxonomyService.class); List<Node> listTaxonomyTrees = taxonomyService.getAllTaxonomyTrees(); List<Node> listExistedTaxonomy = taxonomyService.getAllCategories(node); for (Node existedTaxonomy : listExistedTaxonomy) { for (Node taxonomyTrees : listTaxonomyTrees) { if(existedTaxonomy.getPath().contains(taxonomyTrees.getPath())) { taxonomyService.removeCategory(node, taxonomyTrees.getName(), existedTaxonomy.getPath().substring(taxonomyTrees.getPath().length())); break; } } } uiExplorer.addLockToken(node); Node parentNode = node.getParent(); uiExplorer.addLockToken(parentNode); ActionServiceContainer actionService = uiExplorer.getApplicationComponent(ActionServiceContainer.class); actionService.removeAction(node, uiExplorer.getRepositoryName()); ThumbnailService thumbnailService = uiExplorer.getApplicationComponent(ThumbnailService.class); thumbnailService.processRemoveThumbnail(node); TrashService trashService = uiExplorer.getApplicationComponent(TrashService.class); trashService.removeRelations(node, uiExplorer.getSystemProvider()); node.remove(); parentNode.save(); uiExplorer.updateAjax(event); } private static void removeMixins(Node node) throws Exception { NodeType[] mixins = node.getMixinNodeTypes(); for (NodeType nodeType : mixins) { node.removeMixin(nodeType.getName()); } } private static Node getTrashHomeNode(UIJCRExplorer uiExplorer) throws Exception { PortletRequestContext pcontext = (PortletRequestContext)WebuiRequestContext.getCurrentInstance(); PortletPreferences portletPref = pcontext.getRequest().getPreferences(); String trashHomeNodePath = portletPref.getValue(Utils.TRASH_HOME_NODE_PATH, ""); String trashWorkspace = portletPref.getValue(Utils.TRASH_WORKSPACE, ""); ManageableRepository manageableRepository = WCMCoreUtils.getRepository(); Session trashSession = uiExplorer.getSessionProvider().getSession(trashWorkspace, manageableRepository); return (Node)trashSession.getItem(trashHomeNodePath); } public static class EmptyTrashActionListener extends UIWorkingAreaActionListener<EmptyTrashManageComponent> { public void processEvent(Event<EmptyTrashManageComponent> event) throws Exception { UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); emptyTrashManage(event, uiExplorer); } } @Override public Class<? extends UIAbstractManager> getUIAbstractManagerClass() { return null; } }
8,032
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
DeleteManageComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/rightclick/manager/DeleteManageComponent.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.component.explorer.rightclick.manager; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.LinkedList; import java.util.List; import java.util.Queue; import java.util.ResourceBundle; import java.util.regex.Matcher; import javax.jcr.AccessDeniedException; import javax.jcr.Node; import javax.jcr.NodeIterator; import javax.jcr.PathNotFoundException; import javax.jcr.PropertyIterator; import javax.jcr.ReferentialIntegrityException; import javax.jcr.Session; import javax.jcr.lock.LockException; import javax.jcr.nodetype.ConstraintViolationException; import javax.jcr.query.Query; import javax.jcr.version.VersionException; import javax.portlet.PortletPreferences; import org.apache.commons.codec.binary.StringUtils; import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.lang3.Validate; import org.exoplatform.container.PortalContainer; import org.exoplatform.ecm.utils.lock.LockUtil; import org.exoplatform.ecm.webui.component.explorer.UIConfirmMessage; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.UIWorkingArea; import org.exoplatform.ecm.webui.component.explorer.control.filter.CanDeleteNodeFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotEditingDocumentFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotLockedFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotMandatoryChildNode; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotSpecificFolderNodeFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotTrashHomeNodeFilter; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIWorkingAreaActionListener; import org.exoplatform.ecm.webui.utils.JCRExceptionManager; import org.exoplatform.ecm.webui.utils.PermissionUtil; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.portal.webui.util.Util; import org.exoplatform.services.cms.actions.ActionServiceContainer; import org.exoplatform.services.cms.documents.TrashService; import org.exoplatform.services.cms.folksonomy.NewFolksonomyService; import org.exoplatform.services.cms.jcrext.activity.ActivityCommonService; import org.exoplatform.services.cms.link.LinkManager; import org.exoplatform.services.cms.link.LinkUtils; import org.exoplatform.services.cms.relations.RelationsService; import org.exoplatform.services.cms.taxonomy.TaxonomyService; import org.exoplatform.services.cms.templates.TemplateService; import org.exoplatform.services.cms.thumbnail.ThumbnailService; import org.exoplatform.services.ecm.publication.PublicationService; import org.exoplatform.services.jcr.core.ManageableRepository; import org.exoplatform.services.jcr.ext.audit.AuditService; import org.exoplatform.services.jcr.ext.common.SessionProvider; import org.exoplatform.services.listener.ListenerService; import org.exoplatform.services.log.ExoLogger; import org.exoplatform.services.log.Log; import org.exoplatform.services.wcm.core.NodetypeConstant; import org.exoplatform.services.wcm.extensions.publication.lifecycle.authoring.AuthoringPublicationConstant; import org.exoplatform.services.wcm.publication.PublicationDefaultStates; import org.exoplatform.services.wcm.publication.WCMPublicationService; import org.exoplatform.services.wcm.utils.WCMCoreUtils; import org.exoplatform.web.application.ApplicationMessage; import org.exoplatform.web.application.RequestContext; 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.UIPopupWindow; import org.exoplatform.webui.event.Event; 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 SARL * Author : Hoang Van Hung * hunghvit@gmail.com * Aug 6, 2009 */ @ComponentConfig( events = { @EventConfig(listeners = DeleteManageComponent.DeleteActionListener.class) } ) public class DeleteManageComponent extends UIAbstractManagerComponent { private static final Log LOG = ExoLogger.getLogger(DeleteManageComponent.class.getName()); private static final String DELETE_FILE_CONFIRM_TITLE = "UIDeleteFileConfirmMessage"; private static final String DELETE_FOLDER_CONFIRM_TITLE = "UIDeleteFolderConfirmMessage"; private static final String DELETE_ITEMS_CONFIRM_TITLE = "UIDeleteItemsConfirmMessage"; private static final int GENERIC_TYPE = 1; private static final int FILE_TYPE = 2; private static final int FOLDER_TYPE = 3; private static final int FOLDERS = 1; //"001"; private static final int FILES = 2; //"010"; private static final int FILES_AND_FOLDERS = 3; //"011"; private static final int GENERIC = 4; //"100"; private static final int GENERICS_AND_FOLDERS = 5; //"101"; private static final int GENERICS_AND_FILES = 6; //"110"; private static final int GENERICS_AND_FILES_AND_FOLDERS = 7; //"111"; private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[]{new IsNotSpecificFolderNodeFilter(), new IsNotLockedFilter(), new CanDeleteNodeFilter(), new IsNotTrashHomeNodeFilter(), new IsNotEditingDocumentFilter(), new IsNotMandatoryChildNode()}); @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } private String processRemoveMultiple(String[] nodePaths, Event<?> event) throws Exception { StringBuilder trashId = new StringBuilder(); UIJCRExplorer uiExplorer = getAncestorOfType(UIJCRExplorer.class); UIApplication uiApp = uiExplorer.getAncestorOfType(UIApplication.class); Arrays.sort(nodePaths,Collections.reverseOrder()); for (int i = 0; i < nodePaths.length ; i++) { try { Node node = this.getNodeByPath(nodePaths[i]); Validate.isTrue(node != null, "The ObjectId is invalid '" + nodePaths[i] + "'"); trashId.append(processRemoveOrMoveToTrash(nodePaths[i], node, event, true, true)).append(";"); } catch (PathNotFoundException path) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.path-not-found-exception", null, ApplicationMessage.WARNING)); event.getRequestContext().addUIComponentToUpdateByAjax(uiApp.getUIPopupMessages()); } catch (Exception e) { JCRExceptionManager.process(uiApp, e); } } return trashId.substring(0,trashId.length() - 1); } private void removeAuditForNode(Node node) throws Exception { UIJCRExplorer uiExplorer = this.getAncestorOfType(UIJCRExplorer.class); ManageableRepository repository = uiExplorer.getRepository(); SessionProvider sessionProvider = uiExplorer.getSystemProvider(); Session session = null; session = sessionProvider.getSession(node.getSession().getWorkspace().getName(), repository); Node rootNode = session.getRootNode(); if (rootNode.hasNode("exo:audit") && rootNode.getNode("exo:audit").hasNode(node.getUUID())) { rootNode.getNode("exo:audit").getNode(node.getUUID()).remove(); session.save(); } } /** * Remove or MoveToTrash * * @param nodePath * @param node * @param event * @param isMultiSelect * @param checkToMoveToTrash * @return * 0: node removed * -1: move to trash failed * trashId: moved to trash successfully * @throws Exception */ private String processRemoveOrMoveToTrash(String nodePath, Node node, Event<?> event, boolean isMultiSelect, boolean checkToMoveToTrash) throws Exception { String trashId="-1"; if (!checkToMoveToTrash || Utils.isInTrash(node)) { processRemoveNode(nodePath, node, event, isMultiSelect); return "0"; }else { trashId = moveToTrash(nodePath, node, event, isMultiSelect); if (!trashId.equals("-1")) { //Broadcast the event when delete folder, in case deleting file, Thrash service will broadcast event ListenerService listenerService = WCMCoreUtils.getService(ListenerService.class); TrashService trashService = WCMCoreUtils.getService(TrashService.class); node = trashService.getNodeByTrashId(trashId); if (node != null && !isDocumentNodeType(node) && !node.getPrimaryNodeType().getName().equals(NodetypeConstant.NT_FILE)) { Queue<Node> queue = new LinkedList<Node>(); queue.add(node); //Broadcast event to remove file activities Node tempNode = null; try { while (!queue.isEmpty()) { tempNode = queue.poll(); if (isDocumentNodeType(tempNode) || tempNode.getPrimaryNodeType().getName().equals(NodetypeConstant.NT_FILE)) { listenerService.broadcast(ActivityCommonService.FILE_REMOVE_ACTIVITY, tempNode.getParent(), tempNode); } else { for (NodeIterator iter = tempNode.getNodes(); iter.hasNext(); ) { Node childNode = iter.nextNode(); if(isDocumentNodeType(childNode) || childNode.isNodeType(NodetypeConstant.NT_UNSTRUCTURED) || childNode.isNodeType(NodetypeConstant.NT_FOLDER)) queue.add(childNode); } } } } catch (Exception e) { if (LOG.isWarnEnabled()) { LOG.warn(e.getMessage()); } } } } } return trashId; } /** * Move Node to Trash * Return -1: move failed * Return trashId: move successfully with trashId * @param srcPath * @param node * @param event * @param isMultiSelect * @return * @throws Exception */ private String moveToTrash(String srcPath, Node node, Event<?> event, boolean isMultiSelect) throws Exception { TrashService trashService = WCMCoreUtils.getService(TrashService.class); AuditService auditService = WCMCoreUtils.getService(AuditService.class); boolean ret = true; String trashId="-1"; final String virtualNodePath = srcPath; UIJCRExplorer uiExplorer = getAncestorOfType(UIJCRExplorer.class); UIApplication uiApp = uiExplorer.getAncestorOfType(UIApplication.class); try { uiExplorer.addLockToken(node); } catch (Exception e) { JCRExceptionManager.process(uiApp, e); return trashId; } try { if (node.isLocked()) { LockUtil.removeLock(node); node.unlock(); } //remove audit relations if(auditService.hasHistory(node)) { auditService.removeHistory(node); } //remove mixin auditable if( node.isNodeType(Utils.EXO_AUDITABLE)){ node.removeMixin(Utils.EXO_AUDITABLE); } node.save(); //remove all relations that refer to this node RelationsService relationService = uiApp.getApplicationComponent(RelationsService.class) ; PropertyIterator iter = node.getReferences(); while (iter.hasNext()) { Node refNode = iter.nextProperty().getParent(); relationService.removeRelation(refNode, node.getPath()); } if (!node.isCheckedOut()) throw new VersionException("node is locked, can't move to trash node :" + node.getPath()); if (!PermissionUtil.canRemoveNode(node)) throw new AccessDeniedException("access denied, can't move to trash node:" + node.getPath()); SessionProvider sessionProvider = uiExplorer.getSessionProvider(); Node currentNode = uiExplorer.getCurrentNode(); try { trashId = trashService.moveToTrash(node, sessionProvider); } catch (PathNotFoundException ex) { ret = false; } String currentPath = LinkUtils.getExistPath(currentNode, uiExplorer.getCurrentPath()); uiExplorer.setCurrentPath(currentPath); uiExplorer.updateAjax(event); } catch (LockException e) { if (LOG.isErrorEnabled()) { LOG.error("node is locked, can't move to trash node :" + node.getPath()); } ApplicationMessage appMessage = new ApplicationMessage("UIPopupMenu.msg.can-not-remove-locked-node", new String[] {node.getPath()}, ApplicationMessage.ERROR); appMessage.setArgsLocalized(false); uiApp.addMessage(appMessage); uiExplorer.updateAjax(event); ret = false; } catch (VersionException e) { if (LOG.isErrorEnabled()) { LOG.error("node is checked in, can't move to trash node:" + node.getPath()); } removeMixinEXO_RESTORE_LOCATION(node); ApplicationMessage appMessage = new ApplicationMessage("UIPopupMenu.msg.can-not-remove-checked-in-node", new String[] {node.getPath()}, ApplicationMessage.ERROR); appMessage.setArgsLocalized(false); uiApp.addMessage(appMessage); uiExplorer.updateAjax(event); ret = false; } catch (AccessDeniedException e) { if (LOG.isErrorEnabled()) { LOG.error("access denied, can't move to trash node:" + node.getPath()); } ApplicationMessage appMessage = new ApplicationMessage("UIPopupMenu.msg.access-denied-to-delete", new String[] {node.getPath()}, ApplicationMessage.ERROR); appMessage.setArgsLocalized(false); uiApp.addMessage(appMessage); uiExplorer.updateAjax(event); ret = false; } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error("an unexpected error occurs", e); } uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.unexpected-error", new String[] {node.getPath()}, ApplicationMessage.ERROR)); uiExplorer.updateAjax(event); ret = false; } if (!isMultiSelect) { if (uiExplorer.getCurrentPath().equals(virtualNodePath)) uiExplorer.setSelectNode(LinkUtils.getParentPath(virtualNodePath)); else uiExplorer.setSelectNode(uiExplorer.getCurrentPath()); } return (ret)?trashId:"-1"; } private void processRemoveNode(String nodePath, Node node, Event<?> event, boolean isMultiSelect) throws Exception { final String virtualNodePath = nodePath; UIJCRExplorer uiExplorer = getAncestorOfType(UIJCRExplorer.class); Node currentNode = uiExplorer.getCurrentNode(); Session session = node.getSession(); UIApplication uiApp = uiExplorer.getAncestorOfType(UIApplication.class); try { uiExplorer.addLockToken(node); } catch (Exception e) { JCRExceptionManager.process(uiApp, e); return; } Node parentNode = node.getParent(); uiExplorer.addLockToken(parentNode); try { // If node has taxonomy TaxonomyService taxonomyService = uiExplorer.getApplicationComponent(TaxonomyService.class); List<Node> listTaxonomyTrees = taxonomyService.getAllTaxonomyTrees(); List<Node> listExistedTaxonomy = taxonomyService.getAllCategories(node); for (Node existedTaxonomy : listExistedTaxonomy) { for (Node taxonomyTrees : listTaxonomyTrees) { if(existedTaxonomy.getPath().contains(taxonomyTrees.getPath())) { taxonomyService.removeCategory(node, taxonomyTrees.getName(), existedTaxonomy.getPath().substring(taxonomyTrees.getPath().length())); break; } } } ActionServiceContainer actionService = getApplicationComponent(ActionServiceContainer.class); actionService.removeAction(node, uiExplorer.getRepositoryName()); ThumbnailService thumbnailService = getApplicationComponent(ThumbnailService.class); thumbnailService.processRemoveThumbnail(node); NewFolksonomyService newFolksonomyService = getApplicationComponent(NewFolksonomyService.class); newFolksonomyService.removeTagsOfNodeRecursively(node, uiExplorer.getRepository() .getConfiguration() .getDefaultWorkspaceName(), WCMCoreUtils.getRemoteUser(), getGroups()); //trashService.removeRelations(node, uiExplorer.getSystemProvider(), uiExplorer.getRepositoryName()); if (PermissionUtil.canRemoveNode(node) && node.isNodeType(Utils.EXO_AUDITABLE)) { removeAuditForNode(node); } // Workaround TASK-55628 : Remove referenced live revisions updateReferencedLiveRevisionFromCopies(node, session); // End Workaround TASK-55628 //Remove symlinks LinkManager linkManager = WCMCoreUtils.getService(LinkManager.class); if(!node.isNodeType(NodetypeConstant.EXO_SYMLINK)) { for(Node symlink : linkManager.getAllLinks(node, NodetypeConstant.EXO_SYMLINK)) { symlink.remove(); symlink.getSession().save(); } } node.remove(); parentNode.save(); } catch (VersionException ve) { LOG.warn("Error deleting node", ve); uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.remove-verion-exception", null, ApplicationMessage.WARNING)); uiExplorer.updateAjax(event); return; } catch (ReferentialIntegrityException ref) { LOG.warn("Error deleting node", ref); session.refresh(false); uiExplorer.refreshExplorer(); uiApp.addMessage(new ApplicationMessage( "UIPopupMenu.msg.remove-referentialIntegrityException", null, ApplicationMessage.WARNING)); uiExplorer.updateAjax(event); return; } catch (ConstraintViolationException cons) { LOG.warn("Error deleting node", cons); session.refresh(false); uiExplorer.refreshExplorer(); uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.constraintviolation-exception", null, ApplicationMessage.WARNING)); uiExplorer.updateAjax(event); return; } catch (LockException lockException) { LOG.warn("Error deleting node", lockException); uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.node-locked-other-person", null, ApplicationMessage.WARNING)); uiExplorer.updateAjax(event); return; } catch (Exception e) { LOG.warn("an unexpected error occurs while removing the node", e); JCRExceptionManager.process(uiApp, e); return; } if (!isMultiSelect) { if (currentNode.getPath().equals(virtualNodePath)) uiExplorer.setSelectNode(LinkUtils.getParentPath(virtualNodePath)); else uiExplorer.setSelectNode(currentNode.getPath()); } } /** * Workaround TASK-55628 : This method will search for nodes which references * the same 'liveRevision' than the current node to delete. * * In general case, this incoherence is due to the fact that the copy/paste node didn't * considered the fact that a copied node must reference its own liveRevision. * * @param nodeToDelete * @param session * @throws Exception */ private void updateReferencedLiveRevisionFromCopies(Node nodeToDelete, Session session) throws Exception { PublicationService publicationService = PortalContainer.getInstance().getComponentInstanceOfType(PublicationService.class); WCMPublicationService wcmPublicationService = PortalContainer.getInstance() .getComponentInstanceOfType(WCMPublicationService.class); if (wcmPublicationService.isEnrolledInWCMLifecycle(nodeToDelete) && nodeToDelete.hasProperty(AuthoringPublicationConstant.LIVE_REVISION_PROP)) { String liveRevisionReference = nodeToDelete.getProperty(AuthoringPublicationConstant.LIVE_REVISION_PROP).getString(); Query query = session.getWorkspace() .getQueryManager() .createQuery("SELECT * from " + AuthoringPublicationConstant.PUBLICATION_LIFECYCLE_TYPE + " WHERE " + AuthoringPublicationConstant.LIVE_REVISION_PROP + " = '" + liveRevisionReference + "'", Query.SQL); NodeIterator nodes = query.execute().getNodes(); String siteName = Util.getPortalRequestContext().getPortalOwner(); String remoteUser = Util.getPortalRequestContext().getRemoteUser(); while (nodes.hasNext()) { Node copiedNode = nodes.nextNode(); String lifecycleName = publicationService.getNodeLifecycleName(copiedNode); String originalState = null; if (copiedNode.hasProperty(AuthoringPublicationConstant.CURRENT_STATE)) { originalState = copiedNode.getProperty(AuthoringPublicationConstant.CURRENT_STATE).getString(); } else { originalState = PublicationDefaultStates.DRAFT; } wcmPublicationService.unsubcribeLifecycle(copiedNode); wcmPublicationService.enrollNodeInLifecycle(copiedNode, lifecycleName); // Make content draft again wcmPublicationService.updateLifecyleOnChangeContent(copiedNode, siteName, remoteUser); // Change node publication status to original state String newState = publicationService.getCurrentState(copiedNode); if (!StringUtils.equals(newState, originalState)) { wcmPublicationService.updateLifecyleOnChangeContent(copiedNode, siteName, remoteUser, originalState); } } } } private void processRemoveMultiple(String[] nodePaths, String[] wsNames, Event<?> event) throws Exception { for (int i = 0; i < nodePaths.length; i++) { processRemove(nodePaths[i], wsNames[i], event, true); } } private void processRemove(String nodePath, String wsName, Event<?> event, boolean isMultiSelect) throws Exception { if (wsName == null) { wsName = getDefaultWorkspace(); } doDelete(wsName.concat(":").concat(nodePath), event); } private String getDefaultWorkspace() { UIJCRExplorer uiExplorer = getAncestorOfType(UIJCRExplorer.class); return uiExplorer.getCurrentDriveWorkspace(); } public void doDelete(String nodePath, String wsName, Event<?> event) throws Exception { UIJCRExplorer uiExplorer = getAncestorOfType(UIJCRExplorer.class); if (nodePath.indexOf(";") > -1) { processRemoveMultiple(nodePath.split(";"), wsName.split(";"), event); } else { processRemove(nodePath, wsName, event, false); } uiExplorer.updateAjax(event); } public void doDeleteWithoutTrash(String nodePath, Event<?> event) throws Exception { doDelete(nodePath, event, false); } public void doDelete(String nodePath, Event<?> event) throws Exception { doDelete(nodePath, event, true); } public void doDelete(String nodePath, Event<?> event, boolean checkToMoveToTrash) throws Exception { RequestContext context = RequestContext.getCurrentInstance(); UIJCRExplorer uiExplorer = getAncestorOfType(UIJCRExplorer.class); UIWorkingArea uiWorkingArea = getAncestorOfType(UIWorkingArea.class); ResourceBundle res = context.getApplicationResourceBundle(); String deleteNotice = ""; String deleteNoticeParam = ""; String trashId = ""; if (nodePath.indexOf(";") > -1) { trashId = processRemoveMultiple(Utils.removeChildNodes(nodePath), event); if(checkToMoveToTrash) deleteNotice = "UIWorkingArea.msg.feedback-delete-multi"; else deleteNotice = "UIWorkingArea.msg.feedback-delete-permanently-multi"; deleteNoticeParam = String.valueOf(nodePath.split(";").length); } else { UIApplication uiApp = uiExplorer.getAncestorOfType(UIApplication.class); // Prepare to remove try { Node node = this.getNodeByPath(nodePath); if(checkToMoveToTrash) deleteNotice = "UIWorkingArea.msg.feedback-delete"; else deleteNotice = "UIWorkingArea.msg.feedback-delete-permanently"; deleteNoticeParam = StringEscapeUtils.unescapeHtml4(Utils.getTitle(node)); if (node != null) { trashId = processRemoveOrMoveToTrash(node.getPath(), node, event, false, checkToMoveToTrash); } } catch (PathNotFoundException path) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.path-not-found-exception", null, ApplicationMessage.WARNING)); event.getRequestContext().addUIComponentToUpdateByAjax(uiApp.getUIPopupMessages()); return; } catch (Exception e) { JCRExceptionManager.process(uiApp, e); return; } } deleteNotice = res.getString(deleteNotice); deleteNotice = deleteNotice.replace("{" + 0 + "}", deleteNoticeParam); deleteNotice = deleteNotice.replace("\"", "'"); deleteNotice = StringEscapeUtils.escapeHtml4(deleteNotice); if(checkToMoveToTrash) { String undoLink = getUndoLink(trashId); uiWorkingArea.setDeleteNotice(deleteNotice); uiWorkingArea.setNodePathDelete(undoLink); } else { uiWorkingArea.setWCMNotice(deleteNotice); } uiExplorer.updateAjax(event); } /** * Get undo link to restore nodes that deleted * * @param trashId node path of nodes want to restore * @throws Exception */ private String getUndoLink(String trashId) throws Exception { String undoLink = ""; TrashService trashService = WCMCoreUtils.getService(TrashService.class); UIJCRExplorer uiExplorer = getAncestorOfType(UIJCRExplorer.class); PortletPreferences portletPrefs = uiExplorer.getPortletPreferences(); String trashWorkspace = portletPrefs.getValue(Utils.TRASH_WORKSPACE, ""); StringBuffer sb = new StringBuffer(); if (trashId.indexOf(";") > -1) { String[] nodePaths = trashId.split(";"); for(int i=0; i<nodePaths.length; i++) { trashId = nodePaths[i].substring(nodePaths[i].indexOf(":") + 1, nodePaths[i].length()); sb.append(trashWorkspace).append(":").append(trashService.getNodeByTrashId(trashId).getPath()).append(";"); } undoLink = sb.toString(); if(undoLink.length() > 0) undoLink = undoLink.substring(0,undoLink.length()-1); } else { trashId = trashId.substring(trashId.indexOf(":") + 1, trashId.length()); Node tmpNode = trashService.getNodeByTrashId(trashId); sb.append(tmpNode.getPath()).append(";"); undoLink = sb.toString(); if(undoLink.length() > 0) { undoLink = undoLink.substring(0,undoLink.length()-1); undoLink = trashWorkspace + ":" +undoLink; } } return undoLink; } private boolean isInTrashFolder(String nodePath) throws Exception { UIJCRExplorer uiExplorer = getAncestorOfType(UIJCRExplorer.class); String wsName = null; Session session = null; String[] nodePaths = nodePath.split(";"); for(int i=0; i<nodePaths.length; i++) { Matcher matcher = UIWorkingArea.FILE_EXPLORER_URL_SYNTAX.matcher(nodePaths[i]); if (matcher.find()) { wsName = matcher.group(1); nodePath = matcher.group(2); session = uiExplorer.getSessionByWorkspace(wsName); Node node = uiExplorer.getNodeByPath(nodePath, session, false); return Utils.isInTrash(node); } } return false; } private boolean isDocumentNodeType(Node node) throws Exception { boolean isDocument = true; TemplateService templateService = PortalContainer.getInstance().getComponentInstanceOfType(TemplateService.class); isDocument = templateService.getAllDocumentNodeTypes().contains(node.getPrimaryNodeType().getName()); return isDocument; } /** * Get the content type of one node * * @param nodePath node path of one node * @throws Exception */ private int getContentType(String nodePath) throws Exception { int content_type = 1; Node node = getNodeByPath(nodePath); String primaryType = node.getPrimaryNodeType().getName(); if(node.isNodeType(NodetypeConstant.NT_FILE)) content_type = 2; else if (primaryType.equals(NodetypeConstant.NT_FOLDER) || primaryType.equals(NodetypeConstant.NT_UNSTRUCTURED)) content_type = 3; else content_type = 1; return content_type; } /** * Get the content type of multiple nodes * * @param nodePath node path of multiple nodes * @throws Exception */ private int getMultiContentType(String nodePath) throws Exception { StringBuffer sBuffer = new StringBuffer(); String[] nodePaths = nodePath.split(";"); boolean isGeneric = false; boolean isFile = false; boolean isFolder = false; for(int i=0; i<nodePaths.length; i++) { Node node = getNodeByPath(nodePaths[i]); String primaryType = node.getPrimaryNodeType().getName(); if(node.isNodeType(NodetypeConstant.NT_FILE)) isFile = true; else if (primaryType.equals(NodetypeConstant.NT_FOLDER) || primaryType.equals(NodetypeConstant.NT_UNSTRUCTURED)) isFolder = true; else isGeneric = true; } if(isGeneric) sBuffer.append("1"); else sBuffer.append("0"); if(isFile) sBuffer.append("1"); else sBuffer.append("0"); if(isFolder) sBuffer.append("1"); else sBuffer.append("0"); return Integer.parseInt(sBuffer.toString(),2); } public static void deleteManage(Event<? extends UIComponent> event) throws Exception { UIWorkingArea uiWorkingArea = event.getSource().getParent(); UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); String nodePath = event.getRequestContext().getRequestParameter(OBJECTID); UIConfirmMessage uiConfirmMessage = uiWorkingArea.createUIComponent(UIConfirmMessage.class, null, null); UIApplication uiApp = uiExplorer.getAncestorOfType(UIApplication.class); DeleteManageComponent deleteManageComponent = uiWorkingArea.getChild(DeleteManageComponent.class); //get nodes that have relations referring to them List<String> listNodesHaveRelations = null; try { listNodesHaveRelations = checkRelations(nodePath, uiExplorer); } catch (PathNotFoundException pathEx) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.path-not-found-exception", null, ApplicationMessage.WARNING)); return; } boolean isInTrashFolder = deleteManageComponent.isInTrashFolder(nodePath); uiConfirmMessage.setNodeInTrash(isInTrashFolder); String nodeName = nodePath; int contentType = 1; int multiContentType = 1; String message_key = ""; // Check and set the title for Delete Confirmation Dialog if(nodePath.indexOf(";") > 0) { uiConfirmMessage.setId(DELETE_ITEMS_CONFIRM_TITLE); multiContentType = deleteManageComponent.getMultiContentType(nodePath); } else { Node node = deleteManageComponent.getNodeByPath(nodePath); if(node != null) nodeName = StringEscapeUtils.unescapeHtml4(Utils.getTitle(node)); contentType = deleteManageComponent.getContentType(nodePath); if(contentType == FILE_TYPE) uiConfirmMessage.setId(DELETE_FILE_CONFIRM_TITLE); else if (contentType == FOLDER_TYPE) uiConfirmMessage.setId(DELETE_FOLDER_CONFIRM_TITLE); } //show confirm message if (listNodesHaveRelations != null && listNodesHaveRelations.size() > 0) { // there are some nodes which have relations referring to them // in the deleting node list // build node list to string to add into the confirm message StringBuffer sb = new StringBuffer(); for (int i = 0; i < listNodesHaveRelations.size(); i++) { sb.append("'").append(listNodesHaveRelations.get(i)).append("', "); } //remove "," character at the end of string // Node has relations means it is not in Trash folder and is not Folder if (nodePath.indexOf(";") < 0) { // in case: delete one node that has relations if(contentType == GENERIC_TYPE) message_key = "UIWorkingArea.msg.confirm-delete-has-relations"; else if(contentType == FILE_TYPE) message_key = "UIWorkingArea.msg.confirm-delete-file-has-relations"; else if (contentType == FOLDER_TYPE) { message_key = "UIWorkingArea.msg.confirm-delete-folder-has-relations"; } uiConfirmMessage.setMessageKey(message_key); uiConfirmMessage.setArguments(new String[] { nodeName }); } else { // in case: delete multiple node have relations switch(multiContentType) { case FOLDERS: message_key = "UIWorkingArea.msg.confirm-delete-multi-nodes-folder-have-relations"; break; case FILES: message_key = "UIWorkingArea.msg.confirm-delete-multi-nodes-file-have-relations"; break; case FILES_AND_FOLDERS: message_key = "UIWorkingArea.msg.confirm-delete-multi-nodes-file-and-folder-have-relations"; break; case GENERIC: message_key = "UIWorkingArea.msg.confirm-delete-multi-nodes-generic-have-relations"; break; case GENERICS_AND_FOLDERS: message_key = "UIWorkingArea.msg.confirm-delete-multi-nodes-generic-and" + "-folder-have-relations"; break; case GENERICS_AND_FILES: message_key = "UIWorkingArea.msg.confirm-delete-multi-nodes-generic-" + "and-file-have-relations"; break; case GENERICS_AND_FILES_AND_FOLDERS: message_key = "UIWorkingArea.msg.confirm-delete-multi-nodes-generic-" + "and-file-and-folder-have-relations"; break; default: message_key = "UIWorkingArea.msg.confirm-delete-multi-nodes-generic-have-relations"; break; } uiConfirmMessage.setMessageKey(message_key); uiConfirmMessage.setArguments(new String[] { Integer.toString(nodePath.split(";").length) }); } } else { //there isn't any node which has relations referring to it in the deleting node list if (isInTrashFolder) { if (nodePath.indexOf(";") > -1) { // delete multi switch(multiContentType) { case FOLDERS: message_key = "UIWorkingArea.msg.confirm-delete-multi-nodes-folder-permanently"; break; case FILES: message_key = "UIWorkingArea.msg.confirm-delete-multi-nodes-file-permanently"; break; case FILES_AND_FOLDERS: message_key = "UIWorkingArea.msg.confirm-delete-multi-nodes-file-and-folder-permanently"; break; case GENERIC: message_key = "UIWorkingArea.msg.confirm-delete-multi-nodes-generic-permanently"; break; case GENERICS_AND_FOLDERS: message_key = "UIWorkingArea.msg.confirm-delete-multi-nodes-generic-and-folder-permanently"; break; case GENERICS_AND_FILES: message_key = "UIWorkingArea.msg.confirm-delete-multi-nodes-generic-and-file-permanently"; break; case GENERICS_AND_FILES_AND_FOLDERS: message_key = "UIWorkingArea.msg.confirm-delete-multi-nodes-generic-and-file-and-folder-permanently"; break; default: message_key = "UIWorkingArea.msg.confirm-delete-multi-nodes-generic-permanently"; break; } uiConfirmMessage.setMessageKey(message_key); uiConfirmMessage.setArguments(new String[] { Integer.toString(nodePath.split(";").length) }); } else { // delete one if(contentType == GENERIC_TYPE) message_key = "UIWorkingArea.msg.confirm-delete-permanently"; else if(contentType == FILE_TYPE) message_key = "UIWorkingArea.msg.confirm-delete-file-permanently"; else if(contentType == FOLDER_TYPE) message_key = "UIWorkingArea.msg.confirm-delete-folder-permanently"; uiConfirmMessage.setMessageKey(message_key); uiConfirmMessage.setArguments(new String[] { nodeName }); } } else { if (nodePath.indexOf(";") > -1) { // delete multi switch(multiContentType) { case FOLDERS: message_key = "UIWorkingArea.msg.confirm-delete-multi-nodes-folder"; break; case FILES: message_key = "UIWorkingArea.msg.confirm-delete-multi-nodes-file"; break; case FILES_AND_FOLDERS: message_key = "UIWorkingArea.msg.confirm-delete-multi-nodes-file-and-folder"; break; case GENERIC: message_key = "UIWorkingArea.msg.confirm-delete-multi-nodes-generic"; break; case GENERICS_AND_FOLDERS: message_key = "UIWorkingArea.msg.confirm-delete-multi-nodes-generic-and-folder"; break; case GENERICS_AND_FILES: message_key = "UIWorkingArea.msg.confirm-delete-multi-nodes-generic-and-file"; break; case GENERICS_AND_FILES_AND_FOLDERS: message_key = "UIWorkingArea.msg.confirm-delete-multi-nodes-generic-and-file-" + "and-folder"; break; default: message_key = "UIWorkingArea.msg.confirm-delete-multi-nodes-generic"; break; } uiConfirmMessage.setMessageKey(message_key); uiConfirmMessage.setArguments(new String[] { Integer.toString(nodePath.split(";").length) }); } else { // delete one if(contentType == GENERIC_TYPE) message_key = "UIWorkingArea.msg.confirm-delete"; else if(contentType == FILE_TYPE) message_key = "UIWorkingArea.msg.confirm-delete-file"; else if(contentType == FOLDER_TYPE) message_key = "UIWorkingArea.msg.confirm-delete-folder"; uiConfirmMessage.setMessageKey(message_key); uiConfirmMessage.setArguments(new String[] { nodeName }); } } } uiConfirmMessage.setNodePath(nodePath); UIPopupWindow popUp = uiExplorer.getChild(UIPopupWindow.class); popUp.setUIComponent(uiConfirmMessage); popUp.setShowMask(true); popUp.setShow(true); event.getRequestContext().addUIComponentToUpdateByAjax(popUp); } /** * This function uses to get a node list that have relations referring to them in the deleting node list * * @param nodePath The list of nodes that user wants to delete * @param uiExplorer uiExplorer * @return The list of nodes that have relations referring to them * @throws Exception */ private static List<String> checkRelations(String nodePath, UIJCRExplorer uiExplorer) throws Exception{ Node node = null; String wsName = null; Session session = null; String[] nodePaths = nodePath.split(";"); RelationsService rlService = WCMCoreUtils.getService(RelationsService.class); SessionProvider sessionProvider = WCMCoreUtils.getUserSessionProvider(); List<String> listNodesHaveRelations = new ArrayList<String>(); for (int i = 0; i < nodePaths.length; i++) { Matcher matcher = UIWorkingArea.FILE_EXPLORER_URL_SYNTAX.matcher(nodePaths[i]); if (matcher.find()) { wsName = matcher.group(1); nodePath = matcher.group(2); session = uiExplorer.getSessionByWorkspace(wsName); node = uiExplorer.getNodeByPath(nodePath, session, false); if (rlService.getRelations(node, sessionProvider).size()>0) { //check references listNodesHaveRelations.add(nodePath); } } else { throw new IllegalArgumentException("The ObjectId is invalid '" + nodePath + "'"); } } return listNodesHaveRelations; } /** * Get node by node path. * * @param nodePath node path of specific node with syntax [workspace:node path] * @return Node of specific node nath * @throws Exception */ private Node getNodeByPath(String nodePath) throws Exception { UIJCRExplorer uiExplorer = this.getAncestorOfType(UIJCRExplorer.class); Matcher matcher = UIWorkingArea.FILE_EXPLORER_URL_SYNTAX.matcher(nodePath); if (!matcher.find()) return null; String wsName = matcher.group(1); nodePath = matcher.group(2); Session session = uiExplorer.getSessionByWorkspace(wsName); return uiExplorer.getNodeByPath(nodePath, session, false); } private String getGroups() throws Exception { StringBuilder ret = new StringBuilder(); for (String group : Utils.getGroups()) ret.append(group).append(';'); ret.deleteCharAt(ret.length() - 1); return ret.toString(); } @Override public Class<? extends UIAbstractManager> getUIAbstractManagerClass() { return null; } public static class DeleteActionListener extends UIWorkingAreaActionListener<DeleteManageComponent> { public void processEvent(Event<DeleteManageComponent> event) throws Exception { deleteManage(event); } } private void removeMixinEXO_RESTORE_LOCATION(Node node) throws Exception { if (node.isNodeType(Utils.EXO_RESTORELOCATION)) { node.removeMixin(Utils.EXO_RESTORELOCATION); node.save(); } } }
43,374
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UploadNewVersionManageComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/rightclick/manager/UploadNewVersionManageComponent.java
package org.exoplatform.ecm.webui.component.explorer.rightclick.manager; import org.exoplatform.ecm.webui.component.explorer.control.filter.CanSetPropertyFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsContainBinaryFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsEditableFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotEditingDocumentFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotInTrashFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotLockedFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsVersionableFilter; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIActionBarActionListener; import org.exoplatform.services.log.ExoLogger; import org.exoplatform.services.log.Log; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.config.annotation.EventConfig; import org.exoplatform.webui.event.Event; 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; import java.util.Arrays; import java.util.List; /** * Created by The eXo Platform SEA * Author : eXoPlatform * toannh@exoplatform.com * On 8/6/15 * Upload a new version of document */ @ComponentConfig( events = { @EventConfig(listeners = UploadNewVersionManageComponent.UploadNewVersionActionListener.class) } ) public class UploadNewVersionManageComponent extends UIAbstractManagerComponent { private static Log log = ExoLogger.getExoLogger(UploadNewVersionManageComponent.class); private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[]{ new IsVersionableFilter(), new IsNotInTrashFilter(), new IsNotEditingDocumentFilter(), new IsContainBinaryFilter(), new IsEditableFilter(), new IsNotInTrashFilter(), new IsNotEditingDocumentFilter(), new IsNotLockedFilter(), new CanSetPropertyFilter()}); @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } @Override public Class<? extends UIAbstractManager> getUIAbstractManagerClass() { return null; } public static class UploadNewVersionActionListener extends UIActionBarActionListener<UploadNewVersionManageComponent> { @Override public void processEvent(Event<UploadNewVersionManageComponent> event) throws Exception { log.info("upload new version"); } } }
2,743
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
FavouriteManageComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/rightclick/manager/FavouriteManageComponent.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.component.explorer.rightclick.manager; import java.util.Arrays; import java.util.List; import java.util.regex.Matcher; import javax.jcr.AccessDeniedException; import javax.jcr.Node; import javax.jcr.PathNotFoundException; import javax.jcr.Session; import javax.jcr.lock.LockException; import javax.jcr.version.VersionException; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.UIWorkingArea; import org.exoplatform.ecm.webui.component.explorer.control.filter.CanSetPropertyFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsCheckedOutFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsDocumentFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotFavouriteFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotInTrashFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotLockedFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotTrashHomeNodeFilter; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIWorkingAreaActionListener; import org.exoplatform.ecm.webui.utils.JCRExceptionManager; import org.exoplatform.ecm.webui.utils.PermissionUtil; import org.exoplatform.services.cms.documents.FavoriteService; import org.exoplatform.services.cms.link.LinkManager; import org.exoplatform.services.log.ExoLogger; import org.exoplatform.services.log.Log; import org.exoplatform.services.security.ConversationState; import org.exoplatform.services.wcm.utils.WCMCoreUtils; 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.event.Event; 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 SARL * Author : Nguyen Anh Vu * anhvurz90@gmail.com * Oct 14, 2009 */ @ComponentConfig( events = { @EventConfig(listeners = FavouriteManageComponent.AddToFavouriteActionListener.class) } ) public class FavouriteManageComponent extends UIAbstractManagerComponent { private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[]{new IsNotInTrashFilter(), new IsNotFavouriteFilter(), new IsNotLockedFilter(), new IsCheckedOutFilter(), new IsNotTrashHomeNodeFilter(), new IsDocumentFilter() }); private final static Log LOG = ExoLogger.getLogger(FavouriteManageComponent.class.getName()); @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } private static void addToFavourite(String srcPath, Event<FavouriteManageComponent> event) throws Exception { UIWorkingArea uiWorkingArea = event.getSource().getParent(); UIJCRExplorer uiExplorer = uiWorkingArea.getAncestorOfType(UIJCRExplorer.class); FavoriteService favoriteService = WCMCoreUtils.getService(FavoriteService.class); UIApplication uiApp = uiWorkingArea.getAncestorOfType(UIApplication.class); Matcher matcher = UIWorkingArea.FILE_EXPLORER_URL_SYNTAX.matcher(srcPath); String wsName = null; Node node = null; if (matcher.find()) { wsName = matcher.group(1); srcPath = matcher.group(2); } else { throw new IllegalArgumentException("The ObjectId is invalid '"+ srcPath + "'"); } Session session = uiExplorer.getSessionByWorkspace(wsName); try { // Use the method getNodeByPath because it is link aware node = uiExplorer.getNodeByPath(srcPath, session, false); //check if node is link LinkManager lnkManager = uiExplorer.getApplicationComponent(LinkManager.class); if (lnkManager.isLink(node) && lnkManager.isTargetReachable(node)) { node = lnkManager.getTarget(node); } // Reset the path to manage the links that potentially create virtual path srcPath = node.getPath(); // Reset the session to manage the links that potentially change of workspace session = node.getSession(); // Reset the workspace name to manage the links that potentially change of workspace wsName = session.getWorkspace().getName(); } catch(PathNotFoundException path) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.path-not-found-exception", null,ApplicationMessage.WARNING)); return; } try { uiExplorer.addLockToken(node); } catch (Exception e) { JCRExceptionManager.process(uiApp, e); return; } try { if (!node.isCheckedOut()) { throw new VersionException("node is locked, can't add favourite to node:" + node.getPath()); } favoriteService.addFavorite(node, ConversationState.getCurrent().getIdentity().getUserId()); uiExplorer.updateAjax(event); } catch (LockException e) { if (LOG.isErrorEnabled()) { LOG.error("node is locked, can't add favourite to node:" + node.getPath()); } JCRExceptionManager.process(uiApp, e); uiExplorer.updateAjax(event); } catch (VersionException e) { if (LOG.isErrorEnabled()) { LOG.error("node is checked in, can't add favourite to node:" + node.getPath()); } JCRExceptionManager.process(uiApp, e); uiExplorer.updateAjax(event); } catch (AccessDeniedException e) { if (LOG.isErrorEnabled()) { LOG.error("access denied, can't add favourite to node:" + node.getPath()); } JCRExceptionManager.process(uiApp, e); uiExplorer.updateAjax(event); } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error("an unexpected error occurs", e); } JCRExceptionManager.process(uiApp, e); uiExplorer.updateAjax(event); } } public static class AddToFavouriteActionListener extends UIWorkingAreaActionListener<FavouriteManageComponent> { private void multiAddToFavourite(String[] paths, Event<FavouriteManageComponent> event) throws Exception { for (String path : paths) { if (acceptForMultiNode(event, path)) { addToFavourite(path, event); } } } private void favouriteManage(Event<FavouriteManageComponent> event) throws Exception { String srcPath = event.getRequestContext().getRequestParameter(OBJECTID); if (srcPath.indexOf(';') > -1) { multiAddToFavourite(srcPath.split(";"), event); } else { addToFavourite(srcPath, event); } } public void processEvent(Event<FavouriteManageComponent> event) throws Exception { favouriteManage(event); } } @Override public Class<? extends UIAbstractManager> getUIAbstractManagerClass() { return null; } }
8,167
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
CheckInManageComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/rightclick/manager/CheckInManageComponent.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.component.explorer.rightclick.manager; import java.util.Arrays; import java.util.List; import java.util.regex.Matcher; import javax.jcr.AccessDeniedException; import javax.jcr.Node; import javax.jcr.PathNotFoundException; import javax.jcr.Session; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.UIWorkingArea; import org.exoplatform.ecm.webui.component.explorer.control.filter.CanSetPropertyFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsCheckedOutFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotContainBinaryFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotInTrashFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotLockedFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotTrashHomeNodeFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsVersionableFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsVersionableOrAncestorFilter; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIWorkingAreaActionListener; import org.exoplatform.ecm.webui.utils.JCRExceptionManager; 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.UIComponent; import org.exoplatform.webui.event.Event; 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 SARL * Author : Hoang Van Hung * hunghvit@gmail.com * Aug 6, 2009 */ @ComponentConfig( events = { @EventConfig(listeners = CheckInManageComponent.CheckInActionListener.class) } ) public class CheckInManageComponent extends UIAbstractManagerComponent { private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[]{new IsNotInTrashFilter(), new CanSetPropertyFilter(), new IsNotLockedFilter(), new IsVersionableOrAncestorFilter(), new IsCheckedOutFilter(), new IsVersionableFilter(), new IsNotTrashHomeNodeFilter(), new IsNotContainBinaryFilter()}); @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } public static void checkInManage(Event<? extends UIComponent> event, UIJCRExplorer uiExplorer, UIApplication uiApp) throws Exception { String nodePath = event.getRequestContext().getRequestParameter(OBJECTID); if (nodePath == null) { nodePath = uiExplorer.getCurrentWorkspace() + ':' + uiExplorer.getCurrentPath(); } Matcher matcher = UIWorkingArea.FILE_EXPLORER_URL_SYNTAX.matcher(nodePath); String wsName = null; if (matcher.find()) { wsName = matcher.group(1); nodePath = matcher.group(2); } else { throw new IllegalArgumentException("The ObjectId is invalid '"+ nodePath + "'"); } Session session = uiExplorer.getSessionByWorkspace(wsName); // Use the method getNodeByPath because it is link aware Node node = uiExplorer.getNodeByPath(nodePath, session); // Reset the path to manage the links that potentially create virtual path nodePath = node.getPath(); // Reset the session to manage the links that potentially change of workspace session = node.getSession(); // Reset the workspace name to manage the links that potentially change of workspace wsName = session.getWorkspace().getName(); try { Node parentNode = node.getParent(); uiExplorer.addLockToken(parentNode); node.checkin(); } catch(PathNotFoundException path) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.path-not-found-exception", null,ApplicationMessage.WARNING)); return; } catch (AccessDeniedException adEx) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.can-not-checkin-node", null, ApplicationMessage.WARNING)); uiExplorer.updateAjax(event); return; } catch (Exception e) { JCRExceptionManager.process(uiApp, e); uiExplorer.updateAjax(event); } } public static class CheckInActionListener extends UIWorkingAreaActionListener<CheckInManageComponent> { public void processEvent(Event<CheckInManageComponent> event) throws Exception { UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); UIApplication uiApp = event.getSource().getAncestorOfType(UIApplication.class); checkInManage(event, uiExplorer, uiApp); } } @Override public Class<? extends UIAbstractManager> getUIAbstractManagerClass() { return null; } }
6,342
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
UnlockManageComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/rightclick/manager/UnlockManageComponent.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.component.explorer.rightclick.manager; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.UIWorkingArea; import org.exoplatform.ecm.webui.component.explorer.control.filter.*; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIWorkingAreaActionListener; 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.config.UserACL; import org.exoplatform.services.jcr.core.ManageableRepository; import org.exoplatform.services.log.ExoLogger; import org.exoplatform.services.log.Log; import org.exoplatform.services.wcm.utils.WCMCoreUtils; 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.event.Event; 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; import javax.jcr.Node; import javax.jcr.PathNotFoundException; import javax.jcr.Session; import javax.jcr.lock.LockException; import javax.jcr.version.VersionException; import java.util.Arrays; import java.util.List; import java.util.regex.Matcher; /** * Created by The eXo Platform SARL * Author : Hoang Van Hung * hunghvit@gmail.com * Aug 6, 2009 */ @ComponentConfig( events = { @EventConfig(listeners = UnlockManageComponent.UnlockActionListener.class) } ) public class UnlockManageComponent extends UIAbstractManagerComponent { private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[]{new IsNotInTrashFilter(), new IsHoldsLockFilter(), new IsNotLockedFilter(true, true), new CanSetPropertyFilter(), new IsCheckedOutFilter(), new IsNotTrashHomeNodeFilter() }); private static final Log LOG = ExoLogger.getLogger(UnlockManageComponent.class.getName()); @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } private static Node getNodeByPath(String nodePath, UIJCRExplorer uiExplorer) throws Exception { Matcher matcher = UIWorkingArea.FILE_EXPLORER_URL_SYNTAX.matcher(nodePath); String wsName = null; if (matcher.find()) { wsName = matcher.group(1); nodePath = matcher.group(2); } else { throw new IllegalArgumentException("The ObjectId is invalid '"+ nodePath + "'"); } Session session = uiExplorer.getSessionByWorkspace(wsName); return uiExplorer.getNodeByPath(nodePath, session); } private static void processUnlock(String nodePath, Event<UnlockManageComponent> event, UIJCRExplorer uiExplorer) throws Exception { UIApplication uiApp = uiExplorer.getAncestorOfType(UIApplication.class); Node node; Session session; try { // Use the method getNodeByPath because it is link aware node = getNodeByPath(nodePath, uiExplorer); // Reset the session to manage the links that potentially change of workspace session = node.getSession(); } catch(PathNotFoundException path) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.path-not-found-exception", null,ApplicationMessage.WARNING)); return; } catch (Exception e) { JCRExceptionManager.process(uiApp, e); return; } String superUser = WCMCoreUtils.getService(UserACL.class).getSuperUser(); String remoteUser = WCMCoreUtils.getRemoteUser(); if (remoteUser.equalsIgnoreCase(superUser)) { session = WCMCoreUtils.getSystemSessionProvider() .getSession(node.getSession().getWorkspace().getName(), (ManageableRepository) node.getSession().getRepository()); node = (Node)session.getItem(node.getPath()); } try { if(node.holdsLock()) { String lockToken = LockUtil.getLockToken(node); if(lockToken != null) { session.addLockToken(lockToken); } node.unlock(); node.removeMixin(Utils.MIX_LOCKABLE); node.getSession().save(); //remove lock from Cache LockUtil.removeLock(node); } } catch(LockException le) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.can-not-unlock-node", null, ApplicationMessage.WARNING)); uiExplorer.updateAjax(event); return; } catch(VersionException versionException) { Object[] args = {node.getName()}; uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.can-not-unlock-node-is-checked-in", args, ApplicationMessage.WARNING)); uiExplorer.updateAjax(event); return; } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error("an unexpected error occurs while unloking the node", e); } JCRExceptionManager.process(uiApp, e); uiExplorer.updateAjax(event); } } public static class UnlockActionListener extends UIWorkingAreaActionListener<UnlockManageComponent> { private void unlockManage(Event<UnlockManageComponent> event, UIJCRExplorer uiExplorer) throws Exception { String nodePath = event.getRequestContext().getRequestParameter(OBJECTID); if(nodePath.indexOf(";") > -1) { processMultiUnlock(nodePath.split(";"), event, uiExplorer); } else { processUnlock(nodePath, event, uiExplorer); } } private void processMultiUnlock(String[] nodePaths, Event<UnlockManageComponent> event, UIJCRExplorer uiExplorer) throws Exception { for (String nodePath : nodePaths) { if (acceptForMultiNode(event, nodePath)) processUnlock(nodePath, event, uiExplorer); } uiExplorer.getSession().save(); uiExplorer.updateAjax(event); } public void processEvent(Event<UnlockManageComponent> event) throws Exception { UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); unlockManage(event, uiExplorer); } } @Override public Class<? extends UIAbstractManager> getUIAbstractManagerClass() { return null; } }
7,894
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
OpenDocumentManageComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/rightclick/manager/OpenDocumentManageComponent.java
package org.exoplatform.ecm.webui.component.explorer.rightclick.manager; import java.util.Arrays; import java.util.List; import javax.jcr.Node; import javax.jcr.Session; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.control.filter.CanEditDocFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotEditingDocumentFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotInTrashFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotTrashHomeNodeFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNtFileFilter; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIActionBarActionListener; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.config.annotation.EventConfig; import org.exoplatform.webui.core.UIPopupContainer; import org.exoplatform.webui.event.Event; 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 : eXoPlatform * toannh@exoplatform.com * On Dec 10, 2014 * Filter files can be open by Office or OS */ @ComponentConfig( events = { @EventConfig(listeners = OpenDocumentManageComponent.OpenDocumentActionListener.class) }) public class OpenDocumentManageComponent extends UIAbstractManagerComponent { private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[]{ new IsNotTrashHomeNodeFilter(), new IsNotInTrashFilter(), new IsNotEditingDocumentFilter(), new IsNtFileFilter(), new CanEditDocFilter()}); @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } public static class OpenDocumentActionListener extends UIActionBarActionListener<OpenDocumentManageComponent> { public void processEvent(Event<OpenDocumentManageComponent> event) throws Exception { UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); String objId = event.getRequestContext().getRequestParameter(OBJECTID); Node currentNode=null; if(objId!=null){ String _ws = objId.split(":")[0]; String _nodePath = objId.split(":")[1]; Session _session = uiExplorer.getSessionByWorkspace(_ws); currentNode = uiExplorer.getNodeByPath(_nodePath, _session); }else{ currentNode = uiExplorer.getCurrentNode(); } Utils.openDocumentInDesktop(currentNode, uiExplorer.getChild(UIPopupContainer.class), event); } } @Override public Class<? extends UIAbstractManager> getUIAbstractManagerClass() { return null; } }
3,014
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
RemoveFavouriteManageComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/rightclick/manager/RemoveFavouriteManageComponent.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.component.explorer.rightclick.manager; import java.util.Arrays; import java.util.List; import java.util.regex.Matcher; import javax.jcr.AccessDeniedException; import javax.jcr.Node; import javax.jcr.PathNotFoundException; import javax.jcr.Session; import javax.jcr.lock.LockException; import javax.jcr.version.VersionException; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.UIWorkingArea; import org.exoplatform.ecm.webui.component.explorer.control.filter.HasRemovePermissionFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsCheckedOutFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsFavouriteFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotInTrashFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotLockedFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotTrashHomeNodeFilter; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIWorkingAreaActionListener; import org.exoplatform.ecm.webui.utils.JCRExceptionManager; import org.exoplatform.ecm.webui.utils.PermissionUtil; import org.exoplatform.services.cms.documents.FavoriteService; import org.exoplatform.services.cms.link.LinkManager; import org.exoplatform.services.log.ExoLogger; import org.exoplatform.services.log.Log; import org.exoplatform.services.security.ConversationState; import org.exoplatform.services.wcm.utils.WCMCoreUtils; 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.UIComponent; import org.exoplatform.webui.event.Event; 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 SARL * Author : Nguyen Anh Vu * anhvurz90@gmail.com * Oct 14, 2009 * 5:23:00 PM */ @ComponentConfig( events = { @EventConfig(listeners = RemoveFavouriteManageComponent.RemoveFromFavouriteActionListener.class) } ) public class RemoveFavouriteManageComponent extends UIAbstractManagerComponent { private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[] { new IsNotInTrashFilter(), new IsFavouriteFilter(), new IsNotLockedFilter(), new IsCheckedOutFilter(), new IsNotTrashHomeNodeFilter() }); private final static Log LOG = ExoLogger.getLogger(RemoveFavouriteManageComponent.class.getName()); @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } private static void multiRemoveFromFavourite(String[] paths, Event<UIComponent> event) throws Exception { for (String path : paths) { removeFromFavourite(path, event); } } private static void removeFromFavourite(String srcPath, Event<UIComponent> event) throws Exception { UIWorkingArea uiWorkingArea = ((UIComponent)event.getSource()).getParent(); UIJCRExplorer uiExplorer = uiWorkingArea.getAncestorOfType(UIJCRExplorer.class); FavoriteService favoriteService = WCMCoreUtils.getService(FavoriteService.class); UIApplication uiApp = uiWorkingArea.getAncestorOfType(UIApplication.class); Matcher matcher = UIWorkingArea.FILE_EXPLORER_URL_SYNTAX.matcher(srcPath); String wsName = null; Node node = null; if (matcher.find()) { wsName = matcher.group(1); srcPath = matcher.group(2); } else { throw new IllegalArgumentException("The ObjectId is invalid '"+ srcPath + "'"); } Session session = uiExplorer.getSessionByWorkspace(wsName); try { // Use the method getNodeByPath because it is link aware node = uiExplorer.getNodeByPath(srcPath, session, false); //check if node is link LinkManager lnkManager = uiExplorer.getApplicationComponent(LinkManager.class); if (lnkManager.isLink(node) && lnkManager.isTargetReachable(node)) { node = lnkManager.getTarget(node); } // Reset the path to manage the links that potentially create virtual path //srcPath = node.getPath(); // Reset the session to manage the links that potentially change of workspace session = node.getSession(); // Reset the workspace name to manage the links that potentially change of workspace // wsName = session.getWorkspace().getName(); } catch(PathNotFoundException path) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.path-not-found-exception", null,ApplicationMessage.WARNING)); return; } try { uiExplorer.addLockToken(node); } catch (Exception e) { JCRExceptionManager.process(uiApp, e); return; } try { if (!node.isCheckedOut()) { throw new VersionException("node is locked, can't remove favourite of node :" + node.getPath()); } favoriteService.removeFavorite(node, ConversationState.getCurrent().getIdentity().getUserId()); uiExplorer.updateAjax(event); } catch (LockException e) { if (LOG.isErrorEnabled()) { LOG.error("node is locked, can't remove favourite of node :" + node.getPath()); } JCRExceptionManager.process(uiApp, e); uiExplorer.updateAjax(event); } catch (VersionException e) { if (LOG.isErrorEnabled()) { LOG.error("node is checked in, can't remove favourite of node:" + node.getPath()); } JCRExceptionManager.process(uiApp, e); uiExplorer.updateAjax(event); } catch (AccessDeniedException e) { if (LOG.isErrorEnabled()) { LOG.error("access denied, can't remove favourite of node:" + node.getPath()); } JCRExceptionManager.process(uiApp, e); uiExplorer.updateAjax(event); } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error("an unexpected error occurs", e); } JCRExceptionManager.process(uiApp, e); uiExplorer.updateAjax(event); } } public static void removeFavouriteManage(Event<UIComponent> event) throws Exception { String srcPath = event.getRequestContext().getRequestParameter(OBJECTID); if (srcPath.indexOf(';') > -1) { multiRemoveFromFavourite(srcPath.split(";"), event); } else { removeFromFavourite(srcPath, event); } } public static class RemoveFromFavouriteActionListener extends UIWorkingAreaActionListener<RemoveFavouriteManageComponent> { public void processEvent(Event<RemoveFavouriteManageComponent> event) throws Exception { Event<UIComponent> event_ = new Event<UIComponent>( event.getSource(), event.getName(),event.getRequestContext()); removeFavouriteManage(event_); } } @Override public Class<? extends UIAbstractManager> getUIAbstractManagerClass() { return null; } }
8,195
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
PermlinkActionComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/rightclick/manager/PermlinkActionComponent.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.component.explorer.rightclick.manager; import java.util.Arrays; import java.util.List; import javax.jcr.Node; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsDocumentFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotInTrashFilter; import org.exoplatform.portal.application.PortalRequestContext; import org.exoplatform.portal.webui.util.Util; import org.exoplatform.web.url.navigation.NavigationResource; import org.exoplatform.web.url.navigation.NodeURL; 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 SARL Author : Hoang Van Hung hunghvit@gmail.com * Aug 6, 2009 */ @ComponentConfig( lifecycle = UIContainerLifecycle.class ) public class PermlinkActionComponent extends UIAbstractManagerComponent { private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[] { new IsNotInTrashFilter(), new IsDocumentFilter() }); @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } public String getPermlink(UIJCRExplorer uiExplorer, Node node) throws Exception { if (uiExplorer == null) { uiExplorer = getAncestorOfType(UIJCRExplorer.class); } if (node == null) { node = uiExplorer.getCurrentNode(); } PortalRequestContext pcontext = Util.getPortalRequestContext(); String portletId = pcontext.getNodePath(); String drivename = uiExplorer.getDriveData().getName(); String nodePath = node.getPath().replaceAll("/+", "/"); String path = new StringBuilder().append(drivename) .append(nodePath) .toString(); NodeURL nodeURL = Util.getPortalRequestContext().createURL(NodeURL.TYPE); NavigationResource resource = new NavigationResource(pcontext.getSiteType(), pcontext.getSiteName(), portletId); nodeURL.setResource(resource); nodeURL.setQueryParameterValue("path", path); return nodeURL.toString(); } public String getPermlink(UIJCRExplorer uiExplorer) throws Exception { return getPermlink(uiExplorer, null); } public String getPermlink(Node node) throws Exception { return getPermlink(null, node); } public String getPermlink() throws Exception { return getPermlink(null, null); } @Override public Class<? extends UIAbstractManager> getUIAbstractManagerClass() { return null; } }
3,833
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
DownloadManageComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/rightclick/manager/DownloadManageComponent.java
package org.exoplatform.ecm.webui.component.explorer.rightclick.manager; import org.exoplatform.ecm.webui.component.explorer.UIWorkingArea; import org.exoplatform.ecm.webui.component.explorer.control.filter.DownloadDocumentFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNtFileFilter; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIWorkingAreaActionListener; import org.exoplatform.services.cms.link.NodeFinder; 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.wcm.webui.Utils; import org.exoplatform.webui.config.annotation.ComponentConfig; import org.exoplatform.webui.config.annotation.EventConfig; import org.exoplatform.webui.event.Event; 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; import javax.jcr.Node; import javax.jcr.Session; import java.util.Arrays; import java.util.List; import java.util.regex.Matcher; @ComponentConfig( events = { @EventConfig(listeners = DownloadManageComponent.DownloadActionListener.class) } ) public class DownloadManageComponent extends UIAbstractManagerComponent { private static final Log LOG = ExoLogger.getLogger(DownloadManageComponent.class.getName()); private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[]{new IsNtFileFilter(), new DownloadDocumentFilter() }); @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } @Override public Class<? extends UIAbstractManager> getUIAbstractManagerClass() { return null; } /** * Parse node path with syntax [workspace:node path] to workspace name and path separately * * @param nodePath node path with syntax [workspace:node path] * @return array of String. element with index 0 is workspace name, remaining one is node path */ private String[] parseWorkSpaceNameAndNodePath(String nodePath) { Matcher matcher = UIWorkingArea.FILE_EXPLORER_URL_SYNTAX.matcher(nodePath); if (!matcher.find()) return null; String[] workSpaceNameAndNodePath = new String[2]; workSpaceNameAndNodePath[0] = matcher.group(1); workSpaceNameAndNodePath[1] = matcher.group(2); return workSpaceNameAndNodePath; } /** * Gets user session from a specific workspace. * * @param workspaceName * @return session * @throws Exception */ private Session getSession(String workspaceName) throws Exception { SessionProvider sessionProvider = WCMCoreUtils.getUserSessionProvider(); return sessionProvider.getSession(workspaceName, WCMCoreUtils.getRepository()); } public static class DownloadActionListener extends UIWorkingAreaActionListener<DownloadManageComponent> { public void processEvent(Event<DownloadManageComponent> event) throws Exception { DownloadManageComponent downloadManageComponent = event.getSource(); String nodePath = event.getRequestContext().getRequestParameter(OBJECTID); String[] workspaceAndPath = downloadManageComponent.parseWorkSpaceNameAndNodePath(nodePath); Node downloadedNode = (Node) WCMCoreUtils.getService(NodeFinder.class) .getItem(downloadManageComponent.getSession(workspaceAndPath[0]), workspaceAndPath[1], true); String downloadLink = Utils.getDownloadLink(downloadedNode); event.getRequestContext().getJavascriptManager().require("SHARED/jquery", "gj") .addScripts("setTimeout(\"window.location.assign('" + downloadLink + "');\", 1000);"); } } }
3,879
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
PasteManageComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/rightclick/manager/PasteManageComponent.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.component.explorer.rightclick.manager; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.regex.Matcher; import javax.jcr.AccessDeniedException; import javax.jcr.ItemExistsException; import javax.jcr.ItemNotFoundException; import javax.jcr.LoginException; import javax.jcr.Node; import javax.jcr.PathNotFoundException; import javax.jcr.Property; import javax.jcr.PropertyIterator; import javax.jcr.RepositoryException; import javax.jcr.Session; import javax.jcr.Value; import javax.jcr.Workspace; import javax.jcr.lock.LockException; import javax.jcr.nodetype.ConstraintViolationException; import javax.jcr.nodetype.NodeType; import javax.jcr.version.VersionException; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.exoplatform.container.PortalContainer; import org.exoplatform.ecm.utils.lock.LockUtil; import org.exoplatform.ecm.webui.component.explorer.UIDocumentAutoVersionForm; import org.exoplatform.ecm.webui.component.explorer.UIDocumentInfo; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.UIWorkingArea; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotInTrashFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotNtFileFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotTrashHomeNodeFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsPasteableFilter; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIWorkingAreaActionListener; import org.exoplatform.ecm.webui.component.explorer.sidebar.UITreeExplorer; import org.exoplatform.ecm.webui.component.explorer.sidebar.UITreeNodePageIterator; import org.exoplatform.ecm.webui.utils.JCRExceptionManager; import org.exoplatform.ecm.webui.utils.PermissionUtil; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.portal.webui.util.Util; import org.exoplatform.services.cms.actions.ActionServiceContainer; import org.exoplatform.services.cms.clipboard.ClipboardService; import org.exoplatform.services.cms.clipboard.jcr.model.ClipboardCommand; import org.exoplatform.services.cms.documents.AutoVersionService; import org.exoplatform.services.cms.documents.TrashService; import org.exoplatform.services.cms.jcrext.activity.ActivityCommonService; import org.exoplatform.services.cms.link.LinkUtils; import org.exoplatform.services.cms.relations.RelationsService; import org.exoplatform.services.cms.thumbnail.ThumbnailService; import org.exoplatform.services.ecm.publication.PublicationService; import org.exoplatform.services.jcr.access.PermissionType; import org.exoplatform.services.jcr.ext.ActivityTypeUtils; import org.exoplatform.services.jcr.impl.core.NodeImpl; import org.exoplatform.services.listener.ListenerService; import org.exoplatform.services.log.ExoLogger; import org.exoplatform.services.log.Log; import org.exoplatform.services.security.ConversationState; import org.exoplatform.services.wcm.core.NodetypeConstant; import org.exoplatform.services.wcm.extensions.publication.lifecycle.authoring.AuthoringPublicationConstant; import org.exoplatform.services.wcm.publication.PublicationDefaultStates; import org.exoplatform.services.wcm.publication.WCMPublicationService; import org.exoplatform.services.wcm.utils.WCMCoreUtils; 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.UIPageIterator; import org.exoplatform.webui.core.UIPopupContainer; import org.exoplatform.webui.core.UIPopupWindow; import org.exoplatform.webui.event.Event; import org.exoplatform.webui.exception.MessageException; 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 SARL Author : Hoang Van Hung hunghvit@gmail.com * Aug 6, 2009 */ @ComponentConfig( events = { @EventConfig(listeners = PasteManageComponent.PasteActionListener.class) } ) public class PasteManageComponent extends UIAbstractManagerComponent { private static final Log LOG = ExoLogger.getLogger(PasteManageComponent.class.getName()); private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new IsNotInTrashFilter(), new IsPasteableFilter(), new IsNotNtFileFilter(), new IsNotTrashHomeNodeFilter()); private static final String RELATION_PROP = "exo:relation"; private static final String SYSTEM = "__system"; private static boolean isRefresh = true; private static Map<String, Boolean> versionedRemember = new HashMap<>(); private static Map<String, Boolean> nonVersionedRemember = new HashMap<>(); public static boolean isIsRefresh() { return isRefresh; } @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } public static void pasteManage(Event<PasteManageComponent> event, UIJCRExplorer uiExplorer) throws Exception { ClipboardService clipboardService = WCMCoreUtils.getService(ClipboardService.class); String userId = ConversationState.getCurrent().getIdentity().getUserId(); AutoVersionService autoVersionService = WCMCoreUtils.getService(AutoVersionService.class); UIWorkingArea uiWorkingArea = event.getSource().getParent(); String destPath = event.getRequestContext().getRequestParameter(OBJECTID); String nodePath = null; Session session = null; if (destPath != null) { Matcher matcher = UIWorkingArea.FILE_EXPLORER_URL_SYNTAX.matcher(destPath); String wsName = null; if (matcher.find()) { wsName = matcher.group(1); nodePath = matcher.group(2); session = uiExplorer.getSessionByWorkspace(wsName); } else { throw new IllegalArgumentException("The ObjectId is invalid '" + destPath + "'"); } } UIApplication uiApp = uiExplorer.getAncestorOfType(UIApplication.class); if (clipboardService.getClipboardList(userId, false).size() < 1) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.no-node", null, ApplicationMessage.WARNING)); return; } Node destNode; try { // Use the method getNodeByPath because it is link aware destNode = destPath == null ? uiExplorer.getCurrentNode() : uiExplorer.getNodeByPath( nodePath, session); // Reset the session to manage the links that potentially change of // workspace session = destNode.getSession(); if (destPath == null) { destPath = session.getWorkspace().getName() + ":" + destNode.getPath(); } } catch (PathNotFoundException path) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.path-not-found-exception", null, ApplicationMessage.WARNING)); return; } catch (Exception e) { JCRExceptionManager.process(uiApp, e); return; } if (!PermissionUtil.canAddNode(destNode)) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.can-not-paste-node", null, ApplicationMessage.WARNING)); uiExplorer.updateAjax(event); return; } if (uiExplorer.nodeIsLocked(destNode)) { Object[] arg = { destPath }; uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.node-locked", arg, ApplicationMessage.WARNING)); return; } if (!destNode.isCheckedOut()) { uiApp.addMessage(new ApplicationMessage("UIActionBar.msg.node-checkedin", null)); return; } String currentPath = uiExplorer.getCurrentNode().getPath(); ClipboardCommand clipboardCommand = clipboardService.getLastClipboard(userId); try { if (clipboardCommand!=null && clipboardService.getClipboardList(userId, true).isEmpty()) { processPaste(clipboardCommand, destNode, event, uiExplorer); } else { if(autoVersionService.isVersionSupport(destNode.getPath(), destNode.getSession().getWorkspace().getName())) { processPasteMultiple(destNode, event, uiExplorer); }else{ processPasteMultiple(destPath, event, uiExplorer); } } } catch (PathNotFoundException pe) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.cannot-readsource", null)); return; } //session.save(); // Get paginator of UITreeExplorer && UIDocumentInfo UITreeNodePageIterator extendedPageIterator = null; UITreeExplorer uiTreeExplorer = uiExplorer.findFirstComponentOfType(UITreeExplorer.class); if (uiTreeExplorer != null) { extendedPageIterator = uiTreeExplorer.getUIPageIterator(currentPath); } UIPageIterator contentPageIterator = uiExplorer.findComponentById(UIDocumentInfo.CONTENT_PAGE_ITERATOR_ID); // Get current page index int currentPage = 1; if (contentPageIterator != null) { currentPage = contentPageIterator.getCurrentPage(); } if(isRefresh) { // Rebuild screen after pasting new content versionedRemember.clear(); nonVersionedRemember.clear(); uiExplorer.updateAjax(event); } // Because after updateAjax, paginator automatically set to first page then we need set again current pageindex if (contentPageIterator != null) { contentPageIterator.setCurrentPage(currentPage); } if (extendedPageIterator != null) { extendedPageIterator.setCurrentPage(currentPage); } } public static void processPaste(ClipboardCommand clipboardCommand, Node destNode, Event<?> event, UIJCRExplorer uiExplorer) throws Exception{ AutoVersionService autoVersionService = WCMCoreUtils.getService(AutoVersionService.class); Node sourceNode = (Node)uiExplorer.getSessionByWorkspace(clipboardCommand.getWorkspace()). getItem(clipboardCommand.getSrcPath()); if(destNode.hasNode(sourceNode.getName()) && sourceNode.isNodeType(NodetypeConstant.NT_FILE) && autoVersionService.isVersionSupport(destNode.getPath(), destNode.getSession().getWorkspace().getName())){ Set<ClipboardCommand> clipboardCommands = new HashSet<>(); clipboardCommands.add(clipboardCommand); showConfirmDialog(destNode, sourceNode, uiExplorer, clipboardCommand, clipboardCommands, event); }else { processPaste(clipboardCommand, destNode.getPath(),uiExplorer, event, false, true); } } private static void processPasteMultiple(String destPath, Event<?> event, UIJCRExplorer uiExplorer) throws Exception { ClipboardService clipboardService = WCMCoreUtils.getService(ClipboardService.class); String userId = ConversationState.getCurrent().getIdentity().getUserId(); int pasteNum = 0; Set<ClipboardCommand> virtualClipboards = clipboardService.getClipboardList(userId, true); for (ClipboardCommand clipboard : virtualClipboards) { pasteNum++; if (pasteNum == virtualClipboards.size()) { processPaste(clipboard, destPath, uiExplorer, event, true, true); break; } processPaste(clipboard, destPath, uiExplorer, event, true, false); } } private static void processPasteMultiple(Node destNode, Event<?> event, UIJCRExplorer uiExplorer) throws Exception { ClipboardService clipboardService = WCMCoreUtils.getService(ClipboardService.class); String userId = ConversationState.getCurrent().getIdentity().getUserId(); Set<ClipboardCommand> virtualClipboards = clipboardService.getClipboardList(userId, true); processPasteMultiple(destNode, event, uiExplorer, virtualClipboards, null); } public static void processPasteMultiple(Node destNode, Event<?> event, UIJCRExplorer uiExplorer, Set<ClipboardCommand> virtualClipboards, String action) throws Exception{ int pasteNum = 0; Set<ClipboardCommand> _virtualClipboards = new HashSet<>(virtualClipboards); Set<ClipboardCommand> processList = new HashSet<>(virtualClipboards); UIApplication uiApp = uiExplorer.getAncestorOfType(UIApplication.class); ActionServiceContainer actionContainer = uiExplorer.getApplicationComponent(ActionServiceContainer.class); for (ClipboardCommand clipboard : virtualClipboards) { pasteNum++; Node srcNode = null; try{ srcNode = (Node)uiExplorer.getSessionByWorkspace(clipboard.getWorkspace()).getItem(clipboard.getSrcPath()); String destPath = destNode.getPath(); if(destNode.hasNode(srcNode.getName()) ){ Node _destNode = destNode.getNode(srcNode.getName()); if(_destNode.isNodeType(NodetypeConstant.MIX_VERSIONABLE) && versionedRemember!=null){ if(BooleanUtils.isTrue(versionedRemember.get("keepboth"))) { if(ClipboardCommand.COPY.equals(clipboard.getType())) { pasteByCopy(destNode.getSession(), clipboard.getWorkspace(), clipboard.getSrcPath(), _destNode.getPath()); }else{ pasteByCut(clipboard, uiExplorer, _destNode.getSession(), clipboard.getWorkspace(), clipboard.getSrcPath(), _destNode.getPath(),actionContainer, false, false, false); } } if(BooleanUtils.isTrue(versionedRemember.get("createVersion"))) makeVersion(destNode, _destNode, srcNode, clipboard, action, destPath, uiExplorer, event); processList.remove(clipboard); continue; } if((!_destNode.isNodeType(NodetypeConstant.MIX_VERSIONABLE)) && nonVersionedRemember!=null){ if(BooleanUtils.isTrue(nonVersionedRemember.get("replace"))) { //if(ClipboardCommand.CUT.equals(clipboard.getType())) continue; String _destPath = _destNode.getPath(); if(!StringUtils.equals(_destPath, clipboard.getSrcPath()) && StringUtils.equals(clipboard.getWorkspace(), _destNode.getSession().getWorkspace().getName())) { TrashService trashService = WCMCoreUtils.getService(TrashService.class); String trashID = trashService.moveToTrash(_destNode, WCMCoreUtils.getUserSessionProvider()); if(StringUtils.equals(ClipboardCommand.CUT, clipboard.getType())){ pasteByCut(clipboard, uiExplorer, _destNode.getSession(), clipboard.getWorkspace(), clipboard.getSrcPath(), _destPath, actionContainer, false, false, false); }else { UIDocumentAutoVersionForm.copyNode(destNode.getSession(), clipboard.getWorkspace(), clipboard.getSrcPath(), _destPath, uiApp, uiExplorer, event, ClipboardCommand.COPY); } Node deletedNode = trashService.getNodeByTrashId(trashID); deletedNode.remove(); deletedNode.getSession().save(); } } if(BooleanUtils.isTrue(nonVersionedRemember.get("keepboth"))) { if (ClipboardCommand.COPY.equals(clipboard.getType())) { pasteByCopy(destNode.getSession(), clipboard.getWorkspace(), clipboard.getSrcPath(), _destNode.getPath()); } else { pasteByCut(clipboard, uiExplorer, _destNode.getSession(), clipboard.getWorkspace(), clipboard.getSrcPath(), _destNode.getPath(), actionContainer, false, false, false); } } processList.remove(clipboard); continue; } showConfirmDialog(destNode, srcNode, uiExplorer, clipboard, _virtualClipboards, event); break; }else{ _virtualClipboards.remove(clipboard); if (pasteNum == virtualClipboards.size()) { processPaste(clipboard, destPath, uiExplorer, event, true, true); processList.remove(clipboard); break; } processPaste(clipboard, destPath, uiExplorer, event, true, false); processList.remove(clipboard); } }catch (ConstraintViolationException ce) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.current-node-not-allow-paste", null, ApplicationMessage.WARNING)); uiExplorer.updateAjax(event); return; } catch (VersionException ve) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.copied-node-in-versioning", null, ApplicationMessage.WARNING)); uiExplorer.updateAjax(event); return; } catch (ItemExistsException iee) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.paste-node-same-name", null, ApplicationMessage.WARNING)); uiExplorer.updateAjax(event); processList.remove(clipboard); continue; } catch (LoginException e) { if (ClipboardCommand.CUT.equals(action)) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.cannot-login-node", null, ApplicationMessage.WARNING)); uiExplorer.updateAjax(event); return; } uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.cannot-paste-nodetype", null, ApplicationMessage.WARNING)); uiExplorer.updateAjax(event); return; } catch (AccessDeniedException ace) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.access-denied", null, ApplicationMessage.WARNING)); uiExplorer.updateAjax(event); return; } catch (Exception e) { JCRExceptionManager.process(uiApp, e); uiExplorer.updateAjax(event); return; } } if(processList.isEmpty()){ UIPopupWindow popupAction = uiExplorer.findFirstComponentOfType(UIPopupWindow.class) ; popupAction.setShow(false) ; uiExplorer.updateAjax(event); versionedRemember.clear(); nonVersionedRemember.clear(); } } private static void makeVersion(Node destNode, Node _destNode, Node srcNode, ClipboardCommand clipboard, String action, String destPath, UIJCRExplorer uiExplorer, Event<?> event) throws Exception{ AutoVersionService autoVersionService = WCMCoreUtils.getService(AutoVersionService.class); ActionServiceContainer actionContainer = uiExplorer.getApplicationComponent(ActionServiceContainer.class); UIApplication uiApp = uiExplorer.getAncestorOfType(UIApplication.class); if(destNode.hasNode(srcNode.getName()) && ClipboardCommand.COPY.equals(clipboard.getType()) && UIDocumentAutoVersionForm.CREATE_VERSION.equals(action)) { autoVersionService.autoVersion(destNode.getNode(srcNode.getName()), srcNode); }else if(destNode.hasNode(srcNode.getName()) && ClipboardCommand.COPY.equals(clipboard.getType()) && UIDocumentAutoVersionForm.KEEP_BOTH.equals(action)){ UIDocumentAutoVersionForm.copyNode(destNode.getSession(), destNode.getSession().getWorkspace().getName(), srcNode.getPath(), destNode.getNode(srcNode.getName()).getPath(), uiApp, uiExplorer, event, ClipboardCommand.COPY); }else if(destNode.hasNode(srcNode.getName()) && ClipboardCommand.COPY.equals(clipboard.getType()) && UIDocumentAutoVersionForm.REPLACE.equals(action)) { autoVersionService.autoVersion(destNode.getNode(srcNode.getName()), srcNode); } else{ if(UIDocumentAutoVersionForm.KEEP_BOTH.equals(action)){ if(destNode.hasNode(srcNode.getName())) { pasteByCut(clipboard, uiExplorer, _destNode.getSession(), clipboard.getWorkspace(), clipboard.getSrcPath(), _destNode.getPath(),actionContainer, false, false, false); } }else { pasteByCut(clipboard, uiExplorer, destNode.getSession(), clipboard.getWorkspace(), clipboard.getSrcPath(), destNode.getPath(), actionContainer, false, false, true); } } isRefresh=true; } private static void showConfirmDialog(Node destNode, Node srcNode, UIJCRExplorer uiExplorer, ClipboardCommand clipboard, Set<ClipboardCommand> virtualClipboards, Event<?> event) throws Exception{ Node destExitedNode = destNode.getNode(srcNode.getName()); UIPopupContainer objUIPopupContainer = uiExplorer.getChild(UIPopupContainer.class); UIDocumentAutoVersionForm uiDocumentAutoVersionForm = uiExplorer.createUIComponent(UIDocumentAutoVersionForm.class, null, null); uiDocumentAutoVersionForm.setDestPath(destNode.getPath()); uiDocumentAutoVersionForm.setDestWorkspace(destNode.getSession().getWorkspace().getName()); uiDocumentAutoVersionForm.setSourcePath(srcNode.getPath()); uiDocumentAutoVersionForm.setSourceWorkspace(srcNode.getSession().getWorkspace().getName()); uiDocumentAutoVersionForm.setCurrentClipboard(clipboard); uiDocumentAutoVersionForm.setMessage("UIDocumentAutoVersionForm.msg"); uiDocumentAutoVersionForm.setArguments(new String[]{srcNode.getName()}); uiDocumentAutoVersionForm.setClipboardCommands(virtualClipboards); if(virtualClipboards!=null && virtualClipboards.size()==1) uiDocumentAutoVersionForm.setSingleProcess(true); uiDocumentAutoVersionForm.init(destExitedNode); objUIPopupContainer.activate(uiDocumentAutoVersionForm, 450, 0); event.getRequestContext().addUIComponentToUpdateByAjax(objUIPopupContainer); isRefresh = false; } /** * Update clipboard after CUT node. Detain PathNotFoundException with same name sibling node * @param clipboardCommands * @param mapClipboard * @throws Exception */ private static void updateClipboard(Set<ClipboardCommand> clipboardCommands, Map<ClipboardCommand, Node> mapClipboard) throws Exception { Node srcNode; for (ClipboardCommand clipboard : clipboardCommands) { if (ClipboardCommand.CUT.equals(clipboard.getType())) { srcNode = mapClipboard.get(clipboard); if(srcNode !=null) { srcNode.refresh(true); clipboard.setSrcPath(srcNode.getPath()); } } } } /** * Put data from clipboard to Map<Clipboard, Node>. After cutting node, we keep data to update clipboard by respective node * @param clipboardCommands * @param uiExplorer * @return * @throws Exception */ private static Map<ClipboardCommand, Node> parseToMap(Set<ClipboardCommand> clipboardCommands, UIJCRExplorer uiExplorer) throws Exception { String srcPath; String type; String srcWorkspace; Node srcNode; Session srcSession; Map<ClipboardCommand, Node> mapClipboard = new HashMap<ClipboardCommand, Node>(); for (ClipboardCommand clipboard : clipboardCommands) { srcPath = clipboard.getSrcPath(); type = clipboard.getType(); srcWorkspace = clipboard.getWorkspace(); if (ClipboardCommand.CUT.equals(type)) { srcSession = uiExplorer.getSessionByWorkspace(srcWorkspace); // Use the method getNodeByPath because it is link aware srcNode = uiExplorer.getNodeByPath(srcPath, srcSession, false); clipboard.setSrcPath(srcNode.getPath()); mapClipboard.put(clipboard, srcNode); } } return mapClipboard; } private static void processPaste(ClipboardCommand currentClipboard, String destPath, UIJCRExplorer uiExplorer, Event<?> event, boolean isMultiSelect, boolean isLastPaste) throws Exception { UIApplication uiApp = uiExplorer.getAncestorOfType(UIApplication.class); String srcPath = currentClipboard.getSrcPath(); String type = currentClipboard.getType(); String srcWorkspace = currentClipboard.getWorkspace(); Session srcSession = uiExplorer.getSessionByWorkspace(srcWorkspace); // Use the method getNodeByPath because it is link aware Node srcNode = uiExplorer.getNodeByPath(srcPath, srcSession, false); // Reset the path to manage the links that potentially create virtual path srcPath = srcNode.getPath(); // Reset the session to manage the links that potentially change of workspace srcSession = srcNode.getSession(); // Get thumbnail node of source node ThumbnailService thumbnailService = WCMCoreUtils.getService(ThumbnailService.class); Node srcThumbnailNode = thumbnailService.getThumbnailNode(srcNode); // Reset the workspace name to manage the links that potentially change of // workspace srcWorkspace = srcSession.getWorkspace().getName(); Matcher matcher = UIWorkingArea.FILE_EXPLORER_URL_SYNTAX.matcher(destPath); String destWorkspace = null; if (matcher.find()) { destWorkspace = matcher.group(1); destPath = matcher.group(2); } Session destSession = uiExplorer.getSessionByWorkspace(destWorkspace); if(destWorkspace==null) destWorkspace = destSession.getWorkspace().getName(); // Use the method getNodeByPath because it is link aware Node destNode = uiExplorer.getNodeByPath(destPath, destSession); // Reset the path to manage the links that potentially create virtual path destPath = destNode.getPath(); // Reset the session to manage the links that potentially change of // workspace destSession = destNode.getSession(); if (ClipboardCommand.CUT.equals(type) && srcPath.equals(destPath)) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.node-cutting", null, ApplicationMessage.WARNING)); return; } // Make destination path without index on final name if (!"/".equals(destPath)) destPath = destPath.concat("/"); destPath = destPath.concat(srcNode.getName()); ActionServiceContainer actionContainer = uiExplorer .getApplicationComponent(ActionServiceContainer.class); try { if (ClipboardCommand.COPY.equals(type)) { int i = 1; String originalPath = destPath; String name = srcNode.getName(); String originalName = name; String title = null; while (destNode.hasNode(name)) { destPath = originalPath; destPath += i; name = originalName + i; title = originalName + "(" + i + ")"; i++; } pasteByCopy(destSession, srcWorkspace, srcPath, destPath); destNode = (Node) destSession.getItem(destPath); actionContainer.initiateObservation(destNode); if(destNode.isNodeType(ActivityTypeUtils.EXO_ACTIVITY_INFO)) { destNode.removeMixin(ActivityTypeUtils.EXO_ACTIVITY_INFO); } if(destNode.isNodeType(NodetypeConstant.EOO_ONLYOFFICE_FILE)) { destNode.removeMixin(NodetypeConstant.EOO_ONLYOFFICE_FILE); } // Set title if (title != null) { destNode.setProperty(Utils.EXO_TITLE, title); } destNode.save(); } else { pasteByCut(currentClipboard, uiExplorer, destSession, srcWorkspace, srcPath, destPath, actionContainer, isMultiSelect, isLastPaste, false); destNode = (Node) destSession.getItem(destPath); } if (!srcWorkspace.equals(destWorkspace) || !srcPath.equals(destPath) && srcThumbnailNode != null) { // Remove thumbnail from source folder after moving it thumbnailService.processRemoveThumbnail(srcThumbnailNode); } } catch (ConstraintViolationException ce) { LOG.warn("Error pasting document from {} to {}", srcPath, destPath, ce); uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.current-node-not-allow-paste", null, ApplicationMessage.WARNING)); uiExplorer.updateAjax(event); return; } catch (VersionException ve) { LOG.warn("Error pasting document from {} to {}", srcPath, destPath, ve); uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.copied-node-in-versioning", null, ApplicationMessage.WARNING)); uiExplorer.updateAjax(event); return; } catch (ItemExistsException iee) { LOG.warn("Error pasting document from {} to {}", srcPath, destPath, iee); uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.paste-node-same-name", null, ApplicationMessage.WARNING)); uiExplorer.updateAjax(event); return; } catch (LoginException e) { LOG.warn("Error pasting document from {} to {}", srcPath, destPath, e); if (ClipboardCommand.CUT.equals(type)) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.cannot-login-node", null, ApplicationMessage.WARNING)); uiExplorer.updateAjax(event); return; } uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.cannot-paste-nodetype", null, ApplicationMessage.WARNING)); uiExplorer.updateAjax(event); return; } catch (AccessDeniedException ace) { LOG.debug("Error pasting document from {} to {}", srcPath, destPath, ace); uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.access-denied", null, ApplicationMessage.WARNING)); uiExplorer.updateAjax(event); return; } catch (LockException locke) { LOG.debug("Error pasting document from {} to {}", srcPath, destPath, locke); Object[] arg = { srcPath }; uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.paste-lock-exception", arg, ApplicationMessage.WARNING)); } catch (Exception e) { JCRExceptionManager.process(uiApp, e); uiExplorer.updateAjax(event); return; } } private static void changeCopiedNodeOwner(Node destNode) throws RepositoryException { Node destNodeSystem = WCMCoreUtils.getNodeBySystemSession(destNode); String userID = destNode.getSession().getUserID(); if (destNodeSystem.isNodeType(NodetypeConstant.EXO_OWNEABLE)) { destNodeSystem.removeMixin(NodetypeConstant.EXO_OWNEABLE); destNodeSystem.save(); destNode.refresh(true); } if (destNodeSystem.canAddMixin(NodetypeConstant.EXO_PRIVILEGEABLE)) { destNodeSystem.addMixin(NodetypeConstant.EXO_PRIVILEGEABLE); } if (destNodeSystem.isNodeType(NodetypeConstant.EXO_PRIVILEGEABLE)) { ((NodeImpl) destNodeSystem).setPermission(SYSTEM, PermissionType.ALL); ((NodeImpl) destNodeSystem).setPermission(userID, PermissionType.ALL); destNodeSystem.save(); destNode.refresh(true); } if (destNode.canAddMixin(NodetypeConstant.EXO_OWNEABLE)) { destNode.addMixin(NodetypeConstant.EXO_OWNEABLE); } } private static void updatePublicationLifecycle(Node destNode) throws Exception { try { // Make copied content enrolled as draft in publication lifecycle to cleanup references to old content WCMPublicationService wcmPublicationService = PortalContainer.getInstance().getComponentInstanceOfType(WCMPublicationService.class); if (wcmPublicationService.isEnrolledInWCMLifecycle(destNode)) { PublicationService publicationService = PortalContainer.getInstance().getComponentInstanceOfType(PublicationService.class); String lifecycleName = publicationService.getNodeLifecycleName(destNode); String originalState = null; if (destNode.hasProperty(AuthoringPublicationConstant.CURRENT_STATE)) { originalState = destNode.getProperty(AuthoringPublicationConstant.CURRENT_STATE).getString(); } else { originalState = PublicationDefaultStates.DRAFT; } wcmPublicationService.unsubcribeLifecycle(destNode); wcmPublicationService.enrollNodeInLifecycle(destNode, lifecycleName); String siteName = Util.getPortalRequestContext().getPortalOwner(); String remoteUser = Util.getPortalRequestContext().getRemoteUser(); // Make content draft again wcmPublicationService.updateLifecyleOnChangeContent(destNode, siteName, remoteUser); // Change node publication status to original state String newState = publicationService.getCurrentState(destNode); if (!StringUtils.equals(newState, originalState)) { wcmPublicationService.updateLifecyleOnChangeContent(destNode, siteName, remoteUser, originalState); } } } catch (Exception e) { LOG.warn("Error while cleaning Publication lifecycle of copied content '{}'. Continue to paste content by ignoring optional publication lifecycle cleanup process.", destNode.getPath(), e); } } private static void removeReferences(Node destNode) throws Exception { NodeType[] mixinTypes = destNode.getMixinNodeTypes(); Session session = destNode.getSession(); for (int i = 0; i < mixinTypes.length; i++) { if (mixinTypes[i].getName().equals(Utils.EXO_CATEGORIZED) && destNode.hasProperty(Utils.EXO_CATEGORIZED)) { Node valueNode = null; Value valueAdd = session.getValueFactory().createValue(valueNode); destNode.setProperty(Utils.EXO_CATEGORIZED, new Value[] { valueAdd }); } } destNode.save(); } private static void pasteByCopy(Session session, String srcWorkspaceName, String srcPath, String destPath) throws Exception { Workspace workspace = session.getWorkspace(); if (workspace.getName().equals(srcWorkspaceName)) { workspace.copy(srcPath, destPath); Node destNode = (Node) session.getItem(destPath); changeCopiedNodeOwner(destNode); removeReferences(destNode); updatePublicationLifecycle(destNode); } else { try { if (LOG.isDebugEnabled()) LOG.debug("Copy to another workspace"); workspace.copy(srcWorkspaceName, srcPath, destPath); } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error("an unexpected error occurs while pasting the node", e); } if (LOG.isDebugEnabled()) LOG.debug("Copy to other workspace by clone"); try { workspace.clone(srcWorkspaceName, srcPath, destPath, false); } catch (Exception f) { if (LOG.isErrorEnabled()) { LOG.error("an unexpected error occurs while pasting the node", f); } } } } } public static void pasteByCut(ClipboardCommand currentClipboard, UIJCRExplorer uiExplorer, Session session, String srcWorkspace, String srcPath, String destPath, ActionServiceContainer actionContainer, boolean isMultiSelect, boolean isLastPaste, boolean isCreateVersion) throws Exception { ClipboardService clipboardService = WCMCoreUtils.getService(ClipboardService.class); String userId = ConversationState.getCurrent().getIdentity().getUserId(); UIWorkingArea uiWorkingArea = uiExplorer.getChild(UIWorkingArea.class); Workspace workspace = session.getWorkspace(); if (workspace.getName().equals(srcWorkspace)) { if (srcPath.equals(destPath)) return; } Set<ClipboardCommand> allClipboard = clipboardService.getClipboardList(userId, false); Set<ClipboardCommand> virtualClipboard = clipboardService.getClipboardList(userId, true); Map<ClipboardCommand, Node> mapAllClipboardNode = parseToMap(allClipboard, uiExplorer); Map<ClipboardCommand, Node> mapVirtualClipboardNode = parseToMap(virtualClipboard, uiExplorer); RelationsService relationsService = uiExplorer.getApplicationComponent(RelationsService.class); List<Node> refList = new ArrayList<Node>(); boolean isReference = false; PropertyIterator references = null; Node srcNode = (Node) uiExplorer.getSessionByWorkspace(srcWorkspace).getItem(srcPath); try { references = srcNode.getReferences(); isReference = true; } catch (Exception e) { isReference = false; } if (isReference && references != null) { if (references.getSize() > 0) { while (references.hasNext()) { Property pro = references.nextProperty(); Node refNode = pro.getParent(); if (refNode.hasProperty(RELATION_PROP)) { relationsService.removeRelation(refNode, srcPath); refNode.save(); refList.add(refNode); } } } } // Add locked token for the source node ListenerService listenerService = WCMCoreUtils.getService(ListenerService.class); ActivityCommonService activityService = WCMCoreUtils.getService(ActivityCommonService.class); uiExplorer.addLockToken(srcNode); if (workspace.getName().equals(srcWorkspace)) { try { if(isCreateVersion){ Node _destNode = ((Node)session.getItem(destPath)).getNode(srcNode.getName()); AutoVersionService autoVersionService = WCMCoreUtils.getService(AutoVersionService.class); autoVersionService.autoVersion(_destNode, srcNode); if(!srcNode.getPath().equals(_destNode.getPath())) { srcNode.remove(); } }else { workspace.move(srcPath, destPath); } LockUtil.changeLockToken(srcPath, (Node)session.getItem(destPath)); } catch (ArrayIndexOutOfBoundsException e) { throw new MessageException(new ApplicationMessage("UIPopupMenu.msg.node-cutting", null, ApplicationMessage.WARNING)); } if (!isMultiSelect || (isMultiSelect && isLastPaste)) { Node desNode = null; try { desNode = (Node) session.getItem(destPath); } catch (PathNotFoundException pathNotFoundException) { uiExplorer.setCurrentPath(LinkUtils.getParentPath(uiExplorer.getCurrentPath())); desNode = uiExplorer.getCurrentNode(); } catch (ItemNotFoundException itemNotFoundException) { uiExplorer.setCurrentPath(LinkUtils.getParentPath(uiExplorer.getCurrentPath())); desNode = uiExplorer.getCurrentNode(); } if (!session.itemExists(uiExplorer.getCurrentPath())) { uiExplorer.setCurrentPath(LinkUtils.getParentPath(uiExplorer.getCurrentPath())); } if (activityService.isAcceptedNode(desNode) || desNode.getPrimaryNodeType().getName().equals(NodetypeConstant.NT_FILE)) { listenerService.broadcast(ActivityCommonService.NODE_MOVED_ACTIVITY, desNode, desNode.getPath()); } if (!(desNode.getPath().equals(uiExplorer.getCurrentPath()))) actionContainer.initiateObservation(desNode); for (int i = 0; i < refList.size(); i++) { Node addRef = refList.get(i); relationsService.addRelation(addRef, destPath, session.getWorkspace().getName()); addRef.save(); } clipboardService.clearClipboardList(userId, true); Node currentNode = uiExplorer.getCurrentNode(); String realCurrentPath = currentNode.getPath(); if (srcWorkspace.equals(currentNode.getSession().getWorkspace().getName()) && (srcPath.equals(realCurrentPath) || realCurrentPath.startsWith(srcPath))) { uiExplorer.setCurrentPath(LinkUtils.getParentPath(uiExplorer.getCurrentPath())); } } } else { workspace.clone(srcWorkspace, srcPath, destPath, false); Node desNode =(Node) workspace.getSession().getItem(destPath); if (activityService.isAcceptedNode(desNode) || desNode.getPrimaryNodeType().getName().equals(NodetypeConstant.NT_FILE)) { listenerService.broadcast(ActivityCommonService.NODE_MOVED_ACTIVITY, desNode, destPath); } if (!isMultiSelect || (isMultiSelect && isLastPaste)) { clipboardService.clearClipboardList(userId, true); } } clipboardService.getClipboardList(userId, false).remove(currentClipboard); updateClipboard(clipboardService.getClipboardList(userId, true), mapVirtualClipboardNode); updateClipboard(clipboardService.getClipboardList(userId, false), mapAllClipboardNode); clipboardService.clearClipboardList(userId, true); clipboardService.clearClipboardList(userId, false); } public static class PasteActionListener extends UIWorkingAreaActionListener<PasteManageComponent> { public void processEvent(Event<PasteManageComponent> event) throws Exception { UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); pasteManage(event, uiExplorer); } } @Override public Class<? extends UIAbstractManager> getUIAbstractManagerClass() { return null; } public static void setVersionedRemember(Map<String, Boolean> versionedRemember) { PasteManageComponent.versionedRemember.clear(); if(versionedRemember != null && !versionedRemember.isEmpty()) { PasteManageComponent.versionedRemember.putAll(versionedRemember); } } public static void setNonVersionedRemember(Map<String, Boolean> nonVersionedRemember) { PasteManageComponent.nonVersionedRemember.clear(); if(nonVersionedRemember != null && !nonVersionedRemember.isEmpty()) { PasteManageComponent.nonVersionedRemember.putAll(nonVersionedRemember); } } public static Map<String, Boolean> getVersionedRemember() { return versionedRemember; } }
43,305
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
CreateLinkManageComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/rightclick/manager/CreateLinkManageComponent.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.component.explorer.rightclick.manager; import java.util.Arrays; import java.util.List; import java.util.regex.Matcher; import javax.jcr.AccessDeniedException; import javax.jcr.Node; import javax.jcr.PathNotFoundException; import javax.jcr.Session; import javax.jcr.lock.LockException; import javax.jcr.nodetype.ConstraintViolationException; import org.exoplatform.services.log.Log; import org.exoplatform.ecm.utils.text.Text; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.UIWorkingArea; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotInTrashFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotTrashHomeNodeFilter; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIWorkingAreaActionListener; import org.exoplatform.ecm.webui.utils.JCRExceptionManager; 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.log.ExoLogger; 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.UIComponent; import org.exoplatform.webui.event.Event; 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 SARL * Author : Hoang Van Hung * hunghvit@gmail.com * Aug 16, 2009 */ @ComponentConfig( events = { @EventConfig(listeners = CreateLinkManageComponent.CreateLinkActionListener.class) } ) public class CreateLinkManageComponent extends UIAbstractManagerComponent { private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[]{new IsNotInTrashFilter(), new IsNotTrashHomeNodeFilter()}); private static final Log LOG = ExoLogger.getLogger(CreateLinkManageComponent.class.getName()); private static final String EXO_TRASH_FOLDER = "exo:trashFolder"; @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } private static void createMultiLink(String[] srcPaths, Node destNode, Event<? extends UIComponent> event) throws Exception { for (int i = 0; i < srcPaths.length; i++) { createLink(srcPaths[i], destNode, event); } } private static void createLink(String srcPath, Node destNode, Event<? extends UIComponent> event) throws Exception { UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); Matcher matcher = UIWorkingArea.FILE_EXPLORER_URL_SYNTAX.matcher(srcPath); String wsName = null; if (matcher.find()) { wsName = matcher.group(1); srcPath = matcher.group(2); } else { throw new IllegalArgumentException("The ObjectId is invalid '" + srcPath + "'"); } Session session = uiExplorer.getSessionByWorkspace(wsName); Node selectedNode = uiExplorer.getNodeByPath(srcPath, session, false); if (selectedNode.isNodeType(EXO_TRASH_FOLDER)) return; UIApplication uiApp = event.getSource().getAncestorOfType(UIApplication.class); LinkManager linkManager = event.getSource().getApplicationComponent(LinkManager.class); if (linkManager.isLink(destNode)) { Object[] args = { destNode.getPath() }; uiApp.addMessage(new ApplicationMessage("UIWorkingArea.msg.dest-node-is-link", args, ApplicationMessage.WARNING)); return; } if (linkManager.isLink(selectedNode)) { Object[] args = { srcPath }; uiApp.addMessage(new ApplicationMessage("UIWorkingArea.msg.selected-is-link", args, ApplicationMessage.WARNING)); return; } try { linkManager.createLink(destNode, Utils.EXO_SYMLINK, selectedNode, selectedNode.getName() + ".lnk"); } catch (Exception e) { Object[] args = { Text.unescapeIllegalJcrChars(srcPath), Text.unescapeIllegalJcrChars(destNode.getPath()) }; uiApp.addMessage(new ApplicationMessage("UIWorkingArea.msg.create-link-problem", args, ApplicationMessage.WARNING)); return; } } public static class CreateLinkActionListener extends UIWorkingAreaActionListener<CreateLinkManageComponent> { public void processEvent(Event<CreateLinkManageComponent> event) throws Exception { CreateLinkManageComponent.createLinkManager(event); } } private static void createLinkManager(Event<? extends UIComponent> event) throws Exception { String nodePath = event.getRequestContext().getRequestParameter(OBJECTID); String destPath = event.getRequestContext().getRequestParameter("destInfo"); processMultipleSelection(nodePath.trim(), destPath.trim(), event); } private static void processMultipleSelection(String nodePath, String destPath, Event<? extends UIComponent> event) throws Exception { UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); Matcher matcher = UIWorkingArea.FILE_EXPLORER_URL_SYNTAX.matcher(destPath); String wsName = null; if (matcher.find()) { wsName = matcher.group(1); destPath = matcher.group(2); } else { throw new IllegalArgumentException("The ObjectId is invalid '" + destPath + "'"); } Session session = uiExplorer.getSessionByWorkspace(wsName); UIApplication uiApp = event.getSource().getAncestorOfType(UIApplication.class); if (destPath.startsWith(nodePath)) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.bound-move-exception", null, ApplicationMessage.WARNING)); return; } Node destNode; try { // Use the method getNodeByPath because it is link aware destNode = uiExplorer.getNodeByPath(destPath, session); // Reset the path to manage the links that potentially create virtual path destPath = destNode.getPath(); } catch (PathNotFoundException path) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.path-not-found-exception", null, ApplicationMessage.WARNING)); return; } catch (Exception e) { JCRExceptionManager.process(uiApp, e); return; } if (!PermissionUtil.canAddNode(destNode)) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.can-not-move-node", null, ApplicationMessage.WARNING)); uiExplorer.updateAjax(event); return; } if (uiExplorer.nodeIsLocked(destNode)) { Object[] arg = { destPath }; uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.node-locked", arg, ApplicationMessage.WARNING)); return; } if (!destNode.isCheckedOut()) { uiApp.addMessage(new ApplicationMessage("UIActionBar.msg.node-checkedin", null)); return; } try { if (nodePath.indexOf(";") > -1) { createMultiLink(nodePath.split(";"), destNode, event); } else { createLink(nodePath, destNode, event); } destNode.save(); uiExplorer.updateAjax(event); } catch (AccessDeniedException ace) { Object[] arg = { destPath }; uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.has-not-add-permission", arg, ApplicationMessage.WARNING)); return; } catch (LockException lock) { Object[] arg = { nodePath }; uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.node-locked", arg, ApplicationMessage.WARNING)); return; } catch (ConstraintViolationException constraint) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.move-constraint-exception", null, ApplicationMessage.WARNING)); return; } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error("an unexpected error occurs while selecting the node", e); } JCRExceptionManager.process(uiApp, e); return; } } @Override public Class<? extends UIAbstractManager> getUIAbstractManagerClass() { return null; } }
9,543
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
RenameManageComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/rightclick/manager/RenameManageComponent.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.component.explorer.rightclick.manager; import java.util.Arrays; import java.util.List; import org.exoplatform.ecm.webui.component.explorer.control.filter.*; 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; import org.exoplatform.webui.ext.manager.UIAbstractManagerComponent; /** * Created by The eXo Platform SARL * Author : Hoang Van Hung * hunghvit@gmail.com * Aug 6, 2009 */ @ComponentConfig() public class RenameManageComponent extends UIAbstractManagerComponent { private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[]{new IsNotSpecificFolderNodeFilter(), new IsNotInTrashFilter(), new IsNotParentLockedWhenRenameFilter(), new CanSetPropertyFilter(), new IsNotLockedFilter(), new IsCheckedOutFilter(), new IsNotTrashHomeNodeFilter(), new IsNotEditingDocumentFilter()}); @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } @Override public Class<? extends UIAbstractManager> getUIAbstractManagerClass() { return null; } }
2,531
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
LockManageComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/rightclick/manager/LockManageComponent.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.component.explorer.rightclick.manager; import java.util.Arrays; import java.util.List; import java.util.regex.Matcher; import javax.jcr.AccessDeniedException; import javax.jcr.Node; import javax.jcr.PathNotFoundException; import javax.jcr.Session; import javax.jcr.lock.Lock; import javax.jcr.lock.LockException; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.UIWorkingArea; import org.exoplatform.ecm.webui.component.explorer.control.filter.CanSetPropertyFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsCheckedOutFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotHoldsLockFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotInTrashFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotSimpleLockedFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotTrashHomeNodeFilter; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIWorkingAreaActionListener; import org.exoplatform.ecm.webui.utils.JCRExceptionManager; 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.cms.lock.LockService; import org.exoplatform.services.log.ExoLogger; import org.exoplatform.services.log.Log; import org.exoplatform.services.organization.MembershipType; import org.exoplatform.services.organization.OrganizationService; import org.exoplatform.services.wcm.utils.WCMCoreUtils; 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.UIComponent; import org.exoplatform.webui.event.Event; 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 SARL * Author : Hoang Van Hung * hunghvit@gmail.com * Aug 6, 2009 */ @ComponentConfig( events = { @EventConfig(listeners = LockManageComponent.LockActionListener.class) } ) public class LockManageComponent extends UIAbstractManagerComponent { private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[]{new IsNotInTrashFilter(), new IsNotHoldsLockFilter(), new IsNotSimpleLockedFilter(), new CanSetPropertyFilter(), new IsCheckedOutFilter(), new IsNotTrashHomeNodeFilter() }); private static final Log LOG = ExoLogger.getLogger(LockManageComponent.class.getName()); @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } private static void processMultiLock(String[] nodePaths, Event<?> event, UIJCRExplorer uiExplorer) throws Exception { for(int i=0; i< nodePaths.length; i++) { processLock(nodePaths[i], event, uiExplorer); } uiExplorer.updateAjax(event); } private static void processLock(String nodePath, Event<?> event, UIJCRExplorer uiExplorer) throws Exception { UIApplication uiApp = uiExplorer.getAncestorOfType(UIApplication.class); Matcher matcher = UIWorkingArea.FILE_EXPLORER_URL_SYNTAX.matcher(nodePath); String wsName = null; if (matcher.find()) { wsName = matcher.group(1); nodePath = matcher.group(2); } else { throw new IllegalArgumentException("The ObjectId is invalid '"+ nodePath + "'"); } Session session = uiExplorer.getSessionByWorkspace(wsName); Node node; try { // Use the method getNodeByPath because it is link aware node = uiExplorer.getNodeByPath(nodePath, session); // Reset the path to manage the links that potentially create virtual path nodePath = node.getPath(); // Reset the session to manage the links that potentially change of workspace session = node.getSession(); // Reset the workspace name to manage the links that potentially change of workspace wsName = session.getWorkspace().getName(); } catch(PathNotFoundException path) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.path-not-found-exception", null,ApplicationMessage.WARNING)); return; } catch (Exception e) { JCRExceptionManager.process(uiApp, e); return; } try { if (!PermissionUtil.canSetProperty(node)) throw new AccessDeniedException("access denied, can't lock node:" + node.getPath()); if(node.canAddMixin(Utils.MIX_LOCKABLE)){ node.addMixin(Utils.MIX_LOCKABLE); node.save(); } Lock lock = node.lock(false, false); LockUtil.keepLock(lock); LockService lockService = uiExplorer.getApplicationComponent(LockService.class); List<String> settingLockList = lockService.getAllGroupsOrUsersForLock(); OrganizationService service = WCMCoreUtils.getService(OrganizationService.class); List<MembershipType> memberships = (List<MembershipType>) service.getMembershipTypeHandler().findMembershipTypes(); for (String settingLock : settingLockList) { LockUtil.keepLock(lock, settingLock); if (!settingLock.startsWith("*")) continue; String lockTokenString = settingLock; for (MembershipType membership : memberships) { lockTokenString = settingLock.replace("*", membership.getName()); LockUtil.keepLock(lock, lockTokenString); } } session.save(); } catch(LockException le) { ApplicationMessage appMessage = new ApplicationMessage("UIPopupMenu.msg.cant-lock", new String[] {node.getPath()}, ApplicationMessage.ERROR); appMessage.setArgsLocalized(false); uiApp.addMessage(appMessage); uiExplorer.updateAjax(event); return; } catch (AccessDeniedException adEx) { ApplicationMessage appMessage = new ApplicationMessage("UIPopupMenu.msg.can-not-lock-node", new String[] {node.getPath()}, ApplicationMessage.ERROR); appMessage.setArgsLocalized(false); uiApp.addMessage(appMessage); uiExplorer.updateAjax(event); return; } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error("an unexpected error occurs while locking the node", e); } JCRExceptionManager.process(uiApp, e); uiExplorer.updateAjax(event); } } public static void lockManage(Event<? extends UIComponent> event, UIJCRExplorer uiExplorer) throws Exception { String nodePath = event.getRequestContext().getRequestParameter(OBJECTID); if(nodePath.indexOf(";") > -1) { processMultiLock(nodePath.split(";"), event, uiExplorer); } else { processLock(nodePath, event, uiExplorer); } } public static class LockActionListener extends UIWorkingAreaActionListener<LockManageComponent> { public void processEvent(Event<LockManageComponent> event) throws Exception { UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); lockManage(event, uiExplorer); } } @Override public Class<? extends UIAbstractManager> getUIAbstractManagerClass() { return null; } }
8,856
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
RestoreFromTrashManageComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/rightclick/manager/RestoreFromTrashManageComponent.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.component.explorer.rightclick.manager; import org.apache.commons.lang3.StringEscapeUtils; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.UIWorkingArea; import org.exoplatform.ecm.webui.component.explorer.control.filter.*; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIWorkingAreaActionListener; import org.exoplatform.ecm.webui.component.explorer.popup.actions.UISelectRestorePath; import org.exoplatform.ecm.webui.utils.JCRExceptionManager; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.services.cms.documents.TrashService; import org.exoplatform.services.cms.link.LinkManager; import org.exoplatform.services.cms.link.NodeFinder; import org.exoplatform.services.jcr.RepositoryService; 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; import org.exoplatform.web.application.ApplicationMessage; import org.exoplatform.web.application.RequestContext; 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.UIPopupContainer; import org.exoplatform.webui.event.Event; 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; import javax.jcr.AccessDeniedException; import javax.jcr.Node; import javax.jcr.PathNotFoundException; import javax.jcr.Session; import javax.jcr.lock.LockException; import javax.jcr.nodetype.ConstraintViolationException; import javax.jcr.version.VersionException; import javax.portlet.PortletPreferences; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.ResourceBundle; import java.util.regex.Matcher; /** * Created by The eXo Platform SARL * Author : Nguyen Anh Vu * anhvurz90@gmail.com * Oct 14, 2009 * 5:24:01 PM */ @ComponentConfig( events = { @EventConfig(listeners = RestoreFromTrashManageComponent.RestoreFromTrashActionListener.class , csrfCheck = false) } ) public class RestoreFromTrashManageComponent extends UIAbstractManagerComponent { private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new IsInTrashFilter(), new IsNotLockedFilter(), new IsCheckedOutFilter(), new HasRemovePermissionFilter(), new IsAbleToRestoreFilter(), new IsNotTrashHomeNodeFilter()); private final static Log LOG = ExoLogger.getLogger(RestoreFromTrashManageComponent.class.getName()); @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } public static class RestoreFromTrashActionListener extends UIWorkingAreaActionListener<RestoreFromTrashManageComponent> { private String itemName = ""; private int numberItemsRestored = 0; public void restoreFromTrashManage(Event<RestoreFromTrashManageComponent> event) throws Exception { numberItemsRestored = 0; String srcPath = event.getRequestContext().getRequestParameter(OBJECTID); if (srcPath.indexOf(';') > -1) { multiRestoreFromTrash(srcPath.split(";"), event); } else { restoreFromTrash(srcPath, event); } RequestContext context = RequestContext.getCurrentInstance(); ResourceBundle res = context.getApplicationResourceBundle(); String restoreNotice = ""; if(!srcPath.contains(";") && numberItemsRestored == 1) { restoreNotice = "UIWorkingArea.msg.feedback-restore"; restoreNotice = res.getString(restoreNotice); restoreNotice = restoreNotice.replace("{" + 0 + "}", itemName); } else if(srcPath.indexOf(';') > -1 && numberItemsRestored >= 1) { restoreNotice = "UIWorkingArea.msg.feedback-restore-multi"; restoreNotice = res.getString(restoreNotice); restoreNotice = restoreNotice.replace("{" + 0 + "}", String.valueOf(numberItemsRestored)); } restoreNotice = restoreNotice.replace("\"", "'"); restoreNotice = StringEscapeUtils.escapeHtml4(restoreNotice); if(restoreNotice.length() > 0) { UIWorkingArea uiWorkingArea = event.getSource().getParent(); uiWorkingArea.setWCMNotice(restoreNotice); } } private void multiRestoreFromTrash(String[] paths, Event<RestoreFromTrashManageComponent> event) throws Exception { UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); Session session; Matcher matcher; String wsName; Node node; String origialPath; Arrays.sort(paths,Collections.reverseOrder()); List<String> newPaths = new ArrayList<>(); // In case multi checked items, check if a Symlink node is with its Target in Trash or not. for (int i = 0; i < paths.length ; i++) { String srcPath = paths[i]; origialPath = srcPath; matcher = UIWorkingArea.FILE_EXPLORER_URL_SYNTAX.matcher(srcPath); if (matcher.find()) { wsName = matcher.group(1); srcPath = matcher.group(2); } else { throw new IllegalArgumentException("The ObjectId is invalid '" + srcPath + "'"); } try { session = uiExplorer.getSessionByWorkspace(wsName); // Use the method getNodeByPath because it is link aware node = uiExplorer.getNodeByPath(srcPath, session, false); // Not allow to restore multi items if there is a symlink node, which have Target-In-Trash, in items list. // program returns at once. if (Utils.targetNodeAndLinkInTrash(node)) { continue; } // Reset the path to manage the links that potentially create virtual newPaths.add(origialPath); } catch (PathNotFoundException path) { return; } } for (String path : newPaths) { if (acceptForMultiNode(event, path)) restoreFromTrash(path, event); } } private void restoreFromTrash(String srcPath, Event<RestoreFromTrashManageComponent> event) throws Exception { UIWorkingArea uiWorkingArea = event.getSource().getParent(); UIJCRExplorer uiExplorer = uiWorkingArea.getAncestorOfType(UIJCRExplorer.class); UIApplication uiApp = uiWorkingArea.getAncestorOfType(UIApplication.class); Matcher matcher = UIWorkingArea.FILE_EXPLORER_URL_SYNTAX.matcher(srcPath); String wsName; Node node; if (matcher.find()) { wsName = matcher.group(1); srcPath = matcher.group(2); } else { throw new IllegalArgumentException("The ObjectId is invalid '"+ srcPath + "'"); } Session session = uiExplorer.getSessionByWorkspace(wsName); try { // Use the method getNodeByPath because it is link aware node = uiExplorer.getNodeByPath(srcPath, session, false); //return false if the target is already deleted if ( Utils.targetNodeAndLinkInTrash(node) ) { return; } // Reset the path to manage the links that potentially create virtual path srcPath = node.getPath(); } catch(PathNotFoundException path) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.path-not-found-exception", null,ApplicationMessage.WARNING)); return; } confirmToRestore(node, srcPath, event); } private void confirmToRestore(Node node, String srcPath, Event<RestoreFromTrashManageComponent> event) throws Exception { UIWorkingArea uiWorkingArea = event.getSource().getParent(); UIJCRExplorer uiExplorer = uiWorkingArea.getAncestorOfType(UIJCRExplorer.class); itemName = Utils.getTitle(node); String restorePath = node.getProperty(Utils.EXO_RESTOREPATH).getString(); String restoreWs = node.getProperty(Utils.EXO_RESTORE_WORKSPACE).getString(); Session session = uiExplorer.getSessionByWorkspace(restoreWs); NodeFinder nodeFinder = uiExplorer.getApplicationComponent(NodeFinder.class); try { nodeFinder.getItem(session, restorePath); } catch (PathNotFoundException e) { doRestore(srcPath, node, event); numberItemsRestored++; return; } doRestore(srcPath, node, event); numberItemsRestored++; } public void doRestore(String srcPath, Node node, Event<? extends UIComponent> event) throws Exception { UIJCRExplorer uiExplorer = event.getSource().getAncestorOfType(UIJCRExplorer.class); UIWorkingArea uiWorkingArea = event.getSource().getParent(); TrashService trashService = WCMCoreUtils.getService(TrashService.class); UIApplication uiApp = event.getSource().getAncestorOfType(UIApplication.class); try { uiExplorer.addLockToken(node); } catch (Exception e) { JCRExceptionManager.process(uiApp, e); return; } SessionProvider sessionProvider = null; try { PortletPreferences portletPrefs = uiExplorer.getPortletPreferences(); String repository = uiExplorer.getRepositoryName(); String trashWorkspace = portletPrefs.getValue(Utils.TRASH_WORKSPACE, ""); String trashHomeNodePath = portletPrefs.getValue(Utils.TRASH_HOME_NODE_PATH, ""); //Have to create session from System Provider to allow normal user to restore the content that deleted before sessionProvider = WCMCoreUtils.getSystemSessionProvider(); RepositoryService repositoryService = uiExplorer.getApplicationComponent(RepositoryService.class); ManageableRepository manageableRepository = repositoryService.getCurrentRepository(); Session trashSession = sessionProvider.getSession(trashWorkspace, manageableRepository); Node trashHomeNode = (Node) trashSession.getItem(trashHomeNodePath); try { trashService.restoreFromTrash(srcPath, sessionProvider); // delete symlink after target node LinkManager linkManager = WCMCoreUtils.getService(LinkManager.class); List<Node> symlinks = linkManager.getAllLinks(node, org.exoplatform.services.cms.impl.Utils.EXO_SYMLINK); for (Node symlink : symlinks) { String realPath = symlink.getPath(); if(!trashHomeNode.getSession().itemExists(realPath)){ realPath = trashHomeNodePath + "/" + symlink.getName(); } trashService.restoreFromTrash(realPath, sessionProvider); } uiExplorer.updateAjax(event); } catch(PathNotFoundException e) { UIPopupContainer uiPopupContainer = uiExplorer.getChild(UIPopupContainer.class); UISelectRestorePath uiSelectRestorePath = uiWorkingArea.createUIComponent(UISelectRestorePath.class, null, null); uiSelectRestorePath.setTrashHomeNode(trashHomeNode); uiSelectRestorePath.setSrcPath(srcPath); uiSelectRestorePath.setRepository(repository); uiPopupContainer.activate(uiSelectRestorePath, 600, 300); event.getRequestContext().addUIComponentToUpdateByAjax(uiPopupContainer); } } catch (PathNotFoundException e) { if (LOG.isErrorEnabled()) { LOG.error("Path not found! Maybe, it was removed or path changed, can't restore node :" + node.getPath()); } JCRExceptionManager.process(uiApp, e); uiExplorer.updateAjax(event); } catch (LockException e) { if (LOG.isErrorEnabled()) { LOG.error("node is locked, can't restore node :" + node.getPath()); } JCRExceptionManager.process(uiApp, e); uiExplorer.updateAjax(event); } catch (VersionException e) { if (LOG.isErrorEnabled()) { LOG.error("node is checked in, can't restore node:" + node.getPath()); } JCRExceptionManager.process(uiApp, e); uiExplorer.updateAjax(event); } catch (AccessDeniedException | ConstraintViolationException e) { if (LOG.isErrorEnabled()) { LOG.error("access denied, can't restore of node:" + node.getPath()); } JCRExceptionManager.process(uiApp, e); uiExplorer.updateAjax(event); } catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error("an unexpected error occurs", e); } JCRExceptionManager.process(uiApp, e); uiExplorer.updateAjax(event); } } public void processEvent(Event<RestoreFromTrashManageComponent> event) throws Exception { restoreFromTrashManage(event); } } @Override public Class<? extends UIAbstractManager> getUIAbstractManagerClass() { return null; } }
13,929
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
CopyManageComponent.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/rightclick/manager/CopyManageComponent.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.component.explorer.rightclick.manager; import java.util.Arrays; import java.util.List; import java.util.regex.Matcher; import javax.jcr.Node; import javax.jcr.PathNotFoundException; import javax.jcr.Session; import javax.jcr.nodetype.ConstraintViolationException; import org.exoplatform.services.cms.clipboard.ClipboardService; import org.exoplatform.services.cms.clipboard.jcr.model.ClipboardCommand; import org.exoplatform.services.log.Log; import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer; import org.exoplatform.ecm.webui.component.explorer.UIWorkingArea; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotInTrashFilter; import org.exoplatform.ecm.webui.component.explorer.control.filter.IsNotTrashHomeNodeFilter; import org.exoplatform.ecm.webui.component.explorer.control.listener.UIWorkingAreaActionListener; import org.exoplatform.ecm.webui.utils.JCRExceptionManager; import org.exoplatform.ecm.webui.utils.Utils; import org.exoplatform.services.log.ExoLogger; import org.exoplatform.services.security.ConversationState; import org.exoplatform.services.wcm.utils.WCMCoreUtils; 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.UIComponent; import org.exoplatform.webui.event.Event; 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 SARL * Author : Hoang Van Hung * hunghvit@gmail.com * Aug 5, 2009 */ @ComponentConfig( events = { @EventConfig(listeners = CopyManageComponent.CopyActionListener.class) } ) public class CopyManageComponent extends UIAbstractManagerComponent { private static final List<UIExtensionFilter> FILTERS = Arrays.asList(new UIExtensionFilter[]{new IsNotInTrashFilter(), new IsNotTrashHomeNodeFilter()}); private final static Log LOG = ExoLogger.getLogger(CopyManageComponent.class.getName()); @UIExtensionFilters public List<UIExtensionFilter> getFilters() { return FILTERS; } public static void multipleCopy(String[] srcPaths, Event<UIComponent> event) throws Exception { for(int i=0; i< srcPaths.length; i++) { processCopy(srcPaths[i], event, true); } } public static void processCopy(String srcPath, Event<?> event, boolean isMultiSelect) throws Exception { UIWorkingArea uiWorkingArea = ((UIComponent)event.getSource()).getParent(); UIJCRExplorer uiExplorer = uiWorkingArea.getAncestorOfType(UIJCRExplorer.class); UIApplication uiApp = uiWorkingArea.getAncestorOfType(UIApplication.class); Matcher matcher = UIWorkingArea.FILE_EXPLORER_URL_SYNTAX.matcher(srcPath); String wsName = null; if (matcher.find()) { wsName = matcher.group(1); srcPath = matcher.group(2); } else { throw new IllegalArgumentException("The ObjectId is invalid '"+ srcPath + "'"); } Session session = uiExplorer.getSessionByWorkspace(wsName); try { // Use the method getNodeByPath because it is link aware Node node = uiExplorer.getNodeByPath(srcPath, session, false); // Reset the path to manage the links that potentially create virtual path srcPath = node.getPath(); // Reset the session to manage the links that potentially change of workspace session = node.getSession(); // Reset the workspace name to manage the links that potentially change of workspace wsName = session.getWorkspace().getName(); } catch(PathNotFoundException path) { uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.path-not-found-exception", null,ApplicationMessage.WARNING)); return; } ClipboardCommand clipboard = new ClipboardCommand(ClipboardCommand.COPY, srcPath, wsName); ClipboardService clipboardService = WCMCoreUtils.getService(ClipboardService.class); String userId = ConversationState.getCurrent().getIdentity().getUserId(); clipboardService.addClipboardCommand(userId, clipboard, false); if (isMultiSelect) { clipboardService.addClipboardCommand(userId, clipboard, true); } } public static void copyManage(Event<UIComponent> event) throws Exception { String srcPath = event.getRequestContext().getRequestParameter(OBJECTID); ClipboardService clipboardService = WCMCoreUtils.getService(ClipboardService.class); String userId = ConversationState.getCurrent().getIdentity().getUserId(); clipboardService.clearClipboardList(userId, true); if(srcPath.indexOf(";") > -1) { multipleCopy(Utils.removeChildNodes(srcPath), event); } else { processCopy(srcPath, event, false); } } public static class CopyActionListener extends UIWorkingAreaActionListener<CopyManageComponent> { public void processEvent(Event<CopyManageComponent> event) throws Exception { Event<UIComponent> event_ = new Event<UIComponent>( event.getSource(), event.getName(),event.getRequestContext()); copyManage(event_); } } @Override public Class<? extends UIAbstractManager> getUIAbstractManagerClass() { return null; } }
6,522
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
BaseConnectorTestSuite.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/connector/src/test/java/org/exoplatform/BaseConnectorTestSuite.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; import org.exoplatform.commons.testing.BaseExoContainerTestSuite; import org.exoplatform.commons.testing.ConfigTestCase; //import org.exoplatform.wcm.connector.authoring.TestCopyContentFile; //import org.exoplatform.wcm.connector.authoring.TestLifecycleConnector; import org.exoplatform.ecm.connector.platform.ManageDocumentServiceTest; import org.exoplatform.wcm.connector.collaboration.TestDownloadConnector; import org.exoplatform.wcm.connector.collaboration.TestFavoriteRESTService; import org.exoplatform.wcm.connector.collaboration.TestOpenInOfficeConnector; import org.exoplatform.wcm.connector.collaboration.TestThumbnailRESTService; import org.exoplatform.wcm.connector.fckeditor.TestPortalLinkConnector; import org.exoplatform.wcm.connector.viewer.TestPDFViewerRESTService; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.runner.RunWith; import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; /** * Created by The eXo Platform SAS * Author : Pham Duy Dong * dongpd@exoplatform.com */ @RunWith(Suite.class) @SuiteClasses({ TestPortalLinkConnector.class, TestPDFViewerRESTService.class, // TestCopyContentFile.class, // TestLifecycleConnector.class, TestDownloadConnector.class, TestOpenInOfficeConnector.class, TestThumbnailRESTService.class, TestFavoriteRESTService.class, ManageDocumentServiceTest.class }) @ConfigTestCase(BaseConnectorTestCase.class) public class BaseConnectorTestSuite extends BaseExoContainerTestSuite { @BeforeClass public static void setUp() throws Exception { initConfiguration(BaseConnectorTestSuite.class); beforeSetup(); } @AfterClass public static void tearDown() { afterTearDown(); } }
2,452
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
BaseConnectorTestCase.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/connector/src/test/java/org/exoplatform/BaseConnectorTestCase.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 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; import org.exoplatform.component.test.ConfigurationUnit; import org.exoplatform.component.test.ConfiguredBy; import org.exoplatform.component.test.ContainerScope; import org.exoplatform.ecms.test.BaseECMSResourceTestCase; /** * Created by The eXo Platform SAS * Author : Lai Trung Hieu * hieult@exoplatform.com * Aug 6, 2012 */ @ConfiguredBy({ @ConfigurationUnit(scope = ContainerScope.ROOT, path = "conf/configuration.xml"), @ConfigurationUnit(scope = ContainerScope.PORTAL, path = "conf/portal/configuration.xml"), @ConfigurationUnit(scope = ContainerScope.PORTAL, path = "conf/exo.social.component.core-configuration.xml"), @ConfigurationUnit(scope = ContainerScope.PORTAL, path = "conf/standalone/ecms-test-configuration.xml"), @ConfigurationUnit(scope = ContainerScope.PORTAL, path = "conf/standalone/ecms-core-connector-test-configuration.xml") }) public abstract class BaseConnectorTestCase extends BaseECMSResourceTestCase { }
1,710
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
TestPortalLinkConnector.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/connector/src/test/java/org/exoplatform/wcm/connector/fckeditor/TestPortalLinkConnector.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 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.wcm.connector.fckeditor; import javax.ws.rs.core.Response; import javax.xml.transform.dom.DOMSource; import org.apache.commons.lang3.StringUtils; import org.exoplatform.BaseConnectorTestCase; import org.exoplatform.services.rest.impl.ContainerResponse; import org.exoplatform.services.rest.wadl.research.HTTPMethods; import org.exoplatform.services.security.ConversationState; import org.exoplatform.services.security.Identity; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; /** * Created by The eXo Platform SAS * Author : Lai Trung Hieu * hieult@exoplatform.com * Aug 6, 2012 */ public class TestPortalLinkConnector extends BaseConnectorTestCase { public void setUp() throws Exception { super.setUp(); // Bind PortalLinkConnector REST service PortalLinkConnector restService = (PortalLinkConnector) this.container.getComponentInstanceOfType(PortalLinkConnector.class); this.binder.addResource(restService, null); } public void tearDown() throws Exception { super.tearDown(); } /** * Test method PortalLinkConnector.getPageURI() * Input 1: /portalLinks/getFoldersAndFiles/ * Expect 1: Connector return data in XML format as: * <Connector command="" resourceType="PortalPageURI"> * <CurrentFolder path="" url=""> * </CurrentFolder> * <Folders> * <Folder name="classic" url="" path="/"> * </Folder> * </Folders> * </Connector> * * Input 2: /portalLinks/getFoldersAndFiles?currentFolder=/classic/ * Expect 2: Connector return data in XML format OK * * Input 3: /portalLinks/getFoldersAndFiles?currentFolder=/classic/home * Expect 3: Connector return data in XML format as: * <Connector command="" resourceType="PortalPageURI"> * <CurrentFolder path="/classic/home" url=""> * </CurrentFolder> * <Folders> * <Folder name="classic" url="" path="/"> * </Folder> * </Folders> * <Files> * </Files> * </Connector> * @throws Exception */ public void testGetPageURI() throws Exception{ ConversationState.setCurrent(new ConversationState(new Identity("root"))); String restPath = "/portalLinks/getFoldersAndFiles/"; ContainerResponse response = service(HTTPMethods.GET.toString(), restPath, StringUtils.EMPTY, null, null); assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); DOMSource object = (DOMSource) response.getEntity(); Document node = (Document) object.getNode(); Element connector = (Element) node.getChildNodes().item(0); NodeList ConnectorChildren = connector.getChildNodes(); assertEquals("Connector", connector.getNodeName()); assertEquals("", connector.getAttribute("command")); assertEquals("PortalPageURI", connector.getAttribute("resourceType")); assertEquals(2, ConnectorChildren.getLength()); Element currentFolder = (Element) ConnectorChildren.item(0); assertEquals("CurrentFolder", currentFolder.getNodeName()); assertEquals("/", currentFolder.getAttribute("path")); assertEquals("", currentFolder.getAttribute("url")); Node folders = ConnectorChildren.item(1); assertEquals("Folders", folders.getNodeName()); Element firstFolder = (Element) folders.getChildNodes().item(0); assertNotNull(firstFolder); assertEquals("classic", firstFolder.getAttribute("name")); assertEquals("", firstFolder.getAttribute("url")); assertEquals("", firstFolder.getAttribute("folderType")); restPath = "/portalLinks/getFoldersAndFiles?currentFolder=/classic/"; response = service(HTTPMethods.GET.toString(), restPath, StringUtils.EMPTY, null, null); assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); restPath = "/portalLinks/getFoldersAndFiles?currentFolder=/classic/home"; response = service(HTTPMethods.GET.toString(), restPath, StringUtils.EMPTY, null, null); assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); object = (DOMSource) response.getEntity(); node = (Document) object.getNode(); connector = (Element) node.getChildNodes().item(0); ConnectorChildren = connector.getChildNodes(); assertEquals("Connector", connector.getNodeName()); assertEquals("", connector.getAttribute("command")); assertEquals("PortalPageURI", connector.getAttribute("resourceType")); assertEquals(3, ConnectorChildren.getLength()); currentFolder = (Element) ConnectorChildren.item(0); assertEquals("CurrentFolder", currentFolder.getNodeName()); assertEquals("/classic/home", currentFolder.getAttribute("path")); assertEquals("", currentFolder.getAttribute("url")); folders = ConnectorChildren.item(1); assertEquals("Folders", folders.getNodeName()); Node files = ConnectorChildren.item(2); assertEquals("Files", files.getNodeName()); } }
5,672
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
TestPDFViewerRESTService.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/connector/src/test/java/org/exoplatform/wcm/connector/viewer/TestPDFViewerRESTService.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 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.wcm.connector.viewer; import javax.jcr.Node; import javax.jcr.Session; import javax.ws.rs.core.Response; import org.apache.commons.lang3.StringUtils; import org.exoplatform.BaseConnectorTestCase; import org.exoplatform.services.jcr.core.ManageableRepository; import org.exoplatform.services.rest.impl.ContainerResponse; import org.exoplatform.services.rest.wadl.research.HTTPMethods; import org.exoplatform.services.wcm.utils.WCMCoreUtils; /** * Created by The eXo Platform SAS * Author : Nguyen The Vinh From ECM Of eXoPlatform * vinh_nguyen@exoplatform.com * 22 Aug 2012 */ public class TestPDFViewerRESTService extends BaseConnectorTestCase { private static final String restPath = "/pdfviewer/repository/collaboration/1/0.0/1.0/"; private static final String WrongNumberPath = "/pdfviewer/repository/collaboration/1a/0.a/1.b/"; private ManageableRepository manageableRepository; public void setUp() throws Exception { super.setUp(); PDFViewerRESTService pdfViewerRestService = (PDFViewerRESTService) this.container.getComponentInstanceOfType(PDFViewerRESTService.class); this.binder.addResource(pdfViewerRestService, null); } public void tearDown() throws Exception { super.tearDown(); } //http://localhost:8080/ecmdemo/rest-ecmdemo4d725eb57f0001010030cc50eb140189?2012-08-22T15:28:05.522+07:00 public void testGetFavoriteByUser() throws Exception{ /* Prepare the favourite nodes */ manageableRepository = repositoryService.getCurrentRepository(); Session session = WCMCoreUtils.getSystemSessionProvider().getSession(COLLABORATION_WS, manageableRepository); //Test the main case Node node = (Node) session.getItem("/metro.pdf"); String restUUIDPath = restPath + node.getUUID(); ContainerResponse response = service(HTTPMethods.GET.toString(), restUUIDPath, StringUtils.EMPTY, null, null); assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); response = service(HTTPMethods.GET.toString(), restUUIDPath, StringUtils.EMPTY, null, null); assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); //Cover the case of wrong number format input restUUIDPath = WrongNumberPath + node.getUUID(); response = service(HTTPMethods.GET.toString(), restUUIDPath, StringUtils.EMPTY, null, null); assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); //Test pdfViewer with doc file node = (Node) session.getItem("/conditions.doc"); restUUIDPath = restPath + node.getUUID(); response = service(HTTPMethods.GET.toString(), restUUIDPath, StringUtils.EMPTY, null, null); assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); } }
3,484
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z
TestThumbnailRESTService.java
/FileExtraction/Java_unseen/exoplatform_ecms/core/connector/src/test/java/org/exoplatform/wcm/connector/collaboration/TestThumbnailRESTService.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 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.wcm.connector.collaboration; import java.net.URLEncoder; import java.text.SimpleDateFormat; import java.util.*; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.Response; import javax.jcr.Node; import org.apache.commons.lang3.StringUtils; import org.exoplatform.BaseConnectorTestCase; import org.exoplatform.services.jcr.impl.core.NodeImpl; import org.exoplatform.services.jcr.util.Text; import org.exoplatform.services.rest.impl.ContainerResponse; import org.exoplatform.services.rest.impl.MultivaluedMapImpl; import org.exoplatform.services.rest.wadl.research.HTTPMethods; import org.exoplatform.services.security.ConversationState; import org.exoplatform.services.security.Identity; import org.exoplatform.services.wcm.core.NodetypeConstant; /** * Created by The eXo Platform SAS * Author : Nguyen The Vinh From ECM Of eXoPlatform * vinh_nguyen@exoplatform.com * 23 Aug 2012 */ public class TestThumbnailRESTService extends BaseConnectorTestCase{ public void setUp() throws Exception { super.setUp(); ThumbnailRESTService restService = (ThumbnailRESTService) this.container.getComponentInstanceOfType(ThumbnailRESTService.class); this.binder.addResource(restService, null); } public void testGetOriginImageSpecialCharacter() throws Exception{ String restPath = "/thumbnailImage/origin/repository/collaboration/" + URLEncoder.encode(Text.escapeIllegalJcrChars("~!@%23$%^()`=}{-%22,.___ -.png"), "UTF-8"); ConversationState.setCurrent(new ConversationState(new Identity("john"))); applyUserSession("john", "gtn", "collaboration"); /* Prepare the favourite nodes */ ContainerResponse response = service(HTTPMethods.GET.toString(), restPath, StringUtils.EMPTY, null, null); assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); } public void testGetOriginImage() throws Exception{ String restPath = "/thumbnailImage/origin/repository/collaboration/offices.jpg"; ConversationState.setCurrent(new ConversationState(new Identity("john"))); /* Prepare the favourite nodes */ ContainerResponse response = service(HTTPMethods.GET.toString(), restPath, StringUtils.EMPTY, null, null); assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); } public void testGetLargeImage() throws Exception{ String restPath = "/thumbnailImage/large/repository/collaboration/offices.jpg"; ConversationState.setCurrent(new ConversationState(new Identity("john"))); /* Prepare the favourite nodes */ ContainerResponse response = service(HTTPMethods.GET.toString(), restPath, StringUtils.EMPTY, null, null); assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); } public void testGetBigImage() throws Exception{ String restPath = "/thumbnailImage/big/repository/collaboration/offices.jpg"; ConversationState.setCurrent(new ConversationState(new Identity("john"))); /* Prepare the favourite nodes */ ContainerResponse response = service(HTTPMethods.GET.toString(), restPath, StringUtils.EMPTY, null, null); assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); } public void testGetMediumImage() throws Exception{ String restPath = "/thumbnailImage/medium/repository/collaboration/offices.jpg"; ConversationState.setCurrent(new ConversationState(new Identity("john"))); /* Prepare the favourite nodes */ ContainerResponse response = service(HTTPMethods.GET.toString(), restPath, StringUtils.EMPTY, null, null); assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); } public void testGetSmallImage() throws Exception{ applyUserSession("john", "gtn", "collaboration"); String restPath = "/thumbnailImage/small/repository/collaboration/metro.pdf"; ConversationState.setCurrent(new ConversationState(new Identity("john"))); MultivaluedMap<String, String> headers = new MultivaluedMapImpl(); Calendar cal = Calendar.getInstance(); cal.add(Calendar.YEAR, -10); SimpleDateFormat dateFormat = new SimpleDateFormat(ThumbnailRESTService.IF_MODIFIED_SINCE_DATE_FORMAT); headers.putSingle("If-Modified-Since", dateFormat.format(cal.getTime())); /* Prepare the favourite nodes */ ContainerResponse response = service(HTTPMethods.GET.toString(), restPath, StringUtils.EMPTY, headers, null); assertNotNull(response); if(response.getStatus() == 200) { assertEquals("image", response.getContentType().getType()); } } public void testGetCustomImage() throws Exception{ String workspaceName = "collaboration"; String userName = "john"; Node rootNode = session.getRootNode(); Node node = rootNode.addNode("test"); node.setProperty(NodetypeConstant.JCR_MIME_TYPE, "image/png"); session.save(); String identifier = ((NodeImpl) node).getIdentifier(); applyUserSession(userName, "gtn", workspaceName); ConversationState.setCurrent(new ConversationState(new Identity(userName))); String restPath = "/thumbnailImage/custom/250x250/collaboration/"+identifier; MultivaluedMap<String, String> headers = new MultivaluedMapImpl(); Calendar cal = Calendar.getInstance(); cal.add(Calendar.YEAR, -10); SimpleDateFormat dateFormat = new SimpleDateFormat(ThumbnailRESTService.IF_MODIFIED_SINCE_DATE_FORMAT); headers.putSingle("If-Modified-Since", dateFormat.format(cal.getTime())); ContainerResponse response = service(HTTPMethods.GET.toString(), restPath, StringUtils.EMPTY, headers, null); assertNotNull(response); assertEquals(200,response.getStatus()); } public void tearDown() throws Exception { super.tearDown(); } }
6,448
Java
.java
exoplatform/ecms
25
59
13
2012-04-05T03:17:28Z
2024-05-09T08:26:32Z