/** * If any endpoint is used in an active File Export, throws an exception * * @param endpoints endpoints being added * @param varrays endpoints belong to * <p>Assumes endpoint formats have been validated. */ public static void checkNotUsedByActiveFileExport(String endpoint, DbClient dbClient) { Network network = NetworkUtil.getEndpointNetwork(endpoint, dbClient); if (network != null) { Set<String> netVArrayIds = network.getConnectedVirtualArrays(); if ((netVArrayIds != null) && (!netVArrayIds.isEmpty())) { Iterator<String> netVArrayIdsIter = netVArrayIds.iterator(); while (netVArrayIdsIter.hasNext()) { String varrayId = netVArrayIdsIter.next(); List<FileShare> fileShares = CustomQueryUtility.queryActiveResourcesByConstraint( dbClient, FileShare.class, AlternateIdConstraint.Factory.getConstraint(FileShare.class, "varray", varrayId)); for (FileShare fileShare : fileShares) { FSExportMap fsExports = fileShare.getFsExports(); if (fsExports != null) { Iterator<FileExport> it = fsExports.values().iterator(); while (it.hasNext()) { FileExport fileExport = it.next(); if (fileExport.getClients().contains(endpoint) || fileExport.getStoragePort().contains(endpoint)) { throw APIException.badRequests.endpointsCannotBeUpdatedActiveExport(endpoint); } } } } } } } }