Skip to content

Commit

Permalink
ECMS-3746 Revert Wrong behavior of manage public tag of ECMS-3280
Browse files Browse the repository at this point in the history
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
dongpd authored and nguyenthienhuong committed Jun 8, 2012
1 parent f6ef7f3 commit e89fe47
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 475 deletions.
Expand Up @@ -613,33 +613,8 @@ public void removeTagsOfNodeRecursively(Node node,
* @param scope Scope of tag * @param scope Scope of tag
* @param memberships Memberships * @param memberships Memberships
* @return true If it is possible * @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); 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 * Get all tag names which start within given scope
Expand Down
Expand Up @@ -49,8 +49,6 @@
import org.exoplatform.services.jcr.ext.hierarchy.NodeHierarchyCreator; import org.exoplatform.services.jcr.ext.hierarchy.NodeHierarchyCreator;
import org.exoplatform.services.log.ExoLogger; import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log; import org.exoplatform.services.log.Log;
import org.exoplatform.services.security.ConversationState;
import org.exoplatform.services.wcm.utils.WCMCoreUtils;
import org.picocontainer.Startable; import org.picocontainer.Startable;


/** /**
Expand Down Expand Up @@ -241,8 +239,8 @@ public void addPublicTag(String treePath,
public void addPublicTag(String treePath, public void addPublicTag(String treePath,
String[] tagsName, String[] tagsName,
Node documentNode, Node documentNode,
String workspace) throws Exception { String workspace) throws Exception {
Node publicFolksonomyTreeNode = getNode(workspace, treePath, WCMCoreUtils.getUserSessionProvider()); Node publicFolksonomyTreeNode = getNode(workspace, treePath);
Node targetNode = getTargetNode(documentNode); Node targetNode = getTargetNode(documentNode);
for (String tag : tagsName) { for (String tag : tagsName) {
try { try {
Expand Down Expand Up @@ -928,11 +926,7 @@ public List<String> getTagPermissionList() {


/** /**
* {@inheritDoc} * {@inheritDoc}
*
* @see NewFolksonomyServiceImpl#canEditTag(Node, int, List)
* @see NewFolksonomyServiceImpl#canEditTag(String, String, int, List)
*/ */
@Deprecated
public boolean canEditTag(int scope, List<String> memberships) { public boolean canEditTag(int scope, List<String> memberships) {
if (scope == PUBLIC) { if (scope == PUBLIC) {
if (tagPermissionList != null) if (tagPermissionList != null)
Expand All @@ -948,58 +942,6 @@ public boolean canEditTag(int scope, List<String> memberships) {
} }
return true; 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} * {@inheritDoc}
Expand Down
Expand Up @@ -117,184 +117,4 @@
</component-plugin> </component-plugin>
</external-component-plugins> </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> </configuration>

0 comments on commit e89fe47

Please sign in to comment.