Commit 3ec65a31 authored by Ate Douma's avatar Ate Douma

HIPPLUG-1262 Reintegrate bugfix/HIPPLUG-1262

parents 8bff4d41 00d4fe07
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2016 Hippo B.V. (http://www.onehippo.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS"
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<sv:node xmlns:sv="http://www.jcp.org/jcr/sv/1.0" sv:name="AddImagelinkEditorTemplateNodetypesProperty">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>hipposys:updaterinfo</sv:value>
</sv:property>
<sv:property sv:name="hipposys:batchsize" sv:type="Long">
<sv:value>10</sv:value>
</sv:property>
<sv:property sv:name="hipposys:description" sv:type="String">
<sv:value/>
</sv:property>
<sv:property sv:name="hipposys:dryrun" sv:type="Boolean">
<sv:value>false</sv:value>
</sv:property>
<sv:property sv:name="hipposys:parameters" sv:type="String">
<sv:value/>
</sv:property>
<sv:property sv:name="hipposys:query" sv:type="String">
<sv:value>//hippo:namespaces/hippogallerypicker/imagelink/editor:templates/_default_</sv:value>
</sv:property>
<sv:property sv:name="hipposys:script" sv:type="String">
<sv:value>package org.hippoecm.frontend.plugins.cms.admin.updater&#xd;
&#xd;
import org.onehippo.repository.update.BaseNodeUpdateVisitor&#xd;
import javax.jcr.Node&#xd;
&#xd;
class UpdaterTemplate extends BaseNodeUpdateVisitor {&#xd;
&#xd;
boolean doUpdate(Node node) {&#xd;
log.debug "visiting node ${node.path}"&#xd;
if (node.hasProperty("nodetypes")) {&#xd;
if (!node.getProperty("nodetypes").isMultiple()) {&#xd;
log.debug "Updating hippogallerypicker:imagelink nodetypes property template to multivalue"&#xd;
String[] values = [ node.getProperty("nodetypes").getString() ]&#xd;
node.getProperty("nodetypes").remove()&#xd;
node.setProperty("nodetypes", values)&#xd;
return true;&#xd;
}&#xd;
}&#xd;
else {&#xd;
log.debug "Adding hippogallerypicker:imagelink nodetypes property template (multivalue)"&#xd;
node.setProperty("nodetypes", (String[])[]);&#xd;
return true;&#xd;
}&#xd;
return false&#xd;
}&#xd;
&#xd;
boolean undoUpdate(Node node) {&#xd;
throw new UnsupportedOperationException('Updater does not implement undoUpdate method')&#xd;
}&#xd;
&#xd;
}</sv:value>
</sv:property>
<sv:property sv:name="hipposys:throttle" sv:type="Long">
<sv:value>1000</sv:value>
</sv:property>
</sv:node>
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2016 Hippo B.V. (http://www.onehippo.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS"
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<sv:node xmlns:sv="http://www.jcp.org/jcr/sv/1.0" sv:name="GalleryPickerFixMultipleNodetypesSupport">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>hipposys:updaterinfo</sv:value>
</sv:property>
<sv:property sv:name="hipposys:batchsize" sv:type="Long">
<sv:value>10</sv:value>
</sv:property>
<sv:property sv:name="hipposys:description" sv:type="String">
<sv:value/>
</sv:property>
<sv:property sv:name="hipposys:dryrun" sv:type="Boolean">
<sv:value>false</sv:value>
</sv:property>
<sv:property sv:name="hipposys:parameters" sv:type="String">
<sv:value/>
</sv:property>
<sv:property sv:name="hipposys:query" sv:type="String">
<sv:value>//element(*, hipposysedit:field)[@hipposysedit:type='hippogallerypicker:imagelink']</sv:value>
</sv:property>
<sv:property sv:name="hipposys:script" sv:type="String">
<sv:value>package org.hippoecm.frontend.plugins.cms.admin.updater&#xd;
&#xd;
import org.onehippo.repository.update.BaseNodeUpdateVisitor&#xd;
import javax.jcr.Node&#xd;
&#xd;
class UpdaterTemplate extends BaseNodeUpdateVisitor {&#xd;
&#xd;
boolean doUpdate(Node node) {&#xd;
String fieldName = node.getName()&#xd;
log.debug "Checking node ${node.path}"&#xd;
Node typeNode = node.getParent().getParent().getParent()&#xd;
if (typeNode.hasNode("editor:templates/_default_/${fieldName}/cluster.options")) {&#xd;
Node fieldConfig = typeNode.getNode("editor:templates/_default_/"+fieldName+"/cluster.options")&#xd;
if (fieldConfig.hasProperty("nodetypes") &amp;&amp; !fieldConfig.getProperty("nodetypes").isMultiple()) {&#xd;
log.debug "Updating property ${fieldConfig.path}/nodetypes to multivalue"&#xd;
String[] values = [fieldConfig.getProperty("nodetypes").getString()]&#xd;
fieldConfig.getProperty("nodetypes").remove()&#xd;
fieldConfig.setProperty("nodetypes", values)&#xd;
return true;
}&#xd;
}&#xd;
return false&#xd;
}&#xd;
&#xd;
boolean undoUpdate(Node node) {&#xd;
throw new UnsupportedOperationException('Updater does not implement undoUpdate method')&#xd;
}&#xd;
&#xd;
}</sv:value>
</sv:property>
<sv:property sv:name="hipposys:throttle" sv:type="Long">
<sv:value>1000</sv:value>
</sv:property>
</sv:node>
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2008-2015 Hippo
Copyright 2008-2016 Hippo B.V. (http://www.onehippo.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
......@@ -128,4 +128,34 @@
</sv:property>
</sv:node>
<sv:node sv:name="add-imagelink-editor-template-nodetypes-property-script">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>hippo:initializeitem</sv:value>
</sv:property>
<sv:property sv:name="hippo:sequence" sv:type="Double">
<sv:value>10002.1</sv:value>
</sv:property>
<sv:property sv:name="hippo:contentresource" sv:type="String">
<sv:value>add-imagelink-editor-template-nodetypes-property-script.xml</sv:value>
</sv:property>
<sv:property sv:name="hippo:contentroot" sv:type="String">
<sv:value>/hippo:configuration/hippo:update/hippo:queue</sv:value>
</sv:property>
</sv:node>
<sv:node sv:name="gallerypicker-imagelink-fix-multiple-nodetypes-support-script">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>hippo:initializeitem</sv:value>
</sv:property>
<sv:property sv:name="hippo:sequence" sv:type="Double">
<sv:value>10002.1</sv:value>
</sv:property>
<sv:property sv:name="hippo:contentresource" sv:type="String">
<sv:value>gallerypicker-imagelink-fix-multiple-nodetypes-support-script.xml</sv:value>
</sv:property>
<sv:property sv:name="hippo:contentroot" sv:type="String">
<sv:value>/hippo:configuration/hippo:update/hippo:queue</sv:value>
</sv:property>
</sv:node>
</sv:node>
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2009 Hippo
Copyright 2009-2016 Hippo B.V. (http://www.onehippo.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
......@@ -79,6 +79,7 @@
<sv:value>frontend:plugincluster</sv:value>
</sv:property>
<sv:property sv:multiple="true" sv:name="nodetypes" sv:type="String"/>
<sv:property sv:name="frontend:services" sv:type="String">
<sv:value>wicket.id</sv:value>
</sv:property>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment