Search in sources :

Example 1 with ArrayOfTRequestTokenReturn

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);
}
Also used : SrmResponse(org.dcache.srm.SrmResponse) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) ArrayList(java.util.ArrayList) SrmGetRequestTokensResponse(org.dcache.srm.v2_2.SrmGetRequestTokensResponse) ArrayOfTRequestTokenReturn(org.dcache.srm.v2_2.ArrayOfTRequestTokenReturn) TRequestTokenReturn(org.dcache.srm.v2_2.TRequestTokenReturn) ArrayOfTRequestTokenReturn(org.dcache.srm.v2_2.ArrayOfTRequestTokenReturn)

Example 2 with ArrayOfTRequestTokenReturn

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());
    }
}
Also used : TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) Calendar(java.util.Calendar) SrmGetRequestTokensRequest(org.dcache.srm.v2_2.SrmGetRequestTokensRequest) SrmGetRequestTokensResponse(org.dcache.srm.v2_2.SrmGetRequestTokensResponse) IOException(java.io.IOException) ArrayOfTRequestTokenReturn(org.dcache.srm.v2_2.ArrayOfTRequestTokenReturn) IOException(java.io.IOException) TRequestTokenReturn(org.dcache.srm.v2_2.TRequestTokenReturn) ArrayOfTRequestTokenReturn(org.dcache.srm.v2_2.ArrayOfTRequestTokenReturn)

Example 3 with ArrayOfTRequestTokenReturn

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));
}
Also used : TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) SrmGetRequestTokensResponse(org.dcache.srm.v2_2.SrmGetRequestTokensResponse) ArrayOfTRequestTokenReturn(org.dcache.srm.v2_2.ArrayOfTRequestTokenReturn) SRMInvalidRequestException(org.dcache.srm.SRMInvalidRequestException) TRequestTokenReturn(org.dcache.srm.v2_2.TRequestTokenReturn) ArrayOfTRequestTokenReturn(org.dcache.srm.v2_2.ArrayOfTRequestTokenReturn)

Aggregations

ArrayOfTRequestTokenReturn (org.dcache.srm.v2_2.ArrayOfTRequestTokenReturn)3 SrmGetRequestTokensResponse (org.dcache.srm.v2_2.SrmGetRequestTokensResponse)3 TRequestTokenReturn (org.dcache.srm.v2_2.TRequestTokenReturn)3 TReturnStatus (org.dcache.srm.v2_2.TReturnStatus)3 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 SRMInvalidRequestException (org.dcache.srm.SRMInvalidRequestException)1 SrmResponse (org.dcache.srm.SrmResponse)1 SrmGetRequestTokensRequest (org.dcache.srm.v2_2.SrmGetRequestTokensRequest)1