use of com.emc.storageos.volumecontroller.FileShareExport.SecurityTypes in project coprhd-controller by CoprHD.
the class FileService method verifyExports.
/**
* Since, Modifying an export is not allowed
* This method verifies the existing export params with the new one issued to modify.
*
* @param fs
* @param param
*/
private void verifyExports(FileShare fs, FileExportUpdateParam param, String permissions, String securityType, String rootUserMapping, String path) {
// Check to see if th permission passed in is valid
Boolean allowedPermission = false;
for (Permissions me : Permissions.values()) {
if (me.name().equalsIgnoreCase(permissions)) {
allowedPermission = true;
break;
}
}
if (!allowedPermission) {
throw APIException.badRequests.invalidPermissionType(permissions);
}
// Check to see if the Security Type passed in is valid
Boolean allowedsecurityType = false;
for (SecurityTypes secType : SecurityTypes.values()) {
if (secType.name().equalsIgnoreCase(securityType)) {
allowedsecurityType = true;
break;
}
}
if (!allowedsecurityType) {
throw APIException.badRequests.invalidSecurityType(securityType);
}
FSExportMap fsExports = fs.getFsExports();
URI id = fs.getId();
if (null != fsExports) {
Iterator<FileExport> it = fs.getFsExports().values().iterator();
while (it.hasNext()) {
FileExport fileExport = it.next();
// If no key found then it should process as it is.
boolean isAlreadyExportedToSameEndpoint = false;
if (fileExport.getPath().equals(path)) {
List<String> availableEndpoints = fileExport.getClients();
List<String> providedEndpoints = param.getAdd();
for (String providedEndpoint : providedEndpoints) {
if (availableEndpoints.contains(providedEndpoint)) {
isAlreadyExportedToSameEndpoint = true;
break;
}
}
if (isAlreadyExportedToSameEndpoint) {
_log.info(String.format("Existing Export params for FileShare id: %1$s, SecurityType: %2$s, " + "Permissions: %3$s, Root user mapping: %4$s, ", id, fileExport.getSecurityType(), fileExport.getPermissions(), fileExport.getRootUserMapping()));
_log.info(String.format("Recieved Export params for FileShare id: %1$s, SecurityType: %2$s, " + "Permissions: %3$s, Root user mapping: %4$s, ", id, securityType, permissions, rootUserMapping));
if (!fileExport.getPermissions().equals(permissions)) {
throw APIException.badRequests.updatingFileSystemExportNotAllowed("permission");
}
if (!fileExport.getSecurityType().equals(securityType)) {
throw APIException.badRequests.updatingFileSystemExportNotAllowed("security type");
}
if (!fileExport.getRootUserMapping().equals(rootUserMapping)) {
throw APIException.badRequests.updatingFileSystemExportNotAllowed("root user mapping");
}
}
}
}
}
}
Aggregations