use of com.emc.storageos.model.file.ExportRule in project coprhd-controller by CoprHD.
the class FileService method isSecurityValid.
private boolean isSecurityValid(FileShare fs, FileSystemMountParam param) {
List<String> allowedSecurities = new ArrayList<String>();
String subDirectory = param.getSubDir();
if (StringUtils.isEmpty(param.getSubDir())) {
subDirectory = null;
}
List<ExportRule> exports = FileOperationUtils.getExportRules(fs.getId(), false, subDirectory, _dbClient);
for (ExportRule rule : exports) {
List<String> securityTypes = Arrays.asList(rule.getSecFlavor().split("\\s*,\\s*"));
allowedSecurities.addAll(securityTypes);
}
if (allowedSecurities.contains(param.getSecurity())) {
return true;
}
return false;
}
use of com.emc.storageos.model.file.ExportRule in project coprhd-controller by CoprHD.
the class FileService method getFSExportRules.
/**
* Get FS Export Rules
*
* @param id
* the URN of a ViPR fileSystem
* @param subDir
* sub-directory within a filesystem
* @param allDirs
* All Dirs within a filesystem
* @brief Show export rules for a file system
* @return ExportRules
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/export")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public ExportRules getFSExportRules(@PathParam("id") URI id, @QueryParam("allDirs") boolean allDirs, @QueryParam("subDir") String subDir) {
_log.info("Request recieved for Exports with Id : {} allDirs : {} subDir : {}", new Object[] { id, allDirs, subDir });
// Validate the FS id.
ArgValidator.checkFieldUriType(id, FileShare.class, "id");
// validate the subDir,no need to check return value as it is optional.
ArgValidator.checkSubDirName("subDir", subDir);
List<ExportRule> exportRule = FileOperationUtils.getExportRules(id, allDirs, subDir, _dbClient);
ExportRules rules = new ExportRules();
if (!exportRule.isEmpty()) {
rules.setExportRules(exportRule);
}
return rules;
}
use of com.emc.storageos.model.file.ExportRule in project coprhd-controller by CoprHD.
the class ExportVerificationUtility method verifyDeleteExportRule.
/**
* Verify each export rule that can be added
*
* @param fs
* @param listExportRule
*/
private void verifyDeleteExportRule(List<ExportRule> listExportRule) throws Exception {
if (listExportRule == null) {
return;
}
_log.info("{} Export Rule(s) Requested to Delete {} - Iterating ..", listExportRule.size());
for (ExportRule exportRule : listExportRule) {
exportRule.setIsToProceed(true, ExportOperationErrorType.NO_ERROR);
_log.info("Verifying Export Rule {}", exportRule.toString());
// is same security flavor found in several exports - report the error
scanForDuplicateSecFlavor(exportRule);
if (!exportRule.isToProceed()) {
_log.info("Same Security Flavor found across the exports {}", exportRule.toString());
break;
}
FileExportRule rule = validateInputAndQueryDB(exportRule);
// If found -- allow to delete.
if (rule != null) {
exportRule.setIsToProceed(true, ExportOperationErrorType.NO_ERROR);
} else // If not, stop proceed further.
{
_log.info("Export not found to delete");
exportRule.setIsToProceed(false, ExportOperationErrorType.EXPORT_NOT_FOUND);
}
}
}
use of com.emc.storageos.model.file.ExportRule in project coprhd-controller by CoprHD.
the class ExportVerificationUtility method reportDeleteErrors.
private void reportDeleteErrors(FileExportUpdateParams param) throws Exception {
String opName = ExportOperationType.DELETE.name();
// Report Delete Export Errors
ExportRules listExportRules = param.getExportRulesToDelete();
if (listExportRules == null || listExportRules.getExportRules().isEmpty()) {
return;
}
List<ExportRule> listExportRule = listExportRules.getExportRules();
for (ExportRule exportRule : listExportRule) {
if (!exportRule.isToProceed()) {
ExportOperationErrorType error = exportRule.getErrorTypeIfNotToProceed();
switch(error) {
case INVALID_SECURITY_TYPE:
{
if (exportRule.getSecFlavor() != null) {
throw APIException.badRequests.invalidSecurityType(exportRule.getSecFlavor());
} else {
throw APIException.badRequests.missingInputTypeFound(SEC_TYPE, ExportOperationType.DELETE.name());
}
}
case MULTIPLE_EXPORTS_WITH_SAME_SEC_FLAVOR:
{
if (exportRule.getSecFlavor() != null) {
throw APIException.badRequests.sameSecurityFlavorInMultipleExportsFound(exportRule.getSecFlavor(), opName);
} else {
throw APIException.badRequests.missingInputTypeFound(SEC_TYPE, opName);
}
}
case EXPORT_NOT_FOUND:
{
throw APIException.badRequests.exportNotFound(ExportOperationType.DELETE.name(), exportRule.toString());
}
case EXPORT_EXISTS:
case INVALID_ANON:
case NO_ERROR:
default:
break;
}
}
}
}
use of com.emc.storageos.model.file.ExportRule in project coprhd-controller by CoprHD.
the class ExportVerificationUtility method saveAndRetrieveExportURIs.
public void saveAndRetrieveExportURIs(List<ExportRule> listExportRule, ExportOperationType type) {
if (listExportRule == null) {
return;
}
for (ExportRule exportRule : listExportRule) {
if (exportRule.isToProceed()) {
FileExportRule rule = new FileExportRule();
copyPropertiesToSave(rule, exportRule);
rule.setOpType(type.name());
URI uri = URIUtil.createId(FileExportRule.class);
rule.setId(uri);
_log.debug("Saving Object {}", rule.toString());
_dbClient.createObject(rule);
allSavedURIs.add(uri);
}
continue;
}
}
Aggregations