Search in sources :

Example 1 with ArrayOfTSURLReturnStatus

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

the class SrmHandler method mapReleaseFilesResponse.

private SrmReleaseFilesResponse mapReleaseFilesResponse(SrmReleaseFilesRequest request, List<SrmResponse> responses) {
    Map<URI, TSURLReturnStatus> map = new HashMap<>();
    for (SrmResponse srmResponse : responses) {
        SrmReleaseFilesResponse response = (SrmReleaseFilesResponse) srmResponse.getResponse();
        for (TSURLReturnStatus status : response.getArrayOfFileStatuses().getStatusArray()) {
            if (status.getStatus().getStatusCode() == SRM_SUCCESS) {
                map.put(status.getSurl(), status);
            } else if (status.getStatus().getStatusCode() == SRM_INVALID_PATH) {
            // no entry
            } else if (status.getStatus().getStatusCode() == SRM_AUTHORIZATION_FAILURE) {
                map.putIfAbsent(status.getSurl(), status);
            } else if (status.getStatus().getStatusCode() == SRM_FILE_LIFETIME_EXPIRED) {
                map.putIfAbsent(status.getSurl(), status);
            } else if (status.getStatus().getStatusCode() == SRM_FAILURE) {
                map.putIfAbsent(status.getSurl(), status);
            }
        }
    }
    TSURLReturnStatus[] statuses = Stream.of(request.getArrayOfSURLs().getUrlArray()).map(surl -> {
        TSURLReturnStatus status = map.get(surl);
        return (status != null) ? status : new TSURLReturnStatus(surl, new TReturnStatus(SRM_INVALID_PATH, "File not found"));
    }).toArray(TSURLReturnStatus[]::new);
    return new SrmReleaseFilesResponse(getSummaryReturnStatus(statuses), new ArrayOfTSURLReturnStatus(statuses));
}
Also used : SrmResponse(org.dcache.srm.SrmResponse) SrmExtendFileLifeTimeRequest(org.dcache.srm.v2_2.SrmExtendFileLifeTimeRequest) TCopyFileRequest(org.dcache.srm.v2_2.TCopyFileRequest) SRM_PARTIAL_SUCCESS(org.dcache.srm.v2_2.TStatusCode.SRM_PARTIAL_SUCCESS) ArrayOfString(org.dcache.srm.v2_2.ArrayOfString) Map(java.util.Map) SrmStatusOfReserveSpaceRequestRequest(org.dcache.srm.v2_2.SrmStatusOfReserveSpaceRequestRequest) SrmExtendFileLifeTimeResponse(org.dcache.srm.v2_2.SrmExtendFileLifeTimeResponse) SRMException(org.dcache.srm.SRMException) OidcSubjectPrincipal(org.dcache.auth.OidcSubjectPrincipal) CellInfo(dmg.cells.nucleus.CellInfo) TPutRequestFileStatus(org.dcache.srm.v2_2.TPutRequestFileStatus) SrmGetRequestSummaryRequest(org.dcache.srm.v2_2.SrmGetRequestSummaryRequest) TPutFileRequest(org.dcache.srm.v2_2.TPutFileRequest) SrmRmRequest(org.dcache.srm.v2_2.SrmRmRequest) Stream(java.util.stream.Stream) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException) SRM_AUTHENTICATION_FAILURE(org.dcache.srm.v2_2.TStatusCode.SRM_AUTHENTICATION_FAILURE) TStatusCode(org.dcache.srm.v2_2.TStatusCode) LoginAttribute(org.dcache.auth.attributes.LoginAttribute) SrmBringOnlineResponse(org.dcache.srm.v2_2.SrmBringOnlineResponse) ArrayOfTCopyRequestFileStatus(org.dcache.srm.v2_2.ArrayOfTCopyRequestFileStatus) SrmPrepareToPutResponse(org.dcache.srm.v2_2.SrmPrepareToPutResponse) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) NetLoggerBuilder(org.dcache.util.NetLoggerBuilder) Constructor(java.lang.reflect.Constructor) SrmLsRequest(org.dcache.srm.v2_2.SrmLsRequest) Strings(com.google.common.base.Strings) CellStub(org.dcache.cells.CellStub) SrmReleaseSpaceResponse(org.dcache.srm.v2_2.SrmReleaseSpaceResponse) SrmResumeRequestRequest(org.dcache.srm.v2_2.SrmResumeRequestRequest) TRequestSummary(org.dcache.srm.v2_2.TRequestSummary) SrmGetSpaceMetaDataResponse(org.dcache.srm.v2_2.SrmGetSpaceMetaDataResponse) Throwables(com.google.common.base.Throwables) IOException(java.io.IOException) SRM_NON_EMPTY_DIRECTORY(org.dcache.srm.v2_2.TStatusCode.SRM_NON_EMPTY_DIRECTORY) Field(java.lang.reflect.Field) FutureCallback(com.google.common.util.concurrent.FutureCallback) ExecutionException(java.util.concurrent.ExecutionException) TBringOnlineRequestFileStatus(org.dcache.srm.v2_2.TBringOnlineRequestFileStatus) SrmMvResponse(org.dcache.srm.v2_2.SrmMvResponse) TSURLReturnStatus(org.dcache.srm.v2_2.TSURLReturnStatus) SrmExtendFileLifeTimeInSpaceResponse(org.dcache.srm.v2_2.SrmExtendFileLifeTimeInSpaceResponse) SrmAbortRequestResponse(org.dcache.srm.v2_2.SrmAbortRequestResponse) SrmStatusOfBringOnlineRequestRequest(org.dcache.srm.v2_2.SrmStatusOfBringOnlineRequestRequest) SrmSetPermissionResponse(org.dcache.srm.v2_2.SrmSetPermissionResponse) SRM_EXCEED_ALLOCATION(org.dcache.srm.v2_2.TStatusCode.SRM_EXCEED_ALLOCATION) SRM_FILE_BUSY(org.dcache.srm.v2_2.TStatusCode.SRM_FILE_BUSY) SrmRmResponse(org.dcache.srm.v2_2.SrmRmResponse) SrmStatusOfChangeSpaceForFilesRequestResponse(org.dcache.srm.v2_2.SrmStatusOfChangeSpaceForFilesRequestResponse) SrmAbortFilesResponse(org.dcache.srm.v2_2.SrmAbortFilesResponse) SrmCopyResponse(org.dcache.srm.v2_2.SrmCopyResponse) TExtraInfo(org.dcache.srm.v2_2.TExtraInfo) SettableFuture(com.google.common.util.concurrent.SettableFuture) ArrayOfTGetFileRequest(org.dcache.srm.v2_2.ArrayOfTGetFileRequest) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) Collectors.toMap(java.util.stream.Collectors.toMap) SRM_FILE_LIFETIME_EXPIRED(org.dcache.srm.v2_2.TStatusCode.SRM_FILE_LIFETIME_EXPIRED) SrmSetPermissionRequest(org.dcache.srm.v2_2.SrmSetPermissionRequest) RequestCounters(org.dcache.commons.stats.RequestCounters) Method(java.lang.reflect.Method) ImmutableSet(com.google.common.collect.ImmutableSet) Collection(java.util.Collection) SrmGetPermissionResponse(org.dcache.srm.v2_2.SrmGetPermissionResponse) SrmMkdirResponse(org.dcache.srm.v2_2.SrmMkdirResponse) JwtJtiPrincipal(org.dcache.auth.JwtJtiPrincipal) SrmGetPermissionRequest(org.dcache.srm.v2_2.SrmGetPermissionRequest) RemoteException(java.rmi.RemoteException) CacheLoader(com.google.common.cache.CacheLoader) TMetaDataPathDetail(org.dcache.srm.v2_2.TMetaDataPathDetail) ArrayOfTPutRequestFileStatus(org.dcache.srm.v2_2.ArrayOfTPutRequestFileStatus) SrmPrepareToGetRequest(org.dcache.srm.v2_2.SrmPrepareToGetRequest) CuratorFramework(org.apache.curator.framework.CuratorFramework) SrmMvRequest(org.dcache.srm.v2_2.SrmMvRequest) SrmReleaseSpaceRequest(org.dcache.srm.v2_2.SrmReleaseSpaceRequest) SRM_NO_FREE_SPACE(org.dcache.srm.v2_2.TStatusCode.SRM_NO_FREE_SPACE) SRM_INVALID_PATH(org.dcache.srm.v2_2.TStatusCode.SRM_INVALID_PATH) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) SrmExtendFileLifeTimeInSpaceRequest(org.dcache.srm.v2_2.SrmExtendFileLifeTimeInSpaceRequest) Function(java.util.function.Function) SrmGetRequestTokensResponse(org.dcache.srm.v2_2.SrmGetRequestTokensResponse) SrmPutDoneRequest(org.dcache.srm.v2_2.SrmPutDoneRequest) SRMAuthenticationException(org.dcache.srm.SRMAuthenticationException) SrmResponse(org.dcache.srm.SrmResponse) ArrayOfTPutFileRequest(org.dcache.srm.v2_2.ArrayOfTPutFileRequest) SrmStatusOfLsRequestResponse(org.dcache.srm.v2_2.SrmStatusOfLsRequestResponse) SrmRmdirRequest(org.dcache.srm.v2_2.SrmRmdirRequest) SRMInvalidRequestException(org.dcache.srm.SRMInvalidRequestException) SrmStatusOfLsRequestRequest(org.dcache.srm.v2_2.SrmStatusOfLsRequestRequest) SRM_INTERNAL_ERROR(org.dcache.srm.v2_2.TStatusCode.SRM_INTERNAL_ERROR) SrmGetRequestSummaryResponse(org.dcache.srm.v2_2.SrmGetRequestSummaryResponse) Logger(org.slf4j.Logger) SrmResumeRequestResponse(org.dcache.srm.v2_2.SrmResumeRequestResponse) URI(org.apache.axis.types.URI) SrmStatusOfGetRequestResponse(org.dcache.srm.v2_2.SrmStatusOfGetRequestResponse) ArrayOfTSURLReturnStatus(org.dcache.srm.v2_2.ArrayOfTSURLReturnStatus) Subject(javax.security.auth.Subject) TGetRequestFileStatus(org.dcache.srm.v2_2.TGetRequestFileStatus) SRM_TOO_MANY_RESULTS(org.dcache.srm.v2_2.TStatusCode.SRM_TOO_MANY_RESULTS) Collectors.toList(java.util.stream.Collectors.toList) Required(org.springframework.beans.factory.annotation.Required) SrmSuspendRequestRequest(org.dcache.srm.v2_2.SrmSuspendRequestRequest) LoadingCache(com.google.common.cache.LoadingCache) SrmReserveSpaceResponse(org.dcache.srm.v2_2.SrmReserveSpaceResponse) Subjects(org.dcache.auth.Subjects) SRM_SPACE_LIFETIME_EXPIRED(org.dcache.srm.v2_2.TStatusCode.SRM_SPACE_LIFETIME_EXPIRED) SRM_AUTHORIZATION_FAILURE(org.dcache.srm.v2_2.TStatusCode.SRM_AUTHORIZATION_FAILURE) SrmPingRequest(org.dcache.srm.v2_2.SrmPingRequest) SrmAbortFilesRequest(org.dcache.srm.v2_2.SrmAbortFilesRequest) SRM_FAILURE(org.dcache.srm.v2_2.TStatusCode.SRM_FAILURE) SrmCheckPermissionRequest(org.dcache.srm.v2_2.SrmCheckPermissionRequest) ArrayOfTRequestSummary(org.dcache.srm.v2_2.ArrayOfTRequestSummary) CertificateFactories(org.dcache.util.CertificateFactories) SrmPurgeFromSpaceRequest(org.dcache.srm.v2_2.SrmPurgeFromSpaceRequest) PrintWriter(java.io.PrintWriter) SrmPurgeFromSpaceResponse(org.dcache.srm.v2_2.SrmPurgeFromSpaceResponse) TRequestTokenReturn(org.dcache.srm.v2_2.TRequestTokenReturn) TTransferParameters(org.dcache.srm.v2_2.TTransferParameters) SrmLsResponse(org.dcache.srm.v2_2.SrmLsResponse) Set(java.util.Set) SrmReserveSpaceRequest(org.dcache.srm.v2_2.SrmReserveSpaceRequest) InvocationTargetException(java.lang.reflect.InvocationTargetException) ChildData(org.apache.curator.framework.recipes.cache.ChildData) TCopyRequestFileStatus(org.dcache.srm.v2_2.TCopyRequestFileStatus) SrmSuspendRequestResponse(org.dcache.srm.v2_2.SrmSuspendRequestResponse) SrmStatusOfPutRequestRequest(org.dcache.srm.v2_2.SrmStatusOfPutRequestRequest) AccessController(java.security.AccessController) SrmUpdateSpaceResponse(org.dcache.srm.v2_2.SrmUpdateSpaceResponse) SRM_DUPLICATION_ERROR(org.dcache.srm.v2_2.TStatusCode.SRM_DUPLICATION_ERROR) SrmPingResponse(org.dcache.srm.v2_2.SrmPingResponse) SrmStatusOfReserveSpaceRequestResponse(org.dcache.srm.v2_2.SrmStatusOfReserveSpaceRequestResponse) ArrayOfAnyURI(org.dcache.srm.v2_2.ArrayOfAnyURI) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) SRM_NOT_SUPPORTED(org.dcache.srm.v2_2.TStatusCode.SRM_NOT_SUPPORTED) SrmChangeSpaceForFilesResponse(org.dcache.srm.v2_2.SrmChangeSpaceForFilesResponse) ArrayList(java.util.ArrayList) SrmStatusOfCopyRequestRequest(org.dcache.srm.v2_2.SrmStatusOfCopyRequestRequest) SrmGetSpaceTokensResponse(org.dcache.srm.v2_2.SrmGetSpaceTokensResponse) BiConsumer(java.util.function.BiConsumer) SrmCopyRequest(org.dcache.srm.v2_2.SrmCopyRequest) ReturnStatuses.getSummaryReturnStatus(org.dcache.srm.handler.ReturnStatuses.getSummaryReturnStatus) ArrayOfTCopyFileRequest(org.dcache.srm.v2_2.ArrayOfTCopyFileRequest) SrmReleaseFilesResponse(org.dcache.srm.v2_2.SrmReleaseFilesResponse) SrmGetSpaceMetaDataRequest(org.dcache.srm.v2_2.SrmGetSpaceMetaDataRequest) SrmGetTransferProtocolsResponse(org.dcache.srm.v2_2.SrmGetTransferProtocolsResponse) SrmMkdirRequest(org.dcache.srm.v2_2.SrmMkdirRequest) Futures(com.google.common.util.concurrent.Futures) InetAddresses(com.google.common.net.InetAddresses) SrmBringOnlineRequest(org.dcache.srm.v2_2.SrmBringOnlineRequest) ArrayOfTExtraInfo(org.dcache.srm.v2_2.ArrayOfTExtraInfo) CertificateFactory(java.security.cert.CertificateFactory) SRM_FILE_UNAVAILABLE(org.dcache.srm.v2_2.TStatusCode.SRM_FILE_UNAVAILABLE) LoggerFactory(org.slf4j.LoggerFactory) SRM_CUSTOM_STATUS(org.dcache.srm.v2_2.TStatusCode.SRM_CUSTOM_STATUS) PreDestroy(javax.annotation.PreDestroy) AuthenticationHandler(org.dcache.http.AuthenticationHandler) SrmStatusOfUpdateSpaceRequestResponse(org.dcache.srm.v2_2.SrmStatusOfUpdateSpaceRequestResponse) Collectors.toSet(java.util.stream.Collectors.toSet) SRM_INVALID_REQUEST(org.dcache.srm.v2_2.TStatusCode.SRM_INVALID_REQUEST) SRM_NO_USER_SPACE(org.dcache.srm.v2_2.TStatusCode.SRM_NO_USER_SPACE) SrmPrepareToGetResponse(org.dcache.srm.v2_2.SrmPrepareToGetResponse) ImmutableMap(com.google.common.collect.ImmutableMap) SRM_FATAL_INTERNAL_ERROR(org.dcache.srm.v2_2.TStatusCode.SRM_FATAL_INTERNAL_ERROR) SrmGetRequestTokensRequest(org.dcache.srm.v2_2.SrmGetRequestTokensRequest) SrmStatusOfBringOnlineRequestResponse(org.dcache.srm.v2_2.SrmStatusOfBringOnlineRequestResponse) Axis(org.dcache.srm.util.Axis) List(java.util.List) SrmStatusOfChangeSpaceForFilesRequestRequest(org.dcache.srm.v2_2.SrmStatusOfChangeSpaceForFilesRequestRequest) PostConstruct(javax.annotation.PostConstruct) Optional(java.util.Optional) CacheBuilder(com.google.common.cache.CacheBuilder) CellPath(dmg.cells.nucleus.CellPath) X509Credential(eu.emi.security.authn.x509.X509Credential) SrmAbortRequestRequest(org.dcache.srm.v2_2.SrmAbortRequestRequest) SrmPrepareToPutRequest(org.dcache.srm.v2_2.SrmPrepareToPutRequest) CellInfoProvider(dmg.cells.nucleus.CellInfoProvider) ArrayOfTGetRequestFileStatus(org.dcache.srm.v2_2.ArrayOfTGetRequestFileStatus) SrmStatusOfPutRequestResponse(org.dcache.srm.v2_2.SrmStatusOfPutRequestResponse) SRMInternalErrorException(org.dcache.srm.SRMInternalErrorException) SrmStatusOfGetRequestRequest(org.dcache.srm.v2_2.SrmStatusOfGetRequestRequest) HashMap(java.util.HashMap) SrmStatusOfUpdateSpaceRequestRequest(org.dcache.srm.v2_2.SrmStatusOfUpdateSpaceRequestRequest) SrmCheckPermissionResponse(org.dcache.srm.v2_2.SrmCheckPermissionResponse) TGetFileRequest(org.dcache.srm.v2_2.TGetFileRequest) ArrayOfTBringOnlineRequestFileStatus(org.dcache.srm.v2_2.ArrayOfTBringOnlineRequestFileStatus) SrmStatusOfCopyRequestResponse(org.dcache.srm.v2_2.SrmStatusOfCopyRequestResponse) CacheException(diskCacheV111.util.CacheException) SRM_FILE_LOST(org.dcache.srm.v2_2.TStatusCode.SRM_FILE_LOST) SRM_REQUEST_TIMED_OUT(org.dcache.srm.v2_2.TStatusCode.SRM_REQUEST_TIMED_OUT) SrmPutDoneResponse(org.dcache.srm.v2_2.SrmPutDoneResponse) CuratorFrameworkAware(org.dcache.cells.CuratorFrameworkAware) JDC(org.dcache.srm.util.JDC) SrmChangeSpaceForFilesRequest(org.dcache.srm.v2_2.SrmChangeSpaceForFilesRequest) SrmReleaseFilesRequest(org.dcache.srm.v2_2.SrmReleaseFilesRequest) SrmUpdateSpaceRequest(org.dcache.srm.v2_2.SrmUpdateSpaceRequest) RequestExecutionTimeGauges(org.dcache.commons.stats.RequestExecutionTimeGauges) SRMAuthorizationException(org.dcache.srm.SRMAuthorizationException) SRM_ABORTED(org.dcache.srm.v2_2.TStatusCode.SRM_ABORTED) SRM_SUCCESS(org.dcache.srm.v2_2.TStatusCode.SRM_SUCCESS) ArrayOfTMetaDataPathDetail(org.dcache.srm.v2_2.ArrayOfTMetaDataPathDetail) US_ASCII(java.nio.charset.StandardCharsets.US_ASCII) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) SrmRmdirResponse(org.dcache.srm.v2_2.SrmRmdirResponse) SrmGetSpaceTokensRequest(org.dcache.srm.v2_2.SrmGetSpaceTokensRequest) SrmRequest(org.dcache.srm.SrmRequest) PathChildrenCache(org.apache.curator.framework.recipes.cache.PathChildrenCache) ArrayOfTRequestTokenReturn(org.dcache.srm.v2_2.ArrayOfTRequestTokenReturn) SrmGetTransferProtocolsRequest(org.dcache.srm.v2_2.SrmGetTransferProtocolsRequest) SrmReleaseFilesResponse(org.dcache.srm.v2_2.SrmReleaseFilesResponse) HashMap(java.util.HashMap) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) TSURLReturnStatus(org.dcache.srm.v2_2.TSURLReturnStatus) ArrayOfTSURLReturnStatus(org.dcache.srm.v2_2.ArrayOfTSURLReturnStatus) ArrayOfTSURLReturnStatus(org.dcache.srm.v2_2.ArrayOfTSURLReturnStatus) URI(org.apache.axis.types.URI) ArrayOfAnyURI(org.dcache.srm.v2_2.ArrayOfAnyURI)

Example 2 with ArrayOfTSURLReturnStatus

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

the class SRMV2CopyJob method done.

@Override
public void done(boolean success, String error) {
    synchronized (this) {
        if (isDone) {
            return;
        }
        isDone = true;
    }
    try {
        URI[] surlArray = new URI[] { new URI(surl.toASCIIString()) };
        if (!success) {
            SrmAbortFilesRequest srmAbortFilesRequest = new SrmAbortFilesRequest();
            srmAbortFilesRequest.setRequestToken(requestToken);
            srmAbortFilesRequest.setArrayOfSURLs(new ArrayOfAnyURI(surlArray));
            SrmAbortFilesResponse srmAbortFilesResponse = srm.srmAbortFiles(srmAbortFilesRequest);
            if (srmAbortFilesResponse == null) {
                logger.elog("srmAbortFilesResponse is null");
            } else {
                TReturnStatus returnStatus = srmAbortFilesResponse.getReturnStatus();
                if (returnStatus == null) {
                    logger.elog("srmAbortFiles return status is null");
                } else {
                    logger.log("srmAbortFiles status code=" + returnStatus.getStatusCode());
                }
            }
        } else if (isSrmPrepareToGet) {
            SrmReleaseFilesRequest srmReleaseFilesRequest = new SrmReleaseFilesRequest();
            srmReleaseFilesRequest.setRequestToken(requestToken);
            srmReleaseFilesRequest.setArrayOfSURLs(new ArrayOfAnyURI(surlArray));
            SrmReleaseFilesResponse srmReleaseFilesResponse = srm.srmReleaseFiles(srmReleaseFilesRequest);
            TReturnStatus returnStatus = srmReleaseFilesResponse.getReturnStatus();
            if (returnStatus == null) {
                success = false;
                error = "srmReleaseFilesResponse return status is null";
            } else {
                logger.log("srmReleaseFilesResponse status code=" + returnStatus.getStatusCode());
            }
        } else {
            SrmPutDoneRequest srmPutDoneRequest = new SrmPutDoneRequest();
            srmPutDoneRequest.setRequestToken(requestToken);
            srmPutDoneRequest.setArrayOfSURLs(new ArrayOfAnyURI(surlArray));
            SrmPutDoneResponse srmPutDoneResponse = srm.srmPutDone(srmPutDoneRequest);
            TReturnStatus returnStatus = srmPutDoneResponse.getReturnStatus();
            if (returnStatus == null) {
                success = false;
                error = "srmPutDone return status is null";
            } else if (returnStatus.getStatusCode() != TStatusCode.SRM_SUCCESS) {
                success = false;
                ArrayOfTSURLReturnStatus arrayOfFileStatuses = srmPutDoneResponse.getArrayOfFileStatuses();
                if (arrayOfFileStatuses != null && arrayOfFileStatuses.getStatusArray() != null && arrayOfFileStatuses.getStatusArray().length > 0 && arrayOfFileStatuses.getStatusArray()[0].getStatus().getStatusCode() != TStatusCode.SRM_SUCCESS && !Strings.isNullOrEmpty(arrayOfFileStatuses.getStatusArray()[0].getStatus().getExplanation())) {
                    error = arrayOfFileStatuses.getStatusArray()[0].getStatus().getExplanation();
                } else {
                    error = returnStatus.getExplanation();
                }
            }
        }
    } catch (URI.MalformedURIException | RemoteException e) {
        if (success) {
            success = false;
            error = e.toString();
        } else {
            logger.elog(e.toString());
        }
    } finally {
        if (success) {
            if (isSrmPrepareToGet) {
                client.setReportSucceeded(surl, null);
            } else {
                client.setReportSucceeded(null, surl);
            }
        } else {
            error = "received TURL but failed to copy: " + error;
            if (isSrmPrepareToGet) {
                client.setReportFailed(surl, null, error);
            } else {
                client.setReportFailed(null, surl, error);
            }
        }
    }
}
Also used : SrmAbortFilesRequest(org.dcache.srm.v2_2.SrmAbortFilesRequest) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) SrmReleaseFilesRequest(org.dcache.srm.v2_2.SrmReleaseFilesRequest) URI(org.apache.axis.types.URI) ArrayOfAnyURI(org.dcache.srm.v2_2.ArrayOfAnyURI) SrmPutDoneRequest(org.dcache.srm.v2_2.SrmPutDoneRequest) SrmReleaseFilesResponse(org.dcache.srm.v2_2.SrmReleaseFilesResponse) SrmPutDoneResponse(org.dcache.srm.v2_2.SrmPutDoneResponse) SrmAbortFilesResponse(org.dcache.srm.v2_2.SrmAbortFilesResponse) ArrayOfTSURLReturnStatus(org.dcache.srm.v2_2.ArrayOfTSURLReturnStatus) RemoteException(java.rmi.RemoteException) ArrayOfAnyURI(org.dcache.srm.v2_2.ArrayOfAnyURI)

Example 3 with ArrayOfTSURLReturnStatus

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

the class SrmReleaseFiles method unpinBySURLAndRequestToken.

private SrmReleaseFilesResponse unpinBySURLAndRequestToken(String requestToken, org.apache.axis.types.URI[] surls) throws SRMInternalErrorException {
    TSURLReturnStatus[] surlReturnStatusArray = new TSURLReturnStatus[surls.length];
    for (int i = 0; i < surls.length; ++i) {
        org.apache.axis.types.URI surl = surls[i];
        TReturnStatus returnStatus = BringOnlineFileRequest.unpinBySURLandRequestToken(storage, user, requestToken, URI.create(surl.toString()));
        surlReturnStatusArray[i] = new TSURLReturnStatus(surl, returnStatus);
    }
    return new SrmReleaseFilesResponse(getSummaryReturnStatus(surlReturnStatusArray), new ArrayOfTSURLReturnStatus(surlReturnStatusArray));
}
Also used : SrmReleaseFilesResponse(org.dcache.srm.v2_2.SrmReleaseFilesResponse) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) ArrayOfTSURLReturnStatus(org.dcache.srm.v2_2.ArrayOfTSURLReturnStatus) TSURLReturnStatus(org.dcache.srm.v2_2.TSURLReturnStatus) ArrayOfTSURLReturnStatus(org.dcache.srm.v2_2.ArrayOfTSURLReturnStatus)

Example 4 with ArrayOfTSURLReturnStatus

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

the class SrmRm method srmRm.

private SrmRmResponse srmRm() throws DataAccessException, InterruptedException, SRMInternalErrorException, SRMInvalidRequestException {
    if (request.getArrayOfSURLs() == null) {
        throw new SRMInvalidRequestException("arrayOfSURLs is empty");
    }
    org.apache.axis.types.URI[] surls = request.getArrayOfSURLs().getUrlArray();
    if (surls == null || surls.length == 0) {
        throw new SRMInvalidRequestException("arrayOfSURLs is empty");
    }
    TSURLReturnStatus[] returnStatuses = new TSURLReturnStatus[surls.length];
    Semaphore semaphore = new Semaphore(sizeOfSingleRemoveBatch);
    for (int i = 0; i < surls.length; i++) {
        semaphore.acquire();
        returnStatuses[i] = new TSURLReturnStatus(surls[i], null);
        URI surl = URI.create(surls[i].toString());
        storage.removeFile(user, surl, new Callback(semaphore, returnStatuses[i]));
    }
    semaphore.acquire(sizeOfSingleRemoveBatch);
    for (int i = 0; i < surls.length; i++) {
        TSURLReturnStatus returnStatus = returnStatuses[i];
        if (returnStatus.getStatus().getStatusCode() == TStatusCode.SRM_INTERNAL_ERROR) {
            throw new SRMInternalErrorException(returnStatus.getStatus().getExplanation());
        }
        if (returnStatus.getStatus().getStatusCode() == TStatusCode.SRM_SUCCESS || returnStatus.getStatus().getStatusCode() == TStatusCode.SRM_INVALID_PATH) {
            // [SRM 2.2, 4.3.2, e)] srmRm aborts the SURLs from srmPrepareToPut requests not yet
            // in SRM_PUT_DONE state, and must set its file status as SRM_ABORTED.
            // 
            // [SRM 2.2, 4.3.2, f)] srmRm must remove SURLs even if the statuses of the SURLs
            // are SRM_FILE_BUSY. In this case, operations such as srmPrepareToPut or srmCopy
            // that holds the SURL status as SRM_FILE_BUSY must return SRM_INVALID_PATH upon
            // status request or srmPutDone.
            // 
            // It seems the SRM specs is undecided about whether to move put requests to
            // SRM_ABORTED or SRM_INVALID_PATH. We choose SRM_ABORTED as it seems like the saner
            // of the two options.
            // [SRM 2.2, 4.3.2, d)] srmLs,srmPrepareToGet or srmBringOnline must not find these
            // removed files any more. It must set file requests on SURL from srmPrepareToGet
            // as SRM_ABORTED.
            URI surl = URI.create(surls[i].toString());
            try {
                if (srm.abortTransfers(surl, "File was deleted by request " + JDC.getSession() + ".")) {
                    returnStatus.setStatus(new TReturnStatus(TStatusCode.SRM_SUCCESS, "Upload was aborted."));
                }
            } catch (SRMException e) {
                returnStatus.setStatus(new TReturnStatus(e.getStatusCode(), e.getMessage()));
            }
        }
    }
    return new SrmRmResponse(ReturnStatuses.getSummaryReturnStatus(returnStatuses), new ArrayOfTSURLReturnStatus(returnStatuses));
}
Also used : TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) Semaphore(java.util.concurrent.Semaphore) URI(java.net.URI) SRMInternalErrorException(org.dcache.srm.SRMInternalErrorException) RemoveFileCallback(org.dcache.srm.RemoveFileCallback) SRMException(org.dcache.srm.SRMException) ArrayOfTSURLReturnStatus(org.dcache.srm.v2_2.ArrayOfTSURLReturnStatus) TSURLReturnStatus(org.dcache.srm.v2_2.TSURLReturnStatus) ArrayOfTSURLReturnStatus(org.dcache.srm.v2_2.ArrayOfTSURLReturnStatus) SrmRmResponse(org.dcache.srm.v2_2.SrmRmResponse) SRMInvalidRequestException(org.dcache.srm.SRMInvalidRequestException)

Example 5 with ArrayOfTSURLReturnStatus

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

the class SrmPutDone method srmPutDone.

private SrmPutDoneResponse srmPutDone() throws SRMInvalidRequestException, SRMRequestTimedOutException, SRMAbortedException, SRMInternalErrorException, SRMAuthorizationException {
    URI[] surls = getSurls(request);
    PutRequest putRequest = Request.getRequest(request.getRequestToken(), PutRequest.class);
    try (JDC ignored = putRequest.applyJdc()) {
        putRequest.wlock();
        try {
            if (!user.hasAccessTo(putRequest)) {
                throw new SRMAuthorizationException("User is not the owner of request " + request.getRequestToken() + ".");
            }
            switch(putRequest.getState()) {
                case FAILED:
                    if (putRequest.getStatusCode() == TStatusCode.SRM_REQUEST_TIMED_OUT) {
                        throw new SRMRequestTimedOutException("Total request time exceeded");
                    }
                    break;
                case CANCELED:
                    throw new SRMAbortedException("Request has been aborted.");
            }
            TSURLReturnStatus[] returnStatuses = new TSURLReturnStatus[surls.length];
            for (int i = 0; i < surls.length; ++i) {
                if (surls[i] == null) {
                    throw new SRMInvalidRequestException("SiteURLs[" + (i + 1) + "] is null.");
                }
                TReturnStatus returnStatus;
                try {
                    PutFileRequest fileRequest = putRequest.getFileRequestBySurl(java.net.URI.create(surls[i].toString()));
                    try (JDC ignore = fileRequest.applyJdc()) {
                        returnStatus = fileRequest.done(this.user);
                    }
                } catch (SRMFileRequestNotFoundException e) {
                    returnStatus = new TReturnStatus(TStatusCode.SRM_INVALID_PATH, "File does not exist.");
                }
                returnStatuses[i] = new TSURLReturnStatus(surls[i], returnStatus);
            }
            putRequest.updateStatus();
            return new SrmPutDoneResponse(ReturnStatuses.getSummaryReturnStatus(returnStatuses), new ArrayOfTSURLReturnStatus(returnStatuses));
        } finally {
            putRequest.wunlock();
        }
    }
}
Also used : SRMAuthorizationException(org.dcache.srm.SRMAuthorizationException) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) SRMFileRequestNotFoundException(org.dcache.srm.SRMFileRequestNotFoundException) JDC(org.dcache.srm.util.JDC) SRMAbortedException(org.dcache.srm.SRMAbortedException) PutRequest(org.dcache.srm.request.PutRequest) ArrayOfAnyURI(org.dcache.srm.v2_2.ArrayOfAnyURI) URI(org.apache.axis.types.URI) SRMRequestTimedOutException(org.dcache.srm.SRMRequestTimedOutException) PutFileRequest(org.dcache.srm.request.PutFileRequest) SrmPutDoneResponse(org.dcache.srm.v2_2.SrmPutDoneResponse) ArrayOfTSURLReturnStatus(org.dcache.srm.v2_2.ArrayOfTSURLReturnStatus) TSURLReturnStatus(org.dcache.srm.v2_2.TSURLReturnStatus) ArrayOfTSURLReturnStatus(org.dcache.srm.v2_2.ArrayOfTSURLReturnStatus) SRMInvalidRequestException(org.dcache.srm.SRMInvalidRequestException)

Aggregations

ArrayOfTSURLReturnStatus (org.dcache.srm.v2_2.ArrayOfTSURLReturnStatus)8 TReturnStatus (org.dcache.srm.v2_2.TReturnStatus)7 TSURLReturnStatus (org.dcache.srm.v2_2.TSURLReturnStatus)7 ArrayOfAnyURI (org.dcache.srm.v2_2.ArrayOfAnyURI)6 SrmReleaseFilesResponse (org.dcache.srm.v2_2.SrmReleaseFilesResponse)5 SRMInvalidRequestException (org.dcache.srm.SRMInvalidRequestException)4 URI (java.net.URI)3 URI (org.apache.axis.types.URI)3 JDC (org.dcache.srm.util.JDC)3 SrmAbortFilesResponse (org.dcache.srm.v2_2.SrmAbortFilesResponse)3 SrmPutDoneResponse (org.dcache.srm.v2_2.SrmPutDoneResponse)3 RemoteException (java.rmi.RemoteException)2 SRMAuthorizationException (org.dcache.srm.SRMAuthorizationException)2 SRMException (org.dcache.srm.SRMException)2 SRMInternalErrorException (org.dcache.srm.SRMInternalErrorException)2 SrmAbortFilesRequest (org.dcache.srm.v2_2.SrmAbortFilesRequest)2 SrmPutDoneRequest (org.dcache.srm.v2_2.SrmPutDoneRequest)2 SrmReleaseFilesRequest (org.dcache.srm.v2_2.SrmReleaseFilesRequest)2 SrmRmResponse (org.dcache.srm.v2_2.SrmRmResponse)2 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1