diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 731bca9ef03ee2db976da25348cd17d4c560104d..90d1560d5f68e8d944b8724a50a87eeea53ada19 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,3 +16,4 @@ build: artifacts: paths: - target/*.jar + diff --git a/pom.xml b/pom.xml index a68a964af88e38ac681f9348259f5a5cc21fc130..9237dafa0095e957d66534fcde0c191c08647642 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ <groupId>de.landsh.opendata</groupId> <artifactId>dcat-uploader</artifactId> - <version>1.0.4</version> + <version>1.1.0</version> <build> <plugins> @@ -33,61 +33,61 @@ <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> - <version>4.5.12</version> + <version>4.5.13</version> </dependency> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpmime</artifactId> - <version>4.5.7</version> + <version>4.5.13</version> </dependency> <dependency> <groupId>org.dom4j</groupId> <artifactId>dom4j</artifactId> - <version>2.1.1</version> + <version>2.1.3</version> </dependency> <dependency> <groupId>jaxen</groupId> <artifactId>jaxen</artifactId> - <version>1.1.6</version> + <version>1.2.0</version> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-core</artifactId> - <version>1.2.3</version> + <version>1.2.7</version> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> - <version>1.2.3</version> + <version>1.2.7</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> - <version>1.7.28</version> + <version>1.7.32</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> - <version>3.6</version> + <version>3.12.0</version> </dependency> <dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> - <version>20190722</version> + <version>20210307</version> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> - <version>1.18.10</version> + <version>1.18.22</version> <scope>provided</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> - <version>4.13</version> + <version>4.13.2</version> <scope>test</scope> </dependency> <dependency> diff --git a/src/main/java/de/landsh/opendata/ckan/CkanAPI.java b/src/main/java/de/landsh/opendata/ckan/CkanAPI.java index c7f66289b11b30a70b7a3602deea98a7979f6b48..cc3ad156798e89c163120e6d81b4e32f52bfe499 100644 --- a/src/main/java/de/landsh/opendata/ckan/CkanAPI.java +++ b/src/main/java/de/landsh/opendata/ckan/CkanAPI.java @@ -433,4 +433,35 @@ public class CkanAPI { return responseJSON.getBoolean("success"); } + public boolean makePackagePrivate(String packageId) throws IOException { + final String organization = getOrganization(packageId); + final JSONObject json = new JSONObject(); + json.put("datasets", packageId); + json.put("org_id", organization); + + final HttpPost httpPost = new HttpPost(baseURL + "/api/action/bulk_update_private"); + httpPost.addHeader("Authorization", apiKey.toString()); + httpPost.addHeader("Content-Type", "application/json"); + httpPost.setEntity(new StringEntity(json.toString(), StandardCharsets.UTF_8)); + + final JSONObject responseJSON = restClient.executeHttpRequest(httpPost); + + return responseJSON.getBoolean("success"); + } + + public boolean makePackagePublic(String packageId) throws IOException { + final String organization = getOrganization(packageId); + final JSONObject json = new JSONObject(); + json.put("datasets", packageId); + json.put("org_id", organization); + + final HttpPost httpPost = new HttpPost(baseURL + "/api/action/bulk_update_public"); + httpPost.addHeader("Authorization", apiKey.toString()); + httpPost.addHeader("Content-Type", "application/json"); + httpPost.setEntity(new StringEntity(json.toString(), StandardCharsets.UTF_8)); + + final JSONObject responseJSON = restClient.executeHttpRequest(httpPost); + + return responseJSON.getBoolean("success"); + } }