Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve view service admin and add sample view server #8009

Merged
merged 3 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ server.port=9443
#userId used to start up the list of configured servers default is 'system'
startup.user=system
# Comma separated names of servers to be started. The server names should be unquoted.
startup.server.list=active-metadata-store,engine-host,integration-daemon
#startup.server.list=active-metadata-store,engine-host,integration-daemon,view-server

################################################
### SSL security.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@

import org.odpi.openmetadata.frameworks.auditlog.ComponentDevelopmentStatus;

import java.io.Serial;
import java.io.Serializable;

/**
* ViewServiceRegistrationEntry is used by a view service to register its admin services interface.
*/
public class ViewServiceRegistrationEntry implements Serializable
{
private static final long serialVersionUID = 1L;
@Serial
private static final long serialVersionUID = 1L;

private int viewServiceCode;
private ComponentDevelopmentStatus viewServiceDevelopmentStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,29 @@
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import org.odpi.openmetadata.adminservices.configuration.properties.OMAGServerClientConfig;
import org.odpi.openmetadata.adminservices.configuration.properties.ResourceEndpointConfig;

import java.io.Serial;
import java.util.List;
import java.util.Map;
import java.util.Objects;

import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;

/**
* ViewServiceRequestBody passes the minimum information to set up an view server.
* ViewServiceRequestBody passes the minimum information to set up a view server.
*/
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown=true)
public class ViewServiceRequestBody extends OMAGServerClientConfig
{
private static final long serialVersionUID = 1L;
@Serial
private static final long serialVersionUID = 1L;

private Map<String, Object> viewServiceOptions = null;
private Map<String, Object> viewServiceOptions = null;
private List<ResourceEndpointConfig> resourceEndpoints;


/**
Expand All @@ -47,6 +52,7 @@ public ViewServiceRequestBody(ViewServiceRequestBody template)
if (template != null)
{
viewServiceOptions = template.getViewServiceOptions();
resourceEndpoints = template.getResourceEndpoints();
}
}

Expand Down Expand Up @@ -84,6 +90,28 @@ public void setViewServiceOptions(Map<String, Object> viewServiceOptions)
}


/**
* Return the resourceEndpoints list.
*
* @return displayName
*/
public List<ResourceEndpointConfig> getResourceEndpoints()
{
return resourceEndpoints;
}


/**
* Set the resourceEndpoints of resource.
*
* @param resourceEndpoints list of resource endpoint configuration objects
*/
public void setResourceEndpoints(List<ResourceEndpointConfig> resourceEndpoints)
{
this.resourceEndpoints = resourceEndpoints;
}


/**
* Standard toString method.
*
Expand All @@ -94,6 +122,7 @@ public String toString()
{
return "ViewServiceRequestBody{" +
"viewServiceOptions=" + viewServiceOptions +
", resourceEndpoints=" + resourceEndpoints +
", OMAGServerPlatformRootURL='" + getOMAGServerPlatformRootURL() + '\'' +
", OMAGServerName='" + getOMAGServerName() + '\'' +
'}';
Expand Down Expand Up @@ -123,7 +152,8 @@ public boolean equals(Object objectToCompare)
return false;
}
ViewServiceRequestBody that = (ViewServiceRequestBody) objectToCompare;
return Objects.equals(viewServiceOptions, that.viewServiceOptions);
return Objects.equals(viewServiceOptions, that.viewServiceOptions) &&
Objects.equals(resourceEndpoints, that.resourceEndpoints);
}


Expand All @@ -135,6 +165,6 @@ public boolean equals(Object objectToCompare)
@Override
public int hashCode()
{
return Objects.hash(super.hashCode(), viewServiceOptions);
return Objects.hash(super.hashCode(), viewServiceOptions, resourceEndpoints);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

package org.odpi.openmetadata.adminservices.client;

import org.odpi.openmetadata.adminservices.configuration.properties.ResourceEndpointConfig;
import org.odpi.openmetadata.adminservices.configuration.properties.ViewServiceConfig;
import org.odpi.openmetadata.adminservices.ffdc.exception.OMAGConfigurationErrorException;
import org.odpi.openmetadata.adminservices.ffdc.exception.OMAGInvalidParameterException;
Expand All @@ -11,6 +12,7 @@
import org.odpi.openmetadata.adminservices.rest.ViewServicesResponse;
import org.odpi.openmetadata.commonservices.ffdc.rest.RegisteredOMAGService;
import org.odpi.openmetadata.commonservices.ffdc.rest.RegisteredOMAGServicesResponse;
import org.odpi.openmetadata.commonservices.ffdc.rest.VoidResponse;
import org.odpi.openmetadata.frameworks.connectors.ffdc.InvalidParameterException;

import java.util.List;
Expand Down Expand Up @@ -141,12 +143,35 @@
}



/**
* Return the configuration for the view services in this server.
*
* @param viewServices list of view service configuration
* @throws OMAGNotAuthorizedException the supplied userId is not authorized to issue this command.
* @throws OMAGInvalidParameterException invalid parameter.
* @throws OMAGConfigurationErrorException unusual state in the admin server.
*/
public void setViewServicesConfiguration(List<ViewServiceConfig> viewServices) throws OMAGNotAuthorizedException,
OMAGInvalidParameterException,
OMAGConfigurationErrorException
{
final String methodName = "setViewServicesConfiguration";
final String urlTemplate = "/open-metadata/admin-services/users/{0}/servers/{1}/view-services/configuration";

VoidResponse restResult = restClient.callVoidPostRESTCall(methodName,
serverPlatformRootURL + urlTemplate,
viewServices,
adminUserId,
serverName);
Comment on lines +162 to +166

Check notice

Code scanning / CodeQL

Unread local variable Note

Variable 'VoidResponse restResult' is never read.
}


/*
* =============================================================
* Configure server making maximum use of defaults
*/


/**
* Enable a single view service.
*
Expand All @@ -161,6 +186,26 @@
Map<String, Object> viewServiceOptions) throws OMAGNotAuthorizedException,
OMAGInvalidParameterException,
OMAGConfigurationErrorException
{
this.configureViewService(serviceURLMarker, viewServiceOptions, null);
}

/**
* Enable a single view service.
*
* @param serviceURLMarker string indicating which view service it is configuring
* @param viewServiceOptions property name/value pairs used to configure the view service
* @param resourceEndpoints list of resource endpoint configuration objects
*
* @throws OMAGNotAuthorizedException the supplied userId is not authorized to issue this command.
* @throws OMAGInvalidParameterException invalid parameter.
* @throws OMAGConfigurationErrorException unusual state in the admin server.
*/
public void configureViewService(String serviceURLMarker,
Map<String, Object> viewServiceOptions,
List<ResourceEndpointConfig> resourceEndpoints) throws OMAGNotAuthorizedException,
OMAGInvalidParameterException,
OMAGConfigurationErrorException
{
final String methodName = "configureViewService";
final String parameterName = "serviceURLMarker";
Expand All @@ -180,6 +225,7 @@
requestBody.setOMAGServerPlatformRootURL(serverPlatformRootURL);
requestBody.setOMAGServerName(serverName);
requestBody.setViewServiceOptions(viewServiceOptions);
requestBody.setResourceEndpoints(resourceEndpoints);

restClient.callVoidPostRESTCall(methodName,
serverPlatformRootURL + urlTemplate,
Expand All @@ -189,6 +235,7 @@
serviceURLMarker);
}


/**
* Disable a single view service.
*
Expand All @@ -198,9 +245,9 @@
* @throws OMAGInvalidParameterException invalid parameter.
* @throws OMAGConfigurationErrorException unusual state in the admin server.
*/
public void disableViewService(String serviceURLMarker) throws OMAGNotAuthorizedException,
OMAGInvalidParameterException,
OMAGConfigurationErrorException
public void disableViewService(String serviceURLMarker) throws OMAGNotAuthorizedException,
OMAGInvalidParameterException,
OMAGConfigurationErrorException
{
final String methodName = "disableViewService";
final String parameterName = "serviceURLMarker";
Expand Down Expand Up @@ -230,16 +277,18 @@
* @param partnerOMASServerURLRoot URL root of the OMAG Server Platform where the access service used by this view service is running
* @param partnerOMASServerName name of server where the access service used by this view service is running
* @param viewServiceOptions property name/value pairs used to configure the view service
* @param resourceEndpoints list of resource endpoint configuration objects
*
* @throws OMAGNotAuthorizedException the supplied userId is not authorized to issue this command.
* @throws OMAGInvalidParameterException invalid parameter.
* @throws OMAGConfigurationErrorException unusual state in the admin server.
*/
public void configureAllViewService(String partnerOMASServerURLRoot,
String partnerOMASServerName,
Map<String, Object> viewServiceOptions) throws OMAGNotAuthorizedException,
OMAGInvalidParameterException,
OMAGConfigurationErrorException
public void configureAllViewService(String partnerOMASServerURLRoot,
String partnerOMASServerName,
Map<String, Object> viewServiceOptions,
List<ResourceEndpointConfig> resourceEndpoints) throws OMAGNotAuthorizedException,
OMAGInvalidParameterException,
OMAGConfigurationErrorException
{
final String methodName = "configureAllViewService";
final String urlTemplate = "/open-metadata/admin-services/users/{0}/servers/{1}/view-services";
Expand All @@ -249,6 +298,7 @@
requestBody.setOMAGServerPlatformRootURL(partnerOMASServerURLRoot);
requestBody.setOMAGServerName(partnerOMASServerName);
requestBody.setViewServiceOptions(viewServiceOptions);
requestBody.setResourceEndpoints(resourceEndpoints);

restClient.callVoidPostRESTCall(methodName,
serverPlatformRootURL + urlTemplate,
Expand All @@ -258,41 +308,6 @@
}


/**
* Set up the configuration for all the open metadata view services (OMVSs). This overrides
* the current values.
*
* @param viewServicesConfig list of configuration properties for each view service.
*
* @throws OMAGNotAuthorizedException the supplied userId is not authorized to issue this command.
* @throws OMAGInvalidParameterException invalid parameter.
* @throws OMAGConfigurationErrorException unusual state in the admin server.
*/
public void setViewServicesConfig(List<ViewServiceConfig> viewServicesConfig) throws OMAGNotAuthorizedException,
OMAGInvalidParameterException,
OMAGConfigurationErrorException
{
final String methodName = "setViewServicesConfig";
final String configName = "viewServicesConfig";
final String urlTemplate = "/open-metadata/admin-services/users/{0}/servers/{1}/view-services/configuration";

try
{
invalidParameterHandler.validateObject(viewServicesConfig, configName, methodName);
}
catch (InvalidParameterException error)
{
throw new OMAGInvalidParameterException(error.getReportedErrorMessage(), error);
}

restClient.callVoidPostRESTCall(methodName,
serverPlatformRootURL + urlTemplate,
viewServicesConfig,
adminUserId,
serverName);
}


/**
* Disable the view services. This removes all configuration for the view server.
*
Expand Down
Loading
Loading