Search in sources :

Example 1 with ExportOperationErrorType

use of com.emc.storageos.model.file.FileExportUpdateParams.ExportOperationErrorType 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;
            }
        }
    }
}
Also used : ExportRules(com.emc.storageos.model.file.ExportRules) ExportRule(com.emc.storageos.model.file.ExportRule) FileExportRule(com.emc.storageos.db.client.model.FileExportRule) ExportOperationErrorType(com.emc.storageos.model.file.FileExportUpdateParams.ExportOperationErrorType)

Example 2 with ExportOperationErrorType

use of com.emc.storageos.model.file.FileExportUpdateParams.ExportOperationErrorType in project coprhd-controller by CoprHD.

the class ExportVerificationUtility method reportModifyErrors.

private void reportModifyErrors(FileExportUpdateParams param) throws Exception {
    String opName = ExportOperationType.MODIFY.name();
    // Report Modify Export Errors
    ExportRules listExportRules = param.getExportRulesToModify();
    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 SNAPSHOT_EXPORT_SHOULD_BE_READ_ONLY:
                    {
                        throw APIException.badRequests.snapshotExportPermissionReadOnly();
                    }
                case EXPORT_NOT_FOUND:
                    {
                        throw APIException.badRequests.exportNotFound(opName, exportRule.toString());
                    }
                case INVALID_SECURITY_TYPE:
                    {
                        if (exportRule.getSecFlavor() != null) {
                            throw APIException.badRequests.invalidSecurityType(exportRule.getSecFlavor());
                        } else {
                            throw APIException.badRequests.missingInputTypeFound(SEC_TYPE, opName);
                        }
                    }
                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 INVALID_ANON:
                    {
                        if (exportRule.getAnon() != null) {
                            throw APIException.badRequests.invalidAnon(exportRule.getAnon());
                        } else {
                            throw APIException.badRequests.missingInputTypeFound(ANON_TYPE, opName);
                        }
                    }
                case NO_HOSTS_FOUND:
                    {
                        throw APIException.badRequests.missingInputTypeFound(NO_HOSTS_FOUND, opName);
                    }
                case EXPORT_EXISTS:
                case NO_ERROR:
                default:
                    break;
            }
        }
    }
}
Also used : ExportRules(com.emc.storageos.model.file.ExportRules) ExportRule(com.emc.storageos.model.file.ExportRule) FileExportRule(com.emc.storageos.db.client.model.FileExportRule) ExportOperationErrorType(com.emc.storageos.model.file.FileExportUpdateParams.ExportOperationErrorType)

Example 3 with ExportOperationErrorType

use of com.emc.storageos.model.file.FileExportUpdateParams.ExportOperationErrorType in project coprhd-controller by CoprHD.

the class ExportVerificationUtility method reportAddErrors.

private void reportAddErrors(FileExportUpdateParams param) throws Exception {
    String opName = ExportOperationType.ADD.name();
    // Report Add Export Errors
    ExportRules listExportRules = param.getExportRulesToAdd();
    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 SNAPSHOT_EXPORT_SHOULD_BE_READ_ONLY:
                    {
                        throw APIException.badRequests.snapshotExportPermissionReadOnly();
                    }
                case INVALID_SECURITY_TYPE:
                    {
                        if (exportRule.getSecFlavor() != null) {
                            throw APIException.badRequests.invalidSecurityType(exportRule.getSecFlavor());
                        } else {
                            throw APIException.badRequests.missingInputTypeFound(SEC_TYPE, opName);
                        }
                    }
                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 INVALID_ANON:
                    {
                        if (exportRule.getAnon() != null) {
                            throw APIException.badRequests.invalidAnon(exportRule.getAnon());
                        } else {
                            throw APIException.badRequests.missingInputTypeFound(ANON_TYPE, opName);
                        }
                    }
                case NO_HOSTS_FOUND:
                    {
                        throw APIException.badRequests.missingInputTypeFound(NO_HOSTS_FOUND, opName);
                    }
                case EXPORT_EXISTS:
                    {
                        throw APIException.badRequests.exportExists(opName, exportRule.toString());
                    }
                case STORAGE_SYSTEM_NOT_SUPPORT_MUL_SECS:
                    {
                        StorageSystem system = null;
                        String systemName = "";
                        if (fs != null) {
                            system = _dbClient.queryObject(StorageSystem.class, fs.getStorageDevice());
                        } else if (snapshot != null) {
                            FileShare fileSystem = _dbClient.queryObject(FileShare.class, snapshot.getParent());
                            system = _dbClient.queryObject(StorageSystem.class, fileSystem.getStorageDevice());
                        }
                        if (system != null) {
                            systemName = system.getSystemType();
                        }
                        throw APIException.badRequests.storageDoesNotSupportMulSecRule(opName, systemName, exportRule.toString());
                    }
                case EXPORT_NOT_FOUND:
                case NO_ERROR:
                default:
                    break;
            }
        }
    }
}
Also used : ExportRules(com.emc.storageos.model.file.ExportRules) ExportRule(com.emc.storageos.model.file.ExportRule) FileExportRule(com.emc.storageos.db.client.model.FileExportRule) FileShare(com.emc.storageos.db.client.model.FileShare) ExportOperationErrorType(com.emc.storageos.model.file.FileExportUpdateParams.ExportOperationErrorType) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

FileExportRule (com.emc.storageos.db.client.model.FileExportRule)3 ExportRule (com.emc.storageos.model.file.ExportRule)3 ExportRules (com.emc.storageos.model.file.ExportRules)3 ExportOperationErrorType (com.emc.storageos.model.file.FileExportUpdateParams.ExportOperationErrorType)3 FileShare (com.emc.storageos.db.client.model.FileShare)1 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)1