Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

ECMS-3746 Revert Wrong behavior of manage public tag of ECMS-3280

Fix description:
Problem: The patch ECMS-3280 generate a wrong behavior as an user who create a public tag cannot edit this tag is he doesn't have the right to edit.
Solution: Revert what is done in ECMS-3280
  • Loading branch information...
commit e89fe476984499f33bfbbab9a4066fcc12a4e53f 1 parent f6ef7f3
@dongpd dongpd authored nguyenthienhuong committed
View
25 core/services/src/main/java/org/exoplatform/services/cms/folksonomy/NewFolksonomyService.java
@@ -613,33 +613,8 @@ public void removeTagsOfNodeRecursively(Node node,
* @param scope Scope of tag
* @param memberships Memberships
* @return true If it is possible
- *
- * @see NewFolksonomyService#canEditTag(Node, int, List)
- * @see NewFolksonomyService#canEditTag(String, String, int, List)
*/
- @Deprecated
public boolean canEditTag(int scope, List<String> memberships);
-
- /**
- * Can edit tag or not?
- * @param workspace
- * @param tagName
- * @param scope
- * @param memberships
- * @return
- * @throws Exception
- */
- public boolean canEditTag(String workspace, String tagName, int scope, List<String> memberships) throws Exception;
-
- /**
- * Can edit tag or not?
- * @param tagNode
- * @param scope
- * @param memberships
- * @return
- * @throws Exception
- */
- public boolean canEditTag(Node tagNode, int scope, List<String> memberships) throws Exception;
/**
* Get all tag names which start within given scope
View
62 core/services/src/main/java/org/exoplatform/services/cms/folksonomy/impl/NewFolksonomyServiceImpl.java
@@ -49,8 +49,6 @@
import org.exoplatform.services.jcr.ext.hierarchy.NodeHierarchyCreator;
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.picocontainer.Startable;
/**
@@ -241,8 +239,8 @@ public void addPublicTag(String treePath,
public void addPublicTag(String treePath,
String[] tagsName,
Node documentNode,
- String workspace) throws Exception {
- Node publicFolksonomyTreeNode = getNode(workspace, treePath, WCMCoreUtils.getUserSessionProvider());
+ String workspace) throws Exception {
+ Node publicFolksonomyTreeNode = getNode(workspace, treePath);
Node targetNode = getTargetNode(documentNode);
for (String tag : tagsName) {
try {
@@ -928,11 +926,7 @@ public void removeTagPermission(String usersOrGroups) {
/**
* {@inheritDoc}
- *
- * @see NewFolksonomyServiceImpl#canEditTag(Node, int, List)
- * @see NewFolksonomyServiceImpl#canEditTag(String, String, int, List)
*/
- @Deprecated
public boolean canEditTag(int scope, List<String> memberships) {
if (scope == PUBLIC) {
if (tagPermissionList != null)
@@ -948,58 +942,6 @@ public boolean canEditTag(int scope, List<String> memberships) {
}
return true;
}
-
- public boolean canEditTag(String workspace, String tagName, int scope, List<String> memberships) throws Exception {
- if (scope == PUBLIC) {
- String tagPath = nodeHierarchyCreator.getJcrPath(PUBLIC_TAG_NODE_PATH) + '/' + tagName;
- Node tagNode = getNode(workspace, tagPath);
- return canEditPublicTag(tagNode, scope, memberships);
- }
- return true;
- }
-
- public boolean canEditTag(Node tagNode, int scope, List<String> memberships) throws Exception {
- if (scope == PUBLIC) {
- return canEditPublicTag(tagNode, scope, memberships);
- }
- return true;
- }
-
- /**
- * used to check a public tag could be edited or not
- * @param tagNode
- * @param scope
- * @param memberships
- * @return
- * @throws Exception
- */
- private boolean canEditPublicTag(Node tagNode, int scope, List<String> memberships) throws Exception {
- //check if tagNode is not a public tag
- if (!tagNode.getPath().startsWith(nodeHierarchyCreator.getJcrPath(PUBLIC_TAG_NODE_PATH))) {
- return false;
- }
-
- //tag owner can edit tag
- if (tagNode.hasProperty("exo:owner")) {
- String owner = tagNode.getProperty("exo:owner").getString();
- String currentUser = ConversationState.getCurrent().getIdentity().getUserId();
- if (owner != null && currentUser != null && owner.equals(currentUser)) {
- return true;
- }
- }
-
- //check tag permission
- if (tagPermissionList != null)
- for (String membership : memberships) {
- if (tagPermissionList.contains(membership))
- return true;
- if (membership.contains(":")) {
- if (tagPermissionList.contains("*" + membership.substring(membership.indexOf(":"))))
- return true;
- }
- }
- return false;
- }
/**
* {@inheritDoc}
View
180 core/services/src/test/java/conf/standalone/test-folksonomy-configuration.xml
@@ -117,184 +117,4 @@
</component-plugin>
</external-component-plugins>
- <external-component-plugins>
- <target-component>org.exoplatform.services.jcr.ext.hierarchy.NodeHierarchyCreator</target-component>
- <component-plugin>
- <name>addPaths</name>
- <set-method>addPlugin</set-method>
- <type>org.exoplatform.services.jcr.ext.hierarchy.impl.AddPathPlugin</type>
- <init-params>
- <object-param>
- <name>cms.configuration</name>
- <description>configuration for public tag node</description>
- <object type="org.exoplatform.services.jcr.ext.hierarchy.impl.HierarchyConfig">
- <field name="repository">
- <string>repository</string>
- </field>
- <field name="workspaces">
- <collection type="java.util.ArrayList">
- <value>
- <string>collaboration</string>
- </value>
- </collection>
- </field>
- <field name="jcrPaths">
- <collection type="java.util.ArrayList">
- <value>
- <object type="org.exoplatform.services.jcr.ext.hierarchy.impl.HierarchyConfig$JcrPath">
- <field name="alias">
- <string>exoApplicationDataNode</string>
- </field>
- <field name="path">
- <string>/Application Data</string>
- </field>
- <field name="mixinTypes">
- <collection type="java.util.ArrayList">
- <value>
- <string>exo:hiddenable</string>
- </value>
- </collection>
- </field>
- <field name="permissions">
- <collection type="java.util.ArrayList">
- <value>
- <object type="org.exoplatform.services.jcr.ext.hierarchy.impl.HierarchyConfig$Permission">
- <field name="identity">
- <string>*:/platform/administrators</string>
- </field>
- <field name="read">
- <string>true</string>
- </field>
- <field name="addNode">
- <string>true</string>
- </field>
- <field name="setProperty">
- <string>true</string>
- </field>
- <field name="remove">
- <string>true</string>
- </field>
- </object>
- </value>
- <value>
- <object type="org.exoplatform.services.jcr.ext.hierarchy.impl.HierarchyConfig$Permission">
- <field name="identity">
- <string>*:/platform/users</string>
- </field>
- <field name="read">
- <string>true</string>
- </field>
- <field name="addNode">
- <string>true</string>
- </field>
- <field name="setProperty">
- <string>true</string>
- </field>
- <field name="remove">
- <string>true</string>
- </field>
- </object>
- </value>
- <value>
- <object type="org.exoplatform.services.jcr.ext.hierarchy.impl.HierarchyConfig$Permission">
- <field name="identity">
- <string>any</string>
- </field>
- <field name="read">
- <string>true</string>
- </field>
- <field name="addNode">
- <string>false</string>
- </field>
- <field name="setProperty">
- <string>false</string>
- </field>
- <field name="remove">
- <string>false</string>
- </field>
- </object>
- </value>
- </collection>
- </field>
- </object>
- </value>
- <value>
- <object type="org.exoplatform.services.jcr.ext.hierarchy.impl.HierarchyConfig$JcrPath">
- <field name="alias">
- <string>exoPublicTagNode</string>
- </field>
- <field name="path">
- <string>/Application Data/Tags</string>
- </field>
- <field name="permissions">
- <collection type="java.util.ArrayList">
- <value>
- <object type="org.exoplatform.services.jcr.ext.hierarchy.impl.HierarchyConfig$Permission">
- <field name="identity">
- <string>*:/platform/administrators</string>
- </field>
- <field name="read">
- <string>true</string>
- </field>
- <field name="addNode">
- <string>true</string>
- </field>
- <field name="setProperty">
- <string>true</string>
- </field>
- <field name="remove">
- <string>true</string>
- </field>
- </object>
- </value>
- <value>
- <object type="org.exoplatform.services.jcr.ext.hierarchy.impl.HierarchyConfig$Permission">
- <field name="identity">
- <string>*:/platform/users</string>
- </field>
- <field name="read">
- <string>true</string>
- </field>
- <field name="addNode">
- <string>true</string>
- </field>
- <field name="setProperty">
- <string>true</string>
- </field>
- <field name="remove">
- <string>true</string>
- </field>
- </object>
- </value>
- <value>
- <object type="org.exoplatform.services.jcr.ext.hierarchy.impl.HierarchyConfig$Permission">
- <field name="identity">
- <string>any</string>
- </field>
- <field name="read">
- <string>true</string>
- </field>
- <field name="addNode">
- <string>false</string>
- </field>
- <field name="setProperty">
- <string>false</string>
- </field>
- <field name="remove">
- <string>false</string>
- </field>
- </object>
- </value>
- </collection>
- </field>
- </object>
- </value>
- </collection>
- </field>
- </object>
- </object-param>
- </init-params>
- </component-plugin>
- </external-component-plugins>
-
</configuration>
View
164 core/services/src/test/java/org/exoplatform/services/ecm/dms/folksonomy/TestNewFolksonomyService.java
@@ -16,7 +16,6 @@
*/
package org.exoplatform.services.ecm.dms.folksonomy;
-import java.util.ArrayList;
import java.util.List;
import javax.jcr.Node;
@@ -53,11 +52,13 @@
@Override
public void setUp() throws Exception {
- super.setUp();
-
- newFolksonomyService_ = (NewFolksonomyService)container.getComponentInstanceOfType(NewFolksonomyService.class);
- linkManager = (LinkManager) container.getComponentInstanceOfType(LinkManager.class);
+ super.setUp();
+ newFolksonomyService_ = (NewFolksonomyService)
+ container.getComponentInstanceOfType(NewFolksonomyService.class);
+ linkManager
+ = (LinkManager) container.getComponentInstanceOfType(LinkManager.class);
+// String userName = session.getUserID();
String userName = session.getUserID();
Node root = session.getRootNode();
Node applicationData = root.hasNode("Application Data") ?
@@ -137,137 +138,6 @@ public void testAddPrivateTag() throws Exception {
assertEquals("testAddPrivateTag failed! ", 1L, sportTagNode.getProperty(EXO_TOTAL).getLong());
assertEquals("testAddPrivateTag failed! ", 1L, weatherTagNode.getProperty(EXO_TOTAL).getLong());
}
-
- /** *
- * Test Method: canEditTag()
- * Description: Can edit the PRIVATE tags or not?
- * Input: Node 'test'
- * Test action: add 2 PRIVATE tags 'sport' and 'weather' for node 'test'
- * Expected Result:
- * return true
- */
- public void testCanEditTag_Case01() throws Exception {
- String[] tags = { "sport", "weather" };
- newFolksonomyService_.addPrivateTag(tags, test, COLLABORATION_WS, session.getUserID());
-
- assertTrue("testCanEditTag_Case01 failed! ", folksonomyNode.hasNode("sport"));
- assertTrue("testCanEditTag_Case01 failed! ", folksonomyNode.hasNode("weather"));
-
- List<String> memberships = new ArrayList<String>();
- boolean canEditSport = newFolksonomyService_.canEditTag(COLLABORATION_WS,
- "sport",
- NewFolksonomyService.PRIVATE,
- memberships);
- boolean canEditWeather = newFolksonomyService_.canEditTag(COLLABORATION_WS,
- "weather",
- NewFolksonomyService.
- PRIVATE, memberships);
-
- assertTrue("testCanEditTag_Case01 failed!", canEditSport);
- assertTrue("testCanEditTag_Case01 failed!", canEditWeather);
- }
-
- /**
- * Test Method: canEditTag()
- * Description: Can edit the PUBLIC tags (which user is owner) or not?
- * Input: Node 'test'
- * Test action: add 2 PUBLIC tags 'sport' and 'weather' for node 'test'
- * Expected Result:
- * return true
- */
- public void testCanEditTag_Case02() throws Exception {
- //In this testcase, we need to use User session, instead of using System Session like other testcases
- applyUserSession("root", "exo");
-
- String[] publicTags = { "sport", "weather" };
- String publicFolksonomyTreePath = "/Application Data/Tags";
- newFolksonomyService_.addPublicTag(publicFolksonomyTreePath, publicTags, test, COLLABORATION_WS);
-
- assertTrue("testCanEditTag_Case02 failed! ", publicFolksonomyNode.hasNode("sport"));
- assertTrue("testCanEditTag_Case02 failed! ", publicFolksonomyNode.hasNode("weather"));
-
- List<String> memberships = new ArrayList<String>();
- boolean canEditSport = newFolksonomyService_.canEditTag(COLLABORATION_WS,
- "sport",
- NewFolksonomyService.PUBLIC,
- memberships);
- boolean canEditWeather = newFolksonomyService_.canEditTag(COLLABORATION_WS,
- "weather",
- NewFolksonomyService.PUBLIC,
- memberships);
-
- assertTrue("testCanEditTag_Case02 failed!", canEditSport);
- assertTrue("testCanEditTag_Case02 failed!", canEditWeather);
- }
-
- /**
- * Test Method: canEditTag()
- * Description: Can edit the PUBLIC tags (which user is NOT owner BUT is administrator) or not?
- * Input: Node 'test'
- * Test action: add 2 PUBLIC tags 'sport' and 'weather' for node 'test'
- * Expected Result:
- * return true
- */
- public void testCanEditTag_Case03() throws Exception {
- //In this testcase, we need to use User session, instead of using System Session like other testcases
- applyUserSession("root", "exo");
-
- String[] publicTags = { "sport", "weather" };
- String publicFolksonomyTreePath = "/Application Data/Tags";
- newFolksonomyService_.addPublicTag(publicFolksonomyTreePath, publicTags, test, COLLABORATION_WS);
-
- assertTrue("testCanEditTag_Case03 failed! ", publicFolksonomyNode.hasNode("sport"));
- assertTrue("testCanEditTag_Case03 failed! ", publicFolksonomyNode.hasNode("weather"));
-
- applyUserSession("john", "exo");
- List<String> memberships = new ArrayList<String>();
- memberships.add("*:/platform/administrators");
- boolean canEditSport = newFolksonomyService_.canEditTag(COLLABORATION_WS,
- "sport",
- NewFolksonomyService.PUBLIC,
- memberships);
- boolean canEditWeather = newFolksonomyService_.canEditTag(COLLABORATION_WS,
- "weather",
- NewFolksonomyService.PUBLIC,
- memberships);
-
- assertTrue("testCanEditTag_Case03 failed!", canEditSport);
- assertTrue("testCanEditTag_Case03 failed!", canEditWeather);
- }
-
- /**
- * Test Method: canEditTag()
- * Description: Can edit the PUBLIC tags (which user is NOT owner and is NOT administrator) or not?
- * Input: Node 'test'
- * Test action: add 2 PUBLIC tags 'sport' and 'weather' for node 'test'
- * Expected Result:
- * return false
- */
- public void testCanEditTag_Case04() throws Exception {
- //In this testcase, we need to use User session, instead of using System Session like other testcases
- applyUserSession("root", "exo");
-
- String[] publicTags = { "sport", "weather" };
- String publicFolksonomyTreePath = "/Application Data/Tags";
- newFolksonomyService_.addPublicTag(publicFolksonomyTreePath, publicTags, test, COLLABORATION_WS);
-
- assertTrue("testCanEditTag_Case04 failed! ", publicFolksonomyNode.hasNode("sport"));
- assertTrue("testCanEditTag_Case04 failed! ", publicFolksonomyNode.hasNode("weather"));
-
- applyUserSession("john", "exo");
- List<String> memberships = new ArrayList<String>();
- boolean canEditSport = newFolksonomyService_.canEditTag(COLLABORATION_WS,
- "sport",
- NewFolksonomyService.PUBLIC,
- memberships);
- boolean canEditWeather = newFolksonomyService_.canEditTag(COLLABORATION_WS,
- "weather",
- NewFolksonomyService.PUBLIC,
- memberships);
-
- assertFalse("testCanEditTag_Case04 failed!", canEditSport);
- assertFalse("testCanEditTag_Case04 failed!", canEditWeather);
- }
/**
* Test Method: addGroupsTag()
@@ -332,16 +202,12 @@ public void testAddGroupsTag() throws Exception {
* property 'exo:total' of 'weather' node must be 1 *
*/
public void testAddPublicTag() throws Exception {
- //In this testcase, we need to use User session, instead of using System Session like other testcases
- applyUserSession("root", "exo");
-
String[] tags = { "sport", "weather" };
String publicFolksonomyTreePath = "/Application Data/Tags";
newFolksonomyService_.addPublicTag(publicFolksonomyTreePath,
tags,
test,
- COLLABORATION_WS);
-
+ COLLABORATION_WS);
assertTrue("testAddPublicTag failed! ", publicFolksonomyNode.hasNode("sport"));
assertTrue("testAddPublicTag failed! ", publicFolksonomyNode.hasNode("weather"));
@@ -371,9 +237,6 @@ public void testAddPublicTag() throws Exception {
* property 'exo:total' of 'weather' node must be 1 *
*/
public void testAddSiteTag() throws Exception {
- //In this testcase, we need to use User session, instead of using System Session like other testcases
- applyUserSession("root", "exo");
-
String[] tags = { "sport", "weather" };
String site = "portal1";
Node root = session.getRootNode();
@@ -537,9 +400,6 @@ public void testGetAllPrivateTags() throws Exception {
* sport, weather, boy, girl
*/
public void testGetAllPublicTags() throws Exception {
- //In this testcase, we need to use User session, instead of using System Session like other testcases
- applyUserSession("root", "exo");
-
String[] tags = { "sport", "weather" };
String[] tags2 = { "boy", "girl", "sport" };
String publicFolksonomyTreePath = "/Application Data/Tags";
@@ -574,9 +434,6 @@ public void testGetAllPublicTags() throws Exception {
* sport, weather, boy, girl
*/
public void testGetAllSiteTags() throws Exception {
- //In this testcase, we need to use User session, instead of using System Session like other testcases
- applyUserSession("root", "exo");
-
String[] tags = { "sport", "weather" };
String[] tags2 = { "boy", "girl", "sport" };
String site = "portal1";
@@ -610,9 +467,6 @@ public void testGetAllSiteTags() throws Exception {
* node 'football' must have a symlink child which points to 'test' node
*/
public void testModifyTagName() throws Exception {
- //In this testcase, we need to use User session, instead of using System Session like other testcases
- applyUserSession("root", "exo");
-
String[] tags = { "sport", "weather" };
String publicFolksonomyTreePath = "/Application Data/Tags";
newFolksonomyService_.addPublicTag(publicFolksonomyTreePath,
@@ -640,9 +494,6 @@ public void testModifyTagName() throws Exception {
* 'nobita', 'weather'
*/
public void testRemoveTag() throws Exception {
- //In this testcase, we need to use User session, instead of using System Session like other testcases
- applyUserSession("root", "exo");
-
String[] tags = { "sport", "weather", "nobita"};
String publicFolksonomyTreePath = "/Application Data/Tags";
newFolksonomyService_.addPublicTag(publicFolksonomyTreePath,
@@ -685,7 +536,6 @@ public void testRemoveTagOfDocument() throws Exception {
* Clean data test
*/
public void tearDown() throws Exception {
- applySystemSession();
String[] nodes = {"/Application Data/Tags",
"/Users/" + session.getUserID() + "/Private/Folksonomy",
"Groups/platform/users/ApplicationData/Tags",
View
7 ...-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/popup/actions/UIEditingTagList.java
@@ -25,7 +25,6 @@
import org.exoplatform.commons.utils.ListAccess;
import org.exoplatform.commons.utils.ListAccessImpl;
import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer;
-import org.exoplatform.ecm.webui.utils.Utils;
import org.exoplatform.services.cms.folksonomy.NewFolksonomyService;
import org.exoplatform.services.jcr.ext.hierarchy.NodeHierarchyCreator;
import org.exoplatform.webui.config.annotation.ComponentConfig;
@@ -66,13 +65,9 @@ public void updateGrid() throws Exception {
List<Node> tags = (scope == NewFolksonomyService.PRIVATE) ?
newFolksonomyService.getAllPrivateTags(uiExplorer.getSession().getUserID()) :
newFolksonomyService.getAllPublicTags(publicTagNodePath, workspace);
-
- List<String> memberships = Utils.getMemberships();
List<TagData> tagDataList = new ArrayList<TagData>();
for (Node tag : tags) {
- if (newFolksonomyService.canEditTag(tag, scope, memberships)) {
- tagDataList.add(new TagData(tag.getName()));
- }
+ tagDataList.add(new TagData(tag.getName()));
}
ListAccess<TagData> tagList = new ListAccessImpl<TagData>(TagData.class, tagDataList);
View
31 ...explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/popup/actions/UIEditingTagsForm.java
@@ -25,17 +25,14 @@
import org.exoplatform.ecm.jcr.model.Preference;
import org.exoplatform.ecm.webui.component.explorer.UIJCRExplorer;
import org.exoplatform.ecm.webui.component.explorer.sidebar.UISideBar;
-import org.exoplatform.ecm.webui.utils.Utils;
import org.exoplatform.services.cms.folksonomy.NewFolksonomyService;
import org.exoplatform.services.jcr.RepositoryService;
import org.exoplatform.services.jcr.core.ManageableRepository;
import org.exoplatform.services.jcr.ext.hierarchy.NodeHierarchyCreator;
import org.exoplatform.services.wcm.utils.WCMCoreUtils;
-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.UIContainer;
import org.exoplatform.webui.core.UIPopupComponent;
import org.exoplatform.webui.core.UIPopupWindow;
@@ -113,24 +110,11 @@ public Node getSelectedTag(String tagName) throws Exception {
static public class EditTagActionListener extends EventListener<UIEditingTagsForm> {
public void execute(Event<UIEditingTagsForm> event) throws Exception {
UIEditingTagsForm uiEditingTagsForm = event.getSource() ;
- UIJCRExplorer uiExplorer = uiEditingTagsForm.getAncestorOfType(UIJCRExplorer.class);
String selectedName = event.getRequestContext().getRequestParameter(OBJECTID) ;
-
- String workspace = uiExplorer.getRepository().getConfiguration().getDefaultWorkspaceName();
- int scope = uiExplorer.getTagScope();
- List<String> memberships = Utils.getMemberships();
- NewFolksonomyService newFolksonomyService = WCMCoreUtils.getService(NewFolksonomyService.class);
- if (!newFolksonomyService.canEditTag(workspace, selectedName, scope, memberships)) {
- UIApplication uiApp = uiEditingTagsForm.getAncestorOfType(UIApplication.class);
- uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.editTagAccessDenied",
- null,
- ApplicationMessage.WARNING));
- return;
- }
-
Node selectedTag = uiEditingTagsForm.getSelectedTag(selectedName) ;
uiEditingTagsForm.initTaggingFormPopup(selectedTag) ;
+ UIJCRExplorer uiExplorer = uiEditingTagsForm.getAncestorOfType(UIJCRExplorer.class);
Preference preferences = uiExplorer.getPreference();
if (preferences.isShowSideBar()) {
UISideBar uiSideBar = uiExplorer.findFirstComponentOfType(UISideBar.class);
@@ -145,19 +129,6 @@ public void execute(Event<UIEditingTagsForm> event) throws Exception {
UIEditingTagsForm uiEdit = event.getSource();
UIJCRExplorer uiExplorer = uiEdit.getAncestorOfType(UIJCRExplorer.class);
String selectedName = event.getRequestContext().getRequestParameter(OBJECTID);
-
- String workspace = uiExplorer.getRepository().getConfiguration().getDefaultWorkspaceName();
- int scope = uiExplorer.getTagScope();
- List<String> memberships = Utils.getMemberships();
- NewFolksonomyService newFolksonomyService = WCMCoreUtils.getService(NewFolksonomyService.class);
- if (!newFolksonomyService.canEditTag(workspace, selectedName, scope, memberships)) {
- UIApplication uiApp = uiEdit.getAncestorOfType(UIApplication.class);
- uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.editTagAccessDenied",
- null,
- ApplicationMessage.WARNING));
- return;
- }
-
removeTagFromNode(uiExplorer.getSession().getUserID(), uiExplorer.getTagScope(), selectedName, uiEdit);
uiEdit.getChild(UIEditingTagList.class).updateGrid();
uiExplorer.setTagPath(uiExplorer.getCurrentPath());
View
16 ...bui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/popup/actions/UITaggingForm.java
@@ -362,12 +362,7 @@ public void execute(Event<UITaggingForm> event) throws Exception {
NewFolksonomyService newFolksonomyService = uiForm.getApplicationComponent(NewFolksonomyService.class);
String tagScope = uiForm.getUIFormSelectBox(TAG_SCOPES).getValue();
List<String> memberships = Utils.getMemberships();
-
- RepositoryService repositoryService = WCMCoreUtils.getService(RepositoryService.class);
- ManageableRepository manageableRepo = repositoryService.getCurrentRepository();
- String workspace = manageableRepo.getConfiguration().getDefaultWorkspaceName();
- String tagName = event.getRequestContext().getRequestParameter(OBJECTID);
- if (!newFolksonomyService.canEditTag(workspace, tagName, uiForm.getIntValue(tagScope), memberships)) {
+ if (!newFolksonomyService.canEditTag(uiForm.getIntValue(tagScope), memberships)) {
UIApplication uiApp = uiForm.getAncestorOfType(UIApplication.class);
uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.editTagAccessDenied",
null,
@@ -377,6 +372,7 @@ public void execute(Event<UITaggingForm> event) throws Exception {
}
Node currentNode = uiExplorer.getCurrentNode();
+ String tagName = event.getRequestContext().getRequestParameter(OBJECTID);
String[] arrFilterChar = { "&", "'", "$", "@", ":", "]", "[", "*", "%", "!", "/", "\\" };
UIApplication uiApp = uiForm.getAncestorOfType(UIApplication.class);
if (!Utils.isNameValid(tagName, arrFilterChar)) {
@@ -458,15 +454,9 @@ public void execute(Event<UITaggingForm> event) throws Exception {
public void execute(Event<UITaggingForm> event) throws Exception {
UITaggingForm uiForm = event.getSource();
NewFolksonomyService newFolksonomyService = uiForm.getApplicationComponent(NewFolksonomyService.class);
-
- RepositoryService repositoryService = WCMCoreUtils.getService(RepositoryService.class);
- ManageableRepository manageableRepo = repositoryService.getCurrentRepository();
- String workspace = manageableRepo.getConfiguration().getDefaultWorkspaceName();
- String tagName = event.getRequestContext().getRequestParameter(OBJECTID);
-
String tagScope = uiForm.getUIFormSelectBox(TAG_SCOPES).getValue();
List<String> memberships = Utils.getMemberships();
- if (!newFolksonomyService.canEditTag(workspace, tagName, uiForm.getIntValue(tagScope), memberships)) {
+ if (!newFolksonomyService.canEditTag(uiForm.getIntValue(tagScope), memberships)) {
UIApplication uiApp = uiForm.getAncestorOfType(UIApplication.class);
uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.editTagAccessDenied",
null,
View
21 core/webui-explorer/src/main/java/org/exoplatform/ecm/webui/component/explorer/sidebar/UITagExplorer.java
@@ -32,8 +32,10 @@
import org.exoplatform.services.jcr.RepositoryService;
import org.exoplatform.services.jcr.core.ManageableRepository;
import org.exoplatform.services.jcr.ext.hierarchy.NodeHierarchyCreator;
+import org.exoplatform.web.application.ApplicationMessage;
import org.exoplatform.webui.config.annotation.ComponentConfig;
import org.exoplatform.webui.config.annotation.EventConfig;
+import org.exoplatform.webui.core.UIApplication;
import org.exoplatform.webui.core.UIContainer;
import org.exoplatform.webui.core.UIPopupContainer;
import org.exoplatform.webui.event.Event;
@@ -136,15 +138,26 @@ public void execute(Event<UITagExplorer> event) throws Exception {
static public class EditTagsActionListener extends EventListener<UITagExplorer> {
public void execute(Event<UITagExplorer> event) throws Exception {
UITagExplorer uiTagExplorer = event.getSource();
+ NewFolksonomyService newFolksonomyService = uiTagExplorer.getApplicationComponent(NewFolksonomyService.class);
String scope = event.getRequestContext().getRequestParameter(OBJECTID);
int intScope = Utils.PUBLIC.equals(scope) ? NewFolksonomyService.PUBLIC
: NewFolksonomyService.PRIVATE;
uiTagExplorer.getAncestorOfType(UIJCRExplorer.class).setTagScope(intScope);
- UIJCRExplorer uiExplorer = uiTagExplorer.getAncestorOfType(UIJCRExplorer.class);
- UIPopupContainer uiPopupContainer = uiExplorer.getChild(UIPopupContainer.class);
- uiPopupContainer.activate(UIEditingTagsForm.class, 600);
- event.getRequestContext().addUIComponentToUpdateByAjax(uiPopupContainer);
+ List<String> memberships = Utils.getMemberships();
+ if (newFolksonomyService.canEditTag(intScope, memberships)) {
+ UIJCRExplorer uiExplorer = uiTagExplorer.getAncestorOfType(UIJCRExplorer.class);
+ UIPopupContainer uiPopupContainer = uiExplorer.getChild(UIPopupContainer.class);
+ uiPopupContainer.activate(UIEditingTagsForm.class, 600);
+ event.getRequestContext().addUIComponentToUpdateByAjax(uiPopupContainer);
+ } else {
+ UIApplication uiApp = uiTagExplorer.getAncestorOfType(UIApplication.class);
+ uiApp.addMessage(new ApplicationMessage("UIPopupMenu.msg.editTagAccessDenied",
+ null,
+ ApplicationMessage.WARNING));
+
+ uiTagExplorer.getAncestorOfType(UIJCRExplorer.class).updateAjax(event);
+ }
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.