diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
new file mode 100644
index 0000000..d1ba2bc
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,32 @@
+---
+name: Bug report
+about: Create a report to help us improve
+title: ''
+labels: bug
+assignees: ''
+
+---
+
+**Describe the bug**
+A clear and concise description of what the bug is.
+
+**To Reproduce**
+Steps to reproduce the behavior:
+1. Go to '...'
+2. Click on '....'
+3. Scroll down to '....'
+4. See error
+
+**Expected behavior**
+A clear and concise description of what you expected to happen.
+
+**Screenshots**
+If applicable, add screenshots to help explain your problem.
+
+**Desktop (please complete the following information):**
+ - OS: [e.g. iOS]
+ - Browser [e.g. chrome, safari]
+ - Version [e.g. 22]
+
+**Additional context**
+Add any other context about the problem here.
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
new file mode 100644
index 0000000..11fc491
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -0,0 +1,20 @@
+---
+name: Feature request
+about: Suggest an idea for this project
+title: ''
+labels: enhancement
+assignees: ''
+
+---
+
+**Is your feature request related to a problem? Please describe.**
+A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
+
+**Describe the solution you'd like**
+A clear and concise description of what you want to happen.
+
+**Describe alternatives you've considered**
+A clear and concise description of any alternative solutions or features you've considered.
+
+**Additional context**
+Add any other context or screenshots about the feature request here.
diff --git a/.github/workflows/ci-release.yaml b/.github/workflows/ci-release.yaml
new file mode 100644
index 0000000..1b656ca
--- /dev/null
+++ b/.github/workflows/ci-release.yaml
@@ -0,0 +1,63 @@
+# Copyright (C) 2024 Dynamic Solutions
+#
+# 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.
+
+name: "Release: Release and publish artifacts to GCP Artifacts Registry"
+
+on:
+ workflow_dispatch:
+
+permissions:
+ id-token: write
+ contents: read
+
+jobs:
+ release:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - id: 'auth'
+ name: 'Authenticate to Google Cloud'
+ uses: 'google-github-actions/auth@v2'
+ with:
+ workload_identity_provider: ${{ secrets.GCP_WEBSIGHT_RELEASES_WORKLOAD_IDENTITY_PROVIDER }}
+ service_account: ${{ secrets.GCP_WEBSIGHT_RELEASES_RELEASE_DEPLOY_SA }}
+
+ - name: Configure Git
+ run: |
+ git remote set-url origin git@github.com:${{ github.repository }}.git
+ git config --global user.email "github.actions@ds.pl"
+ git config --global user.name "GitHub Actions"
+ mkdir -p ~/.ssh
+ printf '%s\n' "${{ secrets.GIT_SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
+ chmod 0600 ~/.ssh/id_rsa
+
+ - name: Set up JDK 8
+ uses: actions/setup-java@v3
+ with:
+ java-version: '8'
+ distribution: 'adopt'
+
+ - name: Cache local Maven repository
+ uses: actions/cache@v3
+ with:
+ path: ~/.m2/repository
+ key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
+ restore-keys: |
+ ${{ runner.os }}-maven-
+
+ - name: Release to GCP Artifacts Registry
+ run: mvn -B release:prepare release:perform
diff --git a/.github/workflows/ci-verify.yaml b/.github/workflows/ci-verify.yaml
new file mode 100644
index 0000000..97879f7
--- /dev/null
+++ b/.github/workflows/ci-verify.yaml
@@ -0,0 +1,58 @@
+# Copyright (C) 2024 Dynamic Solutions
+#
+# 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.
+
+name: "Test: Verify module"
+
+on:
+ workflow_dispatch:
+ pull_request:
+ push:
+ branches:
+ - main
+
+permissions:
+ id-token: write
+ contents: read
+
+jobs:
+ verify:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - id: 'auth'
+ name: 'Authenticate to Google Cloud'
+ uses: 'google-github-actions/auth@v2'
+ with:
+ workload_identity_provider: ${{ secrets.GCP_WEBSIGHT_RELEASES_WORKLOAD_IDENTITY_PROVIDER }}
+ service_account: ${{ secrets.GCP_WEBSIGHT_RELEASES_RELEASE_DEPLOY_SA }}
+
+ - name: Set up JDK 8
+ uses: actions/setup-java@v3
+ with:
+ java-version: '8'
+ distribution: 'adopt'
+
+ - name: Cache local Maven repository
+ uses: actions/cache@v3
+ with:
+ path: ~/.m2/repository
+ key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
+ restore-keys: |
+ ${{ runner.os }}-maven-
+
+ - name: Verify
+ run: mvn -B verify
diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml
new file mode 100644
index 0000000..47a8633
--- /dev/null
+++ b/.github/workflows/cla.yml
@@ -0,0 +1,44 @@
+# Copyright (C) 2024 Dynamic Solutions
+#
+# 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.
+
+name: "CLA Assistant"
+on:
+ issue_comment:
+ types: [created]
+ pull_request_target:
+ types: [opened,closed,synchronize]
+
+jobs:
+ cla-assistant:
+ runs-on: ubuntu-latest
+ # diabled WS-3235
+ if: false
+ steps:
+ - name: "CLA Assistant"
+ if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
+ uses: contributor-assistant/github-action@v2.2.0
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ PERSONAL_ACCESS_TOKEN : ${{ secrets.PERSONAL_ACCESS_TOKEN }}
+ with:
+ path-to-signatures: '.github/signatures/v1/cla.json'
+ branch: 'main'
+ allowlist: user1,bot*
+
+ create-file-commit-message: 'Creating file for storing individual CLA Signatures'
+ signed-commit-message: '$contributorName has signed the individual CLA in #$pullRequestNo'
+ custom-notsigned-prcomment: 'You must sign a [Contributor License Agreement](https://github.com/websight-io/websight-bundle-resource-provider/blob/main/CONTRIBUTING.md#contributor-license-agreement-cla) (CLA) to accept your pull request. You only need to do this once. If you submit a pull request for the first time, our CLA bot will automatically ask you to sign before merging the pull request.'
+ custom-pr-sign-comment: 'I have read the Dynamic Solutions Individual Contributor License Agreement (CLA) Document and I hereby sign the CLA'
+ custom-allsigned-prcomment: '**CLA bot** All Contributors have signed the [Dynamic Solutions Individual Contributor License Agreement](https://www.websight.io/product/cla/individual/v1/)'
+ lock-pullrequest-aftermerge: true
diff --git a/.mvn/extensions.xml b/.mvn/extensions.xml
new file mode 100644
index 0000000..67a5aea
--- /dev/null
+++ b/.mvn/extensions.xml
@@ -0,0 +1,8 @@
+
+
+ com.google.cloud.artifactregistry
+ artifactregistry-maven-wagon
+ 2.2.1
+
+
\ No newline at end of file
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
deleted file mode 100644
index 0fa18e5..0000000
--- a/CODE_OF_CONDUCT.md
+++ /dev/null
@@ -1,22 +0,0 @@
-
-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/CONTRIBUTING.md b/CONTRIBUTING.md
index 880019b..d7df3e1 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,30 +1,25 @@
-
-Contributing
-====
-
-Thanks for choosing to contribute!
-
-Here's some great places to get started:
-
- - [Backlog](https://issues.apache.org/jira/issues/?jql=project%20%3D%20SLING%20AND%20status%20%3D%20Open%20AND%20component%20in%20(%22App%20CMS%22%2C%20%22App%20CMS%20Reference%22))
- - [Good Starting Issues](https://issues.apache.org/jira/browse/SLING-8910?jql=project%20%3D%20SLING%20AND%20status%20%3D%20Open%20AND%20component%20in%20(%22App%20CMS%22%2C%20%22App%20CMS%20Reference%22)%20AND%20labels%20%3D%20newbie)
-
-
-You will find all the necessary details about how you can do this at https://sling.apache.org/contributing.html.
+# How to contribute
+We highly appreciate your effort to contribute, but we recommend you [discuss](https://github.com/websight-io/starter/discussions) to a maintainer before spending a lot of time making a pull request that may not align with the project roadmap.
+
+## Feature Requests
+Feature Requests by the community are highly encouraged. Feel free to [submit a new one](https://github.com/websight-io/websight-bundle-resource-provider/issues/new?assignees=&labels=&template=feature_request.md&title=).
+
+## Bugs
+We use [GitHub issues](https://github.com/websight-io/websight-jcr-maintenance/issues) to manage bugs. We keep a close eye on them. Before filing a new issue, try to ensure your problem does not already exist.
+
+## Code of Conduct
+This project, and everyone participating in it, are governed by the [WebSight Code of Conduct](https://github.com/websight-io/starter/blob/main/CODE_OF_CONDUCT.md). By participating, you are expected to uphold it. Make sure to read the [full text](https://github.com/websight-io/starter/blob/main/CODE_OF_CONDUCT.md) to understand which type of actions may or may not be tolerated.
+
+## Contributor License Agreement (CLA)
+
+### Individual contribution
+
+You need to sign a [Dynamic Solutions Individual Contributor License Agreement](https://www.websight.io/product/cla/individual/v1/) (CLA) to accept your pull request. You only need to do this once. If you submit a pull request for the first time, we will ask you to sign our CLA before merging the pull request.
+
+### Company contribution
+
+If you make contributions to our repositories on behalf of your company, we will need a [Dynamic Solutions Corporate Contributor License Agreement](https://www.websight.io/product/cla/corporate/v1/) signed. To do that, please get in touch with us at [websight@ds.pl](mailto:websight@ds.pl).
+
+## Documentation
+
+Pull requests related to fixing documentation for the latest release should be directed towards the [documentation repository](https://github.com/websight-io/docs).
diff --git a/Jenkinsfile b/Jenkinsfile
deleted file mode 100644
index f582519..0000000
--- a/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/LICENSE b/LICENSE
new file mode 100644
index 0000000..261eeb9
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,201 @@
+ 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/NOTICE b/NOTICE
deleted file mode 100644
index 5de96ff..0000000
--- a/NOTICE
+++ /dev/null
@@ -1,5 +0,0 @@
-Apache Sling JCR Maintenance
-Copyright 2021 The Apache Software Foundation
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
diff --git a/README.md b/README.md
index 6615962..6f133cb 100644
--- a/README.md
+++ b/README.md
@@ -1,30 +1,22 @@
-[![Apache Sling](https://sling.apache.org/res/logos/sling.png)](https://sling.apache.org)
+# WebSight JCR Maintenance
- [![Build Status](https://ci-builds.apache.org/job/Sling/job/modules/job/sling-org-apache-sling-jcr-maintenance/job/master/badge/icon)](https://ci-builds.apache.org/job/Sling/job/modules/job/sling-org-apache-sling-jcr-maintenance/job/master/) [![Test Status](https://img.shields.io/jenkins/tests.svg?jobUrl=https://ci-builds.apache.org/job/Sling/job/modules/job/sling-org-apache-sling-jcr-maintenance/job/master/)](https://ci-builds.apache.org/job/Sling/job/modules/job/sling-org-apache-sling-jcr-maintenance/job/master/test/?width=800&height=600) [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=apache_sling-org-apache-sling-jcr-maintenance&metric=coverage)](https://sonarcloud.io/dashboard?id=apache_sling-org-apache-sling-jcr-maintenance) [![Sonarcloud Status](https://sonarcloud.io/api/project_badges/measure?project=apache_sling-org-apache-sling-jcr-maintenance&metric=alert_status)](https://sonarcloud.io/dashboard?id=apache_sling-org-apache-sling-jcr-maintenance) [![JavaDoc](https://www.javadoc.io/badge/org.apache.sling/org.apache.sling.jcr.maintenance.svg)](https://www.javadoc.io/doc/org.apache.sling/org-apache-sling-jcr-maintenance) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.apache.sling/org.apache.sling.jcr.maintenance/badge.svg)](https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.apache.sling%22%20a%3A%22org.apache.sling.jcr.maintenance%22) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
+## Introduction
+This project provides reference implementation of Maintenance jobs for maintaining a Apache
+Jackrabbit OAK repository in Apache Sling.
-# Apache Sling JCR Maintenance
-
-This project provides reference implementation of Maintenance jobs for maintaining a Apache Jackrabbit OAK repository in Apache Sling.
-
-This includes the following Maintenance jobs:
-
-- [DataStoreCleanupScheduler](src/main/java/org/apache/sling/maintenance/internal/DataStoreCleanupScheduler.java) - Run the [RepositoryManagementMBean.startDataStoreGC(true)](https://jackrabbit.apache.org/oak/docs/apidocs/org/apache/jackrabbit/oak/api/jmx/RepositoryManagementMBean.html#startDataStoreGC-boolean-) method to perform a Garbage Collection of the Data Store
-- [RevisionCleanupScheduler](src/main/java/org/apache/sling/maintenance/internal/RevisionCleanupScheduler.java) - Run the [RepositoryManagementMBean.startRevisionGC()](https://jackrabbit.apache.org/oak/docs/apidocs/org/apache/jackrabbit/oak/api/jmx/RepositoryManagementMBean.html#startRevisionGC--) method to perform a Garbage Collection of the Revision Store
-- [VersionCleanup](src/main/java/org/apache/sling/maintenance/internal/VersionCleanup.java) - Job to traverse the JCR Version Store
- and remove versions (oldest-first) exceeding a configurable limit
-
-As well as a [Health Check](src/main/java/org/apache/sling/maintenance/internal/RepositoryMaintenanceHealthCheck.java) to ensure the jobs are scheduled and have not failed.
+It was originally a fork
+of [Apache Sling JCR Maintenance](https://github.com/apache/sling-org-apache-sling-jcr-maintenance).
## Configuration
-To see a reference implementation, see the [Configuration Feature](src/main/features/configuration.json).
-
-## Features
+The reference configuration is available
+in the [Configuration Feature](https://github.com/websight-io/websight-jcr-maintenance/blob/master/src/main/features/configuration.json).
-There are two primary features made by this project include:
+## Changes
-- **Base** - org.apache.sling:org.apache.sling.jcr.maintenance:slingosgifeature:base:${project.version} - only the bundle and service user
-- **Default** - org.apache.sling:org.apache.sling.jcr.maintenance:slingosgifeature:default:${project.version} - the bundle, service user and default configuration which keeps 5 versions and runs the jobs every night
+Changes done on the original implementation are:
-This module is part of the [Apache Sling](https://sling.apache.org) project.
+- Giving a possibility to disable each job. This change prevents unnecessary health check warnings
+ when a job is not required, ensuring that only the relevant jobs are activated in a given
+ application setup.
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 36b8daf..23db379 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,26 +22,62 @@
org.apache.sling
sling-bundle-parent
- 41
+ 46
- org.apache.sling.jcr.maintenance
+
+ io.websight
+ io.websight.sling.jcr.maintenance
1.0.3-SNAPSHOT
- Apache Sling JCR Maintenance
- Maintenance jobs for the JCR
+ WebSight fork of Apache Sling JCR Maintenance
+ Maintenance jobs for the JCR. Forked from 1.0.3-SNAPSHOT
2021-04-15T18:14:05Z
+ 1.8
+ 1.8
+ 5.3.0
+
+
+ Apache License Version 2.0
+ http://www.apache.org/licenses/LICENSE-2.0.txt
+
+
- scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-maintenance.git
- scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-maintenance.git
- https://gitbox.apache.org/repos/asf?p=sling-org-apache-sling-jcr-maintenance.git
+ scm:git:git://github.com/websight-io/websight-jcr-maintenance.git
+ scm:git:git@github.com:websight-io/websight-jcr-maintenance.git
+ https://github.com/websight-io/websight-jcr-maintenance
HEAD
+
+
+ artifact-registry
+ artifactregistry://europe-west1-maven.pkg.dev/websight-io/websight-maven-releases
+
+
+
+
+ Dynamic Solutions sp. z o.o. sp. k.
+ https://websight.io
+
+
+
+
+ artifact-registry
+ artifactregistry://europe-west1-maven.pkg.dev/websight-io/websight-maven-releases
+
+ true
+
+
+ false
+
+
+
+
@@ -92,10 +128,33 @@
+
+ org.apache.maven.plugins
+ maven-release-plugin
+ 3.0.0-M1
+
+ [skip ci] [maven]
+ v@{project.version}
+
+
+
+ biz.aQute.bnd
+ bnd-baseline-maven-plugin
+
+ false
+
+
+
+ org.apache.sling
+ org.apache.sling.testing.sling-mock-oak
+ 3.1.10-1.44.0
+ test
+
+
org.slf4j
slf4j-api
@@ -188,12 +247,6 @@
2.6.2
test
-
- org.apache.sling
- org.apache.sling.testing.sling-mock-oak
- 2.1.10-1.16.0
- test
-
org.mockito
mockito-core
diff --git a/src/main/java/org/apache/sling/jcr/maintenance/DataStoreCleanupConfig.java b/src/main/java/org/apache/sling/jcr/maintenance/DataStoreCleanupConfig.java
index 3374465..468dd8b 100644
--- a/src/main/java/org/apache/sling/jcr/maintenance/DataStoreCleanupConfig.java
+++ b/src/main/java/org/apache/sling/jcr/maintenance/DataStoreCleanupConfig.java
@@ -28,4 +28,7 @@
@AttributeDefinition(name = "%scheduler.expression.name", description = "%scheduler.expression.description")
String scheduler_expression();
+ @AttributeDefinition(name = "%cleanup.enable.name", description = "%cleanup.enable.description")
+ boolean enabled() default true;
+
}
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/jcr/maintenance/RevisionCleanupConfig.java b/src/main/java/org/apache/sling/jcr/maintenance/RevisionCleanupConfig.java
index 4fe54fe..29b937f 100644
--- a/src/main/java/org/apache/sling/jcr/maintenance/RevisionCleanupConfig.java
+++ b/src/main/java/org/apache/sling/jcr/maintenance/RevisionCleanupConfig.java
@@ -28,4 +28,7 @@
@AttributeDefinition(name = "%scheduler.expression.name", description = "%scheduler.expression.description")
String scheduler_expression();
+ @AttributeDefinition(name = "%cleanup.enable.name", description = "%cleanup.enable.description")
+ boolean enabled() default true;
+
}
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/jcr/maintenance/RunnableJob.java b/src/main/java/org/apache/sling/jcr/maintenance/RunnableJob.java
index 137ad6e..92d6e94 100644
--- a/src/main/java/org/apache/sling/jcr/maintenance/RunnableJob.java
+++ b/src/main/java/org/apache/sling/jcr/maintenance/RunnableJob.java
@@ -21,4 +21,5 @@
*/
public interface RunnableJob extends Runnable {
String getSchedulerExpression();
+ boolean isEnabled();
}
diff --git a/src/main/java/org/apache/sling/jcr/maintenance/VersionCleanupConfig.java b/src/main/java/org/apache/sling/jcr/maintenance/VersionCleanupConfig.java
index 4a0c9ae..83f2719 100644
--- a/src/main/java/org/apache/sling/jcr/maintenance/VersionCleanupConfig.java
+++ b/src/main/java/org/apache/sling/jcr/maintenance/VersionCleanupConfig.java
@@ -25,4 +25,7 @@
@AttributeDefinition(name = "%scheduler.expression.name", description = "%scheduler.expression.description")
String scheduler_expression();
+ @AttributeDefinition(name = "%cleanup.enable.name", description = "%cleanup.enable.description")
+ boolean enabled() default true;
+
}
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/jcr/maintenance/internal/DataStoreCleanupScheduler.java b/src/main/java/org/apache/sling/jcr/maintenance/internal/DataStoreCleanupScheduler.java
index ba59feb..e75411b 100644
--- a/src/main/java/org/apache/sling/jcr/maintenance/internal/DataStoreCleanupScheduler.java
+++ b/src/main/java/org/apache/sling/jcr/maintenance/internal/DataStoreCleanupScheduler.java
@@ -42,14 +42,20 @@ public class DataStoreCleanupScheduler implements RunnableJob {
private final String schedulerExpression;
+ private final boolean enabled;
+
@Activate
public DataStoreCleanupScheduler(final DataStoreCleanupConfig config,
@Reference final RepositoryManagementMBean repositoryManager) {
this.repositoryManager = repositoryManager;
this.schedulerExpression = config.scheduler_expression();
+ this.enabled = config.enabled();
}
public void run() {
+ if (!enabled) {
+ return;
+ }
if (!RepositoryManagementUtil.isRunning(repositoryManager.getDataStoreGCStatus())) {
log.info("Starting DataStore Garbage Collection");
repositoryManager.startDataStoreGC(false);
@@ -65,4 +71,11 @@ public String getSchedulerExpression() {
return schedulerExpression;
}
+ /**
+ * @return the enabled
+ */
+ public boolean isEnabled() {
+ return enabled;
+ }
+
}
diff --git a/src/main/java/org/apache/sling/jcr/maintenance/internal/RepositoryMaintenanceHealthCheck.java b/src/main/java/org/apache/sling/jcr/maintenance/internal/RepositoryMaintenanceHealthCheck.java
index d6b1ad6..cc0181e 100644
--- a/src/main/java/org/apache/sling/jcr/maintenance/internal/RepositoryMaintenanceHealthCheck.java
+++ b/src/main/java/org/apache/sling/jcr/maintenance/internal/RepositoryMaintenanceHealthCheck.java
@@ -62,10 +62,13 @@ public void setVersionCleanup(VersionCleanupMBean versionCleanup) {
}
private void evaluateJobStatus(FormattingResultLog log, String jobName, RunnableJob job, CompositeData status) {
- if (job != null) {
- log.debug("{} Schedule: {}", jobName, job.getSchedulerExpression());
- } else {
+ if (job == null) {
log.warn("{} not registered", jobName);
+ } else if (!job.isEnabled()) {
+ log.debug("{} is disabled", jobName);
+ return;
+ } else {
+ log.debug("{} Schedule: {}", jobName, job.getSchedulerExpression());
}
if (RepositoryManagementUtil.isValid(status)) {
log.debug("{} Last Status: {}", jobName, RepositoryManagementUtil.getStatusCode(status).name());
@@ -87,7 +90,9 @@ public Result execute() {
repositoryManagementMBean.getRevisionGCStatus());
if (versionCleanup != null) {
- if (versionCleanup.isFailed()) {
+ if (!versionCleanup.isEnabled()) {
+ log.debug("VersionCleanup is disabled");
+ } else if (versionCleanup.isFailed()) {
log.critical("VersionCleanup Status: FAILED");
log.critical("VersionCleanup Message: {}", versionCleanup.getLastMessage());
} else {
diff --git a/src/main/java/org/apache/sling/jcr/maintenance/internal/RevisionCleanupScheduler.java b/src/main/java/org/apache/sling/jcr/maintenance/internal/RevisionCleanupScheduler.java
index 0a81d0e..25dc9f2 100644
--- a/src/main/java/org/apache/sling/jcr/maintenance/internal/RevisionCleanupScheduler.java
+++ b/src/main/java/org/apache/sling/jcr/maintenance/internal/RevisionCleanupScheduler.java
@@ -42,14 +42,20 @@ public class RevisionCleanupScheduler implements RunnableJob {
private final String schedulerExpression;
+ private final boolean enabled;
+
@Activate
public RevisionCleanupScheduler(final RevisionCleanupConfig config,
@Reference final RepositoryManagementMBean repositoryManager) {
this.repositoryManager = repositoryManager;
this.schedulerExpression = config.scheduler_expression();
+ this.enabled = config.enabled();
}
public void run() {
+ if (!enabled) {
+ return;
+ }
if (!RepositoryManagementUtil.isRunning(repositoryManager.getRevisionGCStatus())) {
log.info("Starting Revision Garbage Collection");
repositoryManager.startRevisionGC();
@@ -64,4 +70,11 @@ public void run() {
public String getSchedulerExpression() {
return schedulerExpression;
}
+
+ /**
+ * @return the enabled
+ */
+ public boolean isEnabled() {
+ return enabled;
+ }
}
diff --git a/src/main/java/org/apache/sling/jcr/maintenance/internal/VersionCleanup.java b/src/main/java/org/apache/sling/jcr/maintenance/internal/VersionCleanup.java
index ac04821..95b0af8 100644
--- a/src/main/java/org/apache/sling/jcr/maintenance/internal/VersionCleanup.java
+++ b/src/main/java/org/apache/sling/jcr/maintenance/internal/VersionCleanup.java
@@ -64,16 +64,17 @@ public class VersionCleanup extends AnnotatedStandardMBean implements Runnable,
private long lastCleanedVersions;
private String lastFailureMessage;
private final List versionCleanupConfigs;
+ private final boolean enabled;
@Activate
public VersionCleanup(
@Reference(cardinality = ReferenceCardinality.AT_LEAST_ONE, policyOption = ReferencePolicyOption.GREEDY) final List versionCleanupConfigs,
- @Reference final ResourceResolverFactory factory) {
+ @Reference final ResourceResolverFactory factory, final VersionCleanupConfig config) {
super(VersionCleanupMBean.class);
this.factory = factory;
this.versionCleanupConfigs = versionCleanupConfigs;
versionCleanupConfigs.sort((c1, c2) -> c1.getPath().compareTo(c2.getPath()) * -1);
-
+ this.enabled = config.enabled();
}
private String getPath(final Session session, final VersionHistory versionHistory) throws RepositoryException {
@@ -162,6 +163,9 @@ private boolean isVersionable(final Node node) throws RepositoryException {
@Override
public void run() {
+ if (!enabled) {
+ return;
+ }
if (isRunning()) {
log.warn("Version cleanup already running!");
} else {
@@ -197,6 +201,11 @@ private void doRun() {
}
}
+ @Override
+ public boolean isEnabled() {
+ return enabled;
+ }
+
@Override
public boolean isRunning() {
return cleanupThread != null && cleanupThread.isAlive();
diff --git a/src/main/java/org/apache/sling/jcr/maintenance/internal/VersionCleanupMBean.java b/src/main/java/org/apache/sling/jcr/maintenance/internal/VersionCleanupMBean.java
index 343bdf5..5bb98fc 100644
--- a/src/main/java/org/apache/sling/jcr/maintenance/internal/VersionCleanupMBean.java
+++ b/src/main/java/org/apache/sling/jcr/maintenance/internal/VersionCleanupMBean.java
@@ -26,6 +26,9 @@
@Description("Cleanup versions")
public interface VersionCleanupMBean {
+ @Description("Whether or not the service is enabled")
+ boolean isEnabled();
+
@Description("Whether or not the service is running")
boolean isRunning();
diff --git a/src/main/resources/OSGI-INF/l10n/bundle.properties b/src/main/resources/OSGI-INF/l10n/bundle.properties
index 3f8f0f3..c106953 100644
--- a/src/main/resources/OSGI-INF/l10n/bundle.properties
+++ b/src/main/resources/OSGI-INF/l10n/bundle.properties
@@ -26,6 +26,9 @@
scheduler.expression.name=Quartz Scheduler Expression
scheduler.expression.description=A quartz expression for configuring when \
a scheduler should be triggered
+cleanup.enable.name=Enable Cleanup Job
+cleanup.enable.description=The cleanup job is enabled by default. \
+Set this property to false to disable the job.
# DataStore Cleanup Entries
datastore.cleanup.name=Apache Sling JCR Maintenance Oak DataStore Garbage Collection
diff --git a/src/test/java/org/apache/sling/jcr/maintenance/internal/DataStoreCleanupSchedulerTest.java b/src/test/java/org/apache/sling/jcr/maintenance/internal/DataStoreCleanupSchedulerTest.java
index 014ae38..71b41f3 100644
--- a/src/test/java/org/apache/sling/jcr/maintenance/internal/DataStoreCleanupSchedulerTest.java
+++ b/src/test/java/org/apache/sling/jcr/maintenance/internal/DataStoreCleanupSchedulerTest.java
@@ -42,7 +42,9 @@ public void testRunnable() {
CompositeData doneCd = CompositeDataMock.init().put("id", id).put("code", StatusCode.SUCCEEDED.ordinal())
.build();
Mockito.when(repositoryManager.getDataStoreGCStatus()).thenReturn(doneCd);
- final DataStoreCleanupScheduler dscs = new DataStoreCleanupScheduler(Mockito.mock(DataStoreCleanupConfig.class),
+ DataStoreCleanupConfig config = Mockito.mock(DataStoreCleanupConfig.class);
+ Mockito.when(config.enabled()).thenReturn(true);
+ final DataStoreCleanupScheduler dscs = new DataStoreCleanupScheduler(config,
repositoryManager);
dscs.run();
@@ -66,6 +68,25 @@ public void testRunCheck() {
Mockito.verify(repositoryManager, never()).startDataStoreGC(Mockito.anyBoolean());
}
+ @Test
+ public void testNoRunWhenDisabled() {
+
+ Integer id = 1;
+ final RepositoryManagementMBean repositoryManager = Mockito.mock(RepositoryManagementMBean.class);
+ CompositeData startingCd = CompositeDataMock.init().put("id", id).build();
+ Mockito.when(repositoryManager.startDataStoreGC(false)).thenReturn(startingCd);
+ CompositeData doneCd = CompositeDataMock.init().put("id", id).put("code", StatusCode.SUCCEEDED.ordinal())
+ .build();
+ Mockito.when(repositoryManager.getDataStoreGCStatus()).thenReturn(doneCd);
+ DataStoreCleanupConfig config = Mockito.mock(DataStoreCleanupConfig.class);
+ Mockito.when(config.enabled()).thenReturn(false);
+ final DataStoreCleanupScheduler dscs = new DataStoreCleanupScheduler(config,
+ repositoryManager);
+ dscs.run();
+
+ Mockito.verify(repositoryManager, never()).startDataStoreGC(Mockito.anyBoolean());
+ }
+
@Test
public void testSheduledExpression() {
final String EXPECTED = "* * * * *";
@@ -82,6 +103,11 @@ public String scheduler_expression() {
return EXPECTED;
}
+ @Override
+ public boolean enabled() {
+ return true;
+ }
+
}, null);
assertEquals(EXPECTED, dscs.getSchedulerExpression());
diff --git a/src/test/java/org/apache/sling/jcr/maintenance/internal/RepositoryMaintenanceHealthCheckTest.java b/src/test/java/org/apache/sling/jcr/maintenance/internal/RepositoryMaintenanceHealthCheckTest.java
index 3315691..c7758de 100644
--- a/src/test/java/org/apache/sling/jcr/maintenance/internal/RepositoryMaintenanceHealthCheckTest.java
+++ b/src/test/java/org/apache/sling/jcr/maintenance/internal/RepositoryMaintenanceHealthCheckTest.java
@@ -21,7 +21,6 @@
import static org.junit.Assert.assertTrue;
import javax.management.openmbean.CompositeData;
-
import org.apache.felix.hc.api.Result;
import org.apache.jackrabbit.oak.api.jmx.RepositoryManagementMBean;
import org.apache.sling.jcr.maintenance.CompositeDataMock;
@@ -101,6 +100,7 @@ public void testDataStoreFailure() {
assertEquals(Result.Status.WARN, result.getStatus());
DataStoreCleanupScheduler dataStoreCleanupScheduler = Mockito.mock(DataStoreCleanupScheduler.class);
+ Mockito.when(dataStoreCleanupScheduler.isEnabled()).thenReturn(true);
repositoryHealthCheck.setDataStoreCleanupScheduler(dataStoreCleanupScheduler);
Mockito.when(repositoryManagementMBean.getDataStoreGCStatus()).thenReturn(failedCompositeData);
result = repositoryHealthCheck.execute();
@@ -131,6 +131,7 @@ public void testRevisionFailure() {
Mockito.when(repositoryManagementMBean.getRevisionGCStatus()).thenReturn(failedCompositeData);
RevisionCleanupScheduler revisionCleanupScheduler = Mockito.mock(RevisionCleanupScheduler.class);
+ Mockito.when(revisionCleanupScheduler.isEnabled()).thenReturn(true);
repositoryHealthCheck.setRevisionCleanupScheduler(revisionCleanupScheduler);
result = repositoryHealthCheck.execute();
assertFalse(result.isOk());
@@ -159,10 +160,97 @@ public void testVersionFailure() {
VersionCleanupMBean versionCleanupMBean = Mockito.mock(VersionCleanupMBean.class);
Mockito.when(versionCleanupMBean.isFailed()).thenReturn(true);
+ Mockito.when(versionCleanupMBean.isEnabled()).thenReturn(true);
repositoryHealthCheck.setVersionCleanup(versionCleanupMBean);
result = repositoryHealthCheck.execute();
assertFalse(result.isOk());
assertEquals(Result.Status.CRITICAL, result.getStatus());
}
+ @Test
+ public void testDataStoreDisabled() {
+ RepositoryMaintenanceHealthCheck repositoryHealthCheck = new RepositoryMaintenanceHealthCheck();
+
+ RepositoryManagementMBean repositoryManagementMBean = Mockito.mock(RepositoryManagementMBean.class);
+ Mockito.when(repositoryManagementMBean.getRevisionGCStatus()).thenReturn(successCompositeData);
+ Mockito.when(repositoryManagementMBean.getDataStoreGCStatus()).thenReturn(successCompositeData);
+
+ repositoryHealthCheck.setRepositoryManagementMBean(repositoryManagementMBean);
+
+ RevisionCleanupScheduler revisionCleanupScheduler = Mockito.mock(RevisionCleanupScheduler.class);
+ repositoryHealthCheck.setRevisionCleanupScheduler(revisionCleanupScheduler);
+
+ VersionCleanupMBean versionCleanupMBean = Mockito.mock(VersionCleanupMBean.class);
+ Mockito.when(versionCleanupMBean.isFailed()).thenReturn(false);
+ repositoryHealthCheck.setVersionCleanup(versionCleanupMBean);
+
+ Result result = repositoryHealthCheck.execute();
+ assertFalse(result.isOk());
+ assertEquals(Result.Status.WARN, result.getStatus());
+
+ DataStoreCleanupScheduler dataStoreCleanupScheduler = Mockito.mock(DataStoreCleanupScheduler.class);
+ Mockito.when(dataStoreCleanupScheduler.isEnabled()).thenReturn(false);
+ repositoryHealthCheck.setDataStoreCleanupScheduler(dataStoreCleanupScheduler);
+ Mockito.when(repositoryManagementMBean.getDataStoreGCStatus()).thenReturn(failedCompositeData);
+ result = repositoryHealthCheck.execute();
+ assertTrue(result.isOk());
+ }
+
+ @Test
+ public void testRevisionDisabled() {
+ RepositoryMaintenanceHealthCheck repositoryHealthCheck = new RepositoryMaintenanceHealthCheck();
+
+ DataStoreCleanupScheduler dataStoreCleanupScheduler = Mockito.mock(DataStoreCleanupScheduler.class);
+ repositoryHealthCheck.setDataStoreCleanupScheduler(dataStoreCleanupScheduler);
+
+ RepositoryManagementMBean repositoryManagementMBean = Mockito.mock(RepositoryManagementMBean.class);
+ Mockito.when(repositoryManagementMBean.getRevisionGCStatus()).thenReturn(successCompositeData);
+ Mockito.when(repositoryManagementMBean.getDataStoreGCStatus()).thenReturn(successCompositeData);
+
+ repositoryHealthCheck.setRepositoryManagementMBean(repositoryManagementMBean);
+
+ VersionCleanupMBean versionCleanupMBean = Mockito.mock(VersionCleanupMBean.class);
+ Mockito.when(versionCleanupMBean.isFailed()).thenReturn(false);
+ repositoryHealthCheck.setVersionCleanup(versionCleanupMBean);
+
+ Result result = repositoryHealthCheck.execute();
+ assertFalse(result.isOk());
+ assertEquals(Result.Status.WARN, result.getStatus());
+
+ Mockito.when(repositoryManagementMBean.getRevisionGCStatus()).thenReturn(failedCompositeData);
+ RevisionCleanupScheduler revisionCleanupScheduler = Mockito.mock(RevisionCleanupScheduler.class);
+ Mockito.when(revisionCleanupScheduler.isEnabled()).thenReturn(false);
+ repositoryHealthCheck.setRevisionCleanupScheduler(revisionCleanupScheduler);
+ result = repositoryHealthCheck.execute();
+ assertTrue(result.isOk());
+ }
+
+ @Test
+ public void testVersionDisabled() {
+ RepositoryMaintenanceHealthCheck repositoryHealthCheck = new RepositoryMaintenanceHealthCheck();
+
+ DataStoreCleanupScheduler dataStoreCleanupScheduler = Mockito.mock(DataStoreCleanupScheduler.class);
+ repositoryHealthCheck.setDataStoreCleanupScheduler(dataStoreCleanupScheduler);
+
+ RepositoryManagementMBean repositoryManagementMBean = Mockito.mock(RepositoryManagementMBean.class);
+ Mockito.when(repositoryManagementMBean.getRevisionGCStatus()).thenReturn(successCompositeData);
+ Mockito.when(repositoryManagementMBean.getDataStoreGCStatus()).thenReturn(successCompositeData);
+
+ repositoryHealthCheck.setRepositoryManagementMBean(repositoryManagementMBean);
+
+ RevisionCleanupScheduler revisionCleanupScheduler = Mockito.mock(RevisionCleanupScheduler.class);
+ repositoryHealthCheck.setRevisionCleanupScheduler(revisionCleanupScheduler);
+
+ Result result = repositoryHealthCheck.execute();
+ assertFalse(result.isOk());
+ assertEquals(Result.Status.WARN, result.getStatus());
+
+ VersionCleanupMBean versionCleanupMBean = Mockito.mock(VersionCleanupMBean.class);
+ Mockito.when(versionCleanupMBean.isFailed()).thenReturn(true);
+ Mockito.when(versionCleanupMBean.isEnabled()).thenReturn(false);
+ repositoryHealthCheck.setVersionCleanup(versionCleanupMBean);
+ result = repositoryHealthCheck.execute();
+ assertTrue(result.isOk());
+ }
+
}
diff --git a/src/test/java/org/apache/sling/jcr/maintenance/internal/RevisionCleanupSchedulerTest.java b/src/test/java/org/apache/sling/jcr/maintenance/internal/RevisionCleanupSchedulerTest.java
index 5797226..e649d58 100644
--- a/src/test/java/org/apache/sling/jcr/maintenance/internal/RevisionCleanupSchedulerTest.java
+++ b/src/test/java/org/apache/sling/jcr/maintenance/internal/RevisionCleanupSchedulerTest.java
@@ -42,8 +42,10 @@ public void testRunnable() {
CompositeData doneCd = CompositeDataMock.init().put("id", (Integer) id + 1)
.put("code", StatusCode.SUCCEEDED.ordinal()).build();
Mockito.when(repositoryManager.getRevisionGCStatus()).thenReturn(doneCd);
- final RevisionCleanupScheduler rcs = new RevisionCleanupScheduler(Mockito.mock(RevisionCleanupConfig.class),
- repositoryManager);
+ RevisionCleanupConfig config = Mockito.mock(RevisionCleanupConfig.class);
+ Mockito.when(config.enabled()).thenReturn(true);
+ final RevisionCleanupScheduler rcs = new RevisionCleanupScheduler(config,
+ repositoryManager);
rcs.run();
@@ -67,6 +69,25 @@ public void testRunning() {
Mockito.verify(repositoryManager, never()).startRevisionGC();
}
+ @Test
+ public void testNoRunWhenDisabled() {
+
+ Integer id = 1;
+ final RepositoryManagementMBean repositoryManager = Mockito.mock(RepositoryManagementMBean.class);
+ CompositeData startingCd = CompositeDataMock.init().put("id", id).build();
+ Mockito.when(repositoryManager.startDataStoreGC(false)).thenReturn(startingCd);
+ CompositeData doneCd = CompositeDataMock.init().put("id", id).put("code", StatusCode.SUCCEEDED.ordinal())
+ .build();
+ Mockito.when(repositoryManager.getDataStoreGCStatus()).thenReturn(doneCd);
+ RevisionCleanupConfig config = Mockito.mock(RevisionCleanupConfig.class);
+ Mockito.when(config.enabled()).thenReturn(false);
+ final RevisionCleanupScheduler rcs = new RevisionCleanupScheduler(config,
+ repositoryManager);
+ rcs.run();
+
+ Mockito.verify(repositoryManager, never()).startDataStoreGC(Mockito.anyBoolean());
+ }
+
@Test
public void testSheduledExpression() {
final String EXPECTED = "* * * * *";
@@ -83,6 +104,11 @@ public String scheduler_expression() {
return EXPECTED;
}
+ @Override
+ public boolean enabled() {
+ return true;
+ }
+
}, null);
assertEquals(EXPECTED, rcs.getSchedulerExpression());
diff --git a/src/test/java/org/apache/sling/jcr/maintenance/internal/VersionCleanupTest.java b/src/test/java/org/apache/sling/jcr/maintenance/internal/VersionCleanupTest.java
index 07fa774..f817759 100644
--- a/src/test/java/org/apache/sling/jcr/maintenance/internal/VersionCleanupTest.java
+++ b/src/test/java/org/apache/sling/jcr/maintenance/internal/VersionCleanupTest.java
@@ -48,6 +48,7 @@
import org.apache.sling.api.resource.LoginException;
import org.apache.sling.api.resource.PersistenceException;
import org.apache.sling.api.resource.ResourceResolverFactory;
+import org.apache.sling.jcr.maintenance.VersionCleanupConfig;
import org.apache.sling.jcr.maintenance.VersionCleanupPathConfig;
import org.apache.sling.testing.mock.sling.ResourceResolverType;
import org.apache.sling.testing.mock.sling.junit.SlingContext;
@@ -65,6 +66,8 @@ public class VersionCleanupTest {
private List globalConfig;
+ private VersionCleanupConfig globalCleanupConfig;
+
private Session session;
@Before
@@ -102,7 +105,23 @@ public String path() {
}
}));
-
+ globalCleanupConfig = new VersionCleanupConfig() {
+
+ @Override
+ public Class extends Annotation> annotationType() {
+ return VersionCleanupConfig.class;
+ }
+
+ @Override
+ public String scheduler_expression() {
+ return null;
+ }
+
+ @Override
+ public boolean enabled() {
+ return true;
+ }
+ };
}
private void doVersions(String path, int count) throws RepositoryException {
@@ -120,7 +139,8 @@ public void testRunnable() throws InterruptedException, VersionException, Unsupp
doVersions("/content/apache/sling-apache-org/index", 10);
- final VersionCleanup vcs = new VersionCleanup(globalConfig, context.getService(ResourceResolverFactory.class));
+ final VersionCleanup vcs = new VersionCleanup(globalConfig, context.getService(ResourceResolverFactory.class),
+ globalCleanupConfig);
vcs.start();
while (vcs.isRunning()) {
@@ -133,13 +153,32 @@ public void testRunnable() throws InterruptedException, VersionException, Unsupp
assertEquals(5L, vcs.getLastCleanedVersionsCount());
}
+ @Test
+ public void testNoRunWhenDisabled() throws RepositoryException {
+
+ doVersions("/content/apache/sling-apache-org/index", 10);
+ VersionCleanupConfig cleanupConfig = Mockito.mock(VersionCleanupConfig.class);
+ Mockito.when(cleanupConfig.enabled()).thenReturn(false);
+
+ final VersionCleanup vcs = new VersionCleanup(globalConfig, context.getService(ResourceResolverFactory.class),
+ cleanupConfig);
+
+ vcs.start();
+
+ assertFalse(vcs.isFailed());
+ assertFalse(vcs.isRunning());
+ assertNull(vcs.getLastMessage());
+ assertEquals(0L, vcs.getLastCleanedVersionsCount());
+ }
+
@Test(timeout = 5000)
public void testStop() throws InterruptedException, VersionException, UnsupportedRepositoryOperationException,
InvalidItemStateException, LockException, RepositoryException {
doVersions("/content/apache/sling-apache-org/index", 100);
- final VersionCleanup vcs = new VersionCleanup(globalConfig, context.getService(ResourceResolverFactory.class));
+ final VersionCleanup vcs = new VersionCleanup(globalConfig, context.getService(ResourceResolverFactory.class),
+ globalCleanupConfig);
vcs.start();
assertTrue(vcs.isRunning());
@@ -158,7 +197,8 @@ public void testReRun() throws InterruptedException, VersionException, Unsupport
doVersions("/content/apache/sling-apache-org/index", 100);
final VersionCleanup vcs = Mockito
- .spy(new VersionCleanup(globalConfig, context.getService(ResourceResolverFactory.class)));
+ .spy(new VersionCleanup(globalConfig, context.getService(ResourceResolverFactory.class),
+ globalCleanupConfig));
vcs.start();
vcs.start();
@@ -180,7 +220,8 @@ public void testMissingServiceUser()
ResourceResolverFactory factory = Mockito.mock(ResourceResolverFactory.class);
Mockito.when(factory.getServiceResourceResolver(Mockito.anyMap()))
.thenThrow(new LoginException("No service user"));
- final VersionCleanup vcs = Mockito.spy(new VersionCleanup(globalConfig, factory));
+ final VersionCleanup vcs = Mockito.spy(new VersionCleanup(globalConfig, factory,
+ globalCleanupConfig));
vcs.start();
@@ -200,7 +241,8 @@ public void testDeleted() throws InterruptedException, VersionException, Unsuppo
context.resourceResolver().delete(context.resourceResolver().getResource("/content/apache/sling-apache-org/test2"));
context.resourceResolver().commit();
- final VersionCleanup vcs = new VersionCleanup(globalConfig, context.getService(ResourceResolverFactory.class));
+ final VersionCleanup vcs = new VersionCleanup(globalConfig, context.getService(ResourceResolverFactory.class),
+ globalCleanupConfig);
vcs.start();
while (vcs.isRunning()) {