Skip to content

Commit

Permalink
DD-1445 Add submitForReview (#47)
Browse files Browse the repository at this point in the history
* WIP

* Better return type for submitForReview

* Fix submitForReview
  • Loading branch information
janvanmansum authored Oct 31, 2023
1 parent fbf3520 commit 8c1a541
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<relativePath />
</parent>
<artifactId>dans-dataverse-client-lib-examples</artifactId>
<version>0.23.1-SNAPSHOT</version>
<version>0.24.0-SNAPSHOT</version>
<name>DANS Dataverse Client Library Examples</name>
<inceptionYear>2021</inceptionYear>
<scm>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (C) 2021 DANS - Data Archiving and Networked Services ([email protected])
*
* 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.
*/
package nl.knaw.dans.lib.dataverse.example;

import lombok.extern.slf4j.Slf4j;
import nl.knaw.dans.lib.dataverse.DataverseResponse;
import nl.knaw.dans.lib.dataverse.ExampleBase;
import nl.knaw.dans.lib.dataverse.model.dataset.DatasetPublicationResult;
import nl.knaw.dans.lib.dataverse.model.dataset.SubmitForReviewResult;

@Slf4j
public class DatasetSubmitForReview extends ExampleBase {

public static void main(String[] args) throws Exception {
String persistentId = args[0];
DataverseResponse<SubmitForReviewResult> r = client.dataset(persistentId).submitForReview();
log.info("Response message: {}", r.getEnvelopeAsJson().toPrettyString());
log.info("In Review?: {}", r.getData().getInReview());
log.info("Message: {}", r.getData().getMessage());
}
}
2 changes: 1 addition & 1 deletion lib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<relativePath />
</parent>
<artifactId>dans-dataverse-client-lib</artifactId>
<version>0.23.1-SNAPSHOT</version>
<version>0.24.0-SNAPSHOT</version>
<name>DANS Dataverse Client Library</name>
<inceptionYear>2021</inceptionYear>
<scm>
Expand Down
15 changes: 14 additions & 1 deletion lib/src/main/java/nl/knaw/dans/lib/dataverse/DatasetApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@
import nl.knaw.dans.lib.dataverse.model.dataset.Embargo;
import nl.knaw.dans.lib.dataverse.model.dataset.FieldList;
import nl.knaw.dans.lib.dataverse.model.dataset.FileList;
import nl.knaw.dans.lib.dataverse.model.dataset.SubmitForReviewResult;
import nl.knaw.dans.lib.dataverse.model.dataset.UpdateType;
import nl.knaw.dans.lib.dataverse.model.file.FileMeta;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpStatus;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.entity.mime.content.StringBody;
Expand Down Expand Up @@ -477,7 +479,18 @@ public DataverseHttpResponse<FileList> addFile(Path file, FileMeta fileMeta) thr

// TODO: https://guides.dataverse.org/en/latest/api/native-api.html#report-the-data-file-size-of-a-dataset
// TODO: https://guides.dataverse.org/en/latest/api/native-api.html#get-the-size-of-downloading-all-the-files-of-a-dataset-version
// TODO: https://guides.dataverse.org/en/latest/api/native-api.html#submit-a-dataset-for-review

/**
* @return todo
* @throws IOException when I/O problems occur during the interaction with Dataverse
* @throws DataverseException when Dataverse fails to perform the request
* @see <a href="https://guides.dataverse.org/en/latest/api/native-api.html#submit-a-dataset-for-review">Dataverse documentation</a>
*/
public DataverseHttpResponse<SubmitForReviewResult> submitForReview() throws IOException, DataverseException {
return httpClientWrapper.post(subPath("submitForReview"), new StringEntity(""), params(emptyMap()), extraHeaders, SubmitForReviewResult.class);
}


// TODO: https://guides.dataverse.org/en/latest/api/native-api.html#return-a-dataset-to-author
// TODO: https://guides.dataverse.org/en/latest/api/native-api.html#link-a-dataset
// TODO: https://guides.dataverse.org/en/latest/api/native-api.html#dataset-locks
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (C) 2021 DANS - Data Archiving and Networked Services ([email protected])
*
* 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.
*/
package nl.knaw.dans.lib.dataverse.model.dataset;

import lombok.Data;

@Data
public class SubmitForReviewResult {
private Boolean inReview;
private String message;
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</parent>

<artifactId>dans-dataverse-client-lib-build</artifactId>
<version>0.23.1-SNAPSHOT</version>
<version>0.24.0-SNAPSHOT</version>
<inceptionYear>2021</inceptionYear>
<name>DANS Dataverse Client Library Master Build</name>
<packaging>pom</packaging>
Expand Down

0 comments on commit 8c1a541

Please sign in to comment.