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);
}
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;
}
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());
}
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();
}
Aggregations