From: <fg...@us...> - 2008-07-27 09:20:30
|
Revision: 899 http://openutils.svn.sourceforge.net/openutils/?rev=899&view=rev Author: fgiust Date: 2008-07-27 09:20:38 +0000 (Sun, 27 Jul 2008) Log Message: ----------- [maven-release-plugin] copy for tag openutils-mgnltasks-3.5.5 Added Paths: ----------- tags/openutils-mgnltasks-3.5.5/ tags/openutils-mgnltasks-3.5.5/pom.xml tags/openutils-mgnltasks-3.5.5/src/main/java/it/openutils/mgnltasks/AddPermissionTask.java tags/openutils-mgnltasks-3.5.5/src/main/java/it/openutils/mgnltasks/BaseCheckMissingTask.java tags/openutils-mgnltasks-3.5.5/src/main/java/it/openutils/mgnltasks/CreateDefaultRepositoryAclForAllUsersTask.java tags/openutils-mgnltasks-3.5.5/src/site/changes/changes.xml Removed Paths: ------------- tags/openutils-mgnltasks-3.5.5/pom.xml tags/openutils-mgnltasks-3.5.5/src/main/java/it/openutils/mgnltasks/BaseCheckMissingTask.java tags/openutils-mgnltasks-3.5.5/src/site/changes/changes.xml Deleted: tags/openutils-mgnltasks-3.5.5/pom.xml =================================================================== --- trunk/openutils-mgnltasks/pom.xml 2008-07-24 08:30:43 UTC (rev 892) +++ tags/openutils-mgnltasks-3.5.5/pom.xml 2008-07-27 09:20:38 UTC (rev 899) @@ -1,101 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <parent> - <groupId>net.sourceforge.openutils</groupId> - <artifactId>openutils</artifactId> - <version>8</version> - <relativePath>..</relativePath> - </parent> - <modelVersion>4.0.0</modelVersion> - <packaging>jar</packaging> - <artifactId>openutils-mgnltasks</artifactId> - <name>openutils-mgnltasks</name> - <version>3.5.4-SNAPSHOT</version> - <description>A collection of useful magnolia update tasks that can be reused in custom modules</description> - <licenses> - <license> - <name>GPLv3</name> - <url>http://www.gnu.org/licenses/gpl-3.0.txt</url> - </license> - </licenses> - <build> - <resources> - <resource> - <filtering>false</filtering> - <directory>src/main/resources</directory> - <includes> - <include>**/*</include> - </includes> - </resource> - <resource> - <filtering>true</filtering> - <directory>src/main/resources</directory> - <includes> - <include>META-INF/magnolia/*</include> - </includes> - </resource> - </resources> - </build> - <dependencies> - <dependency> - <groupId>info.magnolia</groupId> - <artifactId>magnolia-core</artifactId> - <version>3.5.8</version> - <exclusions> - <exclusion> - <groupId>servlets.com</groupId> - <artifactId>cos</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>info.magnolia</groupId> - <artifactId>magnolia-module-admininterface</artifactId> - <version>3.5.8</version> - <exclusions> - <exclusion> - <groupId>servlets.com</groupId> - <artifactId>cos</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>javax.servlet</groupId> - <artifactId>servlet-api</artifactId> - <version>2.4</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>javax.servlet</groupId> - <artifactId>jsp-api</artifactId> - <version>2.0</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.testng</groupId> - <artifactId>testng</artifactId> - <classifier>jdk15</classifier> - <version>5.7</version> - <scope>test</scope> - <exclusions> - <exclusion> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - </exclusion> - </exclusions> - </dependency> - </dependencies> - <repositories> - <repository> - <id>repository.magnolia.info</id> - <name>magnolia repository</name> - <url>http://repo.magnolia.info/m2</url> - <releases> - <enabled>true</enabled> - </releases> - <snapshots> - <enabled>false</enabled> - </snapshots> - </repository> - </repositories> -</project> \ No newline at end of file Copied: tags/openutils-mgnltasks-3.5.5/pom.xml (from rev 898, trunk/openutils-mgnltasks/pom.xml) =================================================================== --- tags/openutils-mgnltasks-3.5.5/pom.xml (rev 0) +++ tags/openutils-mgnltasks-3.5.5/pom.xml 2008-07-27 09:20:38 UTC (rev 899) @@ -0,0 +1,107 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <parent> + <groupId>net.sourceforge.openutils</groupId> + <artifactId>openutils</artifactId> + <version>8</version> + <relativePath>..</relativePath> + </parent> + <modelVersion>4.0.0</modelVersion> + <packaging>jar</packaging> + <artifactId>openutils-mgnltasks</artifactId> + <name>openutils-mgnltasks</name> + <version>3.5.5</version> + <description>A collection of useful magnolia update tasks that can be reused in custom modules</description> + <licenses> + <license> + <name>GPLv3</name> + <url>http://www.gnu.org/licenses/gpl-3.0.txt</url> + </license> + </licenses> + <build> + <resources> + <resource> + <filtering>false</filtering> + <directory>src/main/resources</directory> + <includes> + <include>**/*</include> + </includes> + </resource> + <resource> + <filtering>true</filtering> + <directory>src/main/resources</directory> + <includes> + <include>META-INF/magnolia/*</include> + </includes> + </resource> + </resources> + </build> + <dependencies> + <dependency> + <groupId>info.magnolia</groupId> + <artifactId>magnolia-core</artifactId> + <version>3.5.8</version> + <exclusions> + <exclusion> + <groupId>servlets.com</groupId> + <artifactId>cos</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>info.magnolia</groupId> + <artifactId>magnolia-module-admininterface</artifactId> + <version>3.5.8</version> + <exclusions> + <exclusion> + <groupId>servlets.com</groupId> + <artifactId>cos</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + <version>2.4</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>jsp-api</artifactId> + <version>2.0</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.testng</groupId> + <artifactId>testng</artifactId> + <classifier>jdk15</classifier> + <version>5.7</version> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </exclusion> + </exclusions> + </dependency> + </dependencies> + <repositories> + <repository> + <id>repository.magnolia.info</id> + <name>magnolia repository</name> + <url>http://repo.magnolia.info/m2</url> + <releases> + <enabled>true</enabled> + </releases> + <snapshots> + <enabled>false</enabled> + </snapshots> + </repository> + </repositories> + + <scm> + <connection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-mgnltasks-3.5.5</connection> + <developerConnection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-mgnltasks-3.5.5</developerConnection> + <url>http://openutils.svn.sourceforge.net/viewcvs.cgi/openutils/tags/openutils-mgnltasks-3.5.5</url> + </scm> +</project> \ No newline at end of file Copied: tags/openutils-mgnltasks-3.5.5/src/main/java/it/openutils/mgnltasks/AddPermissionTask.java (from rev 897, trunk/openutils-mgnltasks/src/main/java/it/openutils/mgnltasks/AddPermissionTask.java) =================================================================== --- tags/openutils-mgnltasks-3.5.5/src/main/java/it/openutils/mgnltasks/AddPermissionTask.java (rev 0) +++ tags/openutils-mgnltasks-3.5.5/src/main/java/it/openutils/mgnltasks/AddPermissionTask.java 2008-07-27 09:20:38 UTC (rev 899) @@ -0,0 +1,137 @@ +/** + * Copyright Openmind http://www.openmindonline.it + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 it.openutils.mgnltasks; + +import info.magnolia.cms.beans.config.ContentRepository; +import info.magnolia.cms.core.Content; +import info.magnolia.cms.core.HierarchyManager; +import info.magnolia.cms.core.Path; +import info.magnolia.cms.security.AccessDeniedException; +import info.magnolia.cms.util.NodeDataUtil; +import info.magnolia.module.InstallContext; +import info.magnolia.module.delta.AbstractRepositoryTask; +import info.magnolia.module.delta.Task; +import info.magnolia.module.delta.TaskExecutionException; + +import java.util.Collection; + +import javax.jcr.RepositoryException; + + +/** + * Sets or add permissions on a repository:path for a given role. + * @author fgiust + * @version $Id: $ + */ +public class AddPermissionTask extends AbstractRepositoryTask implements Task +{ + + private final String role; + + private final String repo; + + private final String path; + + private final long permission; + + public AddPermissionTask(String role, String repo, String path, long permission) + { + super("Setup permissions on " + repo + ":" + path + " for " + role, "Setup permissions on " + + repo + + ":" + + path + + " for " + + role); + this.role = role; + this.repo = repo; + this.path = path; + this.permission = permission; + + } + + /** + * {@inheritDoc} + */ + @Override + protected void doExecute(InstallContext installContext) throws RepositoryException, TaskExecutionException + { + + HierarchyManager hm = installContext.getHierarchyManager(ContentRepository.USER_ROLES); + + Content roleNode = hm.getContent("/" + role); + + setupAcl(roleNode, repo, path, permission); + } + + /** + * @param role + * @param repository + * @param newpermissions + * @throws RepositoryException + * @throws AccessDeniedException + */ + @SuppressWarnings("unchecked") + private void setupAcl(Content role, String repository, String path, long newpermissions) + throws RepositoryException, AccessDeniedException + { + Content acls = role.getChildByName("acl_" + repository); + + if (acls == null) + { + acls = role.createContent("acl_" + repository, "mgnl:contentNode"); + } + + Collection<Content> children = acls.getChildren(); + + boolean found = false; + for (Content acl : children) + { + String aclPath = acl.getNodeData("path").getString(); + if (path.equals(aclPath)) + { + found = true; + + long permissions = acl.getNodeData("permissions").getLong(); + if (permissions != newpermissions) + { + setPermission(acl, path, newpermissions); + } + } + } + if (!found) + { + Content acl = acls.createContent(Path.getUniqueLabel(acls, "0"), "mgnl:contentNode"); + setPermission(acl, path, newpermissions); + + } + } + + /** + * @param acl + * @param newpermissions + * @throws RepositoryException + * @throws AccessDeniedException + */ + private void setPermission(Content acl, String path, long newpermissions) throws RepositoryException, + AccessDeniedException + { + log.info("Setting permissions for {} to {}", this.repo + ":" + path, this.role); + NodeDataUtil.getOrCreate(acl, "path").setValue(path); + NodeDataUtil.getOrCreate(acl, "permissions").setValue(newpermissions); + } +} Deleted: tags/openutils-mgnltasks-3.5.5/src/main/java/it/openutils/mgnltasks/BaseCheckMissingTask.java =================================================================== --- trunk/openutils-mgnltasks/src/main/java/it/openutils/mgnltasks/BaseCheckMissingTask.java 2008-07-24 08:30:43 UTC (rev 892) +++ tags/openutils-mgnltasks-3.5.5/src/main/java/it/openutils/mgnltasks/BaseCheckMissingTask.java 2008-07-27 09:20:38 UTC (rev 899) @@ -1,157 +0,0 @@ -/** - * Copyright Openmind http://www.openmindonline.it - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 it.openutils.mgnltasks; - -import info.magnolia.cms.beans.config.ContentRepository; -import info.magnolia.cms.core.Content; -import info.magnolia.cms.core.HierarchyManager; -import info.magnolia.cms.core.search.Query; -import info.magnolia.cms.core.search.QueryManager; -import info.magnolia.module.InstallContext; -import info.magnolia.module.delta.AbstractRepositoryTask; -import info.magnolia.module.delta.TaskExecutionException; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - -import javax.jcr.RepositoryException; -import javax.jcr.query.InvalidQueryException; - -import org.apache.commons.lang.StringUtils; - - -/** - * An abstract task that check for invalid templates/paragraphs. Should not be used directly, see - * {@link CheckMissingTemplatesTask} and {@link CheckMissingParagraphsTask} instead. - * @author fgiust - * @version $Id: $ - */ -public abstract class BaseCheckMissingTask extends AbstractRepositoryTask -{ - - private final String templateOrParagraph; - - private final String nodetype; - - /** - * @param templateOrParagraph "template" or "paragraph" - * @param nodetype node type foc checked nodes - */ - public BaseCheckMissingTask(String templateOrParagraph, String nodetype) - { - super("Check " + templateOrParagraph + "s task", "Checking pages configured with missing " - + templateOrParagraph - + "s"); - this.templateOrParagraph = templateOrParagraph; - this.nodetype = nodetype; - - } - - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - @Override - protected void doExecute(InstallContext installContext) throws RepositoryException, TaskExecutionException - { - - QueryManager configQueryManager = installContext - .getHierarchyManager(ContentRepository.CONFIG) - .getQueryManager(); - - Collection<Content> templates = configQueryManager.createQuery( - "//modules/*/" + templateOrParagraph + "s/*", - Query.XPATH).execute().getContent("mgnl:contentNode"); - - List<String> templ = new ArrayList<String>(); - Iterator<Content> availableTemplates = templates.iterator(); - while (availableTemplates.hasNext()) - { - Content template = availableTemplates.next(); - templ.add(template.getName()); - } - - checkInvalidPages(installContext, templ); - - } - - /** - * @param installContext - * @param templates - * @throws RepositoryException - * @throws InvalidQueryException - */ - @SuppressWarnings("unchecked") - private void checkInvalidPages(InstallContext installContext, List<String> templates) throws RepositoryException, - InvalidQueryException - { - HierarchyManager hm = installContext.getHierarchyManager(ContentRepository.WEBSITE); - - QueryManager qm = hm.getQueryManager(); - - StringBuilder query = new StringBuilder("//*[jcr:primaryType='" - + this.nodetype - + "' and MetaData/mgnl:template and not("); - - Iterator<String> nameIterator = templates.iterator(); - while (nameIterator.hasNext()) - { - String template = nameIterator.next(); - - query.append("MetaData/mgnl:template='"); - query.append(template); - query.append("'"); - if (nameIterator.hasNext()) - { - query.append(" or "); - } - } - - query.append(")]"); - - String queryAAsString = query.toString(); - - log.debug("Running query: {}", queryAAsString); - - Collection<Content> nodes = qm.createQuery(queryAAsString, Query.XPATH).execute().getContent(this.nodetype); - - int count = 0; - StringBuilder sb = new StringBuilder(); - - for (Content page : nodes) - { - String template = page.getMetaData().getTemplate(); - - if (StringUtils.isNotEmpty(template)) - { - count++; - sb.append(page.getHandle()); - sb.append(" "); - sb.append(template); - sb.append("\n"); - } - } - - if (count > 0) - { - log.error("Found {} pages with invalid templates:\n{}", count, sb.toString()); - } - } -} Copied: tags/openutils-mgnltasks-3.5.5/src/main/java/it/openutils/mgnltasks/BaseCheckMissingTask.java (from rev 896, trunk/openutils-mgnltasks/src/main/java/it/openutils/mgnltasks/BaseCheckMissingTask.java) =================================================================== --- tags/openutils-mgnltasks-3.5.5/src/main/java/it/openutils/mgnltasks/BaseCheckMissingTask.java (rev 0) +++ tags/openutils-mgnltasks-3.5.5/src/main/java/it/openutils/mgnltasks/BaseCheckMissingTask.java 2008-07-27 09:20:38 UTC (rev 899) @@ -0,0 +1,157 @@ +/** + * Copyright Openmind http://www.openmindonline.it + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 it.openutils.mgnltasks; + +import info.magnolia.cms.beans.config.ContentRepository; +import info.magnolia.cms.core.Content; +import info.magnolia.cms.core.HierarchyManager; +import info.magnolia.cms.core.search.Query; +import info.magnolia.cms.core.search.QueryManager; +import info.magnolia.module.InstallContext; +import info.magnolia.module.delta.AbstractRepositoryTask; +import info.magnolia.module.delta.TaskExecutionException; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; + +import javax.jcr.RepositoryException; +import javax.jcr.query.InvalidQueryException; + +import org.apache.commons.lang.StringUtils; + + +/** + * An abstract task that check for invalid templates/paragraphs. Should not be used directly, see + * {@link CheckMissingTemplatesTask} and {@link CheckMissingParagraphsTask} instead. + * @author fgiust + * @version $Id: $ + */ +public abstract class BaseCheckMissingTask extends AbstractRepositoryTask +{ + + private final String templateOrParagraph; + + private final String nodetype; + + /** + * @param templateOrParagraph "template" or "paragraph" + * @param nodetype node type foc checked nodes + */ + public BaseCheckMissingTask(String templateOrParagraph, String nodetype) + { + super("Check " + templateOrParagraph + "s task", "Checking pages configured with missing " + + templateOrParagraph + + "s"); + this.templateOrParagraph = templateOrParagraph; + this.nodetype = nodetype; + + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + @Override + protected void doExecute(InstallContext installContext) throws RepositoryException, TaskExecutionException + { + + QueryManager configQueryManager = installContext + .getHierarchyManager(ContentRepository.CONFIG) + .getQueryManager(); + + Collection<Content> templates = configQueryManager.createQuery( + "//modules/*/" + templateOrParagraph + "s/*", + Query.XPATH).execute().getContent("mgnl:contentNode"); + + List<String> templ = new ArrayList<String>(); + Iterator<Content> availableTemplates = templates.iterator(); + while (availableTemplates.hasNext()) + { + Content template = availableTemplates.next(); + templ.add(template.getName()); + } + + checkInvalidPages(installContext, templ); + + } + + /** + * @param installContext + * @param templates + * @throws RepositoryException + * @throws InvalidQueryException + */ + @SuppressWarnings("unchecked") + private void checkInvalidPages(InstallContext installContext, List<String> templates) throws RepositoryException, + InvalidQueryException + { + HierarchyManager hm = installContext.getHierarchyManager(ContentRepository.WEBSITE); + + QueryManager qm = hm.getQueryManager(); + + StringBuilder query = new StringBuilder("//*[jcr:primaryType='" + + this.nodetype + + "' and MetaData/mgnl:template and not("); + + Iterator<String> nameIterator = templates.iterator(); + while (nameIterator.hasNext()) + { + String template = nameIterator.next(); + + query.append("MetaData/mgnl:template='"); + query.append(template); + query.append("'"); + if (nameIterator.hasNext()) + { + query.append(" or "); + } + } + + query.append(")]"); + + String queryAAsString = query.toString(); + + log.debug("Running query: {}", queryAAsString); + + Collection<Content> nodes = qm.createQuery(queryAAsString, Query.XPATH).execute().getContent(this.nodetype); + + int count = 0; + StringBuilder sb = new StringBuilder(); + + for (Content page : nodes) + { + String template = page.getMetaData().getTemplate(); + + if (StringUtils.isNotEmpty(template)) + { + count++; + sb.append(page.getHandle()); + sb.append(" "); + sb.append(template); + sb.append("\n"); + } + } + + if (count > 0) + { + log.error("Found {} pages with invalid " + templateOrParagraph + "s:\n{}", count, sb.toString()); + } + } +} Copied: tags/openutils-mgnltasks-3.5.5/src/main/java/it/openutils/mgnltasks/CreateDefaultRepositoryAclForAllUsersTask.java (from rev 897, trunk/openutils-mgnltasks/src/main/java/it/openutils/mgnltasks/CreateDefaultRepositoryAclForAllUsersTask.java) =================================================================== --- tags/openutils-mgnltasks-3.5.5/src/main/java/it/openutils/mgnltasks/CreateDefaultRepositoryAclForAllUsersTask.java (rev 0) +++ tags/openutils-mgnltasks-3.5.5/src/main/java/it/openutils/mgnltasks/CreateDefaultRepositoryAclForAllUsersTask.java 2008-07-27 09:20:38 UTC (rev 899) @@ -0,0 +1,93 @@ +/** + * Copyright Openmind http://www.openmindonline.it + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 it.openutils.mgnltasks; + +import info.magnolia.cms.beans.config.ContentRepository; +import info.magnolia.cms.core.Content; +import info.magnolia.cms.core.HierarchyManager; +import info.magnolia.cms.core.ItemType; +import info.magnolia.cms.util.ContentUtil; +import info.magnolia.module.InstallContext; +import info.magnolia.module.delta.AbstractRepositoryTask; +import info.magnolia.module.delta.TaskExecutionException; + +import java.util.Collection; + +import javax.jcr.RepositoryException; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * Adds a default repository permissions for all the configured users, only if there is no acl set for the given + * repository. + * @author fgiust + * @version $Id: $ + */ +public class CreateDefaultRepositoryAclForAllUsersTask extends AbstractRepositoryTask +{ + + private static Logger log = LoggerFactory.getLogger(CreateDefaultRepositoryAclForAllUsersTask.class); + + private String repository; + + private long permissions; + + public CreateDefaultRepositoryAclForAllUsersTask(String repository, long permissions) + { + super("Adding permissions on " + repository + " repository", "Adding permissions on " + + repository + + " repository"); + this.repository = repository; + this.permissions = permissions; + } + + @SuppressWarnings("unchecked") + @Override + protected void doExecute(InstallContext ctx) throws RepositoryException, TaskExecutionException + { + HierarchyManager hm = ctx.getHierarchyManager(ContentRepository.USER_ROLES); + final Content parentNode = hm.getContent("/"); + + final Collection<Content> childNodes = ContentUtil.collectAllChildren(parentNode, ItemType.ROLE); + + for (Content content : childNodes) + { + operateOnChildNode(content, ctx); + } + } + + protected void operateOnChildNode(Content node, InstallContext ctx) throws RepositoryException, + TaskExecutionException + { + + String aclpath = "acl_" + repository; + + if (!node.hasContent(aclpath)) + { + log.info("adding permissions on {} to role {}", repository, node.getName()); + + Content aclnode = node.createContent(aclpath, ItemType.CONTENTNODE); + Content permNode = aclnode.createContent("0", ItemType.CONTENTNODE); + permNode.createNodeData("path", "/*"); + permNode.createNodeData("permissions", new Long(permissions)); + } + } + +} Deleted: tags/openutils-mgnltasks-3.5.5/src/site/changes/changes.xml =================================================================== --- trunk/openutils-mgnltasks/src/site/changes/changes.xml 2008-07-24 08:30:43 UTC (rev 892) +++ tags/openutils-mgnltasks-3.5.5/src/site/changes/changes.xml 2008-07-27 09:20:38 UTC (rev 899) @@ -1,34 +0,0 @@ -<?xml version="1.0"?> -<!-- - "type" attribute can be: add, remove, update or fix. ---> -<document> - <properties> - <title>Changes</title> - <author email="fgiust(at)users.sourceforge.net">Fabrizio Giustina</author> - </properties> - <body> - <release version="3.5.4" date="2008-07-24" description=""> - <action type="add" dev="fgiust">new tasks: CheckMissingTemplatesTask, CheckMissingParagraphsTask, - ReplaceTemplateTask</action> - </release> - <release version="3.5.3" date="2008-06-24" description=""> - <action type="add" dev="fgiust">new CheckAndCreateRoleTask and CheckAndCreateGroupTask</action> - <action type="update" dev="fgiust">AnonymousUserSetupTask now also takes care of changing - permissions on URIs</action> - </release> - <release version="3.5.2" date="2008-06-08" description=""> - <action type="add" dev="fgiust">Added [modulename].update.disabled property in SimpleModuleVersionHandler that - can be set to true in order to disable module configuration updates</action> - <action type="add" dev="fgiust">Added it.openutils.mgnltasks.DisableSubscribersTask</action> - </release> - <release version="3.5.1" date="2008-04-28" description="3.5.1"> - <action type="add" dev="fgiust">Added UpdateModuleVersionTask.</action> - <action type="add" dev="fgiust">Added SimpleModuleVersionHandler.</action> - </release> - <release version="3.5" date="2008-04-27" description="first release"> - <action type="add" dev="fgiust">First public release. The version is labeled "3.5" in order to make clear which - version of magnolia is required.</action> - </release> - </body> -</document> \ No newline at end of file Copied: tags/openutils-mgnltasks-3.5.5/src/site/changes/changes.xml (from rev 897, trunk/openutils-mgnltasks/src/site/changes/changes.xml) =================================================================== --- tags/openutils-mgnltasks-3.5.5/src/site/changes/changes.xml (rev 0) +++ tags/openutils-mgnltasks-3.5.5/src/site/changes/changes.xml 2008-07-27 09:20:38 UTC (rev 899) @@ -0,0 +1,37 @@ +<?xml version="1.0"?> +<!-- + "type" attribute can be: add, remove, update or fix. +--> +<document> + <properties> + <title>Changes</title> + <author email="fgiust(at)users.sourceforge.net">Fabrizio Giustina</author> + </properties> + <body> + <release version="3.5.5" date="2008-07-27" description=""> + <action type="add" dev="fgiust">new tasks: AddPermissionTask, CreateDefaultRepositoryAclForAllUsersTask</action> + </release> + <release version="3.5.4" date="2008-07-24" description=""> + <action type="add" dev="fgiust">new tasks: CheckMissingTemplatesTask, CheckMissingParagraphsTask, + ReplaceTemplateTask</action> + </release> + <release version="3.5.3" date="2008-06-24" description=""> + <action type="add" dev="fgiust">new CheckAndCreateRoleTask and CheckAndCreateGroupTask</action> + <action type="update" dev="fgiust">AnonymousUserSetupTask now also takes care of changing + permissions on URIs</action> + </release> + <release version="3.5.2" date="2008-06-08" description=""> + <action type="add" dev="fgiust">Added [modulename].update.disabled property in SimpleModuleVersionHandler that + can be set to true in order to disable module configuration updates</action> + <action type="add" dev="fgiust">Added it.openutils.mgnltasks.DisableSubscribersTask</action> + </release> + <release version="3.5.1" date="2008-04-28" description="3.5.1"> + <action type="add" dev="fgiust">Added UpdateModuleVersionTask.</action> + <action type="add" dev="fgiust">Added SimpleModuleVersionHandler.</action> + </release> + <release version="3.5" date="2008-04-27" description="first release"> + <action type="add" dev="fgiust">First public release. The version is labeled "3.5" in order to make clear which + version of magnolia is required.</action> + </release> + </body> +</document> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |