From: <fg...@us...> - 2010-02-06 19:45:18
|
Revision: 1825 http://openutils.svn.sourceforge.net/openutils/?rev=1825&view=rev Author: fgiust Date: 2010-02-06 19:45:09 +0000 (Sat, 06 Feb 2010) Log Message: ----------- MEDIA-70 new enabled property for media type (set a default in the existing config) Modified Paths: -------------- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/MediaModuleVersionHandler.java Added Paths: ----------- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/CreateMissingPropertyTask.java Added: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/CreateMissingPropertyTask.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/CreateMissingPropertyTask.java (rev 0) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/CreateMissingPropertyTask.java 2010-02-06 19:45:09 UTC (rev 1825) @@ -0,0 +1,78 @@ +/** + * + * Magnolia SimpleMedia Module (http://www.openmindlab.com/lab/products/media.html) + * Copyright (C)2008 - 2010, Openmind S.r.l. 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 net.sourceforge.openutils.mgnlmedia.media.setup; + +import info.magnolia.cms.core.Content; +import info.magnolia.cms.core.HierarchyManager; +import info.magnolia.cms.util.ContentUtil; +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; + + +/** + * Set a nodedata if not existing. Also creates the full path if missing. + * @author fgiust + * @version $Id$ + */ +public class CreateMissingPropertyTask extends AbstractRepositoryTask +{ + + private final String workspaceName; + + private final String nodePath; + + private final String propertyName; + + private final Object propertyValue; + + public CreateMissingPropertyTask(String workspaceName, String nodePath, String propertyName, Object propertyValue) + { + super("Create non-existent property", "Creating property " + + nodePath + + "/" + + propertyName + + " and setting its value to " + + propertyValue); + this.workspaceName = workspaceName; + this.nodePath = nodePath; + this.propertyName = propertyName; + this.propertyValue = propertyValue; + } + + /** + * {@inheritDoc} + */ + @Override + protected void doExecute(InstallContext ctx) throws RepositoryException, TaskExecutionException + { + final HierarchyManager hm = ctx.getHierarchyManager(workspaceName); + + final Content node = ContentUtil.createPath(hm, nodePath, false); + if (!node.hasNodeData(propertyName)) + { + NodeDataUtil.getOrCreateAndSet(node, propertyName, propertyValue); + } + + } + +} Property changes on: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/CreateMissingPropertyTask.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/MediaModuleVersionHandler.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/MediaModuleVersionHandler.java 2010-02-06 18:23:07 UTC (rev 1824) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/setup/MediaModuleVersionHandler.java 2010-02-06 19:45:09 UTC (rev 1825) @@ -29,7 +29,6 @@ import info.magnolia.module.InstallContext; import info.magnolia.module.delta.Task; import info.magnolia.module.delta.TaskExecutionException; -import it.openutils.mgnltasks.CreateMissingPropertyTask; import it.openutils.mgnltasks.NodeSortTask; import it.openutils.mgnltasks.SimpleModuleVersionHandler; @@ -139,13 +138,33 @@ }); tasks.add(new CreateMissingPropertyTask( - "name", - "desc", ContentRepository.CONFIG, "/modules/media/config", "singleinstance", - "false")); + Boolean.FALSE)); + // MEDIA-70 new enabled property for media type + tasks.add(new CreateMissingPropertyTask( + ContentRepository.CONFIG, + "/modules/media/mediatypes/image", + "enabled", + Boolean.TRUE)); + tasks.add(new CreateMissingPropertyTask( + ContentRepository.CONFIG, + "/modules/media/mediatypes/video", + "enabled", + Boolean.TRUE)); + tasks.add(new CreateMissingPropertyTask( + ContentRepository.CONFIG, + "/modules/media/mediatypes/youtube", + "enabled", + Boolean.TRUE)); + tasks.add(new CreateMissingPropertyTask( + ContentRepository.CONFIG, + "/modules/media/mediatypes/audio", + "enabled", + Boolean.TRUE)); + return tasks; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |