use of org.dcache.srm.v2_2.ArrayOfTRequestTokenReturn in project dcache by dCache.
the class SrmHandler method mapGetRequestTokensResponse.
private SrmGetRequestTokensResponse mapGetRequestTokensResponse(List<SrmResponse> responses) {
List<TRequestTokenReturn> tokens = new ArrayList<>();
for (SrmResponse srmResponse : responses) {
SrmGetRequestTokensResponse response = (SrmGetRequestTokensResponse) srmResponse.getResponse();
if (response.getReturnStatus().getStatusCode() != SRM_SUCCESS) {
return response;
}
for (TRequestTokenReturn token : response.getArrayOfRequestTokens().getTokenArray()) {
tokens.add(new TRequestTokenReturn(prefix(srmResponse.getId(), token.getRequestToken()), token.getCreatedAtTime()));
}
}
ArrayOfTRequestTokenReturn arrayOfRequestTokens = new ArrayOfTRequestTokenReturn(tokens.toArray(TRequestTokenReturn[]::new));
return new SrmGetRequestTokensResponse(new TReturnStatus(SRM_SUCCESS, "Request processed successfully."), arrayOfRequestTokens);
}
use of org.dcache.srm.v2_2.ArrayOfTRequestTokenReturn in project dcache by dCache.
the class SRMGetRequestTokensClientV2 method start.
@Override
public void start() throws Exception {
checkCredentialValid();
try {
SrmGetRequestTokensRequest request = new SrmGetRequestTokensRequest();
request.setUserRequestDescription(configuration.getUserRequestDescription());
SrmGetRequestTokensResponse response = srm.srmGetRequestTokens(request);
if (response == null) {
throw new IOException(" null SrmGetRequestTokensResponse ");
}
TReturnStatus rs = response.getReturnStatus();
if (rs == null) {
throw new IOException(" null TReturnStatus ");
}
if (RequestStatusTool.isFailedRequestStatus(rs)) {
throw new IOException("srmGetRequestTokens failed, unexpected or failed return status : " + rs.getStatusCode() + " explanation=" + rs.getExplanation());
}
if (response.getArrayOfRequestTokens() != null) {
ArrayOfTRequestTokenReturn tokens = response.getArrayOfRequestTokens();
if (tokens.getTokenArray() != null) {
TRequestTokenReturn[] tokenArray = tokens.getTokenArray();
for (TRequestTokenReturn aTokenArray : tokenArray) {
String token = aTokenArray.getRequestToken();
Calendar date = aTokenArray.getCreatedAtTime();
System.out.println("Request token=" + ((token != null ? token : "null")) + " Created=" + ((date != null) ? date : "null"));
}
} else {
System.err.println("Couldn't get list of request tokens");
}
} else {
System.err.println("No request tokens found");
}
} catch (Exception e) {
say(e.toString());
}
}
use of org.dcache.srm.v2_2.ArrayOfTRequestTokenReturn in project dcache by dCache.
the class SrmGetRequestTokens method srmGetRequestTokens.
private SrmGetRequestTokensResponse srmGetRequestTokens() throws SRMException {
String description = request.getUserRequestDescription();
String[] requestTokens = getRequestTokens(user, description);
if (requestTokens.length == 0) {
throw new SRMInvalidRequestException("No such requests");
}
TRequestTokenReturn[] requestTokenReturns = new TRequestTokenReturn[requestTokens.length];
for (int i = 0; i < requestTokens.length; ++i) {
requestTokenReturns[i] = new TRequestTokenReturn(requestTokens[i], null);
}
return new SrmGetRequestTokensResponse(new TReturnStatus(TStatusCode.SRM_SUCCESS, null), new ArrayOfTRequestTokenReturn(requestTokenReturns));
}
Aggregations