diff --git a/cra-client/src/Frame.js b/cra-client/src/Frame.js index 001bc90b..8cfaccf6 100644 --- a/cra-client/src/Frame.js +++ b/cra-client/src/Frame.js @@ -15,7 +15,7 @@ import TypeExplorer from "./components/TypeExplorer/TypeExplorer"; import Dino from "./components/Dino/Dino"; import ServerAuthor from "./components/ServerAuthor/ServerAuthor"; import { IdentificationContext } from "./contexts/IdentificationContext"; -import ServerAuthorContext from "./contexts/ServerAuthorContext"; + import { Header, @@ -106,6 +106,9 @@ export default function Frame() { expanded={userOpen} > + + Logged in User: {userId} + - - diff --git a/cra-client/src/components/GlossaryAuthor/components/GlossaryAuthorBreadCrumb.js b/cra-client/src/components/GlossaryAuthor/components/GlossaryAuthorBreadCrumb.js index 53554ad6..a39f251c 100644 --- a/cra-client/src/components/GlossaryAuthor/components/GlossaryAuthorBreadCrumb.js +++ b/cra-client/src/components/GlossaryAuthor/components/GlossaryAuthorBreadCrumb.js @@ -2,7 +2,7 @@ /* Copyright Contributors to the ODPi Egeria project. */ import React, { useState, useEffect } from "react"; import { Breadcrumb, BreadcrumbItem } from "carbon-components-react"; -import { useLocation, withRouter, useHistory, Link } from "react-router-dom"; +import { useLocation, withRouter, Link } from "react-router-dom"; function GlossaryAuthorBreadCrumb(props) { console.log("GlossaryAuthorBreadCrumb "); diff --git a/cra-client/src/components/GlossaryAuthor/components/GlossaryQuickTerms.js b/cra-client/src/components/GlossaryAuthor/components/GlossaryQuickTerms.js index 753e8e5a..de6db14a 100644 --- a/cra-client/src/components/GlossaryAuthor/components/GlossaryQuickTerms.js +++ b/cra-client/src/components/GlossaryAuthor/components/GlossaryQuickTerms.js @@ -8,7 +8,7 @@ import Add32 from "../../../images/carbon/Egeria_add_32"; import getNodeType from "./properties/NodeTypes.js"; import { Button, Form, FormGroup, TextInput, Loading } from "carbon-components-react"; -import { issueRestCreate } from "./RestCaller"; +import { issueRestCreate } from "../../common/RestCaller"; import { useHistory, withRouter } from "react-router-dom"; function GlossaryQuickTerms(props) { diff --git a/cra-client/src/components/GlossaryAuthor/components/authoringforms/NodeReadOnly.js b/cra-client/src/components/GlossaryAuthor/components/authoringforms/NodeReadOnly.js index 431aa148..79129b75 100644 --- a/cra-client/src/components/GlossaryAuthor/components/authoringforms/NodeReadOnly.js +++ b/cra-client/src/components/GlossaryAuthor/components/authoringforms/NodeReadOnly.js @@ -15,9 +15,9 @@ import { TableHeader, TableBody, } from "carbon-components-react"; -import { issueRestCreate } from "../RestCaller"; -import { issueRestUpdate } from "../RestCaller"; -import { issueRestDelete } from "../RestCaller"; +import { issueRestCreate } from "../../../common/RestCaller"; +import { issueRestUpdate } from "../../../common/RestCaller"; +import { issueRestDelete } from "../../../common/RestCaller"; /** * Component to show the input page for a node that is about to be created or updated diff --git a/cra-client/src/components/GlossaryAuthor/components/authoringforms/RelationshipReadOnly.js b/cra-client/src/components/GlossaryAuthor/components/authoringforms/RelationshipReadOnly.js index 7e389d43..49b673e2 100644 --- a/cra-client/src/components/GlossaryAuthor/components/authoringforms/RelationshipReadOnly.js +++ b/cra-client/src/components/GlossaryAuthor/components/authoringforms/RelationshipReadOnly.js @@ -15,9 +15,9 @@ import { TableHeader, TableBody, } from "carbon-components-react"; -import { issueRestCreate } from "../RestCaller"; -import { issueRestUpdate } from "../RestCaller"; -import { issueRestDelete } from "../RestCaller"; +import { issueRestCreate } from "../../../common/RestCaller"; +import { issueRestUpdate } from "../../../common/RestCaller"; +import { issueRestDelete } from "../../../common/RestCaller"; /** * Component to show the page for a relationship that is about to be created or updated diff --git a/cra-client/src/components/GlossaryAuthor/components/create/CreateGlossaryWizard.js b/cra-client/src/components/GlossaryAuthor/components/create/CreateGlossaryWizard.js index dffaf652..99a940ea 100644 --- a/cra-client/src/components/GlossaryAuthor/components/create/CreateGlossaryWizard.js +++ b/cra-client/src/components/GlossaryAuthor/components/create/CreateGlossaryWizard.js @@ -21,7 +21,7 @@ import { parse } from "date-fns"; * where the user can confirm the values that will be used to create the glossary. * * This component drives the NodeInput component, which displays the node. There are callbacks to the wizard - * when the user has finsished with entering creation content. + * when the user has finished with entering creation content. * This component then drives NodeReadOnly which displays the confirmation screen, issues the create and then shows the results * of the create. * diff --git a/cra-client/src/components/GlossaryAuthor/components/navigations/GlossaryAuthorCategoriesNavigation.js b/cra-client/src/components/GlossaryAuthor/components/navigations/GlossaryAuthorCategoriesNavigation.js index d6f46ca2..5211d245 100644 --- a/cra-client/src/components/GlossaryAuthor/components/navigations/GlossaryAuthorCategoriesNavigation.js +++ b/cra-client/src/components/GlossaryAuthor/components/navigations/GlossaryAuthorCategoriesNavigation.js @@ -17,7 +17,7 @@ import { Pagination, Toggle } from "carbon-components-react"; import NodeTableView from "../views/NodeTableView"; import getNodeType from "../properties/NodeTypes.js"; -import { issueRestGet, issueRestDelete } from "../RestCaller"; +import { issueRestGet, issueRestDelete } from "../../../common/RestCaller"; import { Link } from "react-router-dom"; diff --git a/cra-client/src/components/GlossaryAuthor/components/navigations/GlossaryAuthorChildCategoriesNavigation.js b/cra-client/src/components/GlossaryAuthor/components/navigations/GlossaryAuthorChildCategoriesNavigation.js index 5e754299..b77dbdd7 100644 --- a/cra-client/src/components/GlossaryAuthor/components/navigations/GlossaryAuthorChildCategoriesNavigation.js +++ b/cra-client/src/components/GlossaryAuthor/components/navigations/GlossaryAuthorChildCategoriesNavigation.js @@ -19,7 +19,7 @@ import NodeTableView from "../views/NodeTableView"; //import GlossaryImage from "../../../images/Egeria_glossary_32"; import getNodeType from "../properties/NodeTypes.js"; import getPathTypesAndGuids from "../properties/PathAnalyser"; -import { issueRestGet, issueRestDelete } from "../RestCaller"; +import { issueRestGet, issueRestDelete } from "../../../common/RestCaller"; import { Link } from "react-router-dom"; diff --git a/cra-client/src/components/GlossaryAuthor/components/navigations/GlossaryAuthorTermsNavigation.js b/cra-client/src/components/GlossaryAuthor/components/navigations/GlossaryAuthorTermsNavigation.js index 899f3bbf..89deacf8 100644 --- a/cra-client/src/components/GlossaryAuthor/components/navigations/GlossaryAuthorTermsNavigation.js +++ b/cra-client/src/components/GlossaryAuthor/components/navigations/GlossaryAuthorTermsNavigation.js @@ -11,7 +11,7 @@ import Term32 from "../../../../images/odpi/Egeria_term_32"; import { LocalNodeCard, NodeCardSection } from "../NodeCard/NodeCard"; import { withRouter } from "react-router-dom"; import getNodeType from "../properties/NodeTypes.js"; -import { issueRestGet, issueRestDelete } from "../RestCaller"; +import { issueRestGet, issueRestDelete } from "../../../common/RestCaller"; import { Pagination, Toggle } from "carbon-components-react"; import NodeTableView from "../views/NodeTableView"; diff --git a/cra-client/src/components/GlossaryAuthor/components/navigations/StartingNodeNavigation.js b/cra-client/src/components/GlossaryAuthor/components/navigations/StartingNodeNavigation.js index f6ebae4e..72a263d2 100644 --- a/cra-client/src/components/GlossaryAuthor/components/navigations/StartingNodeNavigation.js +++ b/cra-client/src/components/GlossaryAuthor/components/navigations/StartingNodeNavigation.js @@ -14,7 +14,7 @@ import ParentChild32 from "../../../../images/carbon/Egeria_parent_child_32"; import GlossaryImage from "../../../../images/odpi/Egeria_glossary_32"; import { LocalNodeCard, NodeCardSection } from "../NodeCard/NodeCard"; -import { issueRestGet, issueRestDelete } from "../RestCaller"; +import { issueRestGet, issueRestDelete } from "../../../common/RestCaller"; import useDebounce from "../useDebounce"; import NodeTableView from "../views/NodeTableView"; import getNodeType from "../properties/NodeTypes.js"; diff --git a/cra-client/src/components/GlossaryAuthor/components/update/UpdateNode.js b/cra-client/src/components/GlossaryAuthor/components/update/UpdateNode.js index 9f10ae16..6f1500c7 100644 --- a/cra-client/src/components/GlossaryAuthor/components/update/UpdateNode.js +++ b/cra-client/src/components/GlossaryAuthor/components/update/UpdateNode.js @@ -18,7 +18,7 @@ import { TableBody, } from "carbon-components-react"; import Info16 from "@carbon/icons-react/lib/information/16"; -import { issueRestUpdate, issueRestGet } from "../RestCaller"; +import { issueRestUpdate, issueRestGet } from "../../../common/RestCaller"; import { useHistory } from "react-router-dom"; export default function UpdateNode(props) { diff --git a/cra-client/src/components/GlossaryAuthor/components/update/UpdateRelationshipInline.js b/cra-client/src/components/GlossaryAuthor/components/update/UpdateRelationshipInline.js index 097f86fd..4a65932a 100644 --- a/cra-client/src/components/GlossaryAuthor/components/update/UpdateRelationshipInline.js +++ b/cra-client/src/components/GlossaryAuthor/components/update/UpdateRelationshipInline.js @@ -17,7 +17,7 @@ import { TableBody, } from "carbon-components-react"; import Info16 from "@carbon/icons-react/lib/information/16"; -import { issueRestUpdate } from "../RestCaller"; +import { issueRestUpdate } from "../../../common/RestCaller"; export default function UpdateRelationshipInline(props) { const [updateBody, setUpdateBody] = useState({}); diff --git a/cra-client/src/components/GlossaryAuthor/components/visualisation/components/graph-controls/GraphControls.js b/cra-client/src/components/GlossaryAuthor/components/visualisation/components/graph-controls/GraphControls.js index 39da1fd6..705ae6a6 100644 --- a/cra-client/src/components/GlossaryAuthor/components/visualisation/components/graph-controls/GraphControls.js +++ b/cra-client/src/components/GlossaryAuthor/components/visualisation/components/graph-controls/GraphControls.js @@ -19,7 +19,7 @@ import SearchNodeButtonWidget from "./SearchNodeButtonWidget" import "../../glove.scss"; -import { issueRestGet } from "../../../RestCaller"; +import { issueRestGet } from "../../../../../common/RestCaller"; export default function GraphControls(props) { diff --git a/cra-client/src/components/GlossaryAuthor/components/visualisation/contexts/InstancesContext.js b/cra-client/src/components/GlossaryAuthor/components/visualisation/contexts/InstancesContext.js index 7eff59cd..6bef8741 100644 --- a/cra-client/src/components/GlossaryAuthor/components/visualisation/contexts/InstancesContext.js +++ b/cra-client/src/components/GlossaryAuthor/components/visualisation/contexts/InstancesContext.js @@ -4,7 +4,7 @@ import React, { createContext, useContext, useState, useCallback } from "react"; import PropTypes from "prop-types"; -import { issueRestGet } from "../../RestCaller"; +import { issueRestGet } from "../../../../common/RestCaller"; import getNodeType from "../../properties/NodeTypes"; import getRelationshipType from "../../properties/RelationshipTypes"; import { useHistory } from "react-router"; diff --git a/cra-client/src/components/ServerAuthor/ConfigPreview.js b/cra-client/src/components/ServerAuthor/ConfigPreview.js deleted file mode 100644 index 4723b66a..00000000 --- a/cra-client/src/components/ServerAuthor/ConfigPreview.js +++ /dev/null @@ -1,693 +0,0 @@ -/* SPDX-License-Identifier: Apache-2.0 */ -/* Copyright Contributors to the ODPi Egeria project. */ -import React, { useContext, useState } from "react"; -import { - Accordion, - AccordionItem, - Button, - DataTable, - Link, - StructuredListBody, - StructuredListCell, - StructuredListHead, - StructuredListRow, - StructuredListWrapper, - TextInput, - Tooltip, -} from "carbon-components-react"; -import { - CheckmarkOutline16, - Edit16, - MisuseOutline16, - Save16, - TrashCan16, -} from "@carbon/icons-react"; -import JSONPretty from 'react-json-pretty'; -import axios from "axios"; -import { IdentificationContext } from "../../contexts/IdentificationContext"; -import { ServerAuthorContext } from "../../contexts/ServerAuthorContext"; -import './serverConfig.scss'; - -export default function ConfigPreview({ options }) { - - const { userId, serverName: tenantId } = useContext(IdentificationContext); - const { - availableAccessServices, - setNotificationType, - setNotificationTitle, - setNotificationSubtitle, - newServerConfig, setNewServerConfig, - setPreventDeployment, - fetchServerConfig, - setServerAttribute, - } = useContext(ServerAuthorContext); - - const [editing_organizationName, setEditing_organizationName] = useState(false); - const [editing_localServerUserId, setEditing_localServerUserId] = useState(false); - const [editing_localServerPassword, setEditing_localServerPassword] = useState(false); - const [editing_maxPageSize, setEditing_maxPageSize] = useState(false); - - if (!newServerConfig || newServerConfig === {} || newServerConfig === '') { - return null; - } - - if (!options) - options = { - editable: false, - }; - - const { - editable, - } = options; - - const enableAccessServices = (selectedRows) => async () => { - console.log('called enableAccessServices', { selectedRows }); - // Enable Access Services - const accessServiceURLs = []; - selectedRows.forEach((row) => { - console.log({row}); - // TODO: Add comparison of new access services to enable vs. existing access services from config - // to rule out any unneccessary calls - accessServiceURLs.push(`/open-metadata/admin-services/users/${userId}/servers/${newServerConfig.localServerName}/access-services/${row.id}`); - }); - for (const enableServiceAccessURL of accessServiceURLs) { - try { - const enableServiceAccessResponse = await axios.post(enableServiceAccessURL, { - config: '', - tenantId, - }, { - headers: { - 'Content-Type': 'application/json' - }, - timeout: 30000, - }); - if (enableServiceAccessResponse.data.relatedHTTPCode !== 200) { - console.error(enableServiceAccessResponse.data); - throw new Error("Error in enableServiceAccessResponse"); - } - } catch(error) { - console.error("Error enabling service access", { error }); - setNotificationType("error"); - if (error.code && error.code === "ECONNABORTED") { - setNotificationTitle("Connection Error"); - setNotificationSubtitle("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - setNotificationTitle("Configuration Error"); - setNotificationSubtitle("Error enabling access service(s)."); - } - document.getElementById("loading-container").style.display = "none"; - document.getElementById("notification-container").style.display = "block"; - return; - } - } - // Refresh Server Config - const serverConfig = await fetchServerConfig(); - setNewServerConfig(serverConfig); - } - - const disableAccessServices = (selectedRows) => async () => { - console.log('called disableAccessServices', { selectedRows }); - // Disable Access Services - const accessServiceURLs = []; - selectedRows.forEach((row) => { - console.log({row}); - // TODO: Add comparison of new access services to disable vs. existing access services from config - // to rule out any unneccessary calls - accessServiceURLs.push(`/open-metadata/admin-services/users/${userId}/servers/${newServerConfig.localServerName}/access-services/${row.id}`); - }); - for (const disableServiceAccessURL of accessServiceURLs) { - try { - const disableServiceAccessResponse = await axios.delete(disableServiceAccessURL, { - data: { - config: '', - tenantId, - }, - headers: { - 'Content-Type': 'application/json' - }, - timeout: 30000, - }); - if (disableServiceAccessResponse.data.relatedHTTPCode !== 200) { - console.error(disableServiceAccessResponse.data); - throw new Error("Error in disableServiceAccessResponse"); - } - } catch(error) { - console.error("Error disabling access service", { error }); - setNotificationType("error"); - if (error.code && error.code === "ECONNABORTED") { - setNotificationTitle("Connection Error"); - setNotificationSubtitle("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - setNotificationTitle("Configuration Error"); - setNotificationSubtitle("Error disabling access service(s)."); - } - document.getElementById("loading-container").style.display = "none"; - document.getElementById("notification-container").style.display = "block"; - return; - } - } - // Refresh Server Config - const serverConfig = await fetchServerConfig(); - setNewServerConfig(serverConfig); - } - - // Editable Cells - - const makeCellEditable = (field) => { - console.log("called makeCellEditable", { field }); - eval(`setEditing_${field}(true)`); - } - - const cancelChange = (field) => { - console.log("called cancelChange", { field }); - eval(`setEditing_${field}(false)`); - setPreventDeployment(false); - } - - const saveChange = async (field) => { - console.log("called saveChange", { field }); - const value = document.getElementById(`${field}-input`).value; - try { - switch(field) { - case "localServerType": - await setServerAttribute("server-type?typeName", value); - break; - case "organizationName": - await setServerAttribute("organization-name?name", value); - break; - case "localServerUserId": - await setServerAttribute("server-user-id?id", value); - break; - case "localServerPassword": - await setServerAttribute("server-user-password?password", value); - break; - case "maxPageSize": - await setServerAttribute("max-page-size?limit", value); - break; - default: - break; - } - eval(`setEditing_${field}(false)`); - const serverConfig = await fetchServerConfig(); - console.log({ serverConfig }); - setNewServerConfig(serverConfig); - setPreventDeployment(false); - } catch(error) { - console.error({ error }); - } - } - - const handleCellChange = (field, originalValue, currentValue) => { - console.log("called handleCellChange", { field, originalValue, currentValue }); - if (currentValue === originalValue) { - console.log("value matches original"); - setPreventDeployment(false); - } else { - console.log("value has changed"); - setPreventDeployment(true); - } - } - - const editableCell = (field, originalValue, editable = false, editing = false) => { - // console.log("called editableCell", { field, editable, editing }); - if (!editable) { - return {originalValue} - } - if (!editing) { - return ( - - {originalValue} - - - - -
- {availableDiscoveryEngines.map((s, i) => ( - - {s.serviceName} - - ))} -
- - - - - ) - -} \ No newline at end of file diff --git a/cra-client/src/components/ServerAuthor/ConfigureStewardshipEngines.js b/cra-client/src/components/ServerAuthor/ConfigureStewardshipEngines.js deleted file mode 100644 index 0c816da1..00000000 --- a/cra-client/src/components/ServerAuthor/ConfigureStewardshipEngines.js +++ /dev/null @@ -1,128 +0,0 @@ -/* SPDX-License-Identifier: Apache-2.0 */ -/* Copyright Contributors to the ODPi Egeria project. */ - -import React, { useContext } from "react"; -import { - Button, - SelectableTile, - TextInput, -} from "carbon-components-react"; - -import { ServerAuthorContext } from "../../contexts/ServerAuthorContext"; - -export default function ConfigureStewardshipEngines() { - - const { - availableStewardshipEngines, - setSelectedStewardshipEngines, - newServerStewardshipEngineRemoteServerName, setNewServerStewardshipEngineRemoteServerName, - newServerStewardshipEngineRemoteServerURLRoot, setNewServerStewardshipEngineRemoteServerURLRoot, - stewardshipEnginesFormStartRef, - } = useContext(ServerAuthorContext); - - const handleDeselectAllStewardshipEngines = () => { - const boxes = document.getElementsByName('stewardship-engines'); - for (let b = 0; b <= boxes.length - 1; b++) { - const isChecked = boxes[b].checked; - if (isChecked) - boxes[b].click(); - }; - updateStewardshipEngines(); - } - - const handleSelectAllStewardshipEngines = () => { - const boxes = document.getElementsByName('stewardship-engines'); - for (let b = 0; b <= boxes.length - 1; b++) { - const isChecked = boxes[b].checked; - if (!isChecked) - boxes[b].click(); - }; - updateStewardshipEngines(); - } - - const updateStewardshipEngines = () => { - const boxes = document.getElementsByName('stewardship-engines'); - const selectedStewardshipEngines = Array.from(boxes).filter((box) => box.checked).map((box) => box.value); - setSelectedStewardshipEngines(selectedStewardshipEngines); - } - - return ( - -
- -
- - Stewardship Engine Client - - setNewServerStewardshipEngineRemoteServerURLRoot(e.target.value)} - style={{marginBottom: "16px"}} - inline - ref={stewardshipEnginesFormStartRef} - autoComplete="off" - /> - - setNewServerStewardshipEngineRemoteServerName(e.target.value)} - inline - style={{marginBottom: "16px"}} - autoComplete="off" - /> - -
- -
- - Stewardship Engines - -
- - -
- -
- {availableStewardshipEngines.map((s, i) => ( - - {s.serviceName} - - ))} -
- -
-
- - ) - -} \ No newline at end of file diff --git a/cra-client/src/components/ServerAuthor/KnownServers.js b/cra-client/src/components/ServerAuthor/KnownServers.js deleted file mode 100644 index 58ce6710..00000000 --- a/cra-client/src/components/ServerAuthor/KnownServers.js +++ /dev/null @@ -1,235 +0,0 @@ -/* SPDX-License-Identifier: Apache-2.0 */ -/* Copyright Contributors to the ODPi Egeria project. */ -import React, { useContext } from "react"; -import { - Button, - DataTable, - OverflowMenu, - OverflowMenuItem, -} from "carbon-components-react"; -import { - CheckmarkOutline16, - MisuseOutline16, -} from "@carbon/icons-react"; -import axios from "axios"; -import { IdentificationContext } from "../../contexts/IdentificationContext"; -import { ServerAuthorContext } from "../../contexts/ServerAuthorContext"; - -export default function KnownServers() { - - const { userId, serverName: tenantId } = useContext(IdentificationContext); - const { - knownServers, setKnownServers, - setNotificationType, - setNotificationTitle, - setNotificationSubtitle, - fetchKnownServers, - showConfigForm, - } = useContext(ServerAuthorContext); - - const startServers = (selectedRows) => async () => { - console.log('called startServers', { selectedRows }); - // Start servers - const serverURLs = []; - selectedRows.forEach((row) => { - serverURLs.push(`/open-metadata/admin-services/users/${userId}/servers/${row.id}/instance`); - }); - for (const url of serverURLs) { - try { - const startServerResponse = await axios.post(url, { - tenantId, - }, { - headers: { - 'Content-Type': 'application/json' - }, - timeout: 30000, - }); - if (startServerResponse.data.relatedHTTPCode !== 200) { - console.error(startServerResponse.data); - throw new Error(startServerResponse.data.exceptionErrorMessage); - } - } catch(error) { - console.error("Error starting server", { error }); - setNotificationType("error"); - if (error.code && error.code === "ECONNABORTED") { - setNotificationTitle("Connection Error"); - setNotificationSubtitle("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - setNotificationTitle("Deployment Error"); - setNotificationSubtitle("Error starting server(s). " + error.message); - } - document.getElementById("loading-container").style.display = "none"; - document.getElementById("notification-container").style.display = "block"; - return; - } - } - // Refresh Server List - const serverList = await fetchKnownServers(); - setKnownServers(serverList.map((v) => { return { id: v, serverName: v, status: "known" } })); - } - - const stopServers = (selectedRows, del = false) => async () => { - console.log('called stopServers', { selectedRows }); - // Stop servers - const serverURLs = []; - selectedRows.forEach((row) => { - let url = `/open-metadata/admin-services/users/${userId}/servers/${row.id}` - if (!del) { - url += '/instance'; - } - serverURLs.push(url); - }); - for (const url of serverURLs) { - try { - const stopServerResponse = await axios.delete(url, { - data: { - tenantId, - }, - headers: { - 'Content-Type': 'application/json' - }, - timeout: 30000, - }); - if (stopServerResponse.data.relatedHTTPCode !== 200) { - console.error("Error occurred, response:", stopServerResponse.data); - throw new Error(stopServerResponse.data.exceptionErrorMessage); - } - } catch(error) { - console.error("Error stopping server", { error }); - setNotificationType("error"); - if (error.code && error.code === "ECONNABORTED") { - setNotificationTitle("Connection Error"); - setNotificationSubtitle("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - setNotificationTitle("Deployment Error"); - setNotificationSubtitle("Error stopping server(s). " + error.message); - } - document.getElementById("loading-container").style.display = "none"; - document.getElementById("notification-container").style.display = "block"; - return; - } - } - // Refresh Server List - const serverList = await fetchKnownServers(); - setKnownServers(serverList.map((v) => { return { id: v, serverName: v, status: "known" } })); - } - - const headers = [ - { - key: "serverName", - header: "Server Name" - }, - { - key: "status", - header: "Status" - } - ]; - - return ( - -
- - - {({ - rows, - headers, - getHeaderProps, - getRowProps, - getSelectionProps, - getToolbarProps, - getBatchActionProps, - onInputChange, - selectedRows, - getTableProps, - getTableContainerProps, - }) => ( - - - - - Shutdown - - - Shutdown {'&'} Delete - - - Start - - - - - - - - - - - - {headers.map((header, i) => ( - - {header.header} - - ))} - - - - - {rows.map((row, index) => ( - - - - {row.cells.map((cell) => { - return ({cell.value}); - })} - - - - - - - - - - ))} - - - - )} - - -
- - ) - -} \ No newline at end of file diff --git a/cra-client/src/components/ServerAuthor/RegisterCohorts.js b/cra-client/src/components/ServerAuthor/RegisterCohorts.js deleted file mode 100644 index 15fe772a..00000000 --- a/cra-client/src/components/ServerAuthor/RegisterCohorts.js +++ /dev/null @@ -1,89 +0,0 @@ -/* SPDX-License-Identifier: Apache-2.0 */ -/* Copyright Contributors to the ODPi Egeria project. */ - -import React, { useContext } from "react"; -import { - Button, - TextInput, -} from "carbon-components-react"; -import { - Add16, - Subtract16, -} from "@carbon/icons-react"; - -import { ServerAuthorContext } from "../../contexts/ServerAuthorContext"; - -export default function RegisterCohorts() { - - const { newServerCohorts, setNewServerCohorts, } = useContext(ServerAuthorContext); - - const handleAddCohort = e => { - const cohortName = document.getElementById("new-server-cohort-name").value; - console.log("handleAddCohort() called", { cohortName }); - if (cohortName.length === 0) return; - setNewServerCohorts(newServerCohorts.concat(cohortName)); - document.getElementById("new-server-cohort-name").value = ""; - } - - const handleRemoveCohort = index => { - console.log("handleRemoveCohort() called", { index }); - const cohortList = newServerCohorts.filter((v, i) => { return i !== index }); - setNewServerCohorts(cohortList); - } - - return ( - -
- -
    - - {newServerCohorts.map((cohort, i) => ( -
  • - {cohort} -
  • - ))} - -
- -
- - - - - -
- -
- - ) - -} \ No newline at end of file diff --git a/cra-client/src/components/ServerAuthor/ServerAuthor.js b/cra-client/src/components/ServerAuthor/ServerAuthor.js index 1c6c1da9..6e507b9b 100644 --- a/cra-client/src/components/ServerAuthor/ServerAuthor.js +++ b/cra-client/src/components/ServerAuthor/ServerAuthor.js @@ -1,1124 +1,14 @@ /* SPDX-License-Identifier: Apache-2.0 */ /* Copyright Contributors to the ODPi Egeria project. */ -import React, { useContext } from "react"; -import { - CodeSnippet, - Column, - Grid, - InlineNotification, - Loading, - Row, - TileGroup, - RadioTile, -} from "carbon-components-react"; -import axios from "axios"; - -import { IdentificationContext } from "../../contexts/IdentificationContext"; -import { ServerAuthorContext } from "../../contexts/ServerAuthorContext"; -import serverTypes from "./defaults/serverTypes"; - -import KnownServers from "./KnownServers"; -import ConfigurationSteps from "./ConfigurationSteps"; -import NavigationButtons from "./NavigationButtons"; -import BasicConfig from "./BasicConfig"; -import ConfigureAccessServices from "./ConfigureAccessServices"; -import ConfigureAuditLog from "./ConfigureAuditLog"; -import RegisterCohorts from "./RegisterCohorts"; -import ConfigureOMArchives from "./ConfigureOMArchives"; -import ConfigureRepositoryProxyConnectors from "./ConfigureRepositoryProxyConnectors"; -import ConfigureViewServices from "./ConfigureViewServices"; -import ConfigureDiscoveryEngines from "./ConfigureDiscoveryEngines"; -import ConfigureStewardshipEngines from "./ConfigureStewardshipEngines"; -import ConfigureIntegrationServices from "./ConfigureIntegrationServices"; -import ConfigPreview from "./ConfigPreview"; +import React from "react"; +import ServerAuthorContext from "./contexts/ServerAuthorContext"; +import ServerAuthorWizard from"./components/ServerAuthorWizard"; export default function ServerAuthor() { - - const { userId, serverName: tenantId } = useContext(IdentificationContext); - console.log(useContext(ServerAuthorContext)) - const { - newServerName, - newServerLocalServerType, setNewServerLocalServerType, - newServerSecurityConnector, - availableAccessServices, - selectedAccessServices, - newServerRepository, - newServerCohorts, - newServerOMArchives, - newServerProxyConnector, - newServerEventMapperConnector, - newServerEventSource, - availableViewServices, - selectedViewServices, - newServerViewServiceRemoteServerURLRoot, - newServerViewServiceRemoteServerName, - selectedDiscoveryEngines, - newServerDiscoveryEngineRemoteServerName, - newServerDiscoveryEngineRemoteServerURLRoot, - selectedStewardshipEngines, - newServerStewardshipEngineRemoteServerName, - newServerStewardshipEngineRemoteServerURLRoot, - notificationType, setNotificationType, - notificationTitle, setNotificationTitle, - notificationSubtitle, setNotificationSubtitle, - progressIndicatorIndex, setProgressIndicatorIndex, - loadingText, setLoadingText, - setNewServerConfig, - basicConfigFormStartRef, - discoveryEnginesFormStartRef, - stewardshipEnginesFormStartRef, - fetchServerConfig, - generateBasicServerConfig, - registerCohort, - configureAccessServices, - configureArchiveFile, - configureRepositoryProxyConnector, - configureRepositoryEventMapperConnector, - configureViewServices, - configureDiscoveryEngineClient, - configureDiscoveryEngines, - configureStewardshipEngineClient, - configureStewardshipEngines, - serverConfigurationSteps, - } = useContext(ServerAuthorContext); - - // Navigation - - const sectionMapping = { - ["Select server type"]: "server-type-container", - ["Basic configuration"]: "config-basic-container", - ["Configure audit log destinations"]: "audit-log-container", - ["Preview configuration and deploy instance"]: "config-preview-container", - ["Select access services"]: "access-services-container", - ["Register to a cohort"]: "cohort-container", - ["Configure the open metadata archives"]: "archives-container", - ["Configure the repository proxy connectors"]: "repository-proxy-container", - ["Configure the Open Metadata View Services (OMVS)"]: "view-services-container", - ["Configure the discovery engine services"]: "discovery-engines-container", - // ["Configure the security sync services"]: "security-sync-container", - ["Configure the Open Metadata Integration Services (OMIS)"]: "integration-daemon-container", - ["Configure the stewardship engine services"]: "stewardship-engines-container", - } - - const showPreviousStep = () => { - const steps = serverConfigurationSteps(newServerLocalServerType); - if (progressIndicatorIndex === 0) { - return null; - } - const previous = steps[progressIndicatorIndex - 1]; - for (let el of document.querySelectorAll('.hideable')) el.style.display = 'none'; - document.getElementById(sectionMapping[previous]).style.display = "block"; - } - - const showNextStep = () => { - const steps = serverConfigurationSteps(newServerLocalServerType); - if (progressIndicatorIndex === steps.length) { - return null; - } - const next = steps[progressIndicatorIndex + 1]; - for (let el of document.querySelectorAll('.hideable')) el.style.display = 'none'; - document.getElementById(sectionMapping[next]).style.display = "block"; - switch (next) { - case "Basic configuration": - basicConfigFormStartRef.current.focus(); - break; - case "Configure the discovery engine services": - discoveryEnginesFormStartRef.current.focus(); - break; - case "Configure the stewardship engine services": - stewardshipEnginesFormStartRef.current.focus(); - break; - } - } - - const handleBackToPreviousStep = e => { - e.preventDefault(); - showPreviousStep(); - setProgressIndicatorIndex(progressIndicatorIndex - 1); - } - - // Server Type - - const handleServerTypeSelection = async e => { - e.preventDefault(); - showNextStep(); - setProgressIndicatorIndex(progressIndicatorIndex + 1); - } - - // Basic Config - - const handleBasicConfig = async e => { - e.preventDefault(); - // Generate server config - setLoadingText("Generating server configuration..."); - document.getElementById("config-basic-container").style.display = "none"; - document.getElementById("loading-container").style.display = "block"; - let serverConfig; - try { - serverConfig = generateBasicServerConfig(); - } catch(error) { - console.error("Error generating server config", { error }); - setNotificationType("error"); - setNotificationTitle("Configuration Error"); - setNotificationSubtitle("Error generating OMAG server configuration file. " + error.message); - document.getElementById("loading-container").style.display = "none"; - document.getElementById("config-basic-container").style.display = "block"; - document.getElementById("notification-container").style.display = "block"; - return; - } - // Post server config - setLoadingText("Storing basic server configuration on OMAG server platform..."); - const setServerConfigURL = `/open-metadata/admin-services/users/${userId}/servers/${newServerName}/configuration`; - try { - const setServerConfigResponse = await axios.post(setServerConfigURL, { - config: serverConfig, - tenantId, - }, { - headers: { - 'Content-Type': 'application/json' - }, - timeout: 30000, - }); - if (setServerConfigResponse.data.relatedHTTPCode === 200) { - setNewServerConfig(serverConfig); - console.log("Finished updating config preview"); - } else { - console.error(setServerConfigResponse.data); - throw new Error("Error in setServerConfigResponse"); - } - } catch(error) { - console.error("Error sending config to platform", { error }); - setNewServerConfig(null); - setNotificationType("error"); - if (error.code && error.code === 'ECONNABORTED') { - setNotificationTitle("Connection Error"); - setNotificationSubtitle("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - setNotificationTitle("Configuration Error"); - setNotificationSubtitle("Error sending server configuration to the platform."); - } - document.getElementById("loading-container").style.display = "none"; - document.getElementById("config-basic-container").style.display = "block"; - document.getElementById("notification-container").style.display = "block"; - return; - } - // Enable chosen repository - if (newServerLocalServerType === "Metadata Server") { - setLoadingText("Enabling chosen local repository..."); - const enableRepositoryURL = `/open-metadata/admin-services/users/${userId}/servers/${newServerName}/local-repository/mode/${newServerRepository}`; - try { - const enableRepositoryURLResponse = await axios.post(enableRepositoryURL, { - config: '', - tenantId, - }, { - headers: { - 'Content-Type': 'application/json' - }, - timeout: 30000, - }); - if (enableRepositoryURLResponse.data.relatedHTTPCode !== 200) { - console.error(enableRepositoryURLResponse.data); - throw new Error("Error in enableRepositoryURLResponse"); - } - } catch(error) { - console.error("Error enabling chosen repository", { error }); - setNotificationType("error"); - if (error.code && error.code === 'ECONNABORTED') { - setNotificationTitle("Connection Error"); - setNotificationSubtitle("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - setNotificationTitle("Configuration Error"); - setNotificationSubtitle(`Error enabling ${newServerRepository} repository for the server.`); - } - document.getElementById("loading-container").style.display = "none"; - document.getElementById("config-basic-container").style.display = "block"; - document.getElementById("notification-container").style.display = "block"; - return; - } - } - // Configure event bus - setLoadingText("Configuring event bus..."); - const configureEventBusURL = `/open-metadata/admin-services/users/${userId}/servers/${newServerName}/event-bus?topicURLRoot=egeriaTopics`; - try { - const configureEventBusURLResponse = await axios.post(configureEventBusURL, { - config: '', - tenantId, - }, { - headers: { - 'Content-Type': 'application/json' - }, - timeout: 30000, - }); - if (configureEventBusURLResponse.data.relatedHTTPCode !== 200) { - console.error(configureEventBusURLResponse.data); - throw new Error("Error in configureEventBusURLResponse"); - } - } catch(error) { - console.error("error configuring event bus", { error }); - setNotificationType("error"); - if (error.code && error.code === 'ECONNABORTED') { - setNotificationTitle("Connection Error"); - setNotificationSubtitle("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - setNotificationTitle("Configuration Error"); - setNotificationSubtitle(`Error configuring event bus.`); - } - document.getElementById("loading-container").style.display = "none"; - document.getElementById("config-basic-container").style.display = "block"; - document.getElementById("notification-container").style.display = "block"; - return; - } - // Configure security connector - if (newServerSecurityConnector !== "") { - setLoadingText("Configuring security connector..."); - const configureSecurityConnectorURL = `/open-metadata/admin-services/users/${userId}/servers/${newServerName}/security/connection`; - try { - const configureSecurityConnectorURLResponse = await axios.post(configureSecurityConnectorURL, { - config: { - "class": "Connection", - "connectorType": { - "class": "ConnectorType", - "connectorProviderClassName": newServerSecurityConnector - } - }, - tenantId, - }, { - headers: { - 'Content-Type': 'application/json' - }, - timeout: 30000, - }); - if (configureSecurityConnectorURLResponse.data.relatedHTTPCode !== 200) { - console.error(configureSecurityConnectorURLResponse.data); - throw new Error("Error in configureSecurityConnectorURLResponse"); - } - } catch(error) { - console.error("error configuring security connector", { error }); - setNotificationType("error"); - if (error.code && error.code === 'ECONNABORTED') { - setNotificationTitle("Connection Error"); - setNotificationSubtitle("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - setNotificationTitle("Configuration Error"); - setNotificationSubtitle(`Error configuring security connector. Please ensure the fully qualified name is correct.`); - } - document.getElementById("loading-container").style.display = "none"; - document.getElementById("config-basic-container").style.display = "block"; - document.getElementById("notification-container").style.display = "block"; - return; - } - } - // Direct User to Next Step - showNextStep(); - setProgressIndicatorIndex(progressIndicatorIndex + 1); - } - - // Access Services (optional) - - const handleAccessServicesConfig = async () => { - setLoadingText("Enabling access services..."); - document.getElementById("access-services-container").style.display = "none"; - document.getElementById("loading-container").style.display = "block"; - // Enable Access Services - try { - if (selectedAccessServices.length === availableAccessServices.length) { - configureAccessServices(); - } else { - for (const service of selectedAccessServices) { - setLoadingText(`Enabling ${service} access service...`); - configureAccessServices(service); - } - } - } catch(error) { - setNotificationType("error"); - if (error.code && error.code === "ECONNABORTED") { - setNotificationTitle("Connection Error"); - setNotificationSubtitle("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - setNotificationTitle("Configuration Error"); - setNotificationSubtitle(`Error enabling the access service(s).`); - } - document.getElementById("loading-container").style.display = "none"; - document.getElementById("access-services-container").style.display = "block"; - document.getElementById("notification-container").style.display = "block"; - return; - } - // Fetch Server Config - setLoadingText("Fetching final stored server configuration..."); - try { - const serverConfig = await fetchServerConfig(); - setNewServerConfig(serverConfig); - showNextStep(); - setProgressIndicatorIndex(progressIndicatorIndex + 1); - } catch(error) { - console.error("error fetching server config", {error}); - setNotificationType("error"); - if (error.code && error.code === "ECONNABORTED") { - setNotificationTitle("Connection Error"); - setNotificationSubtitle("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - setNotificationTitle("Configuration Error"); - setNotificationSubtitle(`Error fetching configuration for the server.`); - } - document.getElementById("loading-container").style.display = "none"; - document.getElementById("access-services-container").style.display = "block"; - document.getElementById("notification-container").style.display = "block"; - } - } - - // Audit Log Destionations - - const configureAuditLogDestinations = async (auditLogDestinations) => { - setLoadingText("Configuring audit log destinations..."); - document.getElementById("audit-log-container").style.display = "none"; - document.getElementById("loading-container").style.display = "block"; - // Enable Audit Log Destinations - console.log({auditLogDestinations}); - const chosenAuditLogDestinations = auditLogDestinations.filter((destination) => destination.selected); - for (const destination of chosenAuditLogDestinations) { - try { - const url = `/open-metadata/admin-services/users/${userId}/servers/${newServerName}/audit-log-destinations/${destination.id}`; - const data = { - tenantId - }; - if (destination.id !== "default") { - data.config = destination.severities.map((s) => s.id); - } - setLoadingText(`Enabling the ${destination.label} audit log destination...`); - const enableAuditLogDestinationResponse = await axios.post(url, data, { - headers: { - 'Content-Type': 'application/json' - }, - timeout: 30000, - }); - if (enableAuditLogDestinationResponse.data.relatedHTTPCode !== 200) { - console.error(enableAuditLogDestinationResponse.data); - throw new Error("Error in enableAuditLogDestinationResponse"); - } - } catch(error) { - console.error(`Error enabling the ${destination.label} audit log destination`, { error }); - setNotificationType("error"); - if (error.code && error.code === "ECONNABORTED") { - setNotificationTitle("Connection Error"); - setNotificationSubtitle("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - setNotificationTitle("Configuration Error"); - setNotificationSubtitle(`Error enabling the ${destination.label} audit log destination`); - } - document.getElementById("loading-container").style.display = "none"; - document.getElementById("audit-log-container").style.display = "block"; - document.getElementById("notification-container").style.display = "block"; - return; - } - } - // Fetch Server Config - setLoadingText("Fetching final stored server configuration..."); - try { - const serverConfig = await fetchServerConfig(); - setNewServerConfig(serverConfig); - showNextStep(); - setProgressIndicatorIndex(progressIndicatorIndex + 1); - } catch(error) { - console.error("error fetching server config", {error}); - setNotificationType("error"); - if (error.code && error.code === "ECONNABORTED") { - setNotificationTitle("Connection Error"); - setNotificationSubtitle("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - setNotificationTitle("Configuration Error"); - setNotificationSubtitle(`Error fetching configuration for the server.`); - } - document.getElementById("loading-container").style.display = "none"; - document.getElementById("audit-log-container").style.display = "block"; - document.getElementById("notification-container").style.display = "block"; - } - } - - // Optional Steps - - // Register to a cohort - - const handleRegisterCohorts = async () => { - setLoadingText("Registering cohort(s)..."); - document.getElementById("cohort-container").style.display = "none"; - document.getElementById("loading-container").style.display = "block"; - // Register Cohorts - for (const cohortName of newServerCohorts) { - try { - setLoadingText(`Registering the OMAG Server to the ${cohortName} cohort...`); - await registerCohort(cohortName); - } catch(error) { - console.error(`Error registering the OMAG Server to the ${cohortName} cohort`, { error }); - setNotificationType("error"); - if (error.code && error.code === "ECONNABORTED") { - setNotificationTitle("Connection Error"); - setNotificationSubtitle("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - setNotificationTitle("Configuration Error"); - setNotificationSubtitle(`Error registering the OMAG Server to the ${cohortName} cohort`); - } - document.getElementById("loading-container").style.display = "none"; - document.getElementById("cohort-container").style.display = "block"; - document.getElementById("notification-container").style.display = "block"; - return; - } - } - // Fetch Server Config - setLoadingText("Fetching final stored server configuration..."); - try { - const serverConfig = await fetchServerConfig(); - setNewServerConfig(serverConfig); - showNextStep(); - setProgressIndicatorIndex(progressIndicatorIndex + 1); - } catch(error) { - console.error("error fetching server config", {error}); - setNotificationType("error"); - if (error.code && error.code === "ECONNABORTED") { - setNotificationTitle("Connection Error"); - setNotificationSubtitle("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - setNotificationTitle("Configuration Error"); - setNotificationSubtitle(`Error fetching configuration for the server.`); - } - document.getElementById("loading-container").style.display = "none"; - document.getElementById("cohort-container").style.display = "block"; - document.getElementById("notification-container").style.display = "block"; - } - } - - // Configure open metadata archives to load on server startup - - const handleConfigureArchives = async () => { - setLoadingText("Configuring archives(s) to load on server startup..."); - document.getElementById("archives-container").style.display = "none"; - document.getElementById("loading-container").style.display = "block"; - // Register Cohorts - for (const archiveName of newServerOMArchives) { - try { - setLoadingText(`Configuring the OMAG Server to load the ${archiveName} archive upon startup...`); - await configureArchiveFile(archiveName); // TODO - } catch(error) { - console.error(`Error configuring the OMAG Server to load the ${archiveName} archive upon startup`, { error }); - setNotificationType("error"); - if (error.code && error.code === "ECONNABORTED") { - setNotificationTitle("Connection Error"); - setNotificationSubtitle("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - setNotificationTitle("Configuration Error"); - setNotificationSubtitle(`Error configuring the OMAG Server to load the ${archiveName} archive upon startup.`); - } - document.getElementById("loading-container").style.display = "none"; - document.getElementById("archives-container").style.display = "block"; - document.getElementById("notification-container").style.display = "block"; - return; - } - } - // Fetch Server Config - setLoadingText("Fetching final stored server configuration..."); - try { - const serverConfig = await fetchServerConfig(); - setNewServerConfig(serverConfig); - showNextStep(); - setProgressIndicatorIndex(progressIndicatorIndex + 1); - } catch(error) { - console.error("error fetching server config", {error}); - setNotificationType("error"); - if (error.code && error.code === "ECONNABORTED") { - setNotificationTitle("Connection Error"); - setNotificationSubtitle("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - setNotificationTitle("Configuration Error"); - setNotificationSubtitle(`Error fetching configuration for the server.`); - } - document.getElementById("loading-container").style.display = "none"; - document.getElementById("archives-container").style.display = "block"; - document.getElementById("notification-container").style.display = "block"; - } - } - - // Configure the Repository Proxy Connectors - - const handleConfigureRepositoryProxyConnectors = async () => { - // If all three fields are blank, skip to next step - if ( - (!newServerProxyConnector || newServerProxyConnector === "") && - (!newServerEventMapperConnector || newServerEventMapperConnector === "") && - (!newServerEventSource || newServerEventSource === "") - ) { - showNextStep(); - setProgressIndicatorIndex(progressIndicatorIndex + 1); - return; - } - // If one or two fields are blank, show notification - if ( - (!newServerProxyConnector || newServerProxyConnector === "") || - (!newServerEventMapperConnector || newServerEventMapperConnector === "") || - (!newServerEventSource || newServerEventSource === "") - ) { - setNotificationType("error"); - setNotificationTitle("Input Error"); - setNotificationSubtitle(`All three fields are required to configure the repository proxy connector. Leave all three fields blank to skip this step.`); - document.getElementById("notification-container").style.display = "block"; - return; - } - setLoadingText("Configuring repository proxy connector..."); - document.getElementById("repository-proxy-container").style.display = "none"; - document.getElementById("loading-container").style.display = "block"; - // Configure the repository proxy connector - try { - await configureRepositoryProxyConnector(newServerProxyConnector); - } catch(error) { - setNotificationType("error"); - if (error.code && error.code === "ECONNABORTED") { - setNotificationTitle("Connection Error"); - setNotificationSubtitle("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - setNotificationTitle("Configuration Error"); - setNotificationSubtitle(`Error configuring the repository proxy connector. Please ensure the fully qualified repository proxy connectory name is correct.`); - } - document.getElementById("loading-container").style.display = "none"; - document.getElementById("repository-proxy-container").style.display = "block"; - document.getElementById("notification-container").style.display = "block"; - return; - } - // Configure the repository event mapper connector - setLoadingText("Configuring repository event mapper connector..."); - try { - await configureRepositoryEventMapperConnector(newServerEventMapperConnector, newServerEventSource); - } catch(error) { - setNotificationType("error"); - if (error.code && error.code === "ECONNABORTED") { - setNotificationTitle("Connection Error"); - setNotificationSubtitle("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - setNotificationTitle("Configuration Error"); - setNotificationSubtitle(`Error configuring the repository event mapper connector. Please ensure the fully qualified repository event mapper connector name and event source are correct.`); - } - document.getElementById("loading-container").style.display = "none"; - document.getElementById("repository-proxy-container").style.display = "block"; - document.getElementById("notification-container").style.display = "block"; - return; - } - // Fetch Server Config - setLoadingText("Fetching final stored server configuration..."); - try { - const serverConfig = await fetchServerConfig(); - setNewServerConfig(serverConfig); - showNextStep(); - setProgressIndicatorIndex(progressIndicatorIndex + 1); - } catch(error) { - console.error("error fetching server config", {error}); - setNotificationType("error"); - if (error.code && error.code === "ECONNABORTED") { - setNotificationTitle("Connection Error"); - setNotificationSubtitle("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - setNotificationTitle("Configuration Error"); - setNotificationSubtitle(`Error fetching configuration for the server.`); - } - document.getElementById("loading-container").style.display = "none"; - document.getElementById("repository-proxy-container").style.display = "block"; - document.getElementById("notification-container").style.display = "block"; - } - } - - // Configure the open metadata view services - - const handleConfigureViewServices = async () => { - // If all three fields are blank, skip to next step - if ( - (!newServerViewServiceRemoteServerURLRoot || newServerViewServiceRemoteServerURLRoot === "") && - (!newServerViewServiceRemoteServerName || newServerViewServiceRemoteServerName === "") && - (!selectedViewServices || !selectedViewServices.length) - ) { - showNextStep(); - setProgressIndicatorIndex(progressIndicatorIndex + 1); - return; - } - // If one or two fields are blank, show notification - if ( - (!newServerViewServiceRemoteServerURLRoot || newServerViewServiceRemoteServerURLRoot === "") || - (!newServerViewServiceRemoteServerName || newServerViewServiceRemoteServerName === "") || - (!selectedViewServices || !selectedViewServices.length) - ) { - setNotificationType("error"); - setNotificationTitle("Input Error"); - setNotificationSubtitle(`All three fields are required to configure the repository proxy connector. Leave all three fields blank to skip this step.`); - document.getElementById("notification-container").style.display = "block"; - return; - } - setLoadingText("Enabling view services..."); - document.getElementById("view-services-container").style.display = "none"; - document.getElementById("loading-container").style.display = "block"; - // Enable View Services - try { - if (selectedViewServices.length === availableViewServices.length) { - configureViewServices(newServerViewServiceRemoteServerURLRoot, newServerViewServiceRemoteServerName); - } else { - for (const service of selectedViewServices) { - setLoadingText(`Enabling ${service} view service...`); - configureViewServices(newServerViewServiceRemoteServerURLRoot, newServerViewServiceRemoteServerName, service); - } - } - } catch(error) { - setNotificationType("error"); - if (error.code && error.code === "ECONNABORTED") { - setNotificationTitle("Connection Error"); - setNotificationSubtitle("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - setNotificationTitle("Configuration Error"); - setNotificationSubtitle(`Error enabling the view service(s).`); - } - document.getElementById("loading-container").style.display = "none"; - document.getElementById("view-services-container").style.display = "block"; - document.getElementById("notification-container").style.display = "block"; - return; - } - // Fetch Server Config - setLoadingText("Fetching final stored server configuration..."); - try { - const serverConfig = await fetchServerConfig(); - setNewServerConfig(serverConfig); - showNextStep(); - setProgressIndicatorIndex(progressIndicatorIndex + 1); - } catch(error) { - console.error("error fetching server config", {error}); - setNotificationType("error"); - if (error.code && error.code === "ECONNABORTED") { - setNotificationTitle("Connection Error"); - setNotificationSubtitle("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - setNotificationTitle("Configuration Error"); - setNotificationSubtitle(`Error fetching configuration for the server.`); - } - document.getElementById("loading-container").style.display = "none"; - document.getElementById("view-services-container").style.display = "block"; - document.getElementById("notification-container").style.display = "block"; - } - } - - // Configure the Discovery Engines - - const handleConfigureDiscoveryEngines = async () => { - // If all three fields are blank, skip to next step - if ( - (!newServerDiscoveryEngineRemoteServerURLRoot || newServerDiscoveryEngineRemoteServerURLRoot === "") && - (!newServerDiscoveryEngineRemoteServerName || newServerDiscoveryEngineRemoteServerName === "") && - (!selectedDiscoveryEngines || !selectedDiscoveryEngines.length) - ) { - showNextStep(); - setProgressIndicatorIndex(progressIndicatorIndex + 1); - return; - } - // If one or two fields are blank, show notification - if ( - (!newServerDiscoveryEngineRemoteServerURLRoot || newServerDiscoveryEngineRemoteServerURLRoot === "") || - (!newServerDiscoveryEngineRemoteServerName || newServerDiscoveryEngineRemoteServerName === "") || - (!selectedDiscoveryEngines || !selectedDiscoveryEngines.length) - ) { - setNotificationType("error"); - setNotificationTitle("Input Error"); - setNotificationSubtitle(`All three fields are required to configure the discovery engine. Leave all three fields blank to skip this step.`); - document.getElementById("notification-container").style.display = "block"; - return; - } - setLoadingText("Configuring discovery engine client..."); - document.getElementById("discovery-engines-container").style.display = "none"; - document.getElementById("loading-container").style.display = "block"; - // Configure the discovery engines client - try { - await configureDiscoveryEngineClient(newServerDiscoveryEngineRemoteServerURLRoot, newServerDiscoveryEngineRemoteServerName); - } catch(error) { - setNotificationType("error"); - if (error.code && error.code === "ECONNABORTED") { - setNotificationTitle("Connection Error"); - setNotificationSubtitle("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - setNotificationTitle("Configuration Error"); - setNotificationSubtitle(`Error configuring the discovery engine client. Please ensure the metadata server root URL and name are correct.`); - } - document.getElementById("loading-container").style.display = "none"; - document.getElementById("discovery-engines-container").style.display = "block"; - document.getElementById("notification-container").style.display = "block"; - return; - } - // Configure the discovery engines - setLoadingText("Configuring discovery engines..."); - try { - await configureDiscoveryEngines(selectedDiscoveryEngines); - } catch(error) { - setNotificationType("error"); - if (error.code && error.code === "ECONNABORTED") { - setNotificationTitle("Connection Error"); - setNotificationSubtitle("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - setNotificationTitle("Configuration Error"); - setNotificationSubtitle(`Error configuring the discovery engines. ${error.message}`); - } - document.getElementById("loading-container").style.display = "none"; - document.getElementById("discovery-engines-container").style.display = "block"; - document.getElementById("notification-container").style.display = "block"; - return; - } - // Fetch Server Config - setLoadingText("Fetching final stored server configuration..."); - try { - const serverConfig = await fetchServerConfig(); - setNewServerConfig(serverConfig); - showNextStep(); - setProgressIndicatorIndex(progressIndicatorIndex + 1); - } catch(error) { - console.error("error fetching server config", {error}); - setNotificationType("error"); - if (error.code && error.code === "ECONNABORTED") { - setNotificationTitle("Connection Error"); - setNotificationSubtitle("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - setNotificationTitle("Configuration Error"); - setNotificationSubtitle(`Error fetching configuration for the server.`); - } - document.getElementById("loading-container").style.display = "none"; - document.getElementById("discovery-engines-container").style.display = "block"; - document.getElementById("notification-container").style.display = "block"; - } - } - - // Configure the Stewardship Engines - - const handleConfigureStewardshipEngines = async () => { - console.log({ - newServerStewardshipEngineRemoteServerURLRoot, - newServerStewardshipEngineRemoteServerName, - selectedStewardshipEngines - }); - // If all three fields are blank, skip to next step - if ( - (!newServerStewardshipEngineRemoteServerURLRoot || newServerStewardshipEngineRemoteServerURLRoot === "") && - (!newServerStewardshipEngineRemoteServerName || newServerStewardshipEngineRemoteServerName === "") && - (!selectedStewardshipEngines || !selectedStewardshipEngines.length) - ) { - showNextStep(); - setProgressIndicatorIndex(progressIndicatorIndex + 1); - return; - } - // If one or two fields are blank, show notification - if ( - (!newServerStewardshipEngineRemoteServerURLRoot || newServerStewardshipEngineRemoteServerURLRoot === "") || - (!newServerStewardshipEngineRemoteServerName || newServerStewardshipEngineRemoteServerName === "") || - (!selectedStewardshipEngines || !selectedStewardshipEngines.length) - ) { - setNotificationType("error"); - setNotificationTitle("Input Error"); - setNotificationSubtitle(`All three fields are required to configure the stewardship engine. Leave all three fields blank to skip this step.`); - document.getElementById("notification-container").style.display = "block"; - return; - } - setLoadingText("Configuring stewardship engine client..."); - document.getElementById("stewardship-engines-container").style.display = "none"; - document.getElementById("loading-container").style.display = "block"; - // Configure the stewardship engines client - try { - await configureStewardshipEngineClient(newServerStewardshipEngineRemoteServerURLRoot, newServerStewardshipEngineRemoteServerName); - } catch(error) { - setNotificationType("error"); - if (error.code && error.code === "ECONNABORTED") { - setNotificationTitle("Connection Error"); - setNotificationSubtitle("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - setNotificationTitle("Configuration Error"); - setNotificationSubtitle(`Error configuring the stewardship engine client. Please ensure the metadata server root URL and name are correct.`); - } - document.getElementById("loading-container").style.display = "none"; - document.getElementById("stewardship-engines-container").style.display = "block"; - document.getElementById("notification-container").style.display = "block"; - return; - } - // Configure the stewardship engines - setLoadingText("Configuring stewardship engines..."); - try { - await configureStewardshipEngines(selectedStewardshipEngines); - } catch(error) { - setNotificationType("error"); - if (error.code && error.code === "ECONNABORTED") { - setNotificationTitle("Connection Error"); - setNotificationSubtitle("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - setNotificationTitle("Configuration Error"); - setNotificationSubtitle(`Error configuring the stewardship engines. ${error.message}`); - } - document.getElementById("loading-container").style.display = "none"; - document.getElementById("stewardship-engines-container").style.display = "block"; - document.getElementById("notification-container").style.display = "block"; - return; - } - // Fetch Server Config - setLoadingText("Fetching final stored server configuration..."); - try { - const serverConfig = await fetchServerConfig(); - setNewServerConfig(serverConfig); - showNextStep(); - setProgressIndicatorIndex(progressIndicatorIndex + 1); - } catch(error) { - console.error("error fetching server config", {error}); - setNotificationType("error"); - if (error.code && error.code === "ECONNABORTED") { - setNotificationTitle("Connection Error"); - setNotificationSubtitle("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - setNotificationTitle("Configuration Error"); - setNotificationSubtitle(`Error fetching configuration for the server.`); - } - document.getElementById("loading-container").style.display = "none"; - document.getElementById("stewardship-engines-container").style.display = "block"; - document.getElementById("notification-container").style.display = "block"; - } - } - - // Config Preview - - const handleDeployConfig = async e => { - e.preventDefault(); - setLoadingText("Deploying OMAG server from stored configuration..."); - document.getElementById("config-preview-container").style.display = "none"; - document.getElementById("loading-container").style.display = "block"; - // Issue the instance call to start the new server - const startServerURL = `/open-metadata/admin-services/users/${userId}/servers/${newServerName}/instance`; - try{ - const startServerResponse = await axios.post(startServerURL, { - config: '', - tenantId, - }, { - headers: { - 'Content-Type': 'application/json' - }, - timeout: 30000 - }); - if (startServerResponse.data.relatedHTTPCode === 200) { - setNotificationType("success"); - setNotificationTitle("Success!") - setNotificationSubtitle(`Server instance deployed from configuration.`); - document.getElementById("loading-container").style.display = "none"; - document.getElementById("notification-container").style.display = "block"; - document.getElementById("server-list-container").style.display = "flex"; - } else { - console.error(startServerResponse.data); - throw new Error("Error in startServerResponse"); - } - } catch(error) { - console.error("Error starting server from stored config", { error }); - setNotificationType("error"); - if (error.code && error.code === "ECONNABORTED") { - setNotificationTitle("Connection Error"); - setNotificationSubtitle("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - setNotificationTitle("Deployment Error"); - setNotificationSubtitle(`Error starting server from stored configuration file.`); - } - document.getElementById("loading-container").style.display = "none"; - document.getElementById("config-preview-container").style.display = "block"; - document.getElementById("notification-container").style.display = "block"; - } - } - - const serverTypeTiles = serverTypes.map((serverType, i) => { - return ( - - {serverType.label} - - ) - }); - return ( - - - - - - - -

Known OMAG Servers

-

Logged in as {userId}

- - - -
- -
- - - - {/* Form Column */} - - - -

Create New OMAG Server

-

Logged in as {userId}

- -
- -
- -
-

Select Server Type

- setNewServerLocalServerType(value)} - > - {serverTypeTiles} - - -
- -
-

Basic Configuration

- - -
- -
-

Select Access Services

- - -
- -
-

Configure Audit Log Destinations

- configureAuditLogDestinations(destinations)} - previousAction={handleBackToPreviousStep} - /> -
- -
-

Register to the following cohort(s):

- - -
- -
-

Configure the Open Metadata Archives that are loaded on server startup

- - -
- -
-

Configure the Repository Proxy Connectors

- - -
- -
-

Configure the Open Metadata View Services (OMVS)

- - -
- -
-

Configure the discovery engine services

- - -
- -
-

Configure the Open Metadata Integration Services (OMIS)

- - -
- -
-

Configure the stewardship engine services

- - -
- -
-

Preview Configuration

- - -
- -
- -

{loadingText}

-
- -
- - {/* Progress Indicator Column */} - - - - - -
- -
- - ) - -} \ No newline at end of file + + + + ); +} diff --git a/cra-client/src/components/ServerAuthor/components/AllServers.jsx b/cra-client/src/components/ServerAuthor/components/AllServers.jsx new file mode 100644 index 00000000..61d705ed --- /dev/null +++ b/cra-client/src/components/ServerAuthor/components/AllServers.jsx @@ -0,0 +1,275 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ +import React, { useContext } from "react"; +import { + Button, + DataTable, + OverflowMenu, + OverflowMenuItem, +} from "carbon-components-react"; +import { + MisuseOutline16, + Edit16, + Copy16, +} from "@carbon/icons-react"; +import axios from "axios"; +import { IdentificationContext } from "../../../contexts/IdentificationContext"; +import { ServerAuthorContext } from "../contexts/ServerAuthorContext"; + +export default function AllServers() { + const { userId, serverName: tenantId } = useContext(IdentificationContext); + const { + allServers, + setNotificationType, + setNotificationTitle, + setNotificationSubtitle, + fetchAllServers, + showConfigForm, + } = useContext(ServerAuthorContext); + + const startServers = (selectedRows) => async () => { + console.log("called startServers", { selectedRows }); + // Start servers + const serverURLs = []; + selectedRows.forEach((row) => { + serverURLs.push( + `/open-metadata/admin-services/users/${userId}/servers/${row.id}/instance` + ); + }); + for (const url of serverURLs) { + try { + const startServerResponse = await axios.post( + url, + { + tenantId, + }, + { + headers: { + "Content-Type": "application/json", + }, + timeout: 30000, + } + ); + if (startServerResponse.data.relatedHTTPCode !== 200) { + console.error(startServerResponse.data); + throw new Error(startServerResponse.data.exceptionErrorMessage); + } + } catch (error) { + console.error("Error starting server", { error }); + setNotificationType("error"); + if (error.code && error.code === "ECONNABORTED") { + setNotificationTitle("Connection Error"); + setNotificationSubtitle( + "Error connecting to the platform. Please ensure the OMAG server platform is available." + ); + } else { + setNotificationTitle("Deployment Error"); + setNotificationSubtitle("Error starting server(s). " + error.message); + } + document.getElementById("loading-container").style.display = "none"; + document.getElementById("notification-container").style.display = + "block"; + return; + } + } + // Refresh Server List + fetchAllServers(); + }; + + const stopServers = + (selectedRows, del = false) => + async () => { + console.log("called stopServers", { selectedRows }); + // Stop servers + const serverURLs = []; + selectedRows.forEach((row) => { + let url = `/open-metadata/admin-services/users/${userId}/servers/${row.id}`; + if (!del) { + url += "/instance"; + } + serverURLs.push(url); + }); + for (const url of serverURLs) { + try { + const stopServerResponse = await axios.delete(url, { + data: { + tenantId, + }, + headers: { + "Content-Type": "application/json", + }, + timeout: 30000, + }); + if (stopServerResponse.data.relatedHTTPCode !== 200) { + console.error("Error occurred, response:", stopServerResponse.data); + throw new Error(stopServerResponse.data.exceptionErrorMessage); + } + } catch (error) { + console.error("Error stopping server", { error }); + setNotificationType("error"); + if (error.code && error.code === "ECONNABORTED") { + setNotificationTitle("Connection Error"); + setNotificationSubtitle( + "Error connecting to the platform. Please ensure the OMAG server platform is available." + ); + } else { + setNotificationTitle("Deployment Error"); + setNotificationSubtitle( + "Error stopping server(s). " + error.message + ); + } + document.getElementById("loading-container").style.display = "none"; + document.getElementById("notification-container").style.display = + "block"; + return; + } + } + // Refresh Server List + retrieveAllServers(); + }; + + const headers = [ + { + key: "serverName", + header: "Server Name", + }, + { + key: "serverType", + header: "Server Type", + }, + { + key: "platformName", + header: "Platform Name", + }, + ]; + + return ( +
+ + {({ + rows, + headers, + getHeaderProps, + getRowProps, + getSelectionProps, + getToolbarProps, + getBatchActionProps, + onInputChange, + selectedRows, + getTableProps, + getTableContainerProps, + }) => ( + + + + {selectedRows.length === 1 && ( + + Edit + + )} + {selectedRows.length === 1 && ( + + Copy + + )} + + Delete + + + + + + + + + + + + {headers.map((header, i) => ( + + {header.header} + + ))} + + + + + {rows.map((row, index) => ( + + + + {row.cells.map((cell) => { + return ( + + {cell.value} + + ); + })} + + + + + + + + + + ))} + + + + )} + +
+ ); +} diff --git a/cra-client/src/components/ServerAuthor/BasicConfig.js b/cra-client/src/components/ServerAuthor/components/BasicConfig.jsx similarity index 69% rename from cra-client/src/components/ServerAuthor/BasicConfig.js rename to cra-client/src/components/ServerAuthor/components/BasicConfig.jsx index 5e341984..064826f5 100644 --- a/cra-client/src/components/ServerAuthor/BasicConfig.js +++ b/cra-client/src/components/ServerAuthor/components/BasicConfig.jsx @@ -3,12 +3,10 @@ import React, { useContext } from "react"; import { - RadioTile, TextInput, - TileGroup, } from "carbon-components-react"; -import { ServerAuthorContext } from "../../contexts/ServerAuthorContext"; +import { ServerAuthorContext } from "../contexts/ServerAuthorContext"; export default function BasicConfig() { @@ -20,14 +18,12 @@ export default function BasicConfig() { newServerLocalPassword, setNewServerLocalPassword, newServerMaxPageSize, setNewServerMaxPageSize, newServerSecurityConnector, setNewServerSecurityConnector, - newServerLocalServerType, - newServerRepository, setNewServerRepository, basicConfigFormStartRef, } = useContext(ServerAuthorContext); return ( -
+
@@ -121,50 +117,6 @@ export default function BasicConfig() {
- { - // If server type is Metadata Server, show local repository tiles - (newServerLocalServerType === "Metadata Server") && -
- Server repository type - setNewServerRepository(value)} - style={{marginTop: "16px", textAlign: "left"}} - > - - In Memory - - - Janus Graph - - - Read Only - - -
- } -
) diff --git a/cra-client/src/components/ServerAuthor/ConfigurationSteps.js b/cra-client/src/components/ServerAuthor/components/ConfigurationSteps.jsx similarity index 71% rename from cra-client/src/components/ServerAuthor/ConfigurationSteps.js rename to cra-client/src/components/ServerAuthor/components/ConfigurationSteps.jsx index 66d91d54..662ad476 100644 --- a/cra-client/src/components/ServerAuthor/ConfigurationSteps.js +++ b/cra-client/src/components/ServerAuthor/components/ConfigurationSteps.jsx @@ -6,7 +6,8 @@ import { ProgressIndicator, ProgressStep, } from "carbon-components-react"; -import { ServerAuthorContext } from "../../contexts/ServerAuthorContext"; +import { ServerAuthorContext } from "../contexts/ServerAuthorContext"; +import serverConfigElements from "./defaults/serverConfigElements"; export default function ConfigurationSteps() { @@ -18,6 +19,12 @@ export default function ConfigurationSteps() { const steps = serverConfigurationSteps(newServerLocalServerType); + const getStepLabel = (index) => { + const id = steps[index]; + const serverTypeElement = serverConfigElements.find(o => o.id === id); + return serverTypeElement.label; + }; + return ( ( ))} - ) + ); } \ No newline at end of file diff --git a/cra-client/src/components/ServerAuthor/ConfigureAccessServices.js b/cra-client/src/components/ServerAuthor/components/ConfigureAccessServices.jsx similarity index 96% rename from cra-client/src/components/ServerAuthor/ConfigureAccessServices.js rename to cra-client/src/components/ServerAuthor/components/ConfigureAccessServices.jsx index e79e99be..5e2efa43 100644 --- a/cra-client/src/components/ServerAuthor/ConfigureAccessServices.js +++ b/cra-client/src/components/ServerAuthor/components/ConfigureAccessServices.jsx @@ -7,7 +7,7 @@ import { SelectableTile, } from "carbon-components-react"; -import { ServerAuthorContext } from "../../contexts/ServerAuthorContext"; +import { ServerAuthorContext } from "../contexts/ServerAuthorContext"; export default function ConfigureAccessServices() { @@ -24,7 +24,7 @@ export default function ConfigureAccessServices() { boxes[b].click(); }; updateAccessServices(); - } + }; const handleSelectAllAccessServices = () => { const boxes = document.getElementsByName('access-services'); @@ -32,15 +32,15 @@ export default function ConfigureAccessServices() { const isChecked = boxes[b].checked; if (!isChecked) boxes[b].click(); - }; + } updateAccessServices(); - } + }; const updateAccessServices = () => { const boxes = document.getElementsByName('access-services'); const selectedAccessServices = Array.from(boxes).filter((box) => box.checked).map((box) => box.value); setSelectedAccessServices(selectedAccessServices); - } + }; return ( @@ -87,6 +87,6 @@ export default function ConfigureAccessServices() {
- ) + ); } \ No newline at end of file diff --git a/cra-client/src/components/ServerAuthor/ConfigureAuditLog.js b/cra-client/src/components/ServerAuthor/components/ConfigureAuditLog.jsx similarity index 53% rename from cra-client/src/components/ServerAuthor/ConfigureAuditLog.js rename to cra-client/src/components/ServerAuthor/components/ConfigureAuditLog.jsx index e9a09ba7..f8a1f098 100644 --- a/cra-client/src/components/ServerAuthor/ConfigureAuditLog.js +++ b/cra-client/src/components/ServerAuthor/components/ConfigureAuditLog.jsx @@ -1,67 +1,81 @@ /* SPDX-License-Identifier: Apache-2.0 */ /* Copyright Contributors to the ODPi Egeria project. */ import React, { useContext, useReducer } from "react"; -import { - Button, - Checkbox, -} from "carbon-components-react"; +import { Button, Checkbox } from "carbon-components-react"; -import { ServerAuthorContext } from "../../contexts/ServerAuthorContext"; +import { ServerAuthorContext } from "../contexts/ServerAuthorContext"; import auditLogDestinations from "./defaults/auditLogDestinations"; -import auditLogSeverities from "./defaults/auditLogSeverities"; export default function ConfigureAuditLog({ previousAction, nextAction }) { - if (!previousAction || !nextAction) { - throw new Error("ConfigureAuditLog component requires both a previousAction and a nextAction property."); + throw new Error( + "ConfigureAuditLog component requires both a previousAction and a nextAction property." + ); } const { + supportedAuditLogSeverities, newServerLocalServerType, progressIndicatorIndex, - serverConfigurationSteps + serverConfigurationSteps, } = useContext(ServerAuthorContext); const steps = serverConfigurationSteps(newServerLocalServerType); - const previousIndex = (progressIndicatorIndex > 0) ? progressIndicatorIndex - 1 : 0; - const nextIndex = (progressIndicatorIndex < steps.length - 1) ? progressIndicatorIndex + 1 : steps.length - 1; + const previousIndex = progressIndicatorIndex > 0 ? progressIndicatorIndex - 1 : 0; + const nextIndex = progressIndicatorIndex < steps.length - 1 ? progressIndicatorIndex + 1 : steps.length - 1; + + const supportedSeverities = supportedAuditLogSeverities.map((s) => { + return { + ...s, + selected: true, + }; + }); // Initial State has no destinations selected, but all severities selected const initialState = auditLogDestinations.map((d, i) => { + console.log("supportedSeverities " + JSON.stringify(supportedSeverities)); + + console.log( + "returning " + + JSON.stringify({ + ...d, + selected: d.id === "default", + severities: d.id === "default" ? [] : supportedSeverities, + }) + ); + return { ...d, selected: d.id === "default", - severities: d.id === "default" ? [] : auditLogSeverities.map((s) => { - return { - ...s, - selected: true - } - }) - } - }) + severities: d.id === "default" ? [] : supportedSeverities, + }; + }); const reducer = (destinations, action) => { - if (action.type === 'selectDestination') { - return destinations.map(dest => { + if (action.type === "selectDestination") { + return destinations.map((dest) => { if (dest.id === action.destination) { dest.selected = true; } + if (dest.severities.length === 0 && dest.id !== "default") { + dest.severities = supportedSeverities; + } return dest; }); } - if (action.type === 'deselectDestination') { - return destinations.map(destination => { + if (action.type === "deselectDestination") { + return destinations.map((destination) => { if (destination.id === action.destination) { destination.selected = false; } return destination; }); } - if (action.type === 'selectSeverity') { - return destinations.map(dest => { + if (action.type === "selectSeverity") { + return destinations.map((dest) => { if (dest.id === action.destination) { - dest.severities = dest.severities.map(sev => { + dest.severities = dest.severities.map((sev) => { if (sev.id === action.severity) { sev.selected = true; } @@ -71,10 +85,10 @@ export default function ConfigureAuditLog({ previousAction, nextAction }) { return dest; }); } - if (action.type === 'deselectSeverity') { - return destinations.map(dest => { + if (action.type === "deselectSeverity") { + return destinations.map((dest) => { if (dest.id === action.destination) { - dest.severities = dest.severities.map(sev => { + dest.severities = dest.severities.map((sev) => { if (sev.id === action.severity) { sev.selected = false; } @@ -84,23 +98,21 @@ export default function ConfigureAuditLog({ previousAction, nextAction }) { return dest; }); } - } - + }; + const [state, dispatch] = useReducer(reducer, initialState); const handleClick = async () => { console.log({ action: nextAction, state, - }) + }); await nextAction(state); - } + }; return ( - -
- -
+
+
Audit Log Destinations {state.map((destination, i) => (
@@ -109,21 +121,32 @@ export default function ConfigureAuditLog({ previousAction, nextAction }) { labelText={destination.label} id={destination.id} checked={destination.selected} - onChange={(value, id, e) => dispatch({ type: value ? 'selectDestination' : 'deselectDestination', destination: id })} + onChange={(value, id, e) => + dispatch({ + type: value ? "selectDestination" : "deselectDestination", + destination: id, + }) + } /> - {(destination.selected && destination.severities.length > 0) ? -
+ {destination.selected && destination.severities.length > 0 ? ( +
{destination.severities.map((severity, j) => ( dispatch({ type: value ? 'selectSeverity' : 'deselectSeverity', destination: destination.id, severity: id })} + onChange={(value, id, e) => + dispatch({ + type: value ? "selectSeverity" : "deselectSeverity", + destination: destination.id, + severity: id, + }) + } /> ))} -
: null - } +
+ ) : null}
))}
@@ -131,7 +154,7 @@ export default function ConfigureAuditLog({ previousAction, nextAction }) {
-
- - ) - -} \ No newline at end of file + ); +} diff --git a/cra-client/src/components/ServerAuthor/ConfigureIntegrationServices.js b/cra-client/src/components/ServerAuthor/components/ConfigureIntegrationServices.jsx similarity index 99% rename from cra-client/src/components/ServerAuthor/ConfigureIntegrationServices.js rename to cra-client/src/components/ServerAuthor/components/ConfigureIntegrationServices.jsx index 261b5d54..d7a38827 100644 --- a/cra-client/src/components/ServerAuthor/ConfigureIntegrationServices.js +++ b/cra-client/src/components/ServerAuthor/components/ConfigureIntegrationServices.jsx @@ -8,7 +8,7 @@ import { TextInput, } from "carbon-components-react"; -import { ServerAuthorContext } from "../../contexts/ServerAuthorContext"; +import { ServerAuthorContext } from "../contexts/ServerAuthorContext"; export default function ConfigureIntegrationServices() { diff --git a/cra-client/src/components/ServerAuthor/components/ConfigureLocalRepository.jsx b/cra-client/src/components/ServerAuthor/components/ConfigureLocalRepository.jsx new file mode 100644 index 00000000..be02025e --- /dev/null +++ b/cra-client/src/components/ServerAuthor/components/ConfigureLocalRepository.jsx @@ -0,0 +1,68 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +import React, { useContext } from "react"; +import { TileGroup, RadioTile } from "carbon-components-react"; + +import { ServerAuthorContext } from "../contexts/ServerAuthorContext"; + +export default function ConfigureLocalRepository() { + const { newServerRepository, setNewServerRepository } = + useContext(ServerAuthorContext); + + return ( +
+
+ + Server repository type + + setNewServerRepository(value)} + style={{ marginTop: "16px", textAlign: "left" }} + > + + Bitemporal repository (Crux) + + + Non-temporal local Graph (Janus) + + + In Memory + + + + Read Only + + +
+
+ ); +} diff --git a/cra-client/src/components/ServerAuthor/ConfigureOMArchives.js b/cra-client/src/components/ServerAuthor/components/ConfigureOMArchives.jsx similarity index 95% rename from cra-client/src/components/ServerAuthor/ConfigureOMArchives.js rename to cra-client/src/components/ServerAuthor/components/ConfigureOMArchives.jsx index 0d963cee..092b1db3 100644 --- a/cra-client/src/components/ServerAuthor/ConfigureOMArchives.js +++ b/cra-client/src/components/ServerAuthor/components/ConfigureOMArchives.jsx @@ -11,7 +11,7 @@ import { Subtract16, } from "@carbon/icons-react"; -import { ServerAuthorContext } from "../../contexts/ServerAuthorContext"; +import { ServerAuthorContext } from "../contexts/ServerAuthorContext"; export default function ConfigureOMArchives() { @@ -23,13 +23,13 @@ export default function ConfigureOMArchives() { if (archiveName.length === 0) return; setNewServerOMArchives(newServerOMArchives.concat(archiveName)); document.getElementById("new-server-archive-file-name").value = ""; - } + }; const handleRemoveOMArchive = index => { console.log("handleRemoveOMArchive() called", { index }); - const archiveList = newServerOMArchives.filter((v, i) => { return i !== index }); + const archiveList = newServerOMArchives.filter((v, i) => { return i !== index; }); setNewServerOMArchives(archiveList); - } + }; return ( @@ -84,6 +84,6 @@ export default function ConfigureOMArchives() {
- ) + ); } \ No newline at end of file diff --git a/cra-client/src/components/ServerAuthor/ConfigureRepositoryProxyConnectors.js b/cra-client/src/components/ServerAuthor/components/ConfigureRepositoryProxyConnectors.jsx similarity index 80% rename from cra-client/src/components/ServerAuthor/ConfigureRepositoryProxyConnectors.js rename to cra-client/src/components/ServerAuthor/components/ConfigureRepositoryProxyConnectors.jsx index 00a9b1c4..5200ef06 100644 --- a/cra-client/src/components/ServerAuthor/ConfigureRepositoryProxyConnectors.js +++ b/cra-client/src/components/ServerAuthor/components/ConfigureRepositoryProxyConnectors.jsx @@ -11,7 +11,7 @@ import { // Subtract16, // } from "@carbon/icons-react"; -import { ServerAuthorContext } from "../../contexts/ServerAuthorContext"; +import { ServerAuthorContext } from "../contexts/ServerAuthorContext"; export default function ConfigureRepositoryProxyConnectors() { @@ -56,19 +56,6 @@ export default function ConfigureRepositoryProxyConnectors() { style={{marginBottom: "16px"}} autoComplete="off" /> - - {/* TODO: Add button to test connection */} - {/* */} diff --git a/cra-client/src/components/ServerAuthor/ConfigureViewServices.js b/cra-client/src/components/ServerAuthor/components/ConfigureViewServices.jsx similarity index 97% rename from cra-client/src/components/ServerAuthor/ConfigureViewServices.js rename to cra-client/src/components/ServerAuthor/components/ConfigureViewServices.jsx index 764746ad..2855024b 100644 --- a/cra-client/src/components/ServerAuthor/ConfigureViewServices.js +++ b/cra-client/src/components/ServerAuthor/components/ConfigureViewServices.jsx @@ -8,7 +8,7 @@ import { TextInput, } from "carbon-components-react"; -import { ServerAuthorContext } from "../../contexts/ServerAuthorContext"; +import { ServerAuthorContext } from "../contexts/ServerAuthorContext"; export default function ConfigureViewServices() { @@ -26,7 +26,7 @@ export default function ConfigureViewServices() { if (isChecked) boxes[b].click(); }; - } + }; const handleSelectAllViewServices = () => { const boxes = document.getElementsByName('view-services'); @@ -35,13 +35,13 @@ export default function ConfigureViewServices() { if (!isChecked) boxes[b].click(); }; - } + }; const updateViewServices = () => { const boxes = document.getElementsByName('view-services'); const selectedViewServices = Array.from(boxes).filter((box) => box.checked).map((box) => box.value); setSelectedViewServices(selectedViewServices); - } + }; return ( @@ -107,6 +107,6 @@ export default function ConfigureViewServices() { - ) + ); } \ No newline at end of file diff --git a/cra-client/src/components/ServerAuthor/NavigationButtons.js b/cra-client/src/components/ServerAuthor/components/NavigationButtons.jsx similarity index 70% rename from cra-client/src/components/ServerAuthor/NavigationButtons.js rename to cra-client/src/components/ServerAuthor/components/NavigationButtons.jsx index b3609a94..6746c973 100644 --- a/cra-client/src/components/ServerAuthor/NavigationButtons.js +++ b/cra-client/src/components/ServerAuthor/components/NavigationButtons.jsx @@ -5,7 +5,8 @@ import React, { useContext } from "react"; import { Button } from "carbon-components-react"; -import { ServerAuthorContext } from "../../contexts/ServerAuthorContext"; +import { ServerAuthorContext } from "../contexts/ServerAuthorContext"; +import serverConfigElements from "./defaults/serverConfigElements"; export default function NavigationButtons({ handlePreviousStep, handleNextStep }) { @@ -18,6 +19,12 @@ export default function NavigationButtons({ handlePreviousStep, handleNextStep } const steps = serverConfigurationSteps(newServerLocalServerType); + const getStepLabel = (index) => { + const id = steps[index]; + const serverTypeElement = serverConfigElements.find(o => o.id === id); + return serverTypeElement.label; + }; + // First step if (progressIndicatorIndex === 0) { @@ -37,7 +44,7 @@ export default function NavigationButtons({ handlePreviousStep, handleNextStep } style={{margin: "16px auto"}} onClick={handleNextStep} > - Proceed to {steps[progressIndicatorIndex + 1].toLowerCase()} + Proceed to {getStepLabel(progressIndicatorIndex + 1)} ) @@ -52,26 +59,11 @@ export default function NavigationButtons({ handlePreviousStep, handleNextStep }
- -
@@ -96,7 +88,7 @@ export default function NavigationButtons({ handlePreviousStep, handleNextStep } style={{margin: "16px auto"}} onClick={handlePreviousStep} > - Back to {steps[progressIndicatorIndex - 1].toLowerCase()} + Back to {getStepLabel(progressIndicatorIndex - 1)} diff --git a/cra-client/src/components/ServerAuthor/components/RegisterCohorts.jsx b/cra-client/src/components/ServerAuthor/components/RegisterCohorts.jsx new file mode 100644 index 00000000..be2f53ac --- /dev/null +++ b/cra-client/src/components/ServerAuthor/components/RegisterCohorts.jsx @@ -0,0 +1,107 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +import React, { useContext } from "react"; +import { Button, TextInput } from "carbon-components-react"; +import { Add16, Subtract16 } from "@carbon/icons-react"; + +import { ServerAuthorContext } from "../contexts/ServerAuthorContext"; + +export default function RegisterCohorts() { + const { + newServerCohorts, + setNewServerCohorts, + registerCohort, + unRegisterCohort, + } = useContext(ServerAuthorContext); + + const handleAddCohort = (e) => { + const cohortName = document.getElementById("new-server-cohort-name").value; + console.log("handleAddCohort() called", { cohortName }); + if (cohortName.length === 0) return; + registerCohort( + cohortName, + onSuccessfulRegisterCohort, + onErrorRegisterCohort + ); + }; + const onSuccessfulRegisterCohort = () => { + const cohortName = document.getElementById("new-server-cohort-name").value; + setNewServerCohorts(newServerCohorts.concat(cohortName)); + document.getElementById("new-server-cohort-name").value = ""; + }; + const onErrorRegisterCohort = (error) => { + alert("Error registering cohort"); + }; + const onSuccessfulUnRegisterCohort = () => { + const cohortName = document.activeElement.id.substring( + "cohort-remove-button-".length + ); + const cohortList = newServerCohorts.filter((e) => e !== cohortName); + // const cohortList = newServerCohorts.filter((v, i) => { return i !== index }); + setNewServerCohorts(cohortList); + }; + const onErrorUnRegisterCohort = (error) => { + alert("Error unregistering cohort"); + }; + + const handleRemoveCohort = (index) => { + console.log("handleRemoveCohort() called", { index }); + const cohortName = newServerCohorts[index]; + + unRegisterCohort( + cohortName, + onSuccessfulUnRegisterCohort, + onErrorUnRegisterCohort + ); + // const cohortList = newServerCohorts.filter((v, i) => { return i !== index }); + // setNewServerCohorts(cohortList); + }; + + return ( +
+
+ + + +
+
    + {newServerCohorts.map((cohort, i) => ( +
  • +
  • + ))} +
+
+ ); +} diff --git a/cra-client/src/components/ServerAuthor/components/ServerAuthorWizard.jsx b/cra-client/src/components/ServerAuthor/components/ServerAuthorWizard.jsx new file mode 100644 index 00000000..12c39fdd --- /dev/null +++ b/cra-client/src/components/ServerAuthor/components/ServerAuthorWizard.jsx @@ -0,0 +1,1297 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +import React, { useContext, useState } from "react"; +import { + Column, + Grid, + InlineNotification, + Loading, + Row, + Select, + SelectItem, + SelectItemGroup, +} from "carbon-components-react"; +import Info16 from "@carbon/icons-react/lib/information/16"; +import axios from "axios"; +import { issueRestCreate } from "../../common/RestCaller"; + +import { IdentificationContext } from "../../../contexts/IdentificationContext"; +import { ServerAuthorContext } from "../contexts/ServerAuthorContext"; +import serverTypes from "./defaults/serverTypes"; + +import AllServers from "./AllServers"; +import ConfigurationSteps from "./ConfigurationSteps"; +import NavigationButtons from "./NavigationButtons"; +import BasicConfig from "./BasicConfig"; +import ConfigureAccessServices from "./ConfigureAccessServices"; +import ConfigureLocalRepository from "./ConfigureLocalRepository"; +import ConfigureAuditLog from "./ConfigureAuditLog"; +import RegisterCohorts from "./RegisterCohorts"; +import ConfigureOMArchives from "./ConfigureOMArchives"; +import ConfigureRepositoryProxyConnectors from "./ConfigureRepositoryProxyConnectors"; +import ConfigureViewServices from "./ConfigureViewServices"; +import ConfigureIntegrationServices from "./ConfigureIntegrationServices"; + + +export default function ServerAuthorWizard() { + const { userId, serverName: tenantId } = useContext(IdentificationContext); + console.log(useContext(ServerAuthorContext)); + const { + newServerName, + newServerLocalServerType, + setNewServerLocalServerType, + newServerSecurityConnector, + availableAccessServices, + selectedAccessServices, + newServerRepository, + newServerOMArchives, + newServerProxyConnector, + newServerEventMapperConnector, + newServerEventSource, + availableViewServices, + selectedViewServices, + newServerViewServiceRemoteServerURLRoot, + newServerViewServiceRemoteServerName, + notificationType, + setNotificationType, + notificationTitle, + setNotificationTitle, + notificationSubtitle, + setNotificationSubtitle, + progressIndicatorIndex, + setProgressIndicatorIndex, + loadingText, + setLoadingText, + newServerConfig, + setNewServerConfig, + + // functions + cleanForNewServerType, + fetchServerConfig, + generateBasicServerConfig, + configureArchiveFile, + configureRepositoryProxyConnector, + configureRepositoryEventMapperConnector, + configureViewServices, + serverConfigurationSteps, + } = useContext(ServerAuthorContext); + + const [serverTypeDescription, setServerTypeDescription] = useState(); + + const displayHelpForServerTypes = () => { + window.open("https://odpi.github.io/egeria-docs/concepts/omag-server/?h=omag+server+types",'_blank'); + }; + + const showPreviousStep = () => { + if (progressIndicatorIndex === 0) { + return null; + } + const steps = serverConfigurationSteps(newServerLocalServerType); + // hide everything that is hideable + for (let el of document.querySelectorAll(".hideable")) + el.style.display = "none"; + // previous configElement + const previousStep = steps[progressIndicatorIndex - 1]; + // this has been coded so that the configElement identifier is the same as the html id of the associated section we want to show + // for example a config element with id audit-log-config-element with have a html section with that name. + document.getElementById(previousStep).style.display = "block"; + }; + + const showNextStep = () => { + const steps = serverConfigurationSteps(newServerLocalServerType); + if (progressIndicatorIndex === steps.length) { + return null; + } + // hide everything that is hideable + for (let el of document.querySelectorAll(".hideable")) + el.style.display = "none"; + const nextStep = steps[progressIndicatorIndex + 1]; + + document.getElementById(nextStep).style.display = "block"; + // switch (next) { + // case "Basic configuration": + // basicConfigFormStartRef.current.focus(); + // break; + // case "Configure the discovery engine services": + // discoveryEnginesFormStartRef.current.focus(); + // break; + // case "Configure the stewardship engine services": + // stewardshipEnginesFormStartRef.current.focus(); + // break; + // } + }; + + const handleBackToPreviousStep = (e) => { + e.preventDefault(); + showPreviousStep(); + setProgressIndicatorIndex(progressIndicatorIndex - 1); + }; + + // Server Type + + const handleServerTypeSelection = async (e) => { + e.preventDefault(); + // clear out the context. + cleanForNewServerType(); + showNextStep(); + setProgressIndicatorIndex(progressIndicatorIndex + 1); + }; + + // Basic Config + + const handleBasicConfig = async (e) => { + e.preventDefault(); + // Generate server config + setLoadingText("Generating server configuration..."); + document.getElementById("config-basic-config-element").style.display = + "none"; + document.getElementById("loading-container").style.display = "block"; + let serverConfig; + try { + serverConfig = generateBasicServerConfig(); + } catch (error) { + console.error("Error generating server config", { error }); + setNotificationType("error"); + setNotificationTitle("Configuration Error"); + setNotificationSubtitle( + "Error generating OMAG server configuration file. " + error.message + ); + document.getElementById("loading-container").style.display = "none"; + document.getElementById("config-basic-config-element").style.display = + "block"; + document.getElementById("notification-container").style.display = "block"; + return; + } + // Post server config + setLoadingText( + "Storing basic server configuration on OMAG server platform..." + ); + // const setServerConfigURL = `/open-metadata/admin-services/users/${userId}/servers/${newServerName}/configuration`; + const newServerName = serverConfig.localServerName; + const serverConfigURL = encodeURI( + "/servers/" + + tenantId + + "/server-author/users/" + + userId + + "/servers/" + + newServerName + + "/configuration" + ); + issueRestCreate( + serverConfigURL, + serverConfig, + onSuccessfulConfigureServer, + onErrorConfigureServer, + "omagServerConfig" + ); + }; + const onSuccessfulConfigureServer = (json) => { + const serverConfig = json.omagServerConfig; + setNewServerConfig(serverConfig); + // Configure security connector + if (newServerSecurityConnector !== "") { + setLoadingText("Configuring security connector..."); + const serverConfigURL = encodeURI( + "/servers/" + + tenantId + + "/server-author/users/" + + userId + + "/servers/" + + newServerName + + "/security/connection" + ); + config = { + class: "Connection", + connectorType: { + class: "ConnectorType", + connectorProviderClassName: newServerSecurityConnector, + }, + }; + issueRestCreate( + serverConfigURL, + serverConfig, + onSuccessfulConfigurationOfSecurityConnector, + onErrorConfigureServer, + "omagServerConfig" + ); + } else { + directUserToNextStep(); + } + }; + const onErrorConfigureServer = (error) => { + console.error("Error sending config to platform", { error }); + setNewServerConfig(null); + setNotificationType("error"); + if (error.code && error.code === "ECONNABORTED") { + setNotificationTitle("Connection Error"); + setNotificationSubtitle( + "Error connecting to the platform. Please ensure the OMAG server platform is available." + ); + } else { + setNotificationTitle("Configuration Error"); + setNotificationSubtitle( + "Error sending server configuration to the platform." + ); + } + document.getElementById("loading-container").style.display = "none"; + document.getElementById("config-basic-config-element").style.display = + "block"; + document.getElementById("notification-container").style.display = "block"; + }; + + const onSuccessfulEnableRepository = (json) => { + const serverConfig = json.omagServerConfig; + setNewServerConfig(serverConfig); + directUserToNextStep(); + }; + const onSuccessfulConfigureEventBusURL = (json) => { + const serverConfig = json.omagServerConfig; + setNewServerConfig(serverConfig); + directUserToNextStep(); + }; + + const onSuccessfulConfigurationOfSecurityConnector = (json) => { + const serverConfig = json.omagServerConfig; + setNewServerConfig(serverConfig); + directUserToNextStep(); + }; + const directUserToNextStep = () => { + // Direct User to Next Step + showNextStep(); + setProgressIndicatorIndex(progressIndicatorIndex + 1); + }; + // local repository + const handleLocalRepositoryConfig = () => { + setLoadingText("Enabling local repository..."); + document.getElementById("local-repository-config-element").style.display = + "none"; + document.getElementById("loading-container").style.display = "block"; + + if (newServerRepository) { + setLoadingText("Enabling chosen local repository..."); + + //local-repository/mode/plugin-repository/connection + + const serverConfigURL = encodeURI( + "/servers/" + + tenantId + + "/server-author/users/" + + userId + + "/servers/" + + newServerName + + "/local-repository/mode/" + + newServerRepository + ); + let body = undefined; + if (serverConfigURL.endsWith("plugin-repository/connection")) { + body = { + "class": "Connection", + "connectorType": { + "class": "ConnectorType", + "connectorProviderClassName": "org.odpi.egeria.connectors.juxt.crux.repositoryconnector.CruxOMRSRepositoryConnectorProvider" + } + } + } + issueRestCreate( + serverConfigURL, + body, + onSuccessfulEnableRepository, + onErrorConfigureServer, + "omagServerConfig" + ); + } + // Enable Access Services + // try { + // if (selectedAccessServices.length === availableAccessServices.length) { + // configureAccessServices(); + // } else { + // for (const service of selectedAccessServices) { + // setLoadingText(`Enabling ${service} access service...`); + // configureAccessServices(service); + // } + // } + }; + + // Access Services (optional) + const handleAccessServicesConfig = () => { + setLoadingText("Enabling access services..."); + document.getElementById("access-services-config-element").style.display = + "none"; + document.getElementById("loading-container").style.display = "block"; + // Enable Access Services + // try { + if (selectedAccessServices.length === availableAccessServices.length) { + configureAccessServices(); + } else { + for (const service of selectedAccessServices) { + setLoadingText(`Enabling ${service} access service...`); + configureAccessServices(service); + } + } + }; + const configureAccessServices = (serviceURLMarker) => { + console.log("called configureAccessServices", { serviceURLMarker }); + let configureAccessServicesURL = encodeURI( + "/servers/" + + tenantId + + "/server-author/users/" + + userId + + "/servers/" + + newServerName + + "/access-services" + ); + if (serviceURLMarker && serviceURLMarker !== "") { + configureAccessServicesURL += "/" + serviceURLMarker; + } + + issueRestCreate( + configureAccessServicesURL, + {}, // TODO supply appropriate access service options here - for example supported or default zones for asset orientated OMAS's + onSuccessfulConfigureAccessServices, + onErrorConfigureServer, + "omagServerConfig" + ); + }; + const onSuccessfulConfigureAccessServices = (json) => { + const serverConfig = json.omagServerConfig; + setNewServerConfig(serverConfig); + configureAuditLogDestinations(); + }; + + // Audit Log Destinations + + const configureAuditLogDestinations = () => { + setLoadingText("Configuring audit log destinations..."); + document.getElementById("audit-log-config-element").style.display = "none"; + document.getElementById("loading-container").style.display = "block"; + + // Fetch Server Config + setLoadingText("Fetching final stored server configuration..."); + showNextStep(); + setProgressIndicatorIndex(progressIndicatorIndex + 1); + }; + const onSuccessfulFetchServer = (json) => { + const serverConfig = json.serverConfig; + setNewServerConfig(serverConfig); + showNextStep(); + setProgressIndicatorIndex(progressIndicatorIndex + 1); + document.getElementById("loading-container").style.display = "none"; + }; + const onErrorFetchServer = (error) => { + console.error("Error fetching config", { error }); + setNewServerConfig(null); + setNotificationType("error"); + if (error.code && error.code === "ECONNABORTED") { + setNotificationTitle("Connection Error"); + setNotificationSubtitle( + "Error connecting to the platform. Please ensure the OMAG server platform is available." + ); + } else { + setNotificationTitle("Error fetching the configuration"); + setNotificationSubtitle( + "Error getting server configuration from platform." + ); + } + document.getElementById("loading-container").style.display = "none"; + document.getElementById("config-basic-config-element").style.display = + "block"; + document.getElementById("notification-container").style.display = "block"; + }; + + const handleConfigureESB = () => { + setLoadingText("Configuring ESB..."); + document.getElementById("esb-config-element").style.display = "none"; + document.getElementById("loading-container").style.display = "block"; + // Configure event bus + setLoadingText("Configuring event bus..."); + const serverConfigURL = encodeURI( + "/servers/" + + tenantId + + "/server-author/users/" + + userId + + "/servers/" + + newServerName + + "/event-bus?topicURLRoot=egeriaTopics" + ); + issueRestCreate( + serverConfigURL, + newServerConfig, + onSuccessfulConfigureEventBusURL, + onErrorConfigureServer, + "omagServerConfig" + ); + }; + // Register to a cohort + + const handleRegisterCohorts = () => { + setLoadingText("Registering cohort(s)..."); + document.getElementById("cohort-config-element").style.display = "none"; + document.getElementById("loading-container").style.display = "block"; + + // Fetch Server Config + setLoadingText("Fetching final stored server configuration..."); + fetchServerConfig(onSuccessfulFetchServer, onErrorFetchServer); + }; + + // Configure open metadata archives to load on server startup + + const handleConfigureArchives = async () => { + setLoadingText("Configuring archives(s) to load on server startup..."); + document.getElementById("archives-config-element").style.display = "none"; + document.getElementById("loading-container").style.display = "block"; + // Register archives + for (const archiveName of newServerOMArchives) { + try { + setLoadingText( + `Configuring the OMAG Server to load the ${archiveName} archive upon startup...` + ); + await configureArchiveFile(archiveName); // TODO + } catch (error) { + console.error( + `Error configuring the OMAG Server to load the ${archiveName} archive upon startup`, + { error } + ); + setNotificationType("error"); + if (error.code && error.code === "ECONNABORTED") { + setNotificationTitle("Connection Error"); + setNotificationSubtitle( + "Error connecting to the platform. Please ensure the OMAG server platform is available." + ); + } else { + setNotificationTitle("Configuration Error"); + setNotificationSubtitle( + `Error configuring the OMAG Server to load the ${archiveName} archive upon startup.` + ); + } + document.getElementById("loading-container").style.display = "none"; + document.getElementById("cohort-config-element").style.display = "none"; + document.getElementById("archives-config-element").style.display = + "block"; + document.getElementById("notification-container").style.display = + "block"; + return; + } + } + // Fetch Server Config + // setLoadingText("Fetching final stored server configuration..."); + try { + // const serverConfig = await fetchServerConfig(); + // setNewServerConfig(serverConfig); + showNextStep(); + setProgressIndicatorIndex(progressIndicatorIndex + 1); + } catch (error) { + console.error("error fetching server config", { error }); + setNotificationType("error"); + if (error.code && error.code === "ECONNABORTED") { + setNotificationTitle("Connection Error"); + setNotificationSubtitle( + "Error connecting to the platform. Please ensure the OMAG server platform is available." + ); + } else { + setNotificationTitle("Configuration Error"); + setNotificationSubtitle(`Error fetching configuration for the server.`); + } + document.getElementById("loading-container").style.display = "none"; + document.getElementById("cohort-config-element").style.display = "none"; + document.getElementById("archives-config-element").style.display = + "block"; + document.getElementById("notification-container").style.display = "block"; + } + }; + + // Configure the Repository Proxy Connectors + + const handleConfigureRepositoryProxyConnectors = async () => { + // If all three fields are blank, skip to next step + if ( + (!newServerProxyConnector || newServerProxyConnector === "") && + (!newServerEventMapperConnector || + newServerEventMapperConnector === "") && + (!newServerEventSource || newServerEventSource === "") + ) { + showNextStep(); + setProgressIndicatorIndex(progressIndicatorIndex + 1); + return; + } + // If one or two fields are blank, show notification + if ( + !newServerProxyConnector || + newServerProxyConnector === "" || + !newServerEventMapperConnector || + newServerEventMapperConnector === "" || + !newServerEventSource || + newServerEventSource === "" + ) { + setNotificationType("error"); + setNotificationTitle("Input Error"); + setNotificationSubtitle( + `All three fields are required to configure the repository proxy connector. Leave all three fields blank to skip this step.` + ); + document.getElementById("notification-container").style.display = "block"; + return; + } + setLoadingText("Configuring repository proxy connector..."); + document.getElementById("repository-proxy-config-element").style.display = + "none"; + document.getElementById("loading-container").style.display = "block"; + // Configure the repository proxy connector + try { + await configureRepositoryProxyConnector(newServerProxyConnector); + } catch (error) { + setNotificationType("error"); + if (error.code && error.code === "ECONNABORTED") { + setNotificationTitle("Connection Error"); + setNotificationSubtitle( + "Error connecting to the platform. Please ensure the OMAG server platform is available." + ); + } else { + setNotificationTitle("Configuration Error"); + setNotificationSubtitle( + `Error configuring the repository proxy connector. Please ensure the fully qualified repository proxy connectory name is correct.` + ); + } + document.getElementById("loading-container").style.display = "none"; + document.getElementById("repository-proxy-config-element").style.display = + "block"; + document.getElementById("notification-container").style.display = "block"; + return; + } + // Configure the repository event mapper connector + setLoadingText("Configuring repository event mapper connector..."); + try { + await configureRepositoryEventMapperConnector( + newServerEventMapperConnector, + newServerEventSource + ); + } catch (error) { + setNotificationType("error"); + if (error.code && error.code === "ECONNABORTED") { + setNotificationTitle("Connection Error"); + setNotificationSubtitle( + "Error connecting to the platform. Please ensure the OMAG server platform is available." + ); + } else { + setNotificationTitle("Configuration Error"); + setNotificationSubtitle( + `Error configuring the repository event mapper connector. Please ensure the fully qualified repository event mapper connector name and event source are correct.` + ); + } + document.getElementById("loading-container").style.display = "none"; + document.getElementById("repository-proxy-config-element").style.display = + "block"; + document.getElementById("notification-container").style.display = "block"; + return; + } + // Fetch Server Config + setLoadingText("Fetching final stored server configuration..."); + try { + const serverConfig = await fetchServerConfig(); + setNewServerConfig(serverConfig); + showNextStep(); + setProgressIndicatorIndex(progressIndicatorIndex + 1); + } catch (error) { + console.error("error fetching server config", { error }); + setNotificationType("error"); + if (error.code && error.code === "ECONNABORTED") { + setNotificationTitle("Connection Error"); + setNotificationSubtitle( + "Error connecting to the platform. Please ensure the OMAG server platform is available." + ); + } else { + setNotificationTitle("Configuration Error"); + setNotificationSubtitle(`Error fetching configuration for the server.`); + } + document.getElementById("loading-container").style.display = "none"; + document.getElementById("repository-proxy-config-element").style.display = + "block"; + document.getElementById("notification-container").style.display = "block"; + } + }; + const onChangeServerTypeSelected = (e) => { + const serverType = e.currentTarget.value; + setNewServerLocalServerType(serverType); + const serverTypeElement = serverTypes.find((o) => o.id === serverType); + setServerTypeDescription(serverTypeElement.description); + + // move to the next screen on click + }; + + // Configure the open metadata view services + + const handleConfigureViewServices = async () => { + // If all three fields are blank, skip to next step + if ( + (!newServerViewServiceRemoteServerURLRoot || + newServerViewServiceRemoteServerURLRoot === "") && + (!newServerViewServiceRemoteServerName || + newServerViewServiceRemoteServerName === "") && + (!selectedViewServices || !selectedViewServices.length) + ) { + showNextStep(); + setProgressIndicatorIndex(progressIndicatorIndex + 1); + return; + } + // If one or two fields are blank, show notification + if ( + !newServerViewServiceRemoteServerURLRoot || + newServerViewServiceRemoteServerURLRoot === "" || + !newServerViewServiceRemoteServerName || + newServerViewServiceRemoteServerName === "" || + !selectedViewServices || + !selectedViewServices.length + ) { + setNotificationType("error"); + setNotificationTitle("Input Error"); + setNotificationSubtitle( + `All three fields are required to configure the repository proxy connector. Leave all three fields blank to skip this step.` + ); + document.getElementById("notification-container").style.display = "block"; + return; + } + setLoadingText("Enabling view services..."); + document.getElementById("view-services-element").style.display = "none"; + document.getElementById("loading-container").style.display = "block"; + // Enable View Services + try { + if (selectedViewServices.length === availableViewServices.length) { + configureViewServices( + newServerViewServiceRemoteServerURLRoot, + newServerViewServiceRemoteServerName + ); + } else { + for (const service of selectedViewServices) { + setLoadingText(`Enabling ${service} view service...`); + configureViewServices( + newServerViewServiceRemoteServerURLRoot, + newServerViewServiceRemoteServerName, + service + ); + } + } + } catch (error) { + setNotificationType("error"); + if (error.code && error.code === "ECONNABORTED") { + setNotificationTitle("Connection Error"); + setNotificationSubtitle( + "Error connecting to the platform. Please ensure the OMAG server platform is available." + ); + } else { + setNotificationTitle("Configuration Error"); + setNotificationSubtitle(`Error enabling the view service(s).`); + } + document.getElementById("loading-container").style.display = "none"; + document.getElementById("view-services-element").style.display = "block"; + document.getElementById("notification-container").style.display = "block"; + return; + } + // Fetch Server Config + setLoadingText("Fetching final stored server configuration..."); + try { + const serverConfig = await fetchServerConfig(); + setNewServerConfig(serverConfig); + showNextStep(); + setProgressIndicatorIndex(progressIndicatorIndex + 1); + } catch (error) { + console.error("error fetching server config", { error }); + setNotificationType("error"); + if (error.code && error.code === "ECONNABORTED") { + setNotificationTitle("Connection Error"); + setNotificationSubtitle( + "Error connecting to the platform. Please ensure the OMAG server platform is available." + ); + } else { + setNotificationTitle("Configuration Error"); + setNotificationSubtitle(`Error fetching configuration for the server.`); + } + document.getElementById("loading-container").style.display = "none"; + document.getElementById("view-services-element").style.display = "block"; + document.getElementById("notification-container").style.display = "block"; + } + }; + + // // Configure the Discovery Engines + + // const handleConfigureDiscoveryEngines = async () => { + // // If all three fields are blank, skip to next step + // if ( + // (!newServerDiscoveryEngineRemoteServerURLRoot || + // newServerDiscoveryEngineRemoteServerURLRoot === "") && + // (!newServerDiscoveryEngineRemoteServerName || + // newServerDiscoveryEngineRemoteServerName === "") && + // (!selectedDiscoveryEngines || !selectedDiscoveryEngines.length) + // ) { + // showNextStep(); + // setProgressIndicatorIndex(progressIndicatorIndex + 1); + // return; + // } + // // If one or two fields are blank, show notification + // if ( + // !newServerDiscoveryEngineRemoteServerURLRoot || + // newServerDiscoveryEngineRemoteServerURLRoot === "" || + // !newServerDiscoveryEngineRemoteServerName || + // newServerDiscoveryEngineRemoteServerName === "" || + // !selectedDiscoveryEngines || + // !selectedDiscoveryEngines.length + // ) { + // setNotificationType("error"); + // setNotificationTitle("Input Error"); + // setNotificationSubtitle( + // `All three fields are required to configure the discovery engine. Leave all three fields blank to skip this step.` + // ); + // document.getElementById("notification-container").style.display = "block"; + // return; + // } + // setLoadingText("Configuring discovery engine client..."); + // document.getElementById("discovery-engines-container").style.display = + // "none"; + // document.getElementById("loading-container").style.display = "block"; + // // Configure the discovery engines client + // try { + // await configureDiscoveryEngineClient( + // newServerDiscoveryEngineRemoteServerURLRoot, + // newServerDiscoveryEngineRemoteServerName + // ); + // } catch (error) { + // setNotificationType("error"); + // if (error.code && error.code === "ECONNABORTED") { + // setNotificationTitle("Connection Error"); + // setNotificationSubtitle( + // "Error connecting to the platform. Please ensure the OMAG server platform is available." + // ); + // } else { + // setNotificationTitle("Configuration Error"); + // setNotificationSubtitle( + // `Error configuring the discovery engine client. Please ensure the metadata server root URL and name are correct.` + // ); + // } + // document.getElementById("loading-container").style.display = "none"; + // document.getElementById("discovery-engines-container").style.display = + // "block"; + // document.getElementById("notification-container").style.display = "block"; + // return; + // } + // // Configure the discovery engines + // setLoadingText("Configuring discovery engines..."); + // try { + // await configureDiscoveryEngines(selectedDiscoveryEngines); + // } catch (error) { + // setNotificationType("error"); + // if (error.code && error.code === "ECONNABORTED") { + // setNotificationTitle("Connection Error"); + // setNotificationSubtitle( + // "Error connecting to the platform. Please ensure the OMAG server platform is available." + // ); + // } else { + // setNotificationTitle("Configuration Error"); + // setNotificationSubtitle( + // `Error configuring the discovery engines. ${error.message}` + // ); + // } + // document.getElementById("loading-container").style.display = "none"; + // document.getElementById("discovery-engines-container").style.display = + // "block"; + // document.getElementById("notification-container").style.display = "block"; + // return; + // } + // // Fetch Server Config + // setLoadingText("Fetching final stored server configuration..."); + // try { + // const serverConfig = await fetchServerConfig(); + // setNewServerConfig(serverConfig); + // showNextStep(); + // setProgressIndicatorIndex(progressIndicatorIndex + 1); + // } catch (error) { + // console.error("error fetching server config", { error }); + // setNotificationType("error"); + // if (error.code && error.code === "ECONNABORTED") { + // setNotificationTitle("Connection Error"); + // setNotificationSubtitle( + // "Error connecting to the platform. Please ensure the OMAG server platform is available." + // ); + // } else { + // setNotificationTitle("Configuration Error"); + // setNotificationSubtitle(`Error fetching configuration for the server.`); + // } + // document.getElementById("loading-container").style.display = "none"; + // document.getElementById("discovery-engines-container").style.display = + // "block"; + // document.getElementById("notification-container").style.display = "block"; + // } + // }; + + // // Configure the Stewardship Engines + + // const handleConfigureStewardshipEngines = async () => { + // console.log({ + // newServerStewardshipEngineRemoteServerURLRoot, + // newServerStewardshipEngineRemoteServerName, + // selectedStewardshipEngines, + // }); + // // If all three fields are blank, skip to next step + // if ( + // (!newServerStewardshipEngineRemoteServerURLRoot || + // newServerStewardshipEngineRemoteServerURLRoot === "") && + // (!newServerStewardshipEngineRemoteServerName || + // newServerStewardshipEngineRemoteServerName === "") && + // (!selectedStewardshipEngines || !selectedStewardshipEngines.length) + // ) { + // showNextStep(); + // setProgressIndicatorIndex(progressIndicatorIndex + 1); + // return; + // } + // // If one or two fields are blank, show notification + // if ( + // !newServerStewardshipEngineRemoteServerURLRoot || + // newServerStewardshipEngineRemoteServerURLRoot === "" || + // !newServerStewardshipEngineRemoteServerName || + // newServerStewardshipEngineRemoteServerName === "" || + // !selectedStewardshipEngines || + // !selectedStewardshipEngines.length + // ) { + // setNotificationType("error"); + // setNotificationTitle("Input Error"); + // setNotificationSubtitle( + // `All three fields are required to configure the stewardship engine. Leave all three fields blank to skip this step.` + // ); + // document.getElementById("notification-container").style.display = "block"; + // return; + // } + // setLoadingText("Configuring stewardship engine client..."); + // document.getElementById("stewardship-engines-container").style.display = + // "none"; + // document.getElementById("loading-container").style.display = "block"; + // // Configure the stewardship engines client + // try { + // await configureStewardshipEngineClient( + // newServerStewardshipEngineRemoteServerURLRoot, + // newServerStewardshipEngineRemoteServerName + // ); + // } catch (error) { + // setNotificationType("error"); + // if (error.code && error.code === "ECONNABORTED") { + // setNotificationTitle("Connection Error"); + // setNotificationSubtitle( + // "Error connecting to the platform. Please ensure the OMAG server platform is available." + // ); + // } else { + // setNotificationTitle("Configuration Error"); + // setNotificationSubtitle( + // `Error configuring the stewardship engine client. Please ensure the metadata server root URL and name are correct.` + // ); + // } + // document.getElementById("loading-container").style.display = "none"; + // document.getElementById("stewardship-engines-container").style.display = + // "block"; + // document.getElementById("notification-container").style.display = "block"; + // return; + // } + // // Configure the stewardship engines + // setLoadingText("Configuring stewardship engines..."); + // try { + // await configureStewardshipEngines(selectedStewardshipEngines); + // } catch (error) { + // setNotificationType("error"); + // if (error.code && error.code === "ECONNABORTED") { + // setNotificationTitle("Connection Error"); + // setNotificationSubtitle( + // "Error connecting to the platform. Please ensure the OMAG server platform is available." + // ); + // } else { + // setNotificationTitle("Configuration Error"); + // setNotificationSubtitle( + // `Error configuring the stewardship engines. ${error.message}` + // ); + // } + // document.getElementById("loading-container").style.display = "none"; + // document.getElementById("stewardship-engines-container").style.display = + // "block"; + // document.getElementById("notification-container").style.display = "block"; + // return; + // } + // // Fetch Server Config + // setLoadingText("Fetching final stored server configuration..."); + // try { + // const serverConfig = await fetchServerConfig(); + // setNewServerConfig(serverConfig); + // showNextStep(); + // setProgressIndicatorIndex(progressIndicatorIndex + 1); + // } catch (error) { + // console.error("error fetching server config", { error }); + // setNotificationType("error"); + // if (error.code && error.code === "ECONNABORTED") { + // setNotificationTitle("Connection Error"); + // setNotificationSubtitle( + // "Error connecting to the platform. Please ensure the OMAG server platform is available." + // ); + // } else { + // setNotificationTitle("Configuration Error"); + // setNotificationSubtitle(`Error fetching configuration for the server.`); + // } + // document.getElementById("loading-container").style.display = "none"; + // document.getElementById("stewardship-engines-container").style.display = + // "block"; + // document.getElementById("notification-container").style.display = "block"; + // } + // }; + + // Config Preview + + // const handleDeployConfig = async (e) => { + // e.preventDefault(); + // setLoadingText("Deploying OMAG server from stored configuration..."); + // document.getElementById("config-preview-container").style.display = "none"; + // document.getElementById("loading-container").style.display = "block"; + // // Issue the instance call to start the new server + // const startServerURL = `/open-metadata/admin-services/users/${userId}/servers/${newServerName}/instance`; + // try { + // const startServerResponse = await axios.post( + // startServerURL, + // { + // config: "", + // tenantId, + // }, + // { + // headers: { + // "Content-Type": "application/json", + // }, + // timeout: 30000, + // } + // ); + // if (startServerResponse.data.relatedHTTPCode === 200) { + // setNotificationType("success"); + // setNotificationTitle("Success!"); + // setNotificationSubtitle(`Server instance deployed from configuration.`); + // document.getElementById("loading-container").style.display = "none"; + // document.getElementById("notification-container").style.display = + // "block"; + // document.getElementById("server-list-container").style.display = "flex"; + // } else { + // console.error(startServerResponse.data); + // throw new Error("Error in startServerResponse"); + // } + // } catch (error) { + // console.error("Error starting server from stored config", { error }); + // setNotificationType("error"); + // if (error.code && error.code === "ECONNABORTED") { + // setNotificationTitle("Connection Error"); + // setNotificationSubtitle( + // "Error connecting to the platform. Please ensure the OMAG server platform is available." + // ); + // } else { + // setNotificationTitle("Deployment Error"); + // setNotificationSubtitle( + // `Error starting server from stored configuration file.` + // ); + // } + // document.getElementById("loading-container").style.display = "none"; + // document.getElementById("config-preview-container").style.display = + // "block"; + // document.getElementById("config-final-container").style.display = + // "block"; + // document.getElementById("notification-container").style.display = "block"; + // } + // }; + + return ( + + + +

All OMAG Servers

+ + +
+
+ + + {/* Form Column */} + {/* Progress Indicator Column */} +

Create New OMAG Server

+ + + + + +
+ +
+ +
+ + +
+

+ Select Server Type +

+ + displayHelpForServerTypes() }/> + {/* displayHelpForServerTypes() } > + */} +
+ + +
+ +
+ +

+ Basic Configuration +

+ +
+ +
+ +

+ Select Local Repository +

+ +
+ +
+ +

+ Select Access Services +

+ +
+ +
+

+ Configure Audit Log Destinations +

+ configureAuditLogDestinations()} + previousAction={handleBackToPreviousStep} + /> +
+ +
+ +

+ Configure Enterprise Service Bus +

+
+ Configure Enterprise Service Bus with default topicURLRoot as + 'egeriaTopics' +
+
+ +
+ +

+ Register to the following cohort(s): +

+ +
+ +
+ +

+ Configure the Open Metadata Archives that are loaded on server + startup +

+ +
+ +
+ +

+ Configure the Repository Proxy Connectors +

+ +
+ +
+ +

+ Configure the Open Metadata View Services (OMVS) +

+ +
+ +
+ +

+ Configure the Open Metadata Integration Services (OMIS) +

+ +
+ +
+

+ Congratulations you have successfully configured server '{newServerName}'! +

+ +
+ +
+ +

{loadingText}

+
+
+
+
+ ); +} diff --git a/cra-client/src/components/ServerAuthor/defaults/accessServices.js b/cra-client/src/components/ServerAuthor/components/defaults/accessServices.js similarity index 99% rename from cra-client/src/components/ServerAuthor/defaults/accessServices.js rename to cra-client/src/components/ServerAuthor/components/defaults/accessServices.js index 6dd367a4..7f584bd8 100644 --- a/cra-client/src/components/ServerAuthor/defaults/accessServices.js +++ b/cra-client/src/components/ServerAuthor/components/defaults/accessServices.js @@ -140,6 +140,6 @@ const accessServices = [ "serviceDescription": "Capture changes to the data stores and data set managed by a technology managing collections of data", "serviceWiki": "https://egeria.odpi.org/open-metadata-implementation/access-services/data-manager/" } -] +]; export default accessServices; \ No newline at end of file diff --git a/cra-client/src/components/ServerAuthor/defaults/auditLogDestinations.js b/cra-client/src/components/ServerAuthor/components/defaults/auditLogDestinations.js similarity index 99% rename from cra-client/src/components/ServerAuthor/defaults/auditLogDestinations.js rename to cra-client/src/components/ServerAuthor/components/defaults/auditLogDestinations.js index c5dab28a..80ed07a1 100644 --- a/cra-client/src/components/ServerAuthor/defaults/auditLogDestinations.js +++ b/cra-client/src/components/ServerAuthor/components/defaults/auditLogDestinations.js @@ -22,6 +22,6 @@ const auditLogDestinations = [ id: "event-topic", label: "Event Bus" } -] +]; export default auditLogDestinations; \ No newline at end of file diff --git a/cra-client/src/components/ServerAuthor/defaults/integrationServices.js b/cra-client/src/components/ServerAuthor/components/defaults/integrationServices.js similarity index 99% rename from cra-client/src/components/ServerAuthor/defaults/integrationServices.js rename to cra-client/src/components/ServerAuthor/components/defaults/integrationServices.js index 0cf9b25a..ade8fae0 100644 --- a/cra-client/src/components/ServerAuthor/defaults/integrationServices.js +++ b/cra-client/src/components/ServerAuthor/components/defaults/integrationServices.js @@ -32,6 +32,6 @@ const integrationServices = [ "serviceDescription": "Load information about the teams and people in an organization and return collaboration activity.", "serviceWiki": "https://egeria.odpi.org/open-metadata-implementation/integration-services/organization-integrator/" } -] +]; export default integrationServices; \ No newline at end of file diff --git a/cra-client/src/components/ServerAuthor/components/defaults/serverConfigElements.js b/cra-client/src/components/ServerAuthor/components/defaults/serverConfigElements.js new file mode 100644 index 00000000..5d4b2c76 --- /dev/null +++ b/cra-client/src/components/ServerAuthor/components/defaults/serverConfigElements.js @@ -0,0 +1,68 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +const serverConfigElements = [ + { + id: "server-type-config-element", + label: "Select server type", + description: "Set the type of server to be configured." + }, + { + id: "config-basic-config-element", + label: "Basic configuration", + description: "Basic configuration that all server types can have" + }, + { + id: "audit-log-config-element", + label: "Configure audit log destinations", + description: "Configure the audit log destinations" + }, + { + id: "local-repository-config-element", + label: "Configure Local Repository", + description: "Configure the local repository type." + }, + { + id: "access-services-config-element", + label: "Select access services", + description: "Select the access services required for this server." + }, + { + id: "esb-config-element", + label: "Configure Event Bus", + description: "Configure Event Bus." + }, + { + id: "cohort-config-element", + label: "Register to a cohort", + description: "Register which cohorts this server will be part of." + }, + { + id: "archives-config-element", + label: "Configure the open metadata archives", + description: "Configure which open types archives are to be used by this server." + }, + { + id: "repository-proxy-config-element", + label: "Configure the repository proxy connectors", + description: "Configure the repository proxy connectors to the target proprietory metadata repository." + }, + { + id: "view-services-config-element", + label: "Select and configure the View Services", + description: "Configure view services in order to be able to service a UI" + }, + { + id: "integration-daemon-config-element", + label: "Integration Daemon", + description: "Select and configure the Integration Services." + }, + { + id: "final-config-element", + label: "Server configured", + description: "Server has been confiured." + }, + +]; + +export default serverConfigElements; \ No newline at end of file diff --git a/cra-client/src/components/ServerAuthor/components/defaults/serverTypes.js b/cra-client/src/components/ServerAuthor/components/defaults/serverTypes.js new file mode 100644 index 00000000..044a7830 --- /dev/null +++ b/cra-client/src/components/ServerAuthor/components/defaults/serverTypes.js @@ -0,0 +1,63 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +const serverTypes = [ + + { + id: "metadata-server", + label: "Metadata Server", + description: "Supports a metadata repository that can natively store open metadata types as well as specialized metadata APIs for different types of tools (these APIs are called access services).", + serverConfigElements : ["server-type-config-element", "config-basic-config-element", "local-repository-config-element", "esb-config-element", "cohort-config-element", "access-services-config-element", "archives-config-element", "audit-log-config-element", "final-config-element"] + }, + { + id: "metadata-access-point", + label: "Metadata Access Point", + description: "Supports the access services like the metadata server but does not have a repository. All of the metadata it serves up and stores belongs to the metadata repositories in other members of the cohort.", + serverConfigElements : ["server-type-config-element", "config-basic-config-element", "esb-config-element", "cohort-config-element", "access-services-config-element", "archives-config-element", "audit-log-config-element", "final-config-element"] + }, + { + id: "repository-proxy", + label: "Repository Proxy", + description: "Acts as an open metadata translator for a proprietary metadata repository. It supports open metadata API calls and translates them to the proprietary APIs of the repository. It also translates events from the proprietary repository into open metadata events that flow over the cohort.", + serverConfigElements : ["server-type-config-element", "config-basic-config-element", "esb-config-element", "cohort-config-element", "archives-config-element", "audit-log-config-element", "final-config-element"] + }, + { + id: "view-server", + label: "View Server", + description: "Manages specialist services for user interfaces.", + serverConfigElements : ["server-type-config-element", "config-basic-config-element", "view-services-config-element", "audit-log-config-element", "final-config-element"] + }, + { + id: "conformance-test-server", + label: "Conformance Test Server", + description: "Validates that a member of the cohort is conforming with the open metadata protocols. This server is typically only see in development and test cohort rather than production.", + serverConfigElements : ["server-type-config-element", "config-basic-config-element", "esb-config-element", "cohort-config-element",, "audit-log-config-element", "final-config-element"] + }, + { + id: "data-engine-proxy", + label: "Data Engine Proxy", + description: "Supports the capture of metadata from a data engine. This includes details of the processing of data that it is doing which is valuable when piecing together lineage", + serverConfigElements : ["server-type-config-element", "config-basic-config-element", "audit-log-config-element"] + }, + { + id: "integration-daemon", + label: "Integration Daemon", + description: "Manages the synchronization with third party technology that can not call the access services directly.", + serverConfigElements : ["server-type-config-element", "config-basic-config-element", "integration-daemon-config-element", "audit-log-config-element", "final-config-element"] + }, + { + id: "engine-host", + label: "Engine Host", + description: "Provides a runtime for a specific type of governance engine.", + serverConfigElements : ["server-type-config-element", "config-basic-config-element", "audit-log-config-element", "final-config-element"] + }, + { + id: "open-lineage-server", + label: "Open Lineage Server", + description: "Manages the collation of lineage information am maintains it in a format for reporting. This includes the state of the lineage at different points in time.", + serverConfigElements : ["server-type-config-element", "config-basic-config-element", "audit-log-config-element", "final-config-element"] + }, + +]; + +export default serverTypes; \ No newline at end of file diff --git a/cra-client/src/components/ServerAuthor/defaults/viewServices.js b/cra-client/src/components/ServerAuthor/components/defaults/viewServices.js similarity index 99% rename from cra-client/src/components/ServerAuthor/defaults/viewServices.js rename to cra-client/src/components/ServerAuthor/components/defaults/viewServices.js index 55119036..037e11cc 100644 --- a/cra-client/src/components/ServerAuthor/defaults/viewServices.js +++ b/cra-client/src/components/ServerAuthor/components/defaults/viewServices.js @@ -20,6 +20,6 @@ const viewServices = [ "serviceDescription": "Explore the open metadata types.", "serviceWiki": "https://odpi.github.io/egeria/open-metadata-implementation/access-services/subject-area/" } -] +]; export default viewServices; \ No newline at end of file diff --git a/cra-client/src/components/ServerAuthor/components/serverConfig.scss b/cra-client/src/components/ServerAuthor/components/serverConfig.scss new file mode 100644 index 00000000..1ca926c9 --- /dev/null +++ b/cra-client/src/components/ServerAuthor/components/serverConfig.scss @@ -0,0 +1,58 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +.customAccordionItem > div.bx--accordion__content { + // padding-right: 1rem; + // padding-top: 0; + // padding-bottom: 0; + padding: 0; +} + +.customStructuredListHeader { + vertical-align: baseline; +} + +.expanded-td > td { + padding-top: 16px; + padding-bottom: 16px; + padding-left: 64px; +} + +.bx--structured-list:first-child { + border-top: 1px solid #e0e0e0; +} + +.server-type-card { + width:fit-content; + border:1px; +} +.server-type-container { + display: flex; + flex-direction: row; + justify-content: left +} +.flex-column { + flex-direction: column; +} +.diagram-heading { + margin-top: 30px; + text-align: left; +} +.left-text { + text-align: left; +} + +.left-text-bottom-margin-32 { + text-align: left; + margin-bottom: 32px; +} +.left-text-bottom-margin-24 { + text-align: left; + margin-bottom: 24px; +} +.left-text-bottom-margin-16 { + text-align: left; + margin-bottom: 16px; +} + + diff --git a/cra-client/src/components/ServerAuthor/contexts/ServerAuthorContext.js b/cra-client/src/components/ServerAuthor/contexts/ServerAuthorContext.js new file mode 100644 index 00000000..d912aa80 --- /dev/null +++ b/cra-client/src/components/ServerAuthor/contexts/ServerAuthorContext.js @@ -0,0 +1,522 @@ +/* SPDX-License-Identifier: Apache-2.0 */ +/* Copyright Contributors to the ODPi Egeria project. */ + +import React, { createContext, useContext, useEffect, useRef, useState } from "react"; +import PropTypes from "prop-types"; +import axios from "axios"; + +import { IdentificationContext } from "../../../contexts/IdentificationContext"; + +import accessServices from "../components/defaults/accessServices"; +import serverTypes from "../components/defaults/serverTypes"; +import viewServices from "../components/defaults/viewServices"; +import integrationServices from "../components/defaults/integrationServices"; +import { issueRestCreate, issueRestGet, issueRestDelete } from "../../common/RestCaller"; + +export const ServerAuthorContext = createContext(); +export const ServerAuthorContextConsumer = ServerAuthorContext.Consumer; + +const ServerAuthorContextProvider = props => { + + const { userId, serverName: serverName, user } = useContext(IdentificationContext); + + // All Servers + const [allServers, setAllServers] = useState([]); + // supported audit log severities + const [supportedAuditLogSeverities, setSupportedAuditLogSeverities] = useState([]); + // Basic Config + const [newServerName, setNewServerName] = useState(""); + const [newServerLocalURLRoot, setNewServerLocalURLRoot] = useState("https://localhost:9443"); + const [newServerLocalServerType, setNewServerLocalServerType] = useState(serverTypes[0].id); // default to metadata server for now + const [newServerOrganizationName, setNewServerOrganizationName] = useState(user ? user.organizationName || "" : ""); + const [newServerLocalUserId, setNewServerLocalUserId] = useState(""); + const [newServerLocalPassword, setNewServerLocalPassword] = useState(""); + const [newServerSecurityConnector, setNewServerSecurityConnector] = useState(""); + const [newServerRepository, setNewServerRepository] = useState("in-memory-repository"); + const [newServerMaxPageSize, setNewServerMaxPageSize] = useState(1000); + // Access Services + const [availableAccessServices, setAvailableAccessServices] = useState(accessServices); + const [selectedAccessServices, setSelectedAccessServices] = useState(accessServices); + // Cohorts + const [newServerCohorts, setNewServerCohorts] = useState([]); + // Archives + const [newServerOMArchives, setNewServerOMArchives] = useState([]); + // Proxy + const [newServerProxyConnector, setNewServerProxyConnector] = useState(""); + const [newServerEventMapperConnector, setNewServerEventMapperConnector] = useState(""); + const [newServerEventSource, setNewServerEventSource] = useState(""); + // View Services + const [availableViewServices, setAvailableViewServices] = useState(viewServices); + const [selectedViewServices, setSelectedViewServices] = useState([]); + const [newServerViewServiceRemoteServerName, setNewServerViewServiceRemoteServerName] = useState(""); + const [newServerViewServiceRemoteServerURLRoot, setNewServerViewServiceRemoteServerURLRoot] = useState(""); + + // Integration Services + const [availableIntegrationServices, setAvailableIntegrationServices] = useState(integrationServices); + const [selectedIntegrationService, setSelectedIntegrationService] = useState(""); + const [newServerIntegrationServiceRemoteServerName, setNewServerIntegrationServiceRemoteServerName] = useState(""); + const [newServerIntegrationServiceRemoteServerURLRoot, setNewServerIntegrationServiceRemoteServerURLRoot] = useState(""); + const [newServerIntegrationServiceConnectorName, setNewServerIntegrationServiceConnectorName] = useState(""); + const [newServerIntegrationServiceConnectorUserId, setNewServerIntegrationServiceConnectorUserId] = useState(""); + const [newServerIntegrationServiceConnection, setNewServerIntegrationServiceConnection] = useState(""); + const [newServerIntegrationServiceMetadataSource, setNewServerIntegrationServiceMetadataSource] = useState(""); + const [newServerIntegrationServiceRefreshTimeInterval, setNewServerIntegrationServiceRefreshTimeInterval] = useState(60); + const [newServerIntegrationServiceUsesBlockingCalls, setNewServerIntegrationServiceUsesBlockingCalls] = useState(false); + const [newServerIntegrationServicePermittedSynchronization, setNewServerIntegrationServicePermittedSynchronization] = useState("BOTH_DIRECTIONS"); + // Notifications + const [notificationType, setNotificationType] = useState("error"); + const [notificationTitle, setNotificationTitle] = useState(""); + const [notificationSubtitle, setNotificationSubtitle] = useState(""); + // Progress + const [progressIndicatorIndex, setProgressIndicatorIndex] = useState(0); + const [loadingText, setLoadingText] = useState("Loading..."); + // Preview & Deploy + const [newServerConfig, setNewServerConfig] = useState(null); + const [preventDeployment, setPreventDeployment] = useState(false); + + // Refs + const basicConfigFormStartRef = useRef(null); + const integrationServicesFormStartRef = useRef(null); + + useEffect(() => { + const fetchLists = async () => { + retrieveAllServers(); + }; + fetchLists(); + }, []); +/** + * Clear out all the context so the new server type doe not pick up old values in the wizard. + * Leave NewServerLocalServerType + */ +const cleanForNewServerType = () => { + setNewServerConfig(null); + // can/should we clear refs ??? + setNewServerName(""); + setNewServerLocalURLRoot("https://localhost:9443"); + setNewServerOrganizationName(user ? user.organizationName || "" : ""); + setNewServerLocalUserId(""); + setNewServerLocalPassword(""); + setNewServerSecurityConnector(""); + setNewServerRepository("in-memory-repository"); + setNewServerMaxPageSize(1000); + // Access Services + setAvailableAccessServices(accessServices); + setSelectedAccessServices(accessServices); + // Cohorts + setNewServerCohorts([]); + // Archives + setNewServerOMArchives([]); + // Proxy + setNewServerProxyConnector(""); + setNewServerEventMapperConnector(""); + setNewServerEventSource(""); + // View Services + setAvailableViewServices(viewServices); + setSelectedViewServices([]); + setNewServerViewServiceRemoteServerName(""); + setNewServerViewServiceRemoteServerURLRoot(""); + +}; + + const retrieveAllServers = () => { + console.log("called retrieveAllServers()"); + + const restURL = encodeURI("/servers/" + serverName + "/server-author/users/" + userId + "/platforms"); + issueRestGet(restURL, onSuccessfulFetchPlatforms, onErrorFetchPlatforms, "platforms"); + + }; + + const onSuccessfulFetchPlatforms = (json) => { + + console.log("Successfully fetched platforms = " + JSON.stringify(json)); + const platforms = json.platforms; + let serverList = []; + + for (var i=0;i { + // error + setAllServers([]); + alert("Error getting all servers"); + }; + const onErrorFetchAuditLogSeverities = () => { + // error + setSupportedAuditLogSeverities([]); + alert("Error getting audit log supported severities"); + }; + const onSuccessfulFetchAuditLogSeverities = (json) => { + + console.log( + "Successfully fetched supported audit log severities = " + + JSON.stringify(json) + ); + const severities = json.severities; + // give the items ids + let severitiesWithIds = []; + if (severities && severities.length > 0) { + severitiesWithIds = severities.map(function (item) { + if (item.id !== "") { + return { + id : item.name, + label: item.name, + }; + } + }); + } + + setSupportedAuditLogSeverities(severitiesWithIds); + + }; + const fetchServerConfig = (onSuccessfulFetchServer, onErrorFetchServer ) => { + console.log("called fetchServerConfig"); + const fetchServerConfigURL = + encodeURI("/servers/" + serverName + "/server-author/users/" + userId + "/servers/" + newServerName + "/configuration"); + + + issueRestGet(fetchServerConfigURL, onSuccessfulFetchServer, onErrorFetchServer, "omagServerConfig"); + }; + + const generateBasicServerConfig = () => { + + if (!newServerName || newServerName === "") { + throw new Error(`Cannot create OMAG server configuration without Server Name`); + } + + if (!newServerLocalURLRoot || newServerLocalURLRoot === "") { + throw new Error(`Cannot create OMAG server configuration without Local Server URL Root`); + } + + if (!newServerLocalServerType || newServerLocalServerType === "") { + throw new Error(`Cannot create OMAG server configuration without Local Server Type`); + } + + if (!newServerOrganizationName || newServerOrganizationName === "") { + throw new Error(`Cannot create OMAG server configuration without Organization Name`); + } + + if (!newServerLocalUserId || newServerLocalUserId === "") { + throw new Error(`Cannot create OMAG server configuration without Local Server User ID`); + } + + if (!newServerLocalPassword || newServerLocalPassword === "") { + throw new Error(`Cannot create OMAG server configuration without Local Server Password`); + } + + return { + "class": "OMAGServerConfig", + "versionId": "V2.0", + "localServerName": newServerName, + "localServerType": newServerLocalServerType, + "organizationName": newServerOrganizationName, + "localServerURL": newServerLocalURLRoot, + "localServerUserId": newServerLocalUserId, + "localServerPassword": newServerLocalPassword, + "maxPageSize": newServerMaxPageSize, + } + + }; + + const registerCohort = (cohortName, onSuccessfulRegisterCohort, onErrorRegisterCohort) => { + console.log("called registerCohort", { cohortName }); + + const registerCohortURL = encodeURI("/servers/" + serverName + "/server-author/users/" + userId + "/servers/" + newServerName + "/cohorts/" + cohortName); + issueRestCreate(registerCohortURL, undefined, onSuccessfulRegisterCohort, onErrorRegisterCohort, ""); + }; + + + const unRegisterCohort = (cohortName, onSuccessfulUnRegisterCohort, onErrorUnRegisterCohort) => { + console.log("called unRegisterCohort", { cohortName }); + + const unRegisterCohortURL = encodeURI("/servers/" + serverName + "/server-author/users/" + userId + "/servers/" + newServerName + "/cohorts/" + cohortName); + issueRestDelete(unRegisterCohortURL, onSuccessfulUnRegisterCohort, onErrorUnRegisterCohort); + }; + + const configureArchiveFile = (archiveName, onSuccessfulConfigureArchiveFile, onErrorConfigureArchiveFile) => { + console.log("called configureArchive", { archiveName }); + const configureArchiveURL = encodeURI("/servers/" + serverName + "/server-author/users/" + userId + "/servers/" + newServerName + "/open-metadata-archives/file"); + issueRestGet(configureArchiveURL, onSuccessfulConfigureArchiveFile, onErrorConfigureArchiveFile, "????"); + }; + + + const configureRepositoryProxyConnector = async (className) => { + console.log("called configureRepositoryProxyConnector", { className }); + if (className !== "") { + const configureRepositoryProxyConnectorURL = `/open-metadata/admin-services/users/${userId}/servers/${newServerName}/local-repository/mode/repository-proxy/details?connectorProvider=${className}`; + try { + const configureRepositoryProxyConnectorURLResponse = await axios.post(configureRepositoryProxyConnectorURL, { + serverName, + }, { + headers: { + 'Content-Type': 'application/json' + }, + timeout: 30000, + }); + if (configureRepositoryProxyConnectorURLResponse.data.relatedHTTPCode !== 200) { + throw new Error(configureRepositoryProxyConnectorURLResponse.data.exceptionErrorMessage); + } + } catch(error) { + if (error.code && error.code === 'ECONNABORTED') { + console.error("Error connecting to the platform. Please ensure the OMAG server platform is available."); + } else { + console.error("Error configuring repository proxy connector.", error.message); + } + throw error; + } + } + }; + + const configureRepositoryEventMapperConnector = async (className, eventSource) => { + console.log("called configureRepositoryEventMapperConnector", { className }); + if (className !== "" && eventSource !== "") { + const configureRepositoryEventMapperConnectorURL = `/open-metadata/admin-services/users/${userId}/servers/${newServerName}/local-repository/event-mapper-details?connectorProvider=${className}&eventSource=${eventSource}`; + try { + const configureRepositoryEventMapperConnectorURLResponse = await axios.post(configureRepositoryEventMapperConnectorURL, { + serverName, + }, { + headers: { + 'Content-Type': 'application/json' + }, + timeout: 30000, + }); + if (configureRepositoryEventMapperConnectorURLResponse.data.relatedHTTPCode !== 200) { + throw new Error(configureRepositoryEventMapperConnectorURLResponse.data.exceptionErrorMessage); + } + } catch(error) { + if (error.code && error.code === 'ECONNABORTED') { + console.error("Error connecting to the platform. Please ensure the OMAG server platform is available."); + } else { + console.error("Error configuring repository event mapper connector.", error.message); + } + throw error; + } + } + }; + + const configureViewServices = async (remoteServerURLRoot, remoteServerName, serviceURLMarker) => { + console.log("called configureViewServices", { serviceURLMarker }); + let configureViewServicesURL = `/open-metadata/admin-services/users/${userId}/servers/${newServerName}/view-services`; + if (serviceURLMarker && serviceURLMarker !== "") { + configureViewServicesURL += `/${serviceURLMarker}`; + } + try { + const configureViewServicesURLResponse = await axios.post(configureViewServicesURL, { + serverName, + config: { + "class": "ViewServiceConfig", + "omagserverPlatformRootURL": remoteServerURLRoot, + "omagserverName": remoteServerName, + } + }, { + headers: { + 'Content-Type': 'application/json' + }, + timeout: 30000, + }); + if (configureViewServicesURLResponse.data.relatedHTTPCode !== 200) { + throw new Error(configureViewServicesURLResponse.data.exceptionErrorMessage); + } + } catch(error) { + if (error.code && error.code === 'ECONNABORTED') { + console.error("Error connecting to the platform. Please ensure the OMAG server platform is available."); + } else { + console.error("Error configuring view services.", error.message); + } + throw error; + } + }; + + /** + * Get the config elements for this server type. These will be the steps for the wizard + * @param {*} serverType + * @returns an array (order is important) of config elements relevant for this type. + */ + const serverConfigurationSteps = (serverType) => { + + // find the element in the array with the id of serverType + + const serverTypeElement = serverTypes.find(o => o.id === serverType); + + return serverTypeElement.serverConfigElements; + + // const steps = [ + // "Select server type", + // "Basic configuration", + // "Configure audit log destinations", + // "Preview configuration and deploy instance" + // ]; + + // switch(serverType) { + + // case "View Server": + // steps.splice(steps.length - 1, 0, "Configure the Open Metadata View Services (OMVS)"); + // break; + + // case "Metadata Access Point": + // case "Metadata Server": + // steps.splice(2, 0, "Select access services"); + // steps.splice(steps.length - 1, 0, "Register to a cohort"); + // steps.splice(steps.length - 1, 0, "Configure the open metadata archives"); + // break; + + // case "Repository Proxy": + // steps.splice(steps.length - 1, 0, "Register to a cohort"); + // steps.splice(steps.length - 1, 0, "Configure the open metadata archives"); + // steps.splice(steps.length - 1, 0, "Configure the repository proxy connectors"); + // break; + + // case "Conformance Test Server": + // steps.splice(steps.length - 1, 0, "Register to a cohort"); + // break; + + // case "Integration Daemon": + // steps.splice(steps.length - 1, 0, "Configure the Open Metadata Integration Services (OMIS)"); + // break; + + // } + + // return steps; + + }; + + const setServerAttribute = async (attrEndpoint, value) => { + console.log("called setServerAttribute", { attrEndpoint, value }); + const setServerAttrURL = `/open-metadata/admin-services/users/${userId}/servers/${newServerName}/${attrEndpoint}=${value}`; + try { + const setServerAttrResponse = await axios.post(setServerAttrURL, { + serverName, + }, { + timeout: 30000, + }); + if (setServerAttrResponse.data.relatedHTTPCode !== 200) { + throw new Error("Error in setServerAttrResponse"); + } + } catch(error) { + if (error.code && error.code === 'ECONNABORTED') { + console.error("Error connecting to the platform. Please ensure the OMAG server platform is available."); + } else { + console.error("Error configuring/updating property of OMAG Server", { error }); + } + throw error; + } + }; + + const setServerConfig = (serverConfig) => { + const serverConfigURL = encodeURI("/servers/" + serverName + "/server-author/users/" + userId + "/servers/" + newServerName + "/configuration"); + issueRestCreate(serverConfigURL, serverConfig, onSuccessfulSetServer, onErrorSetServer, "omagserverConfig"); + }; + const onSuccessfulSetServer = (json) =>{ + const serverConfig = json.omagserverConfig; + setNewServerConfig(serverConfig); + }; + const onErrorSetServer = (error) => { + alert("Error setting the server config"); + }; + + const showConfigForm = () => { + document.getElementById("server-list-container").style.display = "none"; + document.getElementById("server-config-container").style.display = "flex"; + }; + + const hideConfigForm = () => { + document.getElementById("server-list-container").style.display = "flex"; + document.getElementById("server-config-container").style.display = "none"; + for (let el of document.querySelectorAll('.hideable')) el.style.display = 'none'; + document.getElementById("server-type-container").style.display = "block"; + setProgressIndicatorIndex(0); + }; + + + return ( + + {props.children} + + ); + +}; + +ServerAuthorContextProvider.propTypes = { + children: PropTypes.node +}; + +export default ServerAuthorContextProvider; \ No newline at end of file diff --git a/cra-client/src/components/ServerAuthor/defaults/auditLogSeverities.js b/cra-client/src/components/ServerAuthor/defaults/auditLogSeverities.js deleted file mode 100644 index c60b7738..00000000 --- a/cra-client/src/components/ServerAuthor/defaults/auditLogSeverities.js +++ /dev/null @@ -1,83 +0,0 @@ -/* SPDX-License-Identifier: Apache-2.0 */ -/* Copyright Contributors to the ODPi Egeria project. */ - -// Information - The server is providing information about its normal operation. -// Event - An event was received from another member of the open metadata repository cohort. -// Decision - A decision has been made related to the interaction of the local metadata repository and the rest of the cohort. -// Action - An Action is required by the administrator. At a minimum, the situation needs to be investigated and if necessary, corrective action taken. -// Error - An error occurred, possibly caused by an incompatibility between the local metadata repository and one of the remote repositories. The local repository may restrict some of the metadata interchange functions as a result. -// Exception - An unexpected exception occurred. This means that the server needs some administration attention to correct configuration or fix a logic error because it is not operating as a proper peer in the open metadata repository cohort. -// Security - Unauthorized access to a service or metadata instance has been attempted. -// Startup - A new component is starting up. -// Shutdown - An existing component is shutting down. -// Asset - An auditable action relating to an asset has been taken. -// Types - Activity is occurring that relates to the open metadata types in use by this server. -// Cohort - The server is exchanging registration information about an open metadata repository cohort that it is connecting to. -// Trace - This is additional information on the operation of the server that may be of assistance in debugging a problem. It is not normally logged to any destination, but can be added when needed., -// PerfMon - This log record contains performance monitoring timing information for specific types of processing. It is not normally logged to any destination, but can be added when needed. -// - Uninitialized Severity - -const auditLogSeverities = [ - { - id: "Information", - label: "Information" - }, - { - id: "Event", - label: "Event" - }, - { - id: "Decision", - label: "Decision" - }, - { - id: "Action", - label: "Action" - }, - { - id: "Error", - label: "Error" - }, - { - id: "Exception", - label: "Exception" - }, - { - id: "Security", - label: "Security" - }, - { - id: "Startup", - label: "Startup" - }, - { - id: "Shutdown", - label: "Shutdown" - }, - { - id: "Asset", - label: "Asset" - }, - { - id: "Types", - label: "Types" - }, - { - id: "Cohort", - label: "Cohort" - }, - { - id: "Trace", - label: "Trace" - }, - { - id: "PerfMon", - label: "PerfMon" - }, - { - id: "", - label: "" - } -] - -export default auditLogSeverities; \ No newline at end of file diff --git a/cra-client/src/components/ServerAuthor/defaults/discoveryEngines.js b/cra-client/src/components/ServerAuthor/defaults/discoveryEngines.js deleted file mode 100644 index e5ed18be..00000000 --- a/cra-client/src/components/ServerAuthor/defaults/discoveryEngines.js +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: Apache-2.0 */ -/* Copyright Contributors to the ODPi Egeria project. */ - -const discoveryEngines = [ - { - "serviceName": "Sample Discovery Engine", - "serviceURLMarker": "sample", - "serviceDescription": "Not a real discovery engine.", - "serviceWiki": "" - } -] - -export default discoveryEngines; \ No newline at end of file diff --git a/cra-client/src/components/ServerAuthor/defaults/serverTypes.js b/cra-client/src/components/ServerAuthor/defaults/serverTypes.js deleted file mode 100644 index e8a2e991..00000000 --- a/cra-client/src/components/ServerAuthor/defaults/serverTypes.js +++ /dev/null @@ -1,47 +0,0 @@ -/* SPDX-License-Identifier: Apache-2.0 */ -/* Copyright Contributors to the ODPi Egeria project. */ - -const serverTypes = [ - { - id: "view-server", - label: "View Server" - }, - { - id: "metadata-server", - label: "Metadata Server" - }, - { - id: "metadata-access-point", - label: "Metadata Access Point" - }, - { - id: "repository-proxy", - label: "Repository Proxy" - }, - { - id: "conformance-test-server", - label: "Conformance Test Server" - }, - { - id: "discovery-server", - label: "Discovery Server" - }, - { - id: "stewardship-server", - label: "Stewardship Server" - }, - { - id: "open-lineage-server", - label: "Open Lineage Server" - }, - { - id: "security-officer-server", - label: "Security Officer Server" - }, - { - id: "integration-daemon", - label: "Integration Daemon" - }, -] - -export default serverTypes; \ No newline at end of file diff --git a/cra-client/src/components/ServerAuthor/defaults/stewardshipEngines.js b/cra-client/src/components/ServerAuthor/defaults/stewardshipEngines.js deleted file mode 100644 index 86696dc3..00000000 --- a/cra-client/src/components/ServerAuthor/defaults/stewardshipEngines.js +++ /dev/null @@ -1,13 +0,0 @@ -/* SPDX-License-Identifier: Apache-2.0 */ -/* Copyright Contributors to the ODPi Egeria project. */ - -const stewardshipEngines = [ - { - "serviceName": "Sample Stewardship Engine", - "serviceURLMarker": "sample", - "serviceDescription": "Not a real stewardship engine.", - "serviceWiki": "" - } -] - -export default stewardshipEngines; \ No newline at end of file diff --git a/cra-client/src/components/ServerAuthor/serverConfig.scss b/cra-client/src/components/ServerAuthor/serverConfig.scss deleted file mode 100644 index 49f6bcff..00000000 --- a/cra-client/src/components/ServerAuthor/serverConfig.scss +++ /dev/null @@ -1,23 +0,0 @@ -/* SPDX-License-Identifier: Apache-2.0 */ -/* Copyright Contributors to the ODPi Egeria project. */ - -.customAccordionItem > div.bx--accordion__content { - // padding-right: 1rem; - // padding-top: 0; - // padding-bottom: 0; - padding: 0; -} - -.customStructuredListHeader { - vertical-align: baseline; -} - -.expanded-td > td { - padding-top: 16px; - padding-bottom: 16px; - padding-left: 64px; -} - -.bx--structured-list:first-child { - border-top: 1px solid #e0e0e0; -} \ No newline at end of file diff --git a/cra-client/src/components/GlossaryAuthor/components/RestCaller.js b/cra-client/src/components/common/RestCaller.js similarity index 67% rename from cra-client/src/components/GlossaryAuthor/components/RestCaller.js rename to cra-client/src/components/common/RestCaller.js index 1e535ba7..d41701f5 100644 --- a/cra-client/src/components/GlossaryAuthor/components/RestCaller.js +++ b/cra-client/src/components/common/RestCaller.js @@ -3,14 +3,12 @@ function processErrorJson(operationName, json, response) { const relatedHTTPCode = json.relatedHTTPCode; - let msg = operationName + "Unexpected response."; + let msg; if (relatedHTTPCode) { if (json.exceptionUserAction) { msg = json.exceptionUserAction; } else if (relatedHTTPCode >= 300 && relatedHTTPCode <= 399) { - msg = - operationName + - "Client error."; + msg = operationName + "Client error."; } else if (relatedHTTPCode >= 400 && relatedHTTPCode <= 499) { msg = "Server error."; } else { @@ -33,7 +31,18 @@ function processErrorJson(operationName, json, response) { " Contact your administrator to review the server logs."; return msg; } -export async function issueRestGet(url, onSuccessful, onError) { +/** + * Issue get rest call + * @param {*} url user to use to issue rest call + * @param {*} onSuccessful function to call on success + * @param {*} onError function to call or error + * @param {*} expectedResult optional expected result - default to 'result'. + * The call is successful if there is a good relatedHTTPCode and it contains the expectedResult property + */ +export async function issueRestGet(url, onSuccessful, onError, expectedResult) { + if (expectedResult === undefined) { + expectedResult = "result"; + } try { const response = await fetch(url, { method: "get", @@ -46,13 +55,13 @@ export async function issueRestGet(url, onSuccessful, onError) { console.log("issueRestGet complete"); let msg; - if (json.relatedHTTPCode === 200 && json.result) { - if (json.result) { + if (json.relatedHTTPCode === 200 && json[expectedResult]) { + if (json[expectedResult]) { onSuccessful(json); } else { // got nothing msg = - "Error. Get request succeded but there were no results. Contact your administrator to review the server logs for errors."; + "Error. Get request succeeded but there were no results. Contact your administrator to review the server logs for errors."; } } else { msg = processErrorJson("Get", json, response); @@ -65,27 +74,42 @@ export async function issueRestGet(url, onSuccessful, onError) { } } -export async function issueRestCreate(url, body, onSuccessful, onError) { +export async function issueRestCreate( + url, + body, + onSuccessful, + onError, + expectedResult +) { console.log("issueRestCreate"); + if (expectedResult === undefined) { + expectedResult = "result"; + } try { - const response = await fetch(url, { + let bodyForRest = { method: "post", headers: { Accept: "application/json", "Content-Type": "application/json", - }, - body: JSON.stringify(body), - }); + } + }; + if (body) { + bodyForRest.body = JSON.stringify(body); + } + const response = await fetch(url, bodyForRest); const json = await response.json(); - const relatedHTTPCode = json.relatedHTTPCode; + let msg; - if (relatedHTTPCode === 200 && json.result) { - if (json.result) { + + + if (json.relatedHTTPCode === 200) { + if (json.class === 'VoidResponse') { + onSuccessful(); + } else if (json[expectedResult]) { onSuccessful(json); } else { - // got nothing - msg = - "Error. Create request succeeded but there were no results. Contact your administrator to review the server logs for errors."; + // 200 successful response but we did not get what we expected + msg = "Error. Create request succeeded but there were no " + expectedResult + ". Contact your administrator to review the server logs for errors."; } } else { msg = processErrorJson("Create", json, response); @@ -108,7 +132,7 @@ export async function issueRestDelete(deleteUrl, onSuccessful, onError) { }, }); await response.json(); - // no response from a delete so no json to return or look for errors in + // no response from a delete so no json to return or look for errors in onSuccessful(); } catch (msg) { onError(msg); diff --git a/cra-client/src/contexts/ServerAuthorContext.js b/cra-client/src/contexts/ServerAuthorContext.js deleted file mode 100644 index d4721e73..00000000 --- a/cra-client/src/contexts/ServerAuthorContext.js +++ /dev/null @@ -1,690 +0,0 @@ -/* SPDX-License-Identifier: Apache-2.0 */ -/* Copyright Contributors to the ODPi Egeria project. */ - -import React, { createContext, useContext, useEffect, useRef, useState } from "react"; -import PropTypes from "prop-types"; -import axios from "axios"; - -import { IdentificationContext } from "./IdentificationContext"; - -import accessServices from "../components/ServerAuthor/defaults/accessServices"; -import serverTypes from "../components/ServerAuthor/defaults/serverTypes"; -import viewServices from "../components/ServerAuthor/defaults/viewServices"; -import discoveryEngines from "../components/ServerAuthor/defaults/discoveryEngines"; -import stewardshipEngines from "../components/ServerAuthor/defaults/stewardshipEngines"; -import integrationServices from "../components/ServerAuthor/defaults/integrationServices"; - -export const ServerAuthorContext = createContext(); -export const ServerAuthorContextConsumer = ServerAuthorContext.Consumer; - -const ServerAuthorContextProvider = props => { - - const { userId, serverName: tenantId, user } = useContext(IdentificationContext); - - // Known Servers - const [knownServers, setKnownServers] = useState([]); - // Basic Config - const [newServerName, setNewServerName] = useState(""); - const [newServerLocalURLRoot, setNewServerLocalURLRoot] = useState("https://localhost:9443"); - const [newServerLocalServerType, setNewServerLocalServerType] = useState(serverTypes[0].label); - const [newServerOrganizationName, setNewServerOrganizationName] = useState(user ? user.organizationName || "" : ""); - const [newServerLocalUserId, setNewServerLocalUserId] = useState(""); - const [newServerLocalPassword, setNewServerLocalPassword] = useState(""); - const [newServerSecurityConnector, setNewServerSecurityConnector] = useState(""); - const [newServerRepository, setNewServerRepository] = useState("in-memory-repository"); - const [newServerMaxPageSize, setNewServerMaxPageSize] = useState(1000); - // Access Services - const [availableAccessServices, setAvailableAccessServices] = useState(accessServices); - const [selectedAccessServices, setSelectedAccessServices] = useState(accessServices); - // Cohorts - const [newServerCohorts, setNewServerCohorts] = useState([]); - // Archives - const [newServerOMArchives, setNewServerOMArchives] = useState([]); - // Proxy - const [newServerProxyConnector, setNewServerProxyConnector] = useState(""); - const [newServerEventMapperConnector, setNewServerEventMapperConnector] = useState(""); - const [newServerEventSource, setNewServerEventSource] = useState(""); - // View Services - const [availableViewServices, setAvailableViewServices] = useState(viewServices); - const [selectedViewServices, setSelectedViewServices] = useState([]); - const [newServerViewServiceRemoteServerName, setNewServerViewServiceRemoteServerName] = useState(""); - const [newServerViewServiceRemoteServerURLRoot, setNewServerViewServiceRemoteServerURLRoot] = useState(""); - // Discovery Engines - const [availableDiscoveryEngines, setAvailableDiscoveryEngines] = useState(discoveryEngines); - const [selectedDiscoveryEngines, setSelectedDiscoveryEngines] = useState([]); - const [newServerDiscoveryEngineRemoteServerName, setNewServerDiscoveryEngineRemoteServerName] = useState(""); - const [newServerDiscoveryEngineRemoteServerURLRoot, setNewServerDiscoveryEngineRemoteServerURLRoot] = useState(""); - // Stewardship Engines - const [availableStewardshipEngines, setAvailableStewardshipEngines] = useState(stewardshipEngines); - const [selectedStewardshipEngines, setSelectedStewardshipEngines] = useState([]); - const [newServerStewardshipEngineRemoteServerName, setNewServerStewardshipEngineRemoteServerName] = useState(""); - const [newServerStewardshipEngineRemoteServerURLRoot, setNewServerStewardshipEngineRemoteServerURLRoot] = useState(""); - // Integration Services - const [availableIntegrationServices, setAvailableIntegrationServices] = useState(integrationServices); - const [selectedIntegrationService, setSelectedIntegrationService] = useState(""); - const [newServerIntegrationServiceRemoteServerName, setNewServerIntegrationServiceRemoteServerName] = useState(""); - const [newServerIntegrationServiceRemoteServerURLRoot, setNewServerIntegrationServiceRemoteServerURLRoot] = useState(""); - const [newServerIntegrationServiceConnectorName, setNewServerIntegrationServiceConnectorName] = useState(""); - const [newServerIntegrationServiceConnectorUserId, setNewServerIntegrationServiceConnectorUserId] = useState(""); - const [newServerIntegrationServiceConnection, setNewServerIntegrationServiceConnection] = useState(""); - const [newServerIntegrationServiceMetadataSource, setNewServerIntegrationServiceMetadataSource] = useState(""); - const [newServerIntegrationServiceRefreshTimeInterval, setNewServerIntegrationServiceRefreshTimeInterval] = useState(60); - const [newServerIntegrationServiceUsesBlockingCalls, setNewServerIntegrationServiceUsesBlockingCalls] = useState(false); - const [newServerIntegrationServicePermittedSynchronization, setNewServerIntegrationServicePermittedSynchronization] = useState("BOTH_DIRECTIONS"); - // Notifications - const [notificationType, setNotificationType] = useState("error"); - const [notificationTitle, setNotificationTitle] = useState(""); - const [notificationSubtitle, setNotificationSubtitle] = useState(""); - // Progress - const [progressIndicatorIndex, setProgressIndicatorIndex] = useState(0); - const [loadingText, setLoadingText] = useState("Loading..."); - // Preview & Deploy - const [newServerConfig, setNewServerConfig] = useState(null); - const [preventDeployment, setPreventDeployment] = useState(false); - - // Refs - const basicConfigFormStartRef = useRef(null); - const discoveryEnginesFormStartRef = useRef(null); - const stewardshipEnginesFormStartRef = useRef(null); - const integrationServicesFormStartRef = useRef(null); - - useEffect(() => { - const fetchLists = async () => { - const serverList = await fetchKnownServers(); - setKnownServers(serverList.map((v) => { return { id: v, serverName: v, status: "known" } })); - const accessServices = await fetchAccessServices(); - setAvailableAccessServices(accessServices); - setSelectedAccessServices(accessServices); - } - fetchLists(); - }, []); - - - const fetchAccessServices = async () => { - const fetchAccessServicesURL = `/open-metadata/platform-services/users/${userId}/server-platform/registered-services/access-services`; - try { - const fetchAccessServicesResponse = await axios.get(fetchAccessServicesURL, { - params: { - tenantId, - }, - timeout: 30000, - }); - console.debug({fetchAccessServicesResponse}); - if (fetchAccessServicesResponse.data.relatedHTTPCode === 200) { - return fetchAccessServicesResponse.data.services; - } else { - throw new Error("Error in fetchAccessServicesResponse"); - } - } catch(error) { - if (error.code && error.code === 'ECONNABORTED') { - console.error("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - console.error("Error fetching access services from platform", { error }); - } - throw error; - } - } - - const fetchKnownServers = async () => { - console.log("called fetchKnownServers()"); - const fetchKnownServersURL = `/open-metadata/platform-services/users/${userId}/server-platform/servers`; - try { - const fetchKnownServersResponse = await axios.get(fetchKnownServersURL, { - params: { - tenantId, - }, - timeout: 30000, - }); - if (fetchKnownServersResponse.data.relatedHTTPCode === 200) { - return fetchKnownServersResponse.data.serverList || []; - } else { - throw new Error(fetchKnownServersResponse.data.exceptionErrorMessage); - } - } catch(error) { - if (error.code && error.code === 'ECONNABORTED') { - console.error("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - console.error("Error fetching known servers.", { error }); - } - throw error; - } - } - - const fetchServerConfig = async () => { - console.log("called fetchServerConfig"); - const fetchServerConfigURL = `/open-metadata/admin-services/users/${userId}/servers/${newServerName}/configuration`; - try { - const fetchServerConfigResponse = await axios.get(fetchServerConfigURL, { - params: { - tenantId, - }, - timeout: 30000, - }); - console.debug({fetchServerConfigResponse}); - if (fetchServerConfigResponse.data.relatedHTTPCode === 200) { - return fetchServerConfigResponse.data.omagserverConfig; - } else { - throw new Error("Error in fetchServerConfigResponse"); - } - } catch(error) { - if (error.code && error.code === 'ECONNABORTED') { - console.error("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - console.error("Error fetching config from platform", { error }); - } - throw error; - } - } - - const generateBasicServerConfig = () => { - - if (!newServerName || newServerName === "") { - throw new Error(`Cannot create OMAG server configuration without Server Name`); - } - - if (!newServerLocalURLRoot || newServerLocalURLRoot === "") { - throw new Error(`Cannot create OMAG server configuration without Local Server URL Root`); - } - - if (!newServerLocalServerType || newServerLocalServerType === "") { - throw new Error(`Cannot create OMAG server configuration without Local Server Type`); - } - - if (!newServerOrganizationName || newServerOrganizationName === "") { - throw new Error(`Cannot create OMAG server configuration without Organization Name`); - } - - if (!newServerLocalUserId || newServerLocalUserId === "") { - throw new Error(`Cannot create OMAG server configuration without Local Server User ID`); - } - - if (!newServerLocalPassword || newServerLocalPassword === "") { - throw new Error(`Cannot create OMAG server configuration without Local Server Password`); - } - - return { - "class": "OMAGServerConfig", - "versionId": "V2.0", - "localServerName": newServerName, - "localServerType": newServerLocalServerType, - "organizationName": newServerOrganizationName, - "localServerURL": newServerLocalURLRoot, - "localServerUserId": newServerLocalUserId, - "localServerPassword": newServerLocalPassword, - "maxPageSize": newServerMaxPageSize, - } - - } - - const registerCohort = async (cohortName) => { - console.log("called registerCohort", { cohortName }); - const registerCohortURL = `/open-metadata/admin-services/users/${userId}/servers/${newServerName}/cohorts/${cohortName}`; - try { - const registerCohortResponse = await axios.post(registerCohortURL, { - tenantId, - }, { - timeout: 30000, - }); - if (registerCohortResponse.data.relatedHTTPCode !== 200) { - throw new Error("Error in registerCohortResponse"); - } - } catch(error) { - if (error.code && error.code === 'ECONNABORTED') { - console.error("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - console.error("Error registering OMAG Server with cohort", { error }); - } - throw error; - } - } - - const configureAccessServices = async (serviceURLMarker) => { - console.log("called configureAccessServices", { serviceURLMarker }); - let configureAccessServicesURL = `/open-metadata/admin-services/users/${userId}/servers/${newServerName}/access-services`; - if (serviceURLMarker && serviceURLMarker !== "") { - configureAccessServicesURL += `/${serviceURLMarker}`; - } - try { - const configureAccessServicesURLResponse = await axios.post(configureAccessServicesURL, { - tenantId, - }, { - headers: { - 'Content-Type': 'application/json' - }, - timeout: 30000, - }); - if (configureAccessServicesURLResponse.data.relatedHTTPCode !== 200) { - throw new Error(configureAccessServicesURLResponse.data.exceptionErrorMessage); - } - } catch(error) { - if (error.code && error.code === 'ECONNABORTED') { - console.error("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - console.error("Error configuring access service(s).", error.message); - } - throw error; - } - } - - const configureArchiveFile = async (archiveName) => { - console.log("called configureArchive", { archiveName }); - const configureArchiveURL = `/open-metadata/admin-services/users/${userId}/servers/${newServerName}/open-metadata-archives/file`; - try { - const configureArchiveResponse = await axios.post(configureArchiveURL, { - tenantId, - config: archiveName - }, { - timeout: 30000, - }); - if (configureArchiveResponse.data.relatedHTTPCode !== 200) { - throw new Error("Error in configureArchiveResponse"); - } - } catch(error) { - if (error.code && error.code === 'ECONNABORTED') { - console.error("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - console.error("Error registering OMAG Server with cohort", { error }); - } - throw error; - } - } - - const configureRepositoryProxyConnector = async (className) => { - console.log("called configureRepositoryProxyConnector", { className }); - if (className !== "") { - const configureRepositoryProxyConnectorURL = `/open-metadata/admin-services/users/${userId}/servers/${newServerName}/local-repository/mode/repository-proxy/details?connectorProvider=${className}`; - try { - const configureRepositoryProxyConnectorURLResponse = await axios.post(configureRepositoryProxyConnectorURL, { - tenantId, - }, { - headers: { - 'Content-Type': 'application/json' - }, - timeout: 30000, - }); - if (configureRepositoryProxyConnectorURLResponse.data.relatedHTTPCode !== 200) { - throw new Error(configureRepositoryProxyConnectorURLResponse.data.exceptionErrorMessage); - } - } catch(error) { - if (error.code && error.code === 'ECONNABORTED') { - console.error("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - console.error("Error configuring repository proxy connector.", error.message); - } - throw error; - } - } - } - - const configureRepositoryEventMapperConnector = async (className, eventSource) => { - console.log("called configureRepositoryEventMapperConnector", { className }); - if (className !== "" && eventSource !== "") { - const configureRepositoryEventMapperConnectorURL = `/open-metadata/admin-services/users/${userId}/servers/${newServerName}/local-repository/event-mapper-details?connectorProvider=${className}&eventSource=${eventSource}`; - try { - const configureRepositoryEventMapperConnectorURLResponse = await axios.post(configureRepositoryEventMapperConnectorURL, { - tenantId, - }, { - headers: { - 'Content-Type': 'application/json' - }, - timeout: 30000, - }); - if (configureRepositoryEventMapperConnectorURLResponse.data.relatedHTTPCode !== 200) { - throw new Error(configureRepositoryEventMapperConnectorURLResponse.data.exceptionErrorMessage); - } - } catch(error) { - if (error.code && error.code === 'ECONNABORTED') { - console.error("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - console.error("Error configuring repository event mapper connector.", error.message); - } - throw error; - } - } - } - - const configureViewServices = async (remoteServerURLRoot, remoteServerName, serviceURLMarker) => { - console.log("called configureViewServices", { serviceURLMarker }); - let configureViewServicesURL = `/open-metadata/admin-services/users/${userId}/servers/${newServerName}/view-services`; - if (serviceURLMarker && serviceURLMarker !== "") { - configureViewServicesURL += `/${serviceURLMarker}`; - } - try { - const configureViewServicesURLResponse = await axios.post(configureViewServicesURL, { - tenantId, - config: { - "class": "ViewServiceConfig", - "omagserverPlatformRootURL": remoteServerURLRoot, - "omagserverName": remoteServerName, - } - }, { - headers: { - 'Content-Type': 'application/json' - }, - timeout: 30000, - }); - if (configureViewServicesURLResponse.data.relatedHTTPCode !== 200) { - throw new Error(configureViewServicesURLResponse.data.exceptionErrorMessage); - } - } catch(error) { - if (error.code && error.code === 'ECONNABORTED') { - console.error("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - console.error("Error configuring view services.", error.message); - } - throw error; - } - } - - const configureDiscoveryEngineClient = async (remoteServerURLRoot, remoteServerName) => { - console.log("called configureDiscoveryEngineClient", { remoteServerURLRoot, remoteServerName }); - const configureDiscoveryEngineClientURL = `/open-metadata/admin-services/users/${userId}/servers/${newServerName}/discovery-server/client-config`; - try { - const configureDiscoveryEngineClientURLResponse = await axios.post(configureDiscoveryEngineClientURL, { - tenantId, - config: { - "class": "OMAGServerClientConfig", - "omagserverPlatformRootURL": remoteServerURLRoot, - "omagserverName": remoteServerName, - } - }, { - headers: { - 'Content-Type': 'application/json' - }, - timeout: 30000, - }); - if (configureDiscoveryEngineClientURLResponse.data.relatedHTTPCode !== 200) { - throw new Error(configureDiscoveryEngineClientURLResponse.data.exceptionErrorMessage); - } - } catch(error) { - if (error.code && error.code === 'ECONNABORTED') { - console.error("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - console.error("Error configuring discovery engine client (metadata server).", error.message); - } - throw error; - } - } - - const configureDiscoveryEngines = async (engines) => { - console.log("called configureDiscoveryEngines", { engines }); - const configureDiscoveryEnginesURL = `/open-metadata/admin-services/users/${userId}/servers/${newServerName}/discovery-server/set-discovery-engines`; - try { - const configureDiscoveryEnginesURLResponse = await axios.post(configureDiscoveryEnginesURL, { - tenantId, - config: engines, - }, { - headers: { - 'Content-Type': 'application/json' - }, - timeout: 30000, - }); - if (configureDiscoveryEnginesURLResponse.data.relatedHTTPCode !== 200) { - throw new Error(configureDiscoveryEnginesURLResponse.data.exceptionErrorMessage); - } - } catch(error) { - if (error.code && error.code === 'ECONNABORTED') { - console.error("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - console.error("Error configuring discovery engines.", error.message); - } - throw error; - } - } - - const configureStewardshipEngineClient = async (remoteServerURLRoot, remoteServerName) => { - console.log("called configureStewardshipEngineClient", { remoteServerURLRoot, remoteServerName }); - const configureStewardshipEngineClientURL = `/open-metadata/admin-services/users/${userId}/servers/${newServerName}/stewardship-server/client-config`; - try { - const configureStewardshipEngineClientURLResponse = await axios.post(configureStewardshipEngineClientURL, { - tenantId, - config: { - "class": "OMAGServerClientConfig", - "omagserverPlatformRootURL": remoteServerURLRoot, - "omagserverName": remoteServerName, - } - }, { - headers: { - 'Content-Type': 'application/json' - }, - timeout: 30000, - }); - if (configureStewardshipEngineClientURLResponse.data.relatedHTTPCode !== 200) { - throw new Error(configureStewardshipEngineClientURLResponse.data.exceptionErrorMessage); - } - } catch(error) { - if (error.code && error.code === 'ECONNABORTED') { - console.error("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - console.error("Error configuring stewardship engine client (metadata server).", error.message); - } - throw error; - } - } - - const configureStewardshipEngines = async (engines) => { - console.log("called configureStewardshipEngines", { engines }); - const configureStewardshipEnginesURL = `/open-metadata/admin-services/users/${userId}/servers/${newServerName}/stewardship-server/set-stewardship-engines`; - try { - const configureStewardshipEnginesURLResponse = await axios.post(configureStewardshipEnginesURL, { - tenantId, - config: engines, - }, { - headers: { - 'Content-Type': 'application/json' - }, - timeout: 30000, - }); - if (configureStewardshipEnginesURLResponse.data.relatedHTTPCode !== 200) { - throw new Error(configureStewardshipEnginesURLResponse.data.exceptionErrorMessage); - } - } catch(error) { - if (error.code && error.code === 'ECONNABORTED') { - console.error("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - console.error("Error configuring stewardship engines.", error.message); - } - throw error; - } - } - - const serverConfigurationSteps = (serverType) => { - - const steps = [ - "Select server type", - "Basic configuration", - "Configure audit log destinations", - "Preview configuration and deploy instance" - ]; - - switch(serverType) { - - case "View Server": - steps.splice(steps.length - 1, 0, "Configure the Open Metadata View Services (OMVS)"); - break; - - case "Metadata Access Point": - case "Metadata Server": - steps.splice(2, 0, "Select access services"); - steps.splice(steps.length - 1, 0, "Register to a cohort"); - steps.splice(steps.length - 1, 0, "Configure the open metadata archives"); - break; - - case "Repository Proxy": - steps.splice(steps.length - 1, 0, "Register to a cohort"); - steps.splice(steps.length - 1, 0, "Configure the open metadata archives"); - steps.splice(steps.length - 1, 0, "Configure the repository proxy connectors"); - break; - - case "Conformance Test Server": - steps.splice(steps.length - 1, 0, "Register to a cohort"); - break; - - case "Discovery Server": - steps.splice(steps.length - 1, 0, "Configure the discovery engine services"); - break; - - case "Stewardship Server": - steps.splice(steps.length - 1, 0, "Configure the stewardship engine services"); - break; - - case "Integration Daemon": - steps.splice(steps.length - 1, 0, "Configure the Open Metadata Integration Services (OMIS)"); - break; - - } - - return steps; - - } - - const setServerAttribute = async (attrEndpoint, value) => { - console.log("called setServerAttribute", { attrEndpoint, value }); - const setServerAttrURL = `/open-metadata/admin-services/users/${userId}/servers/${newServerName}/${attrEndpoint}=${value}`; - try { - const setServerAttrResponse = await axios.post(setServerAttrURL, { - tenantId, - }, { - timeout: 30000, - }); - if (setServerAttrResponse.data.relatedHTTPCode !== 200) { - throw new Error("Error in setServerAttrResponse"); - } - } catch(error) { - if (error.code && error.code === 'ECONNABORTED') { - console.error("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - console.error("Error configuring/updating property of OMAG Server", { error }); - } - throw error; - } - } - - const setServerConfig = async (serverConfig) => { - const setServerConfigURL = `/open-metadata/admin-services/users/${userId}/servers/${newServerName}/configuration`; - try { - const setServerConfigResponse = await axios.post(setServerConfigURL, { - config: serverConfig, - tenantId, - }, { - headers: { - 'Content-Type': 'application/json' - }, - timeout: 30000, - }); - if (setServerConfigResponse.data.relatedHTTPCode !== 200) { - throw new Error("Error in setServerConfigResponse"); - } - } catch(error) { - if (error.code && error.code === 'ECONNABORTED') { - console.error("Error connecting to the platform. Please ensure the OMAG server platform is available."); - } else { - console.error("Error updating configuration of OMAG Server", { error }); - } - throw error; - } - } - - const showConfigForm = () => { - document.getElementById("server-list-container").style.display = "none"; - document.getElementById("server-config-container").style.display = "flex"; - } - - const hideConfigForm = () => { - document.getElementById("server-list-container").style.display = "flex"; - document.getElementById("server-config-container").style.display = "none"; - for (let el of document.querySelectorAll('.hideable')) el.style.display = 'none'; - document.getElementById("server-type-container").style.display = "block"; - setProgressIndicatorIndex(0); - } - - - return ( - - {props.children} - - ); - -}; - -ServerAuthorContextProvider.propTypes = { - children: PropTypes.node -}; - -export default ServerAuthorContextProvider; \ No newline at end of file diff --git a/cra-server/router/routes.js b/cra-server/router/routes.js index d317fe21..1fc49474 100644 --- a/cra-server/router/routes.js +++ b/cra-server/router/routes.js @@ -228,7 +228,7 @@ router.get("/open-metadata/admin-services/*", (req, res) => { return; } const servers = req.app.get("servers"); - const urlRoot = servers[req.query.tenantId].remoteURL; + const urlRoot = servers[req.query.serverName].remoteURL; const apiReq = { method: "get", url: urlRoot + incomingPath, @@ -266,9 +266,9 @@ router.post("/open-metadata/admin-services/*", (req, res) => { res.status(400).send("Error, invalid supplied URL: " + incomingUrl); return; } - const { config, tenantId } = req.body; + const { config, serverName } = req.body; const servers = req.app.get("servers"); - const urlRoot = servers[tenantId].remoteURL; + const urlRoot = servers[serverName].remoteURL; const apiReq = { method: "post", url: urlRoot + incomingUrl, @@ -307,9 +307,9 @@ router.delete("/open-metadata/admin-services/*", (req, res) => { res.status(400).send("Error, invalid supplied URL: " + incomingUrl); return; } - const { config, tenantId } = req.body; + const { config, serverName } = req.body; const servers = req.app.get("servers"); - const urlRoot = servers[tenantId].remoteURL; + const urlRoot = servers[serverName].remoteURL; const apiReq = { method: "delete", url: urlRoot + incomingUrl, @@ -349,8 +349,9 @@ router.get("/open-metadata/platform-services/*", (req, res) => { // res.status(400).send("Error, invalid supplied URL: " + incomingPath); // return; // } + console.log("/open-metadata/platform-services req.query " + JSON.stringify(req.query) ); const servers = req.app.get("servers"); - const urlRoot = servers[req.query.tenantId].remoteURL; + const urlRoot = servers[req.query.serverName].remoteURL; const apiReq = { method: "get", url: urlRoot + incomingPath,