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); } } }
private void reportAddErrors(CifsShareACLUpdateParams param) { String opName = ShareACLOperationType.ADD.name(); // Report Add ACL Errors ShareACLs shareAcls = param.getAclsToAdd(); if (shareAcls == null || shareAcls.getShareACLs().size() == 0) return; List<ShareACL> shareAclList = shareAcls.getShareACLs(); for (ShareACL acl : shareAclList) { if (!acl.canProceedToNextStep()) { ShareACLOperationErrorType error = acl.getErrorType(); switch (error) { case SNAPSHOT_SHARE_SHOULD_BE_READ_ONLY: { throw APIException.badRequests.snapshotSMBSharePermissionReadOnly(); } case INVALID_PERMISSION: { if (acl.getPermission() != null) { throw APIException.badRequests.invalidPermissionForACL(acl.getPermission()); } else { throw APIException.badRequests.missingValueInACE(opName, REQUEST_PARAM_PERMISSION); } } case USER_AND_GROUP_PROVIDED: { throw APIException.badRequests.bothUserAndGroupInACLFound( acl.getUser(), acl.getGroup()); } case USER_OR_GROUP_NOT_PROVIDED: { throw APIException.badRequests.missingUserOrGroupInACE(opName); } case MULTIPLE_ACES_WITH_SAME_USER_OR_GROUP: { String userOrGroup = acl.getUser() == null ? acl.getGroup() : acl.getUser(); throw APIException.badRequests.multipleACLsWithUserOrGroupFound(opName, userOrGroup); } case MULTIPLE_DOMAINS_FOUND: { String domain1 = acl.getDomain(); String userOrGroup = acl.getUser() == null ? acl.getGroup() : acl.getUser(); String domain2 = userOrGroup.substring(0, userOrGroup.indexOf("\\")); throw APIException.badRequests.multipleDomainsFound(opName, domain1, domain2); } case ACL_EXISTS: { throw APIException.badRequests.shareACLAlreadyExists(opName, acl.toString()); } // case ACL_NOT_FOUND: default: break; } } } }