public List<ShareACL> queryExistingShareACLs() { List<ShareACL> aclList = new ArrayList<ShareACL>(); List<CifsShareACL> dbShareAclList = queryDBShareACLs(); if (dbShareAclList != null) { Iterator<CifsShareACL> shareAclIter = dbShareAclList.iterator(); while (shareAclIter.hasNext()) { CifsShareACL dbShareAcl = shareAclIter.next(); if (shareName.equals(dbShareAcl.getShareName())) { ShareACL acl = new ShareACL(); acl.setShareName(shareName); acl.setDomain(dbShareAcl.getDomain()); acl.setUser(dbShareAcl.getUser()); acl.setGroup(dbShareAcl.getGroup()); acl.setPermission(dbShareAcl.getPermission()); if (this.fs != null) { acl.setFileSystemId(this.fs.getId()); } else { acl.setSnapshotId(this.snapshot.getId()); } aclList.add(acl); } } } return aclList; }
private void validatePermissions(ShareACL acl) { if (acl == null) { return; } /* * String permissionTypeValue = acl.getPermissionType(); try { * SharePermissionType permissionType = SharePermissionType * .valueOf(permissionTypeValue.toUpperCase()); if (permissionType != * null) { acl.proceedToNextStep(); } } catch (Exception e) { * _log.error("Invalid value for permission type: {}", * permissionTypeValue); * acl.cancelNextStep(ShareACLOperationErrorType.INVALID_PERMISSION_TYPE * ); return; } */ String permissionValue = acl.getPermission(); try { SharePermission permission = SharePermission.valueOf(permissionValue.toUpperCase()); if (permission != null) { acl.setPermission(getFormattedPermissionText(permission)); acl.proceedToNextStep(); } } catch (Exception e) { _log.error("Invalid value for permission: {}", permissionValue); acl.cancelNextStep(ShareACLOperationErrorType.INVALID_PERMISSION); return; } if (this.snapshot != null) { // Snapshot share permission must be read only if (!SharePermission.READ.name().equalsIgnoreCase(acl.getPermission())) { _log.error("Snapshot permission should be read only"); acl.cancelNextStep(ShareACLOperationErrorType.SNAPSHOT_SHARE_SHOULD_BE_READ_ONLY); } } }