From: <fg...@us...> - 2008-04-28 22:17:51
|
Revision: 798 http://openutils.svn.sourceforge.net/openutils/?rev=798&view=rev Author: fgiust Date: 2008-04-28 15:17:55 -0700 (Mon, 28 Apr 2008) Log Message: ----------- changes for 3.5.1 Modified Paths: -------------- trunk/openutils-mgnltasks/src/site/changes/changes.xml Added Paths: ----------- trunk/openutils-mgnltasks/src/main/java/it/openutils/mgnltasks/SimpleModuleVersionHandler.java trunk/openutils-mgnltasks/src/main/java/it/openutils/mgnltasks/UpdateModuleVersionTask.java Added: trunk/openutils-mgnltasks/src/main/java/it/openutils/mgnltasks/SimpleModuleVersionHandler.java =================================================================== --- trunk/openutils-mgnltasks/src/main/java/it/openutils/mgnltasks/SimpleModuleVersionHandler.java (rev 0) +++ trunk/openutils-mgnltasks/src/main/java/it/openutils/mgnltasks/SimpleModuleVersionHandler.java 2008-04-28 22:17:55 UTC (rev 798) @@ -0,0 +1,68 @@ +package it.openutils.mgnltasks; + +import info.magnolia.module.DefaultModuleVersionHandler; +import info.magnolia.module.InstallContext; +import info.magnolia.module.delta.Delta; +import info.magnolia.module.delta.DeltaBuilder; +import info.magnolia.module.model.Version; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang.ObjectUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * A base module version handler that re-bootstrap its configuration each time the version number changes. Can be used + * as is or subclassed (usually overriding getStartupTasks() for configuration tweacks). + * @author fgiust + * @version $Id: $ + */ +public class SimpleModuleVersionHandler extends DefaultModuleVersionHandler +{ + + /** + * Logger. + */ + protected Logger log = LoggerFactory.getLogger(getClass()); + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + @Override + public List<Delta> getDeltas(InstallContext ctx, Version from) + { + if (from == null) + { + log.info("Actual version not set"); + return super.getDeltas(ctx, from); + } + + Version to = ctx.getCurrentModuleDefinition().getVersionDefinition(); + + List<Delta> deltas = new ArrayList<Delta>(); + + if (!to.isEquivalent(from) + || "${project.version}".equals(ObjectUtils.toString(from)) + || "SNAPSHOT".equals(from.getClassifier())) + { + log.info("Updating from version {}", from); + + Delta delta = DeltaBuilder.update(to, "Update to current version"); + delta.getTasks().add(new ModuleConfigBootstrapTask(ctx.getCurrentModuleDefinition().getName())); + delta.getTasks().add(new UpdateModuleVersionTask()); + + deltas.add(delta); + } + else + { + log.info("Version {} already installed, no update tasks to run", from); + } + + return deltas; + } + +} Property changes on: trunk/openutils-mgnltasks/src/main/java/it/openutils/mgnltasks/SimpleModuleVersionHandler.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Added: trunk/openutils-mgnltasks/src/main/java/it/openutils/mgnltasks/UpdateModuleVersionTask.java =================================================================== --- trunk/openutils-mgnltasks/src/main/java/it/openutils/mgnltasks/UpdateModuleVersionTask.java (rev 0) +++ trunk/openutils-mgnltasks/src/main/java/it/openutils/mgnltasks/UpdateModuleVersionTask.java 2008-04-28 22:17:55 UTC (rev 798) @@ -0,0 +1,63 @@ +/** + * 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.core.Content; +import info.magnolia.cms.core.HierarchyManager; +import info.magnolia.cms.core.ItemType; +import info.magnolia.cms.core.NodeData; +import info.magnolia.cms.util.NodeDataUtil; +import info.magnolia.module.InstallContext; +import info.magnolia.module.delta.AbstractRepositoryTask; +import info.magnolia.module.delta.TaskExecutionException; + +import javax.jcr.RepositoryException; + + +/** + * A task that updates the current version of a module stored in the config repository. + * @author fgiust + * @version $Id: $ + */ +public class UpdateModuleVersionTask extends AbstractRepositoryTask +{ + + public UpdateModuleVersionTask() + { + super("Version number", "Sets installed module version number"); + } + + /** + * {@inheritDoc} + */ + @Override + protected void doExecute(InstallContext ctx) throws RepositoryException, TaskExecutionException + { + // make sure we have the /modules node + if (!ctx.hasModulesNode()) + { + final HierarchyManager hm = ctx.getConfigHierarchyManager(); + hm.createContent("/", "modules", ItemType.CONTENT.getSystemName()); + } + + final Content moduleNode = ctx.getOrCreateCurrentModuleNode(); + final NodeData nodeData = NodeDataUtil.getOrCreate(moduleNode, "version"); + nodeData.setValue(ctx.getCurrentModuleDefinition().getVersionDefinition().toString()); + } + +} \ No newline at end of file Property changes on: trunk/openutils-mgnltasks/src/main/java/it/openutils/mgnltasks/UpdateModuleVersionTask.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Modified: trunk/openutils-mgnltasks/src/site/changes/changes.xml =================================================================== --- trunk/openutils-mgnltasks/src/site/changes/changes.xml 2008-04-27 21:45:51 UTC (rev 797) +++ trunk/openutils-mgnltasks/src/site/changes/changes.xml 2008-04-28 22:17:55 UTC (rev 798) @@ -8,6 +8,10 @@ <author email="fgiust(at)users.sourceforge.net">Fabrizio Giustina</author> </properties> <body> + <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> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2008-04-29 12:26:18
|
Revision: 803 http://openutils.svn.sourceforge.net/openutils/?rev=803&view=rev Author: fgiust Date: 2008-04-29 05:26:18 -0700 (Tue, 29 Apr 2008) Log Message: ----------- Added [modulename].update.disabled property in SimpleModuleVersionHandler Modified Paths: -------------- trunk/openutils-mgnltasks/src/main/java/it/openutils/mgnltasks/SimpleModuleVersionHandler.java trunk/openutils-mgnltasks/src/site/changes/changes.xml Modified: trunk/openutils-mgnltasks/src/main/java/it/openutils/mgnltasks/SimpleModuleVersionHandler.java =================================================================== --- trunk/openutils-mgnltasks/src/main/java/it/openutils/mgnltasks/SimpleModuleVersionHandler.java 2008-04-28 22:19:45 UTC (rev 802) +++ trunk/openutils-mgnltasks/src/main/java/it/openutils/mgnltasks/SimpleModuleVersionHandler.java 2008-04-29 12:26:18 UTC (rev 803) @@ -17,6 +17,7 @@ */ package it.openutils.mgnltasks; +import info.magnolia.cms.core.SystemProperty; import info.magnolia.module.DefaultModuleVersionHandler; import info.magnolia.module.InstallContext; import info.magnolia.module.delta.Delta; @@ -58,10 +59,17 @@ return super.getDeltas(ctx, from); } + String modulename = ctx.getCurrentModuleDefinition().getName(); + Version to = ctx.getCurrentModuleDefinition().getVersionDefinition(); List<Delta> deltas = new ArrayList<Delta>(); + if (SystemProperty.getBooleanProperty(modulename + ".update.disabled")) + { + return deltas; + } + if (!to.isEquivalent(from) || "${project.version}".equals(ObjectUtils.toString(from)) || "SNAPSHOT".equals(from.getClassifier())) @@ -69,7 +77,7 @@ log.info("Updating from version {}", from); Delta delta = DeltaBuilder.update(to, "Update to current version"); - delta.getTasks().add(new ModuleConfigBootstrapTask(ctx.getCurrentModuleDefinition().getName())); + delta.getTasks().add(new ModuleConfigBootstrapTask(modulename)); delta.getTasks().add(new UpdateModuleVersionTask()); deltas.add(delta); Modified: trunk/openutils-mgnltasks/src/site/changes/changes.xml =================================================================== --- trunk/openutils-mgnltasks/src/site/changes/changes.xml 2008-04-28 22:19:45 UTC (rev 802) +++ trunk/openutils-mgnltasks/src/site/changes/changes.xml 2008-04-29 12:26:18 UTC (rev 803) @@ -8,6 +8,10 @@ <author email="fgiust(at)users.sourceforge.net">Fabrizio Giustina</author> </properties> <body> + <release version="3.5.2" date="in svn" 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> + </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> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fg...@us...> - 2008-06-24 15:07:11
|
Revision: 860 http://openutils.svn.sourceforge.net/openutils/?rev=860&view=rev Author: fgiust Date: 2008-06-24 08:06:13 -0700 (Tue, 24 Jun 2008) Log Message: ----------- 3.5.3, a few improvements to user/role setup Modified Paths: -------------- trunk/openutils-mgnltasks/src/main/java/it/openutils/mgnltasks/AnonymousUserSetupTask.java trunk/openutils-mgnltasks/src/site/changes/changes.xml Added Paths: ----------- trunk/openutils-mgnltasks/src/main/java/it/openutils/mgnltasks/CheckAndCreateGroupTask.java trunk/openutils-mgnltasks/src/main/java/it/openutils/mgnltasks/CheckAndCreateRoleTask.java Modified: trunk/openutils-mgnltasks/src/main/java/it/openutils/mgnltasks/AnonymousUserSetupTask.java =================================================================== --- trunk/openutils-mgnltasks/src/main/java/it/openutils/mgnltasks/AnonymousUserSetupTask.java 2008-06-24 13:24:09 UTC (rev 859) +++ trunk/openutils-mgnltasks/src/main/java/it/openutils/mgnltasks/AnonymousUserSetupTask.java 2008-06-24 15:06:13 UTC (rev 860) @@ -20,6 +20,7 @@ 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; @@ -36,7 +37,7 @@ /** * 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: $ + * @version $Id$ */ public class AnonymousUserSetupTask extends AbstractRepositoryTask implements Task { @@ -57,7 +58,6 @@ /** * {@inheritDoc} */ - @SuppressWarnings("unchecked") @Override protected void doExecute(InstallContext installContext) throws RepositoryException, TaskExecutionException { @@ -66,19 +66,35 @@ Content role = hm.getContent("/" + UserManager.ANONYMOUS_USER); - Content acls = role.getChildByName("acl_website"); + 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) { - if ("/*".equals(acl.getNodeData("path").getString())) + String aclPath = acl.getNodeData("path").getString(); + if (path.equals(aclPath)) { found = true; long permissions = acl.getNodeData("permissions").getLong(); - long newpermissions = this.allowAccess ? Permission.READ : 0; if (permissions != newpermissions) { NodeDataUtil.getOrCreate(acl, "permissions").setValue(newpermissions); @@ -87,7 +103,7 @@ } if (!found) { - log.warn("Security not configured on anonymous user! No acl for /* found."); + log.warn("Security not configured on anonymous user! No acl for {} found on {}", path, repository); } } Added: trunk/openutils-mgnltasks/src/main/java/it/openutils/mgnltasks/CheckAndCreateGroupTask.java =================================================================== --- trunk/openutils-mgnltasks/src/main/java/it/openutils/mgnltasks/CheckAndCreateGroupTask.java (rev 0) +++ trunk/openutils-mgnltasks/src/main/java/it/openutils/mgnltasks/CheckAndCreateGroupTask.java 2008-06-24 15:06:13 UTC (rev 860) @@ -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); + } + } +} Property changes on: trunk/openutils-mgnltasks/src/main/java/it/openutils/mgnltasks/CheckAndCreateGroupTask.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Added: trunk/openutils-mgnltasks/src/main/java/it/openutils/mgnltasks/CheckAndCreateRoleTask.java =================================================================== --- trunk/openutils-mgnltasks/src/main/java/it/openutils/mgnltasks/CheckAndCreateRoleTask.java (rev 0) +++ trunk/openutils-mgnltasks/src/main/java/it/openutils/mgnltasks/CheckAndCreateRoleTask.java 2008-06-24 15:06:13 UTC (rev 860) @@ -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); + } + } +} Property changes on: trunk/openutils-mgnltasks/src/main/java/it/openutils/mgnltasks/CheckAndCreateRoleTask.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Modified: trunk/openutils-mgnltasks/src/site/changes/changes.xml =================================================================== --- trunk/openutils-mgnltasks/src/site/changes/changes.xml 2008-06-24 13:24:09 UTC (rev 859) +++ trunk/openutils-mgnltasks/src/site/changes/changes.xml 2008-06-24 15:06:13 UTC (rev 860) @@ -8,7 +8,12 @@ <author email="fgiust(at)users.sourceforge.net">Fabrizio Giustina</author> </properties> <body> - <release version="3.5.2" date="2008-06-08" description="in svn"> + <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> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |