use of org.dcache.srm.v2_2.SrmCheckPermissionRequest in project dcache by dCache.
the class AxisSrmFileSystem method checkPermissions.
@Nonnull
@Override
public TSURLPermissionReturn[] checkPermissions(URI... surls) throws RemoteException, SRMException {
checkArgument(surls.length > 0);
SrmCheckPermissionResponse response = srm.srmCheckPermission(new SrmCheckPermissionRequest(new ArrayOfAnyURI(surls), null, null));
checkSuccess(response.getReturnStatus(), TStatusCode.SRM_SUCCESS, TStatusCode.SRM_PARTIAL_SUCCESS, TStatusCode.SRM_FAILURE);
TSURLPermissionReturn[] permissionArray = response.getArrayOfPermissions() == null ? null : response.getArrayOfPermissions().getSurlPermissionArray();
if (permissionArray == null || permissionArray.length == 0) {
checkSuccess(response.getReturnStatus(), TStatusCode.SRM_SUCCESS, TStatusCode.SRM_PARTIAL_SUCCESS);
throw new SrmProtocolException("Server reply lacks permission array.");
}
if (permissionArray.length != surls.length) {
throw new SrmProtocolException("Server returns permissionArray " + "with wrong size (" + permissionArray.length + " != " + surls.length + ")");
}
return permissionArray;
}
use of org.dcache.srm.v2_2.SrmCheckPermissionRequest in project dcache by dCache.
the class SRMCheckPermissionClientV2 method start.
@Override
public void start() throws Exception {
checkCredentialValid();
ArrayOfAnyURI surlarray = new ArrayOfAnyURI();
URI[] uriarray = new URI[surl_string.length];
URI uri;
for (int i = 0; i < uriarray.length; i++) {
uri = new URI(surl_string[i]);
uriarray[i] = uri;
}
surlarray.setUrlArray(uriarray);
SrmCheckPermissionRequest req = new SrmCheckPermissionRequest();
req.setArrayOfSURLs(surlarray);
configuration.getStorageSystemInfo().ifPresent(req::setStorageSystemInfo);
SrmCheckPermissionResponse resp = srm.srmCheckPermission(req);
try {
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());
}
ArrayOfTSURLPermissionReturn permissions = resp.getArrayOfPermissions();
TSURLPermissionReturn[] permissionarray = permissions.getSurlPermissionArray();
StringBuilder txt = new StringBuilder();
for (TSURLPermissionReturn permission : permissionarray) {
txt.append("# file : ").append(permission.getSurl()).append("\n");
if (rs.getStatusCode() != TStatusCode.SRM_SUCCESS) {
txt.append("Return code: ").append(permission.getStatus().getStatusCode().toString()).append("\n");
txt.append("Explanation: ").append(permission.getStatus().getExplanation()).append("\n");
if (permission.getStatus().getStatusCode() != TStatusCode.SRM_SUCCESS) {
continue;
}
}
TPermissionMode mode = permission.getPermission();
txt.append("permission mode:").append(mode.toString()).append("\n");
}
System.out.println(txt.toString());
if (rs.getStatusCode() != TStatusCode.SRM_SUCCESS) {
System.exit(1);
} else {
System.exit(0);
}
} catch (Exception e) {
throw e;
}
}
Aggregations