use of org.dcache.srm.v2_2.TPermissionType in project dcache by dCache.
the class SRMSetPermissionClientV2 method start.
@Override
public void start() throws Exception {
checkCredentialValid();
URI uri = new URI(surl_string);
SrmSetPermissionRequest req = new SrmSetPermissionRequest();
req.setSURL(uri);
TPermissionType type = TPermissionType.fromString(configuration.getSetPermissionType());
req.setPermissionType(type);
TPermissionMode mode = null;
if (configuration.getSetOwnerPermissionMode() != null) {
mode = TPermissionMode.fromString(configuration.getSetOwnerPermissionMode());
}
req.setOwnerPermission(mode);
ArrayOfTGroupPermission arrayOfGroupPermissions = new ArrayOfTGroupPermission();
TGroupPermission[] grouppermissions = null;
if (configuration.getSetGroupPermissionMode() != null) {
grouppermissions = new TGroupPermission[1];
grouppermissions[0] = new TGroupPermission();
grouppermissions[0].setMode(TPermissionMode.fromString(configuration.getSetGroupPermissionMode()));
grouppermissions[0].setGroupID(DEFAULT_DUMMY_GROUP_ID);
}
arrayOfGroupPermissions.setGroupPermissionArray(grouppermissions);
req.setArrayOfGroupPermissions(arrayOfGroupPermissions);
TPermissionMode other = null;
if (configuration.getSetOtherPermissionMode() != null) {
other = TPermissionMode.fromString(configuration.getSetOtherPermissionMode());
}
req.setOtherPermission(other);
configuration.getStorageSystemInfo().ifPresent(req::setStorageSystemInfo);
SrmSetPermissionResponse resp = srm.srmSetPermission(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());
System.exit(1);
} else {
System.exit(0);
}
} catch (Exception e) {
throw e;
}
}
use of org.dcache.srm.v2_2.TPermissionType in project dcache by dCache.
the class SrmSetPermission method srmSetPermission.
private SrmSetPermissionResponse srmSetPermission() throws SRMException {
URI surl = URI.create(request.getSURL().toString());
FileMetaData fmd = storage.getFileMetaData(user, surl, false);
TPermissionType permissionType = request.getPermissionType();
if (permissionType == TPermissionType.REMOVE) {
/* [ SRM 2.2, 3.1.2 ]
*
* h) If TPermissionType is REMOVE, then the TPermissionMode must be ignored.
*
* We interpret this requirement to apply to user and group ACLs only. Since
* we don't support these, we don't support REMOVE.
*/
return getFailedResponse(ACL_NOT_SUPPORTED, TStatusCode.SRM_NOT_SUPPORTED);
}
TPermissionMode ownerMode = request.getOwnerPermission();
TPermissionMode otherMode = request.getOtherPermission();
TPermissionMode groupMode = null;
ArrayOfTUserPermission userPermissions = request.getArrayOfUserPermissions();
if (userPermissions != null) {
return getFailedResponse(ACL_NOT_SUPPORTED, TStatusCode.SRM_NOT_SUPPORTED);
}
ArrayOfTGroupPermission groupPermissions = request.getArrayOfGroupPermissions();
if (groupPermissions != null && groupPermissions.getGroupPermissionArray() != null) {
switch(groupPermissions.getGroupPermissionArray().length) {
case 0:
break;
case 1:
TGroupPermission permission = groupPermissions.getGroupPermissionArray()[0];
String group = permission.getGroupID();
if (!group.equals("-") && !group.equals(fmd.group)) {
/* The dash is a special dCache convention used by our own SRM client to
* indicate that the POSIX group permissions should be updated.
*/
return getFailedResponse(ACL_NOT_SUPPORTED, TStatusCode.SRM_NOT_SUPPORTED);
}
groupMode = permission.getMode();
break;
default:
return getFailedResponse(ACL_NOT_SUPPORTED, TStatusCode.SRM_NOT_SUPPORTED);
}
}
fmd.permMode = toNewPermissions(fmd.permMode, permissionType, ownerMode, groupMode, otherMode);
storage.setFileMetaData(user, surl, fmd);
return new SrmSetPermissionResponse(new TReturnStatus(TStatusCode.SRM_SUCCESS, null));
}
Aggregations