Search in sources :

Example 1 with ArrayOfTExtraInfo

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

the class SrmHandler method buildExtraInfo.

private ArrayOfTExtraInfo buildExtraInfo(Map<String, String> items) {
    if (items.isEmpty()) {
        return null;
    }
    TExtraInfo[] extraInfo = new TExtraInfo[items.size()];
    int i = 0;
    for (Map.Entry<String, String> item : items.entrySet()) {
        extraInfo[i++] = new TExtraInfo(item.getKey(), Strings.emptyToNull(item.getValue()));
    }
    return new ArrayOfTExtraInfo(extraInfo);
}
Also used : TExtraInfo(org.dcache.srm.v2_2.TExtraInfo) ArrayOfTExtraInfo(org.dcache.srm.v2_2.ArrayOfTExtraInfo) ArrayOfString(org.dcache.srm.v2_2.ArrayOfString) ArrayOfTExtraInfo(org.dcache.srm.v2_2.ArrayOfTExtraInfo) Map(java.util.Map) Collectors.toMap(java.util.stream.Collectors.toMap) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap)

Example 2 with ArrayOfTExtraInfo

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

the class SrmPrepareToGet method isStagingAllowed.

private boolean isStagingAllowed() throws SRMInvalidRequestException {
    boolean allowed = true;
    ArrayOfTExtraInfo info = request.getStorageSystemInfo();
    if (info != null) {
        TExtraInfo[] array = info.getExtraInfoArray();
        if (array != null) {
            List<String> stageValues = Arrays.stream(array).filter(i -> Objects.equals(i.getKey(), "stage")).map(i -> i.getValue()).collect(Collectors.toList());
            if (!stageValues.isEmpty()) {
                if (stageValues.size() > 1) {
                    throw new SRMInvalidRequestException("Multiple storageSystemInfo 'stage' entries.");
                }
                String stageValue = stageValues.get(0);
                if (stageValue == null) {
                    throw new SRMInvalidRequestException("Missing value for storageSystemInfo 'stage' entry.");
                }
                switch(stageValue) {
                    case "allow":
                        allowed = true;
                        break;
                    case "deny":
                        allowed = false;
                        break;
                    default:
                        throw new SRMInvalidRequestException("Invalid value \"" + stageValue + "\" for storageSystemInfo 'stage' entry, must be \"allow\" or \"deny\"");
                }
            }
        }
    }
    return allowed;
}
Also used : Arrays(java.util.Arrays) SRMInternalErrorException(org.dcache.srm.SRMInternalErrorException) ArrayOfTExtraInfo(org.dcache.srm.v2_2.ArrayOfTExtraInfo) TExtraInfo(org.dcache.srm.v2_2.TExtraInfo) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) LoggerFactory(org.slf4j.LoggerFactory) IllegalStateTransition(org.dcache.srm.scheduler.IllegalStateTransition) TGetFileRequest(org.dcache.srm.v2_2.TGetFileRequest) Lifetimes(org.dcache.srm.util.Lifetimes) AbstractStorageElement(org.dcache.srm.AbstractStorageElement) Predicates.in(com.google.common.base.Predicates.in) SRMInvalidRequestException(org.dcache.srm.SRMInvalidRequestException) Arrays.asList(java.util.Arrays.asList) Objects.requireNonNull(java.util.Objects.requireNonNull) Tools(org.dcache.srm.util.Tools) GetRequest(org.dcache.srm.request.GetRequest) URI(java.net.URI) SrmPrepareToGetResponse(org.dcache.srm.v2_2.SrmPrepareToGetResponse) SRM(org.dcache.srm.SRM) JDC(org.dcache.srm.util.JDC) Logger(org.slf4j.Logger) TTransferParameters(org.dcache.srm.v2_2.TTransferParameters) Configuration(org.dcache.srm.util.Configuration) SRMUser(org.dcache.srm.SRMUser) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) List(java.util.List) SrmPrepareToGetRequest(org.dcache.srm.v2_2.SrmPrepareToGetRequest) SRMNotSupportedException(org.dcache.srm.SRMNotSupportedException) Optional(java.util.Optional) TStatusCode(org.dcache.srm.v2_2.TStatusCode) Iterables.any(com.google.common.collect.Iterables.any) ArrayOfTExtraInfo(org.dcache.srm.v2_2.ArrayOfTExtraInfo) TExtraInfo(org.dcache.srm.v2_2.TExtraInfo) ArrayOfTExtraInfo(org.dcache.srm.v2_2.ArrayOfTExtraInfo) SRMInvalidRequestException(org.dcache.srm.SRMInvalidRequestException)

Example 3 with ArrayOfTExtraInfo

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

the class SRMPingClientV2 method start.

@Override
public void start() throws IOException {
    SrmPingRequest request = new SrmPingRequest();
    SrmPingResponse response = srm.srmPing(request);
    say("received response");
    if (response == null) {
        throw new IOException(" null response");
    }
    StringBuilder sb = new StringBuilder();
    sb.append("VersionInfo : ").append(response.getVersionInfo()).append("\n");
    if (response.getOtherInfo() != null) {
        ArrayOfTExtraInfo info = response.getOtherInfo();
        if (info.getExtraInfoArray() != null) {
            for (int i = 0; i < info.getExtraInfoArray().length; i++) {
                TExtraInfo extraInfo = info.getExtraInfoArray()[i];
                sb.append(extraInfo.getKey()).append(":").append(extraInfo.getValue()).append("\n");
            }
        }
    }
    System.out.println(sb.toString());
}
Also used : ArrayOfTExtraInfo(org.dcache.srm.v2_2.ArrayOfTExtraInfo) TExtraInfo(org.dcache.srm.v2_2.TExtraInfo) SrmPingRequest(org.dcache.srm.v2_2.SrmPingRequest) SrmPingResponse(org.dcache.srm.v2_2.SrmPingResponse) IOException(java.io.IOException) ArrayOfTExtraInfo(org.dcache.srm.v2_2.ArrayOfTExtraInfo)

Example 4 with ArrayOfTExtraInfo

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

the class SrmCopy method getExtraInfo.

private static ImmutableMap<String, String> getExtraInfo(SrmCopyRequest request) {
    ArrayOfTExtraInfo sourceStorageSystemInfo = request.getSourceStorageSystemInfo();
    if (sourceStorageSystemInfo == null) {
        return ImmutableMap.of();
    }
    TExtraInfo[] extraInfoArray = sourceStorageSystemInfo.getExtraInfoArray();
    if (extraInfoArray == null || extraInfoArray.length <= 0) {
        return ImmutableMap.of();
    }
    ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
    for (TExtraInfo extraInfo : extraInfoArray) {
        builder.put(extraInfo.getKey(), extraInfo.getValue());
    }
    return builder.build();
}
Also used : ArrayOfTExtraInfo(org.dcache.srm.v2_2.ArrayOfTExtraInfo) TExtraInfo(org.dcache.srm.v2_2.TExtraInfo) ArrayOfTExtraInfo(org.dcache.srm.v2_2.ArrayOfTExtraInfo) ImmutableMap(com.google.common.collect.ImmutableMap)

Aggregations

ArrayOfTExtraInfo (org.dcache.srm.v2_2.ArrayOfTExtraInfo)4 TExtraInfo (org.dcache.srm.v2_2.TExtraInfo)4 ImmutableMap (com.google.common.collect.ImmutableMap)2 Predicates.in (com.google.common.base.Predicates.in)1 Iterables.any (com.google.common.collect.Iterables.any)1 IOException (java.io.IOException)1 URI (java.net.URI)1 Arrays (java.util.Arrays)1 Arrays.asList (java.util.Arrays.asList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Objects.requireNonNull (java.util.Objects.requireNonNull)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 Collectors.toMap (java.util.stream.Collectors.toMap)1 AbstractStorageElement (org.dcache.srm.AbstractStorageElement)1 SRM (org.dcache.srm.SRM)1 SRMInternalErrorException (org.dcache.srm.SRMInternalErrorException)1