Skip to content

Commit

Permalink
Issue #1078
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-stastny committed Sep 25, 2024
1 parent 51cdf78 commit 38eed91
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
29 changes: 21 additions & 8 deletions rest/src/main/java/cz/incad/kramerius/rest/oai/ErrorCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,33 @@
public enum ErrorCode {

// acceptable for all verbs
badArgument,
badArgument(400),
// acceptable badResumptionToken
badResumptionToken,
badResumptionToken(400),
// no verb
badVerb,
badVerb(400),
// GetRecord, ListIdentifiers, ListRecords
cannotDisseminateFormat,
cannotDisseminateFormat(400),
// GetRecord, ListMetadataFormat
idDoesNotExist,
idDoesNotExist(404),
//ListIdentifiers ListRecords
noRecordsMatch,
noRecordsMatch(200),
//ListMetadataFormats
noMetadataFormats,
noMetadataFormats(400),

//ListSets ListIdentifiers ListRecords
noSetHierarchy
noSetHierarchy(400);

public int getStatusCode() {
return statusCode;
}

int statusCode;

private ErrorCode(int statusCode) {
this.statusCode = statusCode;
}


}

Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,16 @@ protected OAIException(Response response) {
super(response);
}

// public AbstractOAIException(int errorCode) {
// super(errorCode);
// }
//
// public AbstractOAIException(Response.Status status) {
// super(status);
// }

public OAIException(ErrorCode oaiErrorCode,OAIVerb verb, OAISet set,String baseUrl,MetadataExport metadata) {
this(Response.status(Response.Status.BAD_REQUEST)
this(Response.status(oaiErrorCode.getStatusCode())
.type(MediaType.APPLICATION_XML)
.entity(buildXml(oaiErrorCode, verb, set, baseUrl, metadata, null))
.build());
}

public OAIException(ErrorCode oaiErrorCode,OAIVerb verb, OAISet set,String baseUrl,MetadataExport metadata, String message) {
this(Response.status(Response.Status.BAD_REQUEST)
this(Response.status(oaiErrorCode.getStatusCode())
.type(MediaType.APPLICATION_XML)
.entity(buildXml(oaiErrorCode, verb, set, baseUrl, metadata, message))
.build());
Expand Down

0 comments on commit 38eed91

Please sign in to comment.