This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.installer.factory.configuration-1.0.10 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-installer-factory-configuration.git
commit 537f026d2e5c204b2f40c68ee7d8ac4a057f1d6b Author: Carsten Ziegeler <[email protected]> AuthorDate: Thu Oct 20 09:35:14 2011 +0000 SLING-2252 : If a config is removed and a different config is to be installed perform an update git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/installer/factories/configuration@1186689 13f79535-47bb-0310-9956-ffa450edef68 --- .../configuration/impl/ChangeStateTask.java | 51 ++++++++++++++++++++++ .../configuration/impl/ConfigTaskCreator.java | 10 ++++- 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/sling/installer/factories/configuration/impl/ChangeStateTask.java b/src/main/java/org/apache/sling/installer/factories/configuration/impl/ChangeStateTask.java new file mode 100644 index 0000000..d7ba948 --- /dev/null +++ b/src/main/java/org/apache/sling/installer/factories/configuration/impl/ChangeStateTask.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ +package org.apache.sling.installer.factories.configuration.impl; + +import org.apache.sling.installer.api.tasks.InstallationContext; +import org.apache.sling.installer.api.tasks.ResourceState; +import org.apache.sling.installer.api.tasks.TaskResourceGroup; + +/** + * Simple general task, setting the state of a registered resource. + */ +public class ChangeStateTask extends AbstractConfigTask { + + private static final String ORDER = "00-"; + + private final ResourceState state; + + public ChangeStateTask(final TaskResourceGroup r, + final ResourceState s) { + super(r, null); + this.state = s; + } + + /** + * @see org.apache.sling.installer.api.tasks.InstallTask#execute(org.apache.sling.installer.api.tasks.InstallationContext) + */ + public void execute(final InstallationContext ctx) { + this.setFinishedState(this.state); + } + + @Override + public String getSortKey() { + return ORDER + getResource().getEntityId(); + } +} diff --git a/src/main/java/org/apache/sling/installer/factories/configuration/impl/ConfigTaskCreator.java b/src/main/java/org/apache/sling/installer/factories/configuration/impl/ConfigTaskCreator.java index 8554f80..b8f8ea7 100644 --- a/src/main/java/org/apache/sling/installer/factories/configuration/impl/ConfigTaskCreator.java +++ b/src/main/java/org/apache/sling/installer/factories/configuration/impl/ConfigTaskCreator.java @@ -69,7 +69,15 @@ public class ConfigTaskCreator final InstallTask result; if (toActivate.getState() == ResourceState.UNINSTALL) { - result = new ConfigRemoveTask(group, this.configAdmin); + // if this is an uninstall, check if we have to install an older version + // in this case we should do an update instead of uninstall/install (!) + final TaskResource second = group.getNextActiveResource(); + if ( second != null && + ( second.getState() == ResourceState.IGNORED || second.getState() == ResourceState.INSTALLED || second.getState() == ResourceState.INSTALL ) ) { + result = new ChangeStateTask(group, ResourceState.UNINSTALLED); + } else { + result = new ConfigRemoveTask(group, this.configAdmin); + } } else { result = new ConfigInstallTask(group, this.configAdmin); } -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
