You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2020/04/29 10:45:28 UTC
[sling-whiteboard] branch master updated: Moved feature installer
support to separate git
This is an automated email from the ASF dual-hosted git repository.
cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git
The following commit(s) were added to refs/heads/master by this push:
new 1cec586 Moved feature installer support to separate git
1cec586 is described below
commit 1cec5860552be6df46ac061022288970067f3bbc
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Apr 29 12:45:13 2020 +0200
Moved feature installer support to separate git
---
.../.gitignore | 17 --
.../CODE_OF_CONDUCT.md | 22 --
.../CONTRIBUTING.md | 24 --
.../Jenkinsfile | 20 --
org.apache.sling.installer.factory.feature/LICENSE | 202 ---------------
.../README.md | 9 -
org.apache.sling.installer.factory.feature/bnd.bnd | 2 -
org.apache.sling.installer.factory.feature/pom.xml | 126 ----------
.../model/impl/AbstractFeatureModelTask.java | 94 -------
.../model/impl/FeatureModelInstallerPlugin.java | 273 ---------------------
.../factory/model/impl/InstallContext.java | 35 ---
.../model/impl/InstallFeatureModelTask.java | 263 --------------------
.../model/impl/UninstallFeatureModelTask.java | 60 -----
.../impl/FeatureModelInstallerPluginTest.java | 70 ------
14 files changed, 1217 deletions(-)
diff --git a/org.apache.sling.installer.factory.feature/.gitignore b/org.apache.sling.installer.factory.feature/.gitignore
deleted file mode 100644
index 5b783ed..0000000
--- a/org.apache.sling.installer.factory.feature/.gitignore
+++ /dev/null
@@ -1,17 +0,0 @@
-/target
-.idea
-.classpath
-.metadata
-.project
-.settings
-.externalToolBuilders
-maven-eclipse.xml
-*.swp
-*.iml
-*.ipr
-*.iws
-*.bak
-.vlt
-.DS_Store
-jcr.log
-atlassian-ide-plugin.xml
diff --git a/org.apache.sling.installer.factory.feature/CODE_OF_CONDUCT.md b/org.apache.sling.installer.factory.feature/CODE_OF_CONDUCT.md
deleted file mode 100644
index 0fa18e5..0000000
--- a/org.apache.sling.installer.factory.feature/CODE_OF_CONDUCT.md
+++ /dev/null
@@ -1,22 +0,0 @@
-<!--/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ~ 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.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
-Apache Software Foundation Code of Conduct
-====
-
-Being an Apache project, Apache Sling adheres to the Apache Software Foundation's [Code of Conduct](https://www.apache.org/foundation/policies/conduct.html).
diff --git a/org.apache.sling.installer.factory.feature/CONTRIBUTING.md b/org.apache.sling.installer.factory.feature/CONTRIBUTING.md
deleted file mode 100644
index ac82a1a..0000000
--- a/org.apache.sling.installer.factory.feature/CONTRIBUTING.md
+++ /dev/null
@@ -1,24 +0,0 @@
-<!--/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ~ 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.
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
-Contributing
-====
-
-Thanks for choosing to contribute!
-
-You will find all the necessary details about how you can do this at https://sling.apache.org/contributing.html.
diff --git a/org.apache.sling.installer.factory.feature/Jenkinsfile b/org.apache.sling.installer.factory.feature/Jenkinsfile
deleted file mode 100644
index f582519..0000000
--- a/org.apache.sling.installer.factory.feature/Jenkinsfile
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
- * 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.
- */
-
-slingOsgiBundleBuild()
diff --git a/org.apache.sling.installer.factory.feature/LICENSE b/org.apache.sling.installer.factory.feature/LICENSE
deleted file mode 100644
index d645695..0000000
--- a/org.apache.sling.installer.factory.feature/LICENSE
+++ /dev/null
@@ -1,202 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- 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.
diff --git a/org.apache.sling.installer.factory.feature/README.md b/org.apache.sling.installer.factory.feature/README.md
deleted file mode 100644
index 504ac47..0000000
--- a/org.apache.sling.installer.factory.feature/README.md
+++ /dev/null
@@ -1,9 +0,0 @@
-[<img src="https://sling.apache.org/res/logos/sling.png"/>](https://sling.apache.org)
-
- [![Build Status](https://builds.apache.org/buildStatus/icon?job=Sling/sling-org-apache-sling-installer-factory-model/master)](https://builds.apache.org/job/Sling/job/sling-org-apache-sling-installer-factory-model/job/master) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0) [![installer](https://sling.apache.org/badges/group-installer.svg)](https://github.com/apache/sling-aggregator/blob/master/docs/groups/installer.md)
-
-# Apache Sling Installer Feature Model Support
-
-This module is part of the [Apache Sling](https://sling.apache.org) project.
-
-Provides support for the feature model to the Apache Sling OSGi installer
diff --git a/org.apache.sling.installer.factory.feature/bnd.bnd b/org.apache.sling.installer.factory.feature/bnd.bnd
deleted file mode 100644
index d2c832f..0000000
--- a/org.apache.sling.installer.factory.feature/bnd.bnd
+++ /dev/null
@@ -1,2 +0,0 @@
--includeresource: @org.apache.sling.feature.extension.apiregions-[0-9.]*.jar!/org/apache/sling/feature/extension/apiregions/launcher/LauncherProperties.*
-Conditional-Package: org.apache.sling.feature.extension.apiregions.api
diff --git a/org.apache.sling.installer.factory.feature/pom.xml b/org.apache.sling.installer.factory.feature/pom.xml
deleted file mode 100644
index 814b2ae..0000000
--- a/org.apache.sling.installer.factory.feature/pom.xml
+++ /dev/null
@@ -1,126 +0,0 @@
-<?xml version="1.0"?>
-<!--
- 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.
--->
-<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">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.sling</groupId>
- <artifactId>sling-bundle-parent</artifactId>
- <version>38</version>
- <relativePath/>
- </parent>
-
- <artifactId>org.apache.sling.installer.factory.feature</artifactId>
- <version>0.1.0-SNAPSHOT</version>
-
- <name>Apache Sling Installer Feature Model Support</name>
- <description>
- Provides support for the feature model to the Apache Sling OSGi installer
- </description>
-
- <scm>
- <connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-installer-factory-feature.git</connection>
- <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-installer-factory-feature.git</developerConnection>
- <url>https://gitbox.apache.org/repos/asf?p=sling-org-apache-sling-installer-factory-feature.git</url>
- </scm>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <configuration>
- <excludePackageNames>
- org.apache.sling.installer.factory.model.impl
- </excludePackageNames>
- </configuration>
- </plugin>
- <plugin>
- <groupId>biz.aQute.bnd</groupId>
- <artifactId>bnd-baseline-maven-plugin</artifactId>
- <configuration>
- <skip>true</skip>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.annotation.versioning</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.service.component.annotations</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.service.metatype.annotations</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-json_1.1_spec</artifactId>
- <version>1.2</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>javax.jcr</groupId>
- <artifactId>jcr</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.installer.core</artifactId>
- <version>3.8.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.feature</artifactId>
- <version>1.2.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.feature.extension.apiregions</artifactId>
- <version>1.1.4</version>
- <scope>provided</scope>
- </dependency>
- <!-- Testing -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <version>3.3.0</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-</project>
diff --git a/org.apache.sling.installer.factory.feature/src/main/java/org/apache/sling/installer/factory/model/impl/AbstractFeatureModelTask.java b/org.apache.sling.installer.factory.feature/src/main/java/org/apache/sling/installer/factory/model/impl/AbstractFeatureModelTask.java
deleted file mode 100644
index d58ec51..0000000
--- a/org.apache.sling.installer.factory.feature/src/main/java/org/apache/sling/installer/factory/model/impl/AbstractFeatureModelTask.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * 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.factory.model.impl;
-
-import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.sling.installer.api.tasks.InstallTask;
-import org.apache.sling.installer.api.tasks.TaskResource;
-import org.apache.sling.installer.api.tasks.TaskResourceGroup;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Abstract class for the tasks.
- */
-public abstract class AbstractFeatureModelTask extends InstallTask {
-
- /** Logger. */
- protected final Logger logger = LoggerFactory.getLogger(this.getClass());
-
- private final BundleContext bundleContext;
-
- private final Map<ServiceReference<?>, Object> services = new HashMap<>();
-
- public AbstractFeatureModelTask(final TaskResourceGroup group,
- final BundleContext bundleContext) {
- super(group);
- this.bundleContext = bundleContext;
- }
-
- protected void cleanup() {
- for(final ServiceReference<?> r : this.services.keySet()) {
- this.bundleContext.ungetService(r);
- }
- this.services.clear();
- }
-
- protected String getScheme(final TaskResource resource) {
- return "model-".concat(resource.getAttribute(FeatureModelInstallerPlugin.ATTR_ID).toString().replace(':', '_'));
- }
-
- @SuppressWarnings("unchecked")
- protected <T> T getService(final Class<T> type) {
- T service = null;
- final ServiceReference<T> reference = this.bundleContext.getServiceReference(type);
- if ( reference != null ) {
- service = (T)this.services.get(reference);
- if ( service == null ) {
- service = this.bundleContext.getService(reference);
- if ( service != null ) {
- this.services.put(reference, service);
- } else {
- }
- }
- }
- if ( service == null ) {
- logger.error("Unable to get OSGi service " + type.getName());
- }
- return service;
- }
-
- protected void deleteDirectory(final File dir) {
- if ( dir.exists() ) {
- for(final File f : dir.listFiles()) {
- if ( f.isDirectory() ) {
- deleteDirectory(f);
- } else {
- f.delete();
- }
- }
- dir.delete();
- }
- }
-}
diff --git a/org.apache.sling.installer.factory.feature/src/main/java/org/apache/sling/installer/factory/model/impl/FeatureModelInstallerPlugin.java b/org.apache.sling.installer.factory.feature/src/main/java/org/apache/sling/installer/factory/model/impl/FeatureModelInstallerPlugin.java
deleted file mode 100644
index 3c1b870..0000000
--- a/org.apache.sling.installer.factory.feature/src/main/java/org/apache/sling/installer/factory/model/impl/FeatureModelInstallerPlugin.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * 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.factory.model.impl;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Pattern;
-
-import org.apache.sling.feature.Feature;
-import org.apache.sling.feature.builder.BuilderContext;
-import org.apache.sling.feature.builder.FeatureBuilder;
-import org.apache.sling.feature.io.archive.ArchiveReader;
-import org.apache.sling.feature.io.artifacts.ArtifactManager;
-import org.apache.sling.feature.io.artifacts.ArtifactManagerConfig;
-import org.apache.sling.feature.io.json.FeatureJSONReader;
-import org.apache.sling.feature.io.json.FeatureJSONWriter;
-import org.apache.sling.installer.api.InstallableResource;
-import org.apache.sling.installer.api.tasks.InstallTask;
-import org.apache.sling.installer.api.tasks.InstallTaskFactory;
-import org.apache.sling.installer.api.tasks.RegisteredResource;
-import org.apache.sling.installer.api.tasks.ResourceState;
-import org.apache.sling.installer.api.tasks.ResourceTransformer;
-import org.apache.sling.installer.api.tasks.TaskResource;
-import org.apache.sling.installer.api.tasks.TaskResourceGroup;
-import org.apache.sling.installer.api.tasks.TransformationResult;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.metatype.annotations.AttributeDefinition;
-import org.osgi.service.metatype.annotations.Designate;
-import org.osgi.service.metatype.annotations.ObjectClassDefinition;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * This task factory processes model resources detected by
- * the {@link FeatureModelTransformer}.
- */
-@Component(service = { InstallTaskFactory.class, ResourceTransformer.class })
-@Designate(ocd = FeatureModelInstallerPlugin.Config.class)
-public class FeatureModelInstallerPlugin implements InstallTaskFactory, ResourceTransformer {
-
- @ObjectClassDefinition(name = "Apache Sling Feature Model Installer",
- description = "This component provides support for feature models to the OSGi installer")
- public @interface Config {
-
- @AttributeDefinition(name = "Use Apache Maven",
- description = "If enabled, missing artifacts from a feature are tried by invoking the mvn command")
- boolean useMvn() default true;
-
- @AttributeDefinition(name = "Repository URLs", description = "Additional repository URLs to fetch artifacts")
- String[] repositories();
-
- @AttributeDefinition(name = "Classifier Patterns", description = "Patterns for selecting the features to handle based on the classifier. Without a configuration all features are handled."
- + " The patterns can use an asteriks to match any characters in the classifier. The special token ':' can be used to match the empty classifier.")
- String[] classifierPatterns();
- }
-
- public static final String FILE_EXTENSION = ".json";
-
- public static final String TYPE_FEATURE_MODEL = "featuremodel";
-
- public static final String ATTR_MODEL = "feature";
-
- public static final String ATTR_ID = "featureId";
-
- /** Logger. */
- private final Logger logger = LoggerFactory.getLogger(this.getClass());
-
- private final BundleContext bundleContext;
-
- private final ArtifactManager artifactManager;
-
- private final List<Pattern> classifierPatterns = new ArrayList<>();
-
- private final File storageDirectory;
-
- @Activate
- public FeatureModelInstallerPlugin(final BundleContext ctx, final Config config) throws IOException {
- this.bundleContext = ctx;
- this.storageDirectory = this.bundleContext.getDataFile("repository");
- final ArtifactManagerConfig amCfg = new ArtifactManagerConfig();
- amCfg.setUseMvn(config.useMvn());
- final List<String> repos = new ArrayList<>(Arrays.asList(amCfg.getRepositoryUrls()));
- if (this.storageDirectory != null) {
- repos.add(this.storageDirectory.toURI().toURL().toExternalForm());
- }
- if (config.repositories() != null && config.repositories().length > 0) {
- for (final String r : config.repositories()) {
- if (!r.trim().isEmpty()) {
- repos.add(r);
- }
- }
- }
- amCfg.setRepositoryUrls(repos.toArray(new String[repos.size()]));
-
- this.artifactManager = ArtifactManager.getArtifactManager(amCfg);
- if (config.classifierPatterns() != null) {
- for (final String text : config.classifierPatterns()) {
- if (text != null && !text.trim().isEmpty()) {
- if (":".equals(text.trim())) {
- classifierPatterns.add(Pattern.compile("^$"));
- } else {
- classifierPatterns.add(Pattern.compile(toRegexPattern(text.trim())));
- }
- }
- }
- }
- }
-
- @Override
- public TransformationResult[] transform(final RegisteredResource resource) {
- final List<Feature> features = new ArrayList<>();
- if (resource.getType().equals(InstallableResource.TYPE_FILE) && resource.getURL().endsWith(FILE_EXTENSION)) {
- try (final Reader reader = new InputStreamReader(resource.getInputStream(), "UTF-8")) {
- features.add(FeatureJSONReader.read(reader, resource.getURL()));
- } catch (final IOException ioe) {
- logger.info("Unable to read feature model from " + resource.getURL(), ioe);
- }
- }
- if (resource.getType().equals(InstallableResource.TYPE_FILE) && resource.getURL().endsWith(".far")) {
- try (final InputStream is = resource.getInputStream()) {
- features.addAll(ArchiveReader.read(is, null));
- } catch (final IOException ioe) {
- logger.info("Unable to read feature model from " + resource.getURL(), ioe);
- }
- }
- if (!features.isEmpty()) {
- // persist all features to the file system
- if (this.storageDirectory != null) {
- for (Feature feature : features) {
- final File featureFile = new File(this.storageDirectory,
- feature.getId().toMvnPath().replace('/', File.separatorChar));
- if (!featureFile.exists()) {
- featureFile.getParentFile().mkdirs();
- try (final Writer writer = new FileWriter(featureFile)) {
- FeatureJSONWriter.write(writer, feature);
- } catch (final IOException ioe) {
- logger.error("Unable to write feature to " + featureFile + ":" + ioe.getMessage(), ioe);
- }
- }
- }
- }
-
- boolean error = false;
- final List<TransformationResult> result = new ArrayList<>();
- for (Feature feature : features) {
- if (!classifierMatches(feature.getId().getClassifier())) {
- continue;
- }
-
- // assemble feature now
- if (!feature.isAssembled()) {
- final BuilderContext ctx = new BuilderContext(this.artifactManager.toFeatureProvider());
- ctx.setArtifactProvider(this.artifactManager);
- feature = FeatureBuilder.assemble(feature, ctx);
- }
-
- String featureJson = null;
- try (final StringWriter sw = new StringWriter()) {
- FeatureJSONWriter.write(sw, feature);
- featureJson = sw.toString();
- } catch (final IOException ioe) {
- logger.info("Unable to read feature model from " + resource.getURL(), ioe);
- }
-
- if (featureJson != null) {
- final TransformationResult tr = new TransformationResult();
- tr.setResourceType(TYPE_FEATURE_MODEL);
- tr.setId(feature.getId().toMvnId());
- tr.setVersion(feature.getId().getOSGiVersion());
-
- final Map<String, Object> attributes = new HashMap<>();
- attributes.put(ATTR_MODEL, featureJson);
- attributes.put(ATTR_ID, feature.getId().toMvnId());
-
- tr.setAttributes(attributes);
-
- result.add(tr);
- } else {
- error = true;
- break;
- }
- }
- if (!error) {
- return result.toArray(new TransformationResult[result.size()]);
- }
- }
- return null;
- }
-
- @Override
- public InstallTask createTask(final TaskResourceGroup group) {
- final TaskResource rsrc = group.getActiveResource();
- if (!TYPE_FEATURE_MODEL.equals(rsrc.getType())) {
- return null;
- }
- if (rsrc.getState() == ResourceState.UNINSTALL ) {
- return new UninstallFeatureModelTask(group, bundleContext);
- }
- final InstallContext ctx = new InstallContext(this.artifactManager, this.storageDirectory);
- return new InstallFeatureModelTask(group,
- ctx, this.bundleContext);
- }
-
- boolean classifierMatches(String classifier) {
- boolean select = this.classifierPatterns.isEmpty();
- if (!select) {
- if (classifier == null) {
- classifier = "";
- }
- for (final Pattern pattern : this.classifierPatterns) {
- select = pattern.matcher(classifier).matches();
-
- if (select) {
- break;
- }
- }
- }
- return select;
- }
-
- private static String toRegexPattern(String pattern) {
- StringBuilder stringBuilder = new StringBuilder("^");
- int index = 0;
- while (index < pattern.length()) {
- char currentChar = pattern.charAt(index++);
- switch (currentChar) {
- case '*':
- stringBuilder.append("[^/]*");
- break;
- default:
- if (isRegexMeta(currentChar)) {
- stringBuilder.append(Pattern.quote(Character.toString(currentChar)));
- } else {
- stringBuilder.append(currentChar);
- }
- }
- }
- return stringBuilder.append('$').toString();
- }
-
- private static boolean isRegexMeta(char character) {
- return "<([{\\^-=$!|]})?*+.>".indexOf(character) != -1;
- }
-}
diff --git a/org.apache.sling.installer.factory.feature/src/main/java/org/apache/sling/installer/factory/model/impl/InstallContext.java b/org.apache.sling.installer.factory.feature/src/main/java/org/apache/sling/installer/factory/model/impl/InstallContext.java
deleted file mode 100644
index 8408f91..0000000
--- a/org.apache.sling.installer.factory.feature/src/main/java/org/apache/sling/installer/factory/model/impl/InstallContext.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.factory.model.impl;
-
-import java.io.File;
-
-import org.apache.sling.feature.io.artifacts.ArtifactManager;
-
-public class InstallContext {
-
- public final ArtifactManager artifactManager;
-
- public final File storageDirectory;
-
- public InstallContext(final ArtifactManager artifactManager, final File storageDirectory) {
- this.artifactManager = artifactManager;
- this.storageDirectory = storageDirectory;
- }
-}
diff --git a/org.apache.sling.installer.factory.feature/src/main/java/org/apache/sling/installer/factory/model/impl/InstallFeatureModelTask.java b/org.apache.sling.installer.factory.feature/src/main/java/org/apache/sling/installer/factory/model/impl/InstallFeatureModelTask.java
deleted file mode 100644
index f60c0cb..0000000
--- a/org.apache.sling.installer.factory.feature/src/main/java/org/apache/sling/installer/factory/model/impl/InstallFeatureModelTask.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * 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.factory.model.impl;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.io.StringReader;
-import java.net.MalformedURLException;
-import java.net.URLConnection;
-import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.Hashtable;
-import java.util.List;
-
-import org.apache.sling.feature.Artifact;
-import org.apache.sling.feature.ArtifactId;
-import org.apache.sling.feature.Configuration;
-import org.apache.sling.feature.Extension;
-import org.apache.sling.feature.ExtensionType;
-import org.apache.sling.feature.Feature;
-import org.apache.sling.feature.extension.apiregions.api.ApiRegions;
-import org.apache.sling.feature.extension.apiregions.launcher.LauncherProperties;
-import org.apache.sling.feature.io.archive.ArchiveReader;
-import org.apache.sling.feature.io.artifacts.ArtifactHandler;
-import org.apache.sling.feature.io.json.FeatureJSONReader;
-import org.apache.sling.installer.api.InstallableResource;
-import org.apache.sling.installer.api.OsgiInstaller;
-import org.apache.sling.installer.api.tasks.InstallationContext;
-import org.apache.sling.installer.api.tasks.ResourceState;
-import org.apache.sling.installer.api.tasks.TaskResource;
-import org.apache.sling.installer.api.tasks.TaskResourceGroup;
-import org.osgi.framework.BundleContext;
-
-/**
- * This task installs a feature model resources.
- */
-public class InstallFeatureModelTask extends AbstractFeatureModelTask {
-
- private static final String PROP_idbsnver = "mapping.bundleid.bsnver";
- private static final String PROP_bundleFeatures = "mapping.bundleid.features";
- private static final String PROP_featureRegions = "mapping.featureid.regions";
- private static final String PROP_regionPackage = "mapping.region.packages";
-
- private static final String REGION_FACTORY_PID = "org.apache.sling.feature.apiregions.factory~";
- private static final String REPOINIT_FACTORY_PID = "org.apache.sling.jcr.repoinit.RepositoryInitializer~";
-
- private final InstallContext installContext;
-
- public InstallFeatureModelTask(final TaskResourceGroup group,
- final InstallContext installContext, final BundleContext bundleContext) {
- super(group, bundleContext);
- this.installContext = installContext;
- }
-
- @Override
- public void execute(final InstallationContext ctx) {
- try {
- final TaskResource resource = this.getResource();
- ctx.log("Installing {}", resource.getEntityId());
- final String featureJson = (String) resource.getAttribute(FeatureModelInstallerPlugin.ATTR_MODEL);
- if (featureJson == null) {
- ctx.log("Unable to install feature model resource {} : no model found", resource);
- this.getResourceGroup().setFinishState(ResourceState.IGNORED);
- } else {
- boolean success = false;
- final List<InstallableResource> result = this.transform(featureJson, resource);
- if (result == null) {
- ctx.log("Unable to install feature model resource {} : unable to create resources", resource);
- this.getResourceGroup().setFinishState(ResourceState.IGNORED);
- } else {
- if (!result.isEmpty()) {
- final OsgiInstaller installer = this.getService(OsgiInstaller.class);
- if (installer != null) {
- installer.registerResources(
- getScheme(resource),
- result.toArray(new InstallableResource[result.size()]));
- } else {
- ctx.log("Unable to install feature model resource {} : unable to get OSGi installer",
- resource);
- this.getResourceGroup().setFinishState(ResourceState.IGNORED);
- return;
- }
- }
- this.getResourceGroup().setFinishState(ResourceState.INSTALLED);
- success = true;
- }
- if ( success ) {
- ctx.log("Installed {}", resource.getEntityId());
- }
- }
- } finally {
- this.cleanup();
- }
- }
-
- private File getArtifactFile(final File baseDir, final ArtifactId id) {
- return new File(baseDir, id.toMvnId().replace('/', File.separatorChar));
- }
-
- private List<InstallableResource> transform(final String featureJson,
- final TaskResource rsrc) {
- Feature feature = null;
- try (final Reader reader = new StringReader(featureJson)) {
- feature = FeatureJSONReader.read(reader, null);
- } catch ( final IOException ioe) {
- logger.warn("Unable to read feature model file", ioe);
- }
- if (feature == null) {
- return null;
- }
-
- final List<InstallableResource> result = new ArrayList<>();
- // configurations
- for (final Configuration cfg : feature.getConfigurations()) {
- result.add(new InstallableResource("/".concat(cfg.getPid()).concat(".config"), null,
- cfg.getConfigurationProperties(), null, InstallableResource.TYPE_CONFIG, null));
- }
-
- // repoinit
- final Extension repoInit = feature.getExtensions().getByName(Extension.EXTENSION_NAME_REPOINIT);
- if (repoInit != null && repoInit.getType() == ExtensionType.TEXT) {
- final String configPid = REPOINIT_FACTORY_PID.concat(feature.getId().toMvnName().replace('-', '_'));
- final Dictionary<String, Object> props = new Hashtable<>();
- props.put("scripts", repoInit.getText());
-
- result.add(new InstallableResource("/".concat(configPid).concat(".config"), null,
- props, null, InstallableResource.TYPE_CONFIG, null));
- }
-
- // extract artifacts
- if (this.installContext.storageDirectory != null) {
- final byte[] buffer = new byte[1024*1024*256];
-
- try ( final InputStream is = rsrc.getInputStream() ) {
- ArchiveReader.read(is, new ArchiveReader.ArtifactConsumer() {
-
- @Override
- public void consume(final ArtifactId id, final InputStream is) throws IOException {
- final File artifactFile = getArtifactFile(installContext.storageDirectory, id);
- if (!artifactFile.exists()) {
- artifactFile.getParentFile().mkdirs();
- try (final OutputStream os = new FileOutputStream(artifactFile)) {
- int l = 0;
- while ((l = is.read(buffer)) > 0) {
- os.write(buffer, 0, l);
- }
- }
- }
- }
- });
- } catch ( final IOException ioe) {
- logger.warn("Unable to extract artifacts from feature model " + feature.getId().toMvnId(), ioe);
- return null;
- }
- }
-
- // api regions
- final Extension regionExt = feature.getExtensions().getByName(ApiRegions.EXTENSION_NAME);
- if ( regionExt != null ) {
- try {
- final ApiRegions regions = ApiRegions.parse(regionExt.getJSONStructure().asJsonArray());
-
- final String configPid = REGION_FACTORY_PID.concat(feature.getId().toMvnName().replace('-', '_'));
- final Dictionary<String, Object> props = new Hashtable<>();
- props.put(PROP_idbsnver, LauncherProperties.getBundleIDtoBSNandVersionMap(feature, this.installContext.artifactManager));
- props.put(PROP_bundleFeatures, LauncherProperties.getBundleIDtoFeaturesMap(feature));
- props.put(PROP_featureRegions, LauncherProperties.getFeatureIDtoRegionsMap(regions));
- props.put(PROP_regionPackage, LauncherProperties.getRegionNametoPackagesMap(regions));
-
- result.add(new InstallableResource("/".concat(configPid).concat(".config"), null,
- props, null, InstallableResource.TYPE_CONFIG, null));
- } catch (final IOException ioe) {
- logger.warn("Unable to parse region information " + feature.getId().toMvnId(), ioe);
- return null;
- }
- }
-
- // bundles
- for (final Artifact bundle : feature.getBundles()) {
- if (!addArtifact(bundle, result)) {
- return null;
- }
- }
-
- // content packages
- final Extension ext = feature.getExtensions().getByName(Extension.EXTENSION_NAME_CONTENT_PACKAGES);
- if (ext != null && ext.getType() == ExtensionType.ARTIFACTS) {
- for (final Artifact artifact : ext.getArtifacts()) {
- addArtifact(artifact, result);
- }
- }
-
- return result;
- }
-
- private boolean addArtifact(final Artifact artifact,
- final List<InstallableResource> result) {
- File artifactFile = (this.installContext.storageDirectory == null ? null
- : getArtifactFile(this.installContext.storageDirectory, artifact.getId()));
- ArtifactHandler handler;
- if (artifactFile == null || !artifactFile.exists()) {
- try {
- handler = this.installContext.artifactManager.getArtifactHandler(artifact.getId().toMvnUrl());
- } catch (final IOException ignore) {
- return false;
- }
- } else {
- try {
- handler = new ArtifactHandler(artifactFile);
- } catch (final MalformedURLException e) {
- return false;
- }
- }
- if (handler == null) {
- return false;
- }
- try {
- final URLConnection connection = handler.getLocalURL().openConnection();
- connection.connect();
- final InputStream is = connection.getInputStream();
- final long lastModified = connection.getLastModified();
- final String digest = lastModified == 0 ? null : String.valueOf(lastModified);
- // handle start order
- final Dictionary<String, Object> dict = new Hashtable<String, Object>();
- if (artifact.getStartOrder() > 0) {
- dict.put(InstallableResource.BUNDLE_START_LEVEL, artifact.getStartOrder());
- }
- dict.put(InstallableResource.RESOURCE_URI_HINT, handler.getLocalURL().toString());
-
- result.add(new InstallableResource("/".concat(artifact.getId().toMvnName()), is, dict, digest,
- InstallableResource.TYPE_FILE, null));
- } catch (final IOException ioe) {
- logger.warn("Unable to read artifact " + handler.getLocalURL(), ioe);
- return false;
- }
- return true;
- }
-
- @Override
- public String getSortKey() {
- return "30-" + getResource().getAttribute(FeatureModelInstallerPlugin.ATTR_ID);
- }
-}
diff --git a/org.apache.sling.installer.factory.feature/src/main/java/org/apache/sling/installer/factory/model/impl/UninstallFeatureModelTask.java b/org.apache.sling.installer.factory.feature/src/main/java/org/apache/sling/installer/factory/model/impl/UninstallFeatureModelTask.java
deleted file mode 100644
index 4370438..0000000
--- a/org.apache.sling.installer.factory.feature/src/main/java/org/apache/sling/installer/factory/model/impl/UninstallFeatureModelTask.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.factory.model.impl;
-
-import org.apache.sling.installer.api.OsgiInstaller;
-import org.apache.sling.installer.api.tasks.InstallationContext;
-import org.apache.sling.installer.api.tasks.ResourceState;
-import org.apache.sling.installer.api.tasks.TaskResource;
-import org.apache.sling.installer.api.tasks.TaskResourceGroup;
-import org.osgi.framework.BundleContext;
-
-/**
- * This task uninstalls feature model resources.
- */
-public class UninstallFeatureModelTask extends AbstractFeatureModelTask {
-
- public UninstallFeatureModelTask(final TaskResourceGroup group,
- final BundleContext bundleContext) {
- super(group, bundleContext);
- }
-
- @Override
- public void execute(final InstallationContext ctx) {
- try {
- final OsgiInstaller installer = this.getService(OsgiInstaller.class);
- if ( installer == null ) {
- ctx.log("Unable to get OSGi Installer service!");
- } else {
- final TaskResource resource = this.getResource();
- ctx.log("Uninstalling {}", resource.getEntityId());
- installer.registerResources(getScheme(resource), null);
- this.getResourceGroup().setFinishState(ResourceState.UNINSTALLED);
- ctx.log("Uninstalled {}", resource.getEntityId());
- }
- } finally {
- this.cleanup();
- }
- }
-
- @Override
- public String getSortKey() {
- return "31-" + getResource().getAttribute(FeatureModelInstallerPlugin.ATTR_ID);
- }
-}
diff --git a/org.apache.sling.installer.factory.feature/src/test/java/org/apache/sling/installer/factory/model/impl/FeatureModelInstallerPluginTest.java b/org.apache.sling.installer.factory.feature/src/test/java/org/apache/sling/installer/factory/model/impl/FeatureModelInstallerPluginTest.java
deleted file mode 100644
index e640a5a..0000000
--- a/org.apache.sling.installer.factory.feature/src/test/java/org/apache/sling/installer/factory/model/impl/FeatureModelInstallerPluginTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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.factory.model.impl;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.osgi.framework.BundleContext;
-
-public class FeatureModelInstallerPluginTest {
-
- @Test
- public void testNoPatterns() throws Exception {
- final FeatureModelInstallerPlugin.Config config = Mockito.mock(FeatureModelInstallerPlugin.Config.class);
- Mockito.when(config.classifierPatterns()).thenReturn(null);
-
- final FeatureModelInstallerPlugin plugin = new FeatureModelInstallerPlugin(Mockito.mock(BundleContext.class),
- config);
- assertTrue(plugin.classifierMatches("foo"));
- assertTrue(plugin.classifierMatches(null));
- }
-
- @Test
- public void testNoClassifierPattern() throws Exception {
- final FeatureModelInstallerPlugin.Config config = Mockito.mock(FeatureModelInstallerPlugin.Config.class);
- Mockito.when(config.classifierPatterns()).thenReturn(new String[] { ":" });
-
- final FeatureModelInstallerPlugin plugin = new FeatureModelInstallerPlugin(Mockito.mock(BundleContext.class),
- config);
- assertFalse(plugin.classifierMatches("foo"));
- assertTrue(plugin.classifierMatches(null));
- }
-
- @Test
- public void testClassifierPatterns() throws Exception {
- final FeatureModelInstallerPlugin.Config config = Mockito.mock(FeatureModelInstallerPlugin.Config.class);
- Mockito.when(config.classifierPatterns()).thenReturn(new String[] { ":", "*devfar", "*prodfar", "*special*" });
-
- final FeatureModelInstallerPlugin plugin = new FeatureModelInstallerPlugin(Mockito.mock(BundleContext.class),
- config);
-
- assertTrue(plugin.classifierMatches(null));
- assertTrue(plugin.classifierMatches("mydevfar"));
- assertTrue(plugin.classifierMatches("myprodfar"));
- assertTrue(plugin.classifierMatches("superspecialfar"));
- assertTrue(plugin.classifierMatches("evenmorespecial"));
-
- assertFalse(plugin.classifierMatches("foo"));
- assertFalse(plugin.classifierMatches("devmyfar"));
- assertFalse(plugin.classifierMatches("prodmfar"));
- }
-}