Search in sources :

Example 1 with SrmMvResponse

use of org.dcache.srm.v2_2.SrmMvResponse in project dcache by dCache.

the class SRMMvClientV2 method start.

@Override
public void start() throws Exception {
    checkCredentialValid();
    SrmMvRequest req = new SrmMvRequest();
    req.setFromSURL(new URI(surl_strings[0]));
    req.setToSURL(new URI(surl_strings[1]));
    configuration.getStorageSystemInfo().ifPresent(req::setStorageSystemInfo);
    SrmMvResponse resp = srm.srmMv(req);
    TReturnStatus rs = resp.getReturnStatus();
    if (rs.getStatusCode() != TStatusCode.SRM_SUCCESS) {
        TStatusCode rc = rs.getStatusCode();
        StringBuilder sb = new StringBuilder();
        sb.append("Return code: ").append(rc.toString()).append("\n");
        sb.append("Explanation: ").append(rs.getExplanation()).append("\n");
        System.out.println(sb.toString());
        System.exit(1);
    }
}
Also used : SrmMvResponse(org.dcache.srm.v2_2.SrmMvResponse) SrmMvRequest(org.dcache.srm.v2_2.SrmMvRequest) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) URI(org.apache.axis.types.URI) TStatusCode(org.dcache.srm.v2_2.TStatusCode)

Example 2 with SrmMvResponse

use of org.dcache.srm.v2_2.SrmMvResponse in project dcache by dCache.

the class AxisSrmFileSystem method mv.

@Override
public void mv(URI fromSurl, URI toSurl) throws RemoteException, SRMException {
    SrmMvResponse response = srm.srmMv(new SrmMvRequest(null, fromSurl, toSurl, null));
    checkSuccess(response.getReturnStatus());
}
Also used : SrmMvResponse(org.dcache.srm.v2_2.SrmMvResponse) SrmMvRequest(org.dcache.srm.v2_2.SrmMvRequest)

Example 3 with SrmMvResponse

use of org.dcache.srm.v2_2.SrmMvResponse in project dcache by dCache.

the class SrmMv method srmMv.

private SrmMvResponse srmMv() {
    TReturnStatus returnStatus;
    try {
        URI to_surl = URI.create(request.getToSURL().toString());
        URI from_surl = URI.create(request.getFromSURL().toString());
        // SURL is busy.
        if (srm.isFileBusy(from_surl)) {
            returnStatus = new TReturnStatus(TStatusCode.SRM_FILE_BUSY, "The source SURL is being used by another client.");
        } else if (srm.isFileBusy(to_surl)) {
            returnStatus = new TReturnStatus(TStatusCode.SRM_DUPLICATION_ERROR, "The target SURL is being used by another client.");
        } else {
            storage.moveEntry(user, from_surl, to_surl);
            returnStatus = new TReturnStatus(TStatusCode.SRM_SUCCESS, null);
        }
    } catch (SRMDuplicationException e) {
        returnStatus = new TReturnStatus(TStatusCode.SRM_DUPLICATION_ERROR, e.getMessage());
    } catch (SRMInternalErrorException e) {
        LOGGER.error(e.toString());
        returnStatus = new TReturnStatus(TStatusCode.SRM_INTERNAL_ERROR, e.getMessage());
    } catch (SRMInvalidPathException e) {
        returnStatus = new TReturnStatus(TStatusCode.SRM_INVALID_PATH, e.getMessage());
    } catch (SRMAuthorizationException e) {
        LOGGER.warn(e.toString());
        returnStatus = new TReturnStatus(TStatusCode.SRM_AUTHORIZATION_FAILURE, e.getMessage());
    } catch (SRMException e) {
        LOGGER.error(e.toString());
        returnStatus = new TReturnStatus(TStatusCode.SRM_FAILURE, e.getMessage());
    }
    return new SrmMvResponse(returnStatus);
}
Also used : SRMInternalErrorException(org.dcache.srm.SRMInternalErrorException) SrmMvResponse(org.dcache.srm.v2_2.SrmMvResponse) SRMAuthorizationException(org.dcache.srm.SRMAuthorizationException) SRMException(org.dcache.srm.SRMException) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) SRMInvalidPathException(org.dcache.srm.SRMInvalidPathException) URI(java.net.URI) SRMDuplicationException(org.dcache.srm.SRMDuplicationException)

Example 4 with SrmMvResponse

use of org.dcache.srm.v2_2.SrmMvResponse in project dcache by dCache.

the class SrmMv method getFailedResponse.

public static final SrmMvResponse getFailedResponse(String error, TStatusCode statusCode) {
    SrmMvResponse response = new SrmMvResponse();
    response.setReturnStatus(new TReturnStatus(statusCode, error));
    return response;
}
Also used : SrmMvResponse(org.dcache.srm.v2_2.SrmMvResponse) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus)

Aggregations

SrmMvResponse (org.dcache.srm.v2_2.SrmMvResponse)4 TReturnStatus (org.dcache.srm.v2_2.TReturnStatus)3 SrmMvRequest (org.dcache.srm.v2_2.SrmMvRequest)2 URI (java.net.URI)1 URI (org.apache.axis.types.URI)1 SRMAuthorizationException (org.dcache.srm.SRMAuthorizationException)1 SRMDuplicationException (org.dcache.srm.SRMDuplicationException)1 SRMException (org.dcache.srm.SRMException)1 SRMInternalErrorException (org.dcache.srm.SRMInternalErrorException)1 SRMInvalidPathException (org.dcache.srm.SRMInvalidPathException)1 TStatusCode (org.dcache.srm.v2_2.TStatusCode)1