From b97e5c34e7dd7b332a38cb823c23a825cf63591a Mon Sep 17 00:00:00 2001 From: Abhi Shah Date: Thu, 6 Oct 2022 15:54:38 +0530 Subject: [PATCH 01/10] ACL update feature added ACL Update method along with the corresponding test-cases --- splunk/src/main/java/com/splunk/Entity.java | 22 +++++++++++++ .../test/java/com/splunk/SavedSearchTest.java | 32 +++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/splunk/src/main/java/com/splunk/Entity.java b/splunk/src/main/java/com/splunk/Entity.java index 831b9852..a4856e2a 100644 --- a/splunk/src/main/java/com/splunk/Entity.java +++ b/splunk/src/main/java/com/splunk/Entity.java @@ -50,6 +50,8 @@ protected String actionPath(String action) { return path + "/enable"; if (action.equals("remove")) return path; + if (action.equals("acl")) + return path + "/acl"; throw new IllegalArgumentException("Invalid action: " + action); } @@ -450,6 +452,26 @@ public void update() { update(Collections.EMPTY_MAP); } + + /** + * Update the access control list (ACL) properties for this entity, + * + * @param args: Properties to update for this entity. + * Required Properties in 'args' + * - `owner`: The Splunk username, such as "admin". A value of "nobody" means no specific user. + * - `sharing`: A mode that indicates how the resource is shared. The sharing mode can be "user", "app", "global", or "system". + */ + public void aclUpdate(Map args){ + if(!args.containsKey("sharing")){ + throw new IllegalArgumentException("Required argument 'sharing' is missing."); + } + if(!args.containsKey("owner")){ + throw new IllegalArgumentException("Required argument 'owner' is missing."); + } + service.post(actionPath("acl"), args); + invalidate(); + } + /** * Removes this entity from its corresponding collection. */ diff --git a/splunk/src/test/java/com/splunk/SavedSearchTest.java b/splunk/src/test/java/com/splunk/SavedSearchTest.java index dc45caa1..e62a6294 100644 --- a/splunk/src/test/java/com/splunk/SavedSearchTest.java +++ b/splunk/src/test/java/com/splunk/SavedSearchTest.java @@ -360,6 +360,38 @@ public void testCannotUpdateName() { } catch (Exception e) {} } + @Test + public void testACLUpdates(){ + Record aclInfo = savedSearch.getMetadata().getEaiAcl(); + Assert.assertNotEquals(aclInfo.getString("sharing"), "app"); + Assert.assertNotEquals(aclInfo.getString("owner"), "nobody"); + Assert.assertNull(aclInfo.get("perms")); + Args args = new Args(); + args.add("sharing","app"); + args.add("owner","nobody"); + args.add("app","search"); + args.add("perms.read","admin, nobody"); + savedSearch.aclUpdate(args); + aclInfo = savedSearch.getMetadata().getEaiAcl(); + Assert.assertEquals(aclInfo.getString("sharing"), "app"); + Assert.assertEquals(aclInfo.getString("owner"), "nobody"); + Assert.assertNotNull(aclInfo.get("perms")); + } + + @Test + public void testACLUpdateWithoutSharing(){ + Args args = new Args(); + args.add("owner","nobody"); + args.add("app","search"); + Assert.assertThrows("Required argument 'sharing' is missing.", IllegalArgumentException.class, () -> {savedSearch.aclUpdate(args);}); + } + + @Test + public void testACLUpdateWithoutOwner(){ + Args args = new Args(); + Assert.assertThrows("Required argument 'owner' is missing.", IllegalArgumentException.class, () -> {savedSearch.aclUpdate(args);}); + } + @Test public void testDispatch() { final JobCollection jobs = service.getJobs(); From 22948e3a6a99a7443d0d8a84983473b363543316 Mon Sep 17 00:00:00 2001 From: Abhi Shah Date: Thu, 6 Oct 2022 15:57:41 +0530 Subject: [PATCH 02/10] Update release.yml test doc generation update --- .github/workflows/release.yml | 36 +++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d4cdce89..036fec0a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,6 +1,7 @@ on: - release: - types: [published] + [push] +# release: +# types: [published] name: Release @@ -21,22 +22,25 @@ jobs: run: mvn package --file pom.xml -DskipTests=true - name: Create temp artifacts apidocs folder run: mkdir apidocs - - name: Create GitHub Release - uses: softprops/action-gh-release@v1 - with: -# body_path: ${{ github.workflow }}-CHANGELOG.txt - files: ./target/*.jar - draft: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Deploy to Artifactory - run: mvn --batch-mode deploy -DskipTests=true - env: - MAVEN_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} - MAVEN_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} +# - name: Create GitHub Release +# uses: softprops/action-gh-release@v1 +# with: +## body_path: ${{ github.workflow }}-CHANGELOG.txt +# files: ./target/*.jarln -s /data/to/zip/data.txt data.txt +# draft: true +# env: +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# - name: Deploy to Artifactory +# run: mvn --batch-mode deploy -DskipTests=true +# env: +# MAVEN_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} +# MAVEN_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} - name: Zip docs - run: zip -r apidocs/docs.zip splunk/target/apidocs + run: | + cd splunk/target/apidocs + zip -r ./../../../apidocs/docs.zip ./* + cd ../../.. - name: Upload Artifact uses: actions/upload-artifact@v3 From f92e84a2dfd5f654e1677db7b612d4f51bbffc67 Mon Sep 17 00:00:00 2001 From: Abhi Shah Date: Thu, 6 Oct 2022 16:04:51 +0530 Subject: [PATCH 03/10] Update release.yml reverting test code in the release.yml --- .github/workflows/release.yml | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 036fec0a..fa5c0b59 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,7 +1,6 @@ on: - [push] -# release: -# types: [published] + release: + types: [published] name: Release @@ -22,19 +21,19 @@ jobs: run: mvn package --file pom.xml -DskipTests=true - name: Create temp artifacts apidocs folder run: mkdir apidocs -# - name: Create GitHub Release -# uses: softprops/action-gh-release@v1 -# with: -## body_path: ${{ github.workflow }}-CHANGELOG.txt -# files: ./target/*.jarln -s /data/to/zip/data.txt data.txt -# draft: true -# env: -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# - name: Deploy to Artifactory -# run: mvn --batch-mode deploy -DskipTests=true -# env: -# MAVEN_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} -# MAVEN_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} + - name: Create GitHub Release + uses: softprops/action-gh-release@v1 + with: +# body_path: ${{ github.workflow }}-CHANGELOG.txt + files: ./target/*.jarln -s /data/to/zip/data.txt data.txt + draft: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Deploy to Artifactory + run: mvn --batch-mode deploy -DskipTests=true + env: + MAVEN_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} - name: Zip docs run: | From 0acbf61108021da908528af8129e619516bb63df Mon Sep 17 00:00:00 2001 From: Abhi Shah Date: Fri, 7 Oct 2022 12:18:25 +0530 Subject: [PATCH 04/10] test doc upload --- .github/workflows/release.yml | 45 ++++++++++++++++++----------------- .github/workflows/test.yml | 2 +- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fa5c0b59..ffb2d813 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,6 +1,7 @@ on: - release: - types: [published] + [push] +# release: +# types: [published] name: Release @@ -21,28 +22,28 @@ jobs: run: mvn package --file pom.xml -DskipTests=true - name: Create temp artifacts apidocs folder run: mkdir apidocs - - name: Create GitHub Release - uses: softprops/action-gh-release@v1 - with: -# body_path: ${{ github.workflow }}-CHANGELOG.txt - files: ./target/*.jarln -s /data/to/zip/data.txt data.txt - draft: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Deploy to Artifactory - run: mvn --batch-mode deploy -DskipTests=true - env: - MAVEN_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} - MAVEN_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} - - - name: Zip docs - run: | - cd splunk/target/apidocs - zip -r ./../../../apidocs/docs.zip ./* - cd ../../.. +# - name: Create GitHub Release +# uses: softprops/action-gh-release@v1 +# with: +## body_path: ${{ github.workflow }}-CHANGELOG.txt +# files: ./target/*.jarln -s /data/to/zip/data.txt data.txt +# draft: true +# env: +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# - name: Deploy to Artifactory +# run: mvn --batch-mode deploy -DskipTests=true +# env: +# MAVEN_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} +# MAVEN_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} +# +# - name: Zip docs +# run: | +# cd splunk/target/apidocs +# zip -r ./../../../apidocs/docs.zip ./* +# cd ../../.. - name: Upload Artifact uses: actions/upload-artifact@v3 with: name: apidocs - path: apidocs/docs.zip + path: splunk/target/apidocs diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 84ca35c8..1efa040f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,7 +1,7 @@ name: Java SDK Test on: - [push, pull_request] + [ pull_request] jobs: test: From 8dcad3ac093b1b2f4384985e5c7bc28072a9be3e Mon Sep 17 00:00:00 2001 From: Abhi Shah Date: Fri, 7 Oct 2022 15:32:13 +0530 Subject: [PATCH 05/10] Update release.yml --- .github/workflows/release.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ffb2d813..07363b80 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,8 +20,6 @@ jobs: server-id: splunk-artifactory - name: build run: mvn package --file pom.xml -DskipTests=true - - name: Create temp artifacts apidocs folder - run: mkdir apidocs # - name: Create GitHub Release # uses: softprops/action-gh-release@v1 # with: @@ -45,5 +43,5 @@ jobs: - name: Upload Artifact uses: actions/upload-artifact@v3 with: - name: apidocs + name: docs-java-sdk path: splunk/target/apidocs From 3dad76bd4f4248e996c3cd2589fa1f88520c38b2 Mon Sep 17 00:00:00 2001 From: Abhi Shah Date: Fri, 7 Oct 2022 15:34:17 +0530 Subject: [PATCH 06/10] Update release.yml --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 07363b80..f29c7a9a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -43,5 +43,5 @@ jobs: - name: Upload Artifact uses: actions/upload-artifact@v3 with: - name: docs-java-sdk + name: java_sdk_docs path: splunk/target/apidocs From e7b35781e89e4679ac058fcd4cf761364d2d05cf Mon Sep 17 00:00:00 2001 From: Abhi Shah Date: Fri, 7 Oct 2022 15:39:55 +0530 Subject: [PATCH 07/10] reverted changes done for test purpose --- .github/workflows/release.yml | 37 ++++++++++++++--------------------- .github/workflows/test.yml | 2 +- 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f29c7a9a..9d899e6f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,7 +1,6 @@ on: - [push] -# release: -# types: [published] + release: + types: [published] name: Release @@ -20,25 +19,19 @@ jobs: server-id: splunk-artifactory - name: build run: mvn package --file pom.xml -DskipTests=true -# - name: Create GitHub Release -# uses: softprops/action-gh-release@v1 -# with: -## body_path: ${{ github.workflow }}-CHANGELOG.txt -# files: ./target/*.jarln -s /data/to/zip/data.txt data.txt -# draft: true -# env: -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# - name: Deploy to Artifactory -# run: mvn --batch-mode deploy -DskipTests=true -# env: -# MAVEN_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} -# MAVEN_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} -# -# - name: Zip docs -# run: | -# cd splunk/target/apidocs -# zip -r ./../../../apidocs/docs.zip ./* -# cd ../../.. + - name: Create GitHub Release + uses: softprops/action-gh-release@v1 + with: +# body_path: ${{ github.workflow }}-CHANGELOG.txt + files: ./target/*.jarln -s /data/to/zip/data.txt data.txt + draft: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Deploy to Artifactory + run: mvn --batch-mode deploy -DskipTests=true + env: + MAVEN_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} - name: Upload Artifact uses: actions/upload-artifact@v3 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1efa040f..84ca35c8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,7 +1,7 @@ name: Java SDK Test on: - [ pull_request] + [push, pull_request] jobs: test: From d9c0ce4685f1bea83878b23bd01e144767fe0504 Mon Sep 17 00:00:00 2001 From: Abhi Shah Date: Fri, 21 Oct 2022 12:26:32 +0530 Subject: [PATCH 08/10] Update release.yml --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9d899e6f..2df6aeb3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,7 +23,7 @@ jobs: uses: softprops/action-gh-release@v1 with: # body_path: ${{ github.workflow }}-CHANGELOG.txt - files: ./target/*.jarln -s /data/to/zip/data.txt data.txt + files: ./target/*.jar draft: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 8a0a24e54d5672a38598dcf36b0b60c6def0c606 Mon Sep 17 00:00:00 2001 From: Abhi Shah Date: Fri, 11 Nov 2022 11:44:47 +0530 Subject: [PATCH 09/10] Update XmlUtil.java Null check for the child --- splunk/src/main/java/com/splunk/modularinput/XmlUtil.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/splunk/src/main/java/com/splunk/modularinput/XmlUtil.java b/splunk/src/main/java/com/splunk/modularinput/XmlUtil.java index 0798d97a..3082aa47 100755 --- a/splunk/src/main/java/com/splunk/modularinput/XmlUtil.java +++ b/splunk/src/main/java/com/splunk/modularinput/XmlUtil.java @@ -35,10 +35,12 @@ class XmlUtil { */ static String textInNode(Node node, String errorMessage) throws MalformedDataException { Node child = node.getFirstChild(); - if (child.getNodeType() != Node.TEXT_NODE) { + if (null == child) { + return ""; + } else if (child.getNodeType() != Node.TEXT_NODE) { throw new MalformedDataException(errorMessage); } else { - return ((Text)child).getData(); + return ((Text) child).getData(); } } From df4ea508cc28fd566c3df0f8b85c63f218ee074b Mon Sep 17 00:00:00 2001 From: Abhi Shah Date: Wed, 16 Nov 2022 11:45:38 +0530 Subject: [PATCH 10/10] Release updates version and changelog updates --- CHANGELOG.md | 8 +++++ README.md | 4 +-- deploy | 2 +- deploy.md | 30 +++++++++---------- examples/pom.xml | 2 +- pom.xml | 2 +- splunk/pom.xml | 2 +- .../src/main/java/com/splunk/HttpService.java | 2 +- 8 files changed, 30 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 524833fd..9de98f5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Splunk Enterprise SDK for Java Changelog +## Version 1.9.2 + +### New Features and APIs +* Added feature that allows to update ACL properties of an entity (GitHub PR [#196](https://github.com/splunk/splunk-sdk-java/pull/196)) + +### Minor Changes +* Added null check for child to handle error when no value is passed for a parameter in modular-inputs (Ref issue [#198](https://github.com/splunk/splunk-sdk-java/issues/198) & GitHub PR [#199](https://github.com/splunk/splunk-sdk-java/pull/199)) + ## Version 1.9.1 ### New Features and APIs diff --git a/README.md b/README.md index 72b778d5..f237d7ea 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ [![Java SDK Test](https://github.com/splunk/splunk-sdk-java/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/splunk/splunk-sdk-java/actions/workflows/test.yml) # The Splunk Software Development Kit for Java -#### Version 1.9.1 +#### Version 1.9.2 The Splunk Software Development Kit (SDK) for Java contains library code and examples designed to enable developers to build applications using Splunk. @@ -75,7 +75,7 @@ To add the Splunk SDK for Java `.JAR` file as a dependency: com.splunk splunk - 1.9.1 + 1.9.2 ``` diff --git a/deploy b/deploy index 26bce595..f30b59ad 100755 --- a/deploy +++ b/deploy @@ -2,7 +2,7 @@ declare -r scriptDirectory="$(dirname $(readlink -e $0))" declare -r scriptName="$(basename $0)" -declare -r version="1.9.1" +declare -r version="1.9.2" if [[ $# -ne 1 ]]; then echo 1>&2 "Usage: ${scriptName} {local|staging||production}" diff --git a/deploy.md b/deploy.md index eab0df26..1fb9e68d 100644 --- a/deploy.md +++ b/deploy.md @@ -9,8 +9,8 @@ deploy \ ##DESCRIPTION -Deploy transmits **target/splunk-1.9.1.jar**, **target/splunk-1.9.1-javadoc.jar**, and -**target/splunk-1.9.1-sources.jar** to the **local**, **staging**, or **production** +Deploy transmits **target/splunk-1.9.2.jar**, **target/splunk-1.9.2-javadoc.jar**, and +**target/splunk-1.9.2-sources.jar** to the **local**, **staging**, or **production** maven repository. Repository names are mapped to locations as follows. | repository-name | location | @@ -21,18 +21,18 @@ maven repository. Repository names are mapped to locations as follows. After deployment you should find this tree structure at the location of your repository - com/splunk/splunk/1.9.1/ - ├── splunk-1.9.1-javadoc.jar - ├── splunk-1.9.1-javadoc.jar.md5 - ├── splunk-1.9.1-javadoc.jar.sha1 - ├── splunk-1.9.1-sources.jar - ├── splunk-1.9.1-sources.jar.md5 - ├── splunk-1.9.1-sources.jar.sha1 - ├── splunk-1.9.1.jar - ├── splunk-1.9.1.jar.md5 - ├── splunk-1.9.1.jar.sha1 - ├── splunk-1.9.1.pom - ├── splunk-1.9.1.pom.md5 - └── splunk-1.9.1.pom.sha1 + com/splunk/splunk/1.9.2/ + ├── splunk-1.9.2-javadoc.jar + ├── splunk-1.9.2-javadoc.jar.md5 + ├── splunk-1.9.2-javadoc.jar.sha1 + ├── splunk-1.9.2-sources.jar + ├── splunk-1.9.2-sources.jar.md5 + ├── splunk-1.9.2-sources.jar.sha1 + ├── splunk-1.9.2.jar + ├── splunk-1.9.2.jar.md5 + ├── splunk-1.9.2.jar.sha1 + ├── splunk-1.9.2.pom + ├── splunk-1.9.2.pom.md5 + └── splunk-1.9.2.pom.sha1 Verify this structure prior to release. diff --git a/examples/pom.xml b/examples/pom.xml index 1573e401..0a103858 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -37,7 +37,7 @@ com.splunk splunk - 1.9.1 + 1.9.2 provided diff --git a/pom.xml b/pom.xml index 827b8db6..7518555a 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 4.0.0 - 1.9.1 + 1.9.2 true UTF-8 8 diff --git a/splunk/pom.xml b/splunk/pom.xml index 186d8eda..922cdab9 100644 --- a/splunk/pom.xml +++ b/splunk/pom.xml @@ -5,7 +5,7 @@ 4.0.0 splunk - 1.9.1 + 1.9.2 splunk-sdk-java com.splunk diff --git a/splunk/src/main/java/com/splunk/HttpService.java b/splunk/src/main/java/com/splunk/HttpService.java index ece901ca..d95f3d6e 100644 --- a/splunk/src/main/java/com/splunk/HttpService.java +++ b/splunk/src/main/java/com/splunk/HttpService.java @@ -89,7 +89,7 @@ public boolean verify(String s, SSLSession sslSession) { private String prefix = null; static Map defaultHeader = new HashMap() {{ - put("User-Agent", "splunk-sdk-java/1.9.1"); + put("User-Agent", "splunk-sdk-java/1.9.2"); put("Accept", "*/*"); }};