From: <fg...@us...> - 2008-06-24 15:59:54
|
Revision: 863 http://openutils.svn.sourceforge.net/openutils/?rev=863&view=rev Author: fgiust Date: 2008-06-24 08:28:00 -0700 (Tue, 24 Jun 2008) Log Message: ----------- [maven-release-plugin] copy for tag openutils-mgnltasks-3.5.3 Added Paths: ----------- tags/openutils-mgnltasks-3.5.3/ tags/openutils-mgnltasks-3.5.3/pom.xml tags/openutils-mgnltasks-3.5.3/src/main/java/it/openutils/mgnltasks/AnonymousUserSetupTask.java tags/openutils-mgnltasks-3.5.3/src/main/java/it/openutils/mgnltasks/CheckAndCreateGroupTask.java tags/openutils-mgnltasks-3.5.3/src/main/java/it/openutils/mgnltasks/CheckAndCreateRoleTask.java tags/openutils-mgnltasks-3.5.3/src/site/changes/changes.xml Removed Paths: ------------- tags/openutils-mgnltasks-3.5.3/pom.xml tags/openutils-mgnltasks-3.5.3/src/main/java/it/openutils/mgnltasks/AnonymousUserSetupTask.java tags/openutils-mgnltasks-3.5.3/src/site/changes/changes.xml Copied: tags/openutils-mgnltasks-3.5.3 (from rev 838, trunk/openutils-mgnltasks) Deleted: tags/openutils-mgnltasks-3.5.3/pom.xml =================================================================== --- trunk/openutils-mgnltasks/pom.xml 2008-06-11 21:26:56 UTC (rev 838) +++ tags/openutils-mgnltasks-3.5.3/pom.xml 2008-06-24 15:28:00 UTC (rev 863) @@ -1,89 +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.3-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> - </dependency> - <dependency> - <groupId>info.magnolia</groupId> - <artifactId>magnolia-module-admininterface</artifactId> - <version>3.5.8</version> - </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> Copied: tags/openutils-mgnltasks-3.5.3/pom.xml (from rev 862, trunk/openutils-mgnltasks/pom.xml) =================================================================== --- tags/openutils-mgnltasks-3.5.3/pom.xml (rev 0) +++ tags/openutils-mgnltasks-3.5.3/pom.xml 2008-06-24 15:28:00 UTC (rev 863) @@ -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.3</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.3</connection> + <developerConnection>scm:svn:https://openutils.svn.sourceforge.net/svnroot/openutils/tags/openutils-mgnltasks-3.5.3</developerConnection> + <url>http://openutils.svn.sourceforge.net/viewcvs.cgi/openutils/tags/openutils-mgnltasks-3.5.3</url> + </scm> +</project> \ No newline at end of file Deleted: tags/openutils-mgnltasks-3.5.3/src/main/java/it/openutils/mgnltasks/AnonymousUserSetupTask.java =================================================================== --- trunk/openutils-mgnltasks/src/main/java/it/openutils/mgnltasks/AnonymousUserSetupTask.java 2008-06-11 21:26:56 UTC (rev 838) +++ tags/openutils-mgnltasks-3.5.3/src/main/java/it/openutils/mgnltasks/AnonymousUserSetupTask.java 2008-06-24 15:28:00 UTC (rev 863) @@ -1,94 +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.security.Permission; -import info.magnolia.cms.security.UserManager; -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; - - -/** - * A task that can be used to add or remove read only access to the anonymous user (for an easy admin/public switch). - * @author fgiust - * @version $Id: $ - */ -public class AnonymousUserSetupTask extends AbstractRepositoryTask implements Task -{ - - private boolean allowAccess; - - /** - * @param allowAccess true to add access to anonymous users, false to remove it - */ - public AnonymousUserSetupTask(boolean allowAccess) - { - super("Setup anonymous user", allowAccess - ? "Adding access to anonymous user" - : "Removing access to anonymous user"); - this.allowAccess = allowAccess; - } - - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - @Override - protected void doExecute(InstallContext installContext) throws RepositoryException, TaskExecutionException - { - - HierarchyManager hm = installContext.getHierarchyManager(ContentRepository.USER_ROLES); - - Content role = hm.getContent("/" + UserManager.ANONYMOUS_USER); - - Content acls = role.getChildByName("acl_website"); - - Collection<Content> children = acls.getChildren(); - - boolean found = false; - for (Content acl : children) - { - if ("/*".equals(acl.getNodeData("path").getString())) - { - found = true; - - long permissions = acl.getNodeData("permissions").getLong(); - long newpermissions = this.allowAccess ? Permission.READ : 0; - if (permissions != newpermissions) - { - NodeDataUtil.getOrCreate(acl, "permissions").setValue(newpermissions); - } - } - } - if (!found) - { - log.warn("Security not configured on anonymous user! No acl for /* found."); - } - } - -} Copied: tags/openutils-mgnltasks-3.5.3/src/main/java/it/openutils/mgnltasks/AnonymousUserSetupTask.java (from rev 860, trunk/openutils-mgnltasks/src/main/java/it/openutils/mgnltasks/AnonymousUserSetupTask.java) =================================================================== --- tags/openutils-mgnltasks-3.5.3/src/main/java/it/openutils/mgnltasks/AnonymousUserSetupTask.java (rev 0) +++ tags/openutils-mgnltasks-3.5.3/src/main/java/it/openutils/mgnltasks/AnonymousUserSetupTask.java 2008-06-24 15:28:00 UTC (rev 863) @@ -0,0 +1,110 @@ +/** + * 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.security.AccessDeniedException; +import info.magnolia.cms.security.Permission; +import info.magnolia.cms.security.UserManager; +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; + + +/** + * A task that can be used to add or remove read only access to the anonymous user (for an easy admin/public switch). + * @author fgiust + * @version $Id$ + */ +public class AnonymousUserSetupTask extends AbstractRepositoryTask implements Task +{ + + private boolean allowAccess; + + /** + * @param allowAccess true to add access to anonymous users, false to remove it + */ + public AnonymousUserSetupTask(boolean allowAccess) + { + super("Setup anonymous user", allowAccess + ? "Adding access to anonymous user" + : "Removing access to anonymous user"); + this.allowAccess = allowAccess; + } + + /** + * {@inheritDoc} + */ + @Override + protected void doExecute(InstallContext installContext) throws RepositoryException, TaskExecutionException + { + + HierarchyManager hm = installContext.getHierarchyManager(ContentRepository.USER_ROLES); + + Content role = hm.getContent("/" + UserManager.ANONYMOUS_USER); + + setupAcl(role, "website", "/", this.allowAccess ? Permission.READ : Permission.NONE); + setupAcl(role, "uri", "/*", this.allowAccess ? Permission.ALL : Permission.NONE); + setupAcl(role, "uri", "/.magnolia*", Permission.NONE); + } + + /** + * @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); + + 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) + { + NodeDataUtil.getOrCreate(acl, "permissions").setValue(newpermissions); + } + } + } + if (!found) + { + log.warn("Security not configured on anonymous user! No acl for {} found on {}", path, repository); + } + } + +} Copied: tags/openutils-mgnltasks-3.5.3/src/main/java/it/openutils/mgnltasks/CheckAndCreateGroupTask.java (from rev 860, trunk/openutils-mgnltasks/src/main/java/it/openutils/mgnltasks/CheckAndCreateGroupTask.java) =================================================================== --- tags/openutils-mgnltasks-3.5.3/src/main/java/it/openutils/mgnltasks/CheckAndCreateGroupTask.java (rev 0) +++ tags/openutils-mgnltasks-3.5.3/src/main/java/it/openutils/mgnltasks/CheckAndCreateGroupTask.java 2008-06-24 15:28:00 UTC (rev 863) @@ -0,0 +1,76 @@ +/** + * 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.HierarchyManager; +import info.magnolia.module.InstallContext; +import info.magnolia.module.delta.AbstractRepositoryTask; +import info.magnolia.module.delta.BootstrapSingleResource; +import info.magnolia.module.delta.Task; +import info.magnolia.module.delta.TaskExecutionException; + +import javax.jcr.PathNotFoundException; +import javax.jcr.RepositoryException; + + +/** + * Creates a group if not already existing. + * @author fgiust + * @version $Id$ + */ +public class CheckAndCreateGroupTask extends AbstractRepositoryTask implements Task +{ + + private String group; + + private String bootstrapFile; + + /** + * @param group group name + * @param bootstrapFile bootstrap file used to create the group + */ + public CheckAndCreateGroupTask(String group, String bootstrapFile) + { + super("Checking " + group, "Checking " + group); + this.group = group; + this.bootstrapFile = bootstrapFile; + } + + /** + * {@inheritDoc} + */ + @Override + protected void doExecute(InstallContext installContext) throws RepositoryException, TaskExecutionException + { + + HierarchyManager hm = installContext.getHierarchyManager(ContentRepository.USER_GROUPS); + + try + { + hm.getContent(group); + } + catch (PathNotFoundException e) + { + + BootstrapSingleResource bsr = new BootstrapSingleResource("creating group " + group, "creating group " + + group, bootstrapFile); + bsr.execute(installContext); + } + } +} Copied: tags/openutils-mgnltasks-3.5.3/src/main/java/it/openutils/mgnltasks/CheckAndCreateRoleTask.java (from rev 860, trunk/openutils-mgnltasks/src/main/java/it/openutils/mgnltasks/CheckAndCreateRoleTask.java) =================================================================== --- tags/openutils-mgnltasks-3.5.3/src/main/java/it/openutils/mgnltasks/CheckAndCreateRoleTask.java (rev 0) +++ tags/openutils-mgnltasks-3.5.3/src/main/java/it/openutils/mgnltasks/CheckAndCreateRoleTask.java 2008-06-24 15:28:00 UTC (rev 863) @@ -0,0 +1,78 @@ +/** + * 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.HierarchyManager; +import info.magnolia.module.InstallContext; +import info.magnolia.module.delta.AbstractRepositoryTask; +import info.magnolia.module.delta.BootstrapSingleResource; +import info.magnolia.module.delta.Task; +import info.magnolia.module.delta.TaskExecutionException; + +import javax.jcr.PathNotFoundException; +import javax.jcr.RepositoryException; + + +/** + * Creates a role if not already existing. + * @author fgiust + * @version $Id$ + */ +public class CheckAndCreateRoleTask extends AbstractRepositoryTask implements Task +{ + + private String role; + + private String bootstrapFile; + + /** + * @param role role name + * @param bootstrapFile bootstrap file used to create the role + */ + public CheckAndCreateRoleTask(String role, String bootstrapFile) + { + super("Checking " + role, "Checking " + role); + this.role = role; + this.bootstrapFile = bootstrapFile; + } + + /** + * {@inheritDoc} + */ + @Override + protected void doExecute(InstallContext installContext) throws RepositoryException, TaskExecutionException + { + + HierarchyManager hm = installContext.getHierarchyManager(ContentRepository.USER_ROLES); + + try + { + hm.getContent(role); + } + catch (PathNotFoundException e) + { + + BootstrapSingleResource bsr = new BootstrapSingleResource( + "creating role " + role, + "creating role " + role, + bootstrapFile); + bsr.execute(installContext); + } + } +} Deleted: tags/openutils-mgnltasks-3.5.3/src/site/changes/changes.xml =================================================================== --- trunk/openutils-mgnltasks/src/site/changes/changes.xml 2008-06-11 21:26:56 UTC (rev 838) +++ tags/openutils-mgnltasks-3.5.3/src/site/changes/changes.xml 2008-06-24 15:28:00 UTC (rev 863) @@ -1,25 +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.2" date="2008-06-08" description="in svn"> - <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.3/src/site/changes/changes.xml (from rev 860, trunk/openutils-mgnltasks/src/site/changes/changes.xml) =================================================================== --- tags/openutils-mgnltasks-3.5.3/src/site/changes/changes.xml (rev 0) +++ tags/openutils-mgnltasks-3.5.3/src/site/changes/changes.xml 2008-06-24 15:28:00 UTC (rev 863) @@ -0,0 +1,30 @@ +<?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.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. |