Commit f57fd7f0 by Mandy Chessell Committed by David Radley

ATLAS-1775 Enterprise OMRS Connector Initial Impl 2

parent 9a4ca16d
......@@ -25,13 +25,13 @@ package org.apache.atlas.ocf.properties;
*/
public class ElementType extends PropertyBase
{
protected String elementTypeId = null;
protected String elementTypeName = null;
protected long elementTypeVersion = 0;
protected String elementTypeDescription = null;
protected String elementAccessServiceURL = null;
protected ElementOrigin elementOrigin = null;
protected String elementHomeMetadataCollectionId = null;
protected String elementTypeId = null;
protected String elementTypeName = null;
protected long elementTypeVersion = 0;
protected String elementTypeDescription = null;
protected String elementSourceServer = null;
protected ElementOrigin elementOrigin = null;
protected String elementHomeMetadataCollectionId = null;
/**
......@@ -41,7 +41,7 @@ public class ElementType extends PropertyBase
* @param elementTypeName - element type name
* @param elementTypeVersion - version number for the element type
* @param elementTypeDescription - description of element type
* @param elementAccessServiceURL - url of the OMAS server
* @param elementSourceServer - url of the OMAS server
* @param elementOrigin - enum describing type of origin
* @param elementHomeMetadataCollectionId - metadata collection id
*/
......@@ -49,7 +49,7 @@ public class ElementType extends PropertyBase
String elementTypeName,
long elementTypeVersion,
String elementTypeDescription,
String elementAccessServiceURL,
String elementSourceServer,
ElementOrigin elementOrigin,
String elementHomeMetadataCollectionId)
{
......@@ -59,7 +59,7 @@ public class ElementType extends PropertyBase
this.elementTypeName = elementTypeName;
this.elementTypeVersion = elementTypeVersion;
this.elementTypeDescription = elementTypeDescription;
this.elementAccessServiceURL = elementAccessServiceURL;
this.elementSourceServer = elementSourceServer;
this.elementOrigin = elementOrigin;
this.elementHomeMetadataCollectionId = elementHomeMetadataCollectionId;
}
......@@ -83,7 +83,7 @@ public class ElementType extends PropertyBase
this.elementTypeName = templateType.getElementTypeName();
this.elementTypeVersion = templateType.getElementTypeVersion();
this.elementTypeDescription = templateType.getElementTypeDescription();
this.elementAccessServiceURL = templateType.getElementAccessServiceURL();
this.elementSourceServer = templateType.getElementSourceServer();
this.elementOrigin = templateType.getElementOrigin();
this.elementHomeMetadataCollectionId = templateType.getElementHomeMetadataCollectionId();
}
......@@ -140,9 +140,9 @@ public class ElementType extends PropertyBase
*
* @return elementSourceServerURL - the url of the server where the element came from
*/
public String getElementAccessServiceURL()
public String getElementSourceServer()
{
return elementAccessServiceURL;
return elementSourceServer;
}
......@@ -179,7 +179,7 @@ public class ElementType extends PropertyBase
", elementTypeName='" + elementTypeName + '\'' +
", elementTypeVersion=" + elementTypeVersion +
", elementTypeDescription='" + elementTypeDescription + '\'' +
", elementAccessServiceURL='" + elementAccessServiceURL + '\'' +
", elementSourceServer='" + elementSourceServer + '\'' +
", elementOrigin=" + elementOrigin +
", elementHomeMetadataCollectionId='" + elementHomeMetadataCollectionId + '\'' +
'}';
......
......@@ -21,6 +21,7 @@ import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.HashMap;
import java.util.Map;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
......@@ -35,6 +36,7 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_
@JsonIgnoreProperties(ignoreUnknown=true)
public class AdditionalProperties extends org.apache.atlas.ocf.properties.AdditionalProperties
{
/**
* Default constructor
*/
......@@ -47,7 +49,7 @@ public class AdditionalProperties extends org.apache.atlas.ocf.properties.Additi
/**
* Set up the additional properties.
*
* @param additionalProperties
* @param additionalProperties - property map
*/
public void setAdditionalProperties(Map<String, Object> additionalProperties)
{
......
......@@ -172,7 +172,7 @@ public class Connection extends org.apache.atlas.ocf.properties.Connection
/**
* Set up the secured properties for this Connection.
*
* @param securedProperties
* @param securedProperties - properties that contain secret information such as log on information.
*/
public void setSecuredProperties(AdditionalProperties securedProperties)
{
......
......@@ -40,6 +40,7 @@ public class ElementType extends org.apache.atlas.ocf.properties.ElementType
public ElementType()
{
super(null);
elementOrigin = ElementOrigin.CONFIGURATION;
}
......@@ -105,7 +106,7 @@ public class ElementType extends org.apache.atlas.ocf.properties.ElementType
*/
public void setElementAccessServiceURL(String elementAccessServiceURL)
{
super.elementAccessServiceURL = elementAccessServiceURL;
super.elementSourceServer = elementAccessServiceURL;
}
......
......@@ -91,12 +91,15 @@
<artifactId>om-fwk-ocf</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.atlas</groupId>
<artifactId>omrs</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
......
......@@ -325,6 +325,8 @@ public interface OMAGServerAdministration
*
* @param userId - user that is issuing the request
* @param serverName - local server name
* @throws OMAGNotAuthorizedException - the supplied userId is not authorized to issue this command.
* @throws OMAGInvalidParameterException - the server name is invalid
* @throws OMAGConfigurationErrorException - there is a problem using the supplied configuration
*/
void initialize (String userId,
......
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.omag.admin.server;
import org.apache.atlas.omag.configuration.registration.AccessServiceRegistration;
import java.util.ArrayList;
import java.util.List;
public class OMAGAccessServiceRegistration
{
static private List<AccessServiceRegistration> accessServiceRegistrationList = new ArrayList<>();
/*
* Register OMAS
*/
public static synchronized void registerAccessService(AccessServiceRegistration registration)
{
if (registration != null)
{
accessServiceRegistrationList.add(registration);
}
}
public static synchronized List<AccessServiceRegistration> getAccessServiceRegistrationList()
{
return accessServiceRegistrationList;
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.omag.admin.server.properties;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
/**
* OMAGAPIResponse provides a common header for OMAG managed responses to its REST API.
* It manages information about exceptions. If no exception has been raised exceptionClassName is null.
*/
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown=true)
public abstract class OMAGAPIResponse
{
protected int relatedHTTPCode = 200;
protected String exceptionClassName = null;
protected String exceptionErrorMessage = null;
protected String exceptionSystemAction = null;
protected String exceptionUserAction = null;
/**
* Default constructor
*/
public OMAGAPIResponse()
{
}
/**
* Return the HTTP Code to use if forwarding response to HTTP client.
*
* @return integer HTTP status code
*/
public int getRelatedHTTPCode()
{
return relatedHTTPCode;
}
/**
* Set up the HTTP Code to use if forwarding response to HTTP client.
*
* @param relatedHTTPCode - integer HTTP status code
*/
public void setRelatedHTTPCode(int relatedHTTPCode)
{
this.relatedHTTPCode = relatedHTTPCode;
}
/**
* Return the name of the Java class name to use to recreate the exception.
*
* @return String name of the fully-qualified java class name
*/
public String getExceptionClassName()
{
return exceptionClassName;
}
/**
* Set up the name of the Java class name to use to recreate the exception.
*
* @param exceptionClassName - String name of the fully-qualified java class name
*/
public void setExceptionClassName(String exceptionClassName)
{
this.exceptionClassName = exceptionClassName;
}
/**
* Return the error message associated with the exception.
*
* @return string error message
*/
public String getExceptionErrorMessage()
{
return exceptionErrorMessage;
}
/**
* Set up the error message associated with the exception.
*
* @param exceptionErrorMessage - string error message
*/
public void setExceptionErrorMessage(String exceptionErrorMessage)
{
this.exceptionErrorMessage = exceptionErrorMessage;
}
/**
* Return the description of the action taken by the system as a result of the exception.
*
* @return - string description of the action taken
*/
public String getExceptionSystemAction()
{
return exceptionSystemAction;
}
/**
* Set up the description of the action taken by the system as a result of the exception.
*
* @param exceptionSystemAction - string description of the action taken
*/
public void setExceptionSystemAction(String exceptionSystemAction)
{
this.exceptionSystemAction = exceptionSystemAction;
}
/**
* Return the action that a user should take to resolve the problem.
*
* @return string instructions
*/
public String getExceptionUserAction()
{
return exceptionUserAction;
}
/**
* Set up the action that a user should take to resolve the problem.
*
* @param exceptionUserAction - string instructions
*/
public void setExceptionUserAction(String exceptionUserAction)
{
this.exceptionUserAction = exceptionUserAction;
}
@Override
public String toString()
{
return "OMAGAPIResponse{" +
"relatedHTTPCode=" + relatedHTTPCode +
", exceptionClassName='" + exceptionClassName + '\'' +
", exceptionErrorMessage='" + exceptionErrorMessage + '\'' +
", exceptionSystemAction='" + exceptionSystemAction + '\'' +
", exceptionUserAction='" + exceptionUserAction + '\'' +
'}';
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.omag.admin.server.properties;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.atlas.omag.configuration.properties.OMAGServerConfig;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
/**
* OMAGServerConfigResponse is the response structure used on the OMAG REST API calls that returns a
* Connection object as a response.
*/
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown=true)
public class OMAGServerConfigResponse extends OMAGAPIResponse
{
private OMAGServerConfig serverConfig = null;
/**
* Default constructor
*/
public OMAGServerConfigResponse()
{
}
/**
* Return the OMAGServerConfig object.
*
* @return OMAGServerConfig object
*/
public OMAGServerConfig getOMAGServerConfig()
{
return serverConfig;
}
/**
* Set up the OMAGServerConfig object.
*
* @param serverConfig - OMAGServerConfig object
*/
public void setOMAGServerConfig(OMAGServerConfig serverConfig)
{
this.serverConfig = serverConfig;
}
@Override
public String toString()
{
return "OMAGServerConfigResponse{" +
"serverConfig=" + serverConfig +
", relatedHTTPCode=" + relatedHTTPCode +
", exceptionClassName='" + exceptionClassName + '\'' +
", exceptionErrorMessage='" + exceptionErrorMessage + '\'' +
", exceptionSystemAction='" + exceptionSystemAction + '\'' +
", exceptionUserAction='" + exceptionUserAction + '\'' +
'}';
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.omag.admin.server.properties;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
/**
* VoidResponse defines the response structure for the OMAG REST API calls that returns a
* void as a response.
*/
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown=true)
public class VoidResponse extends OMAGAPIResponse
{
/**
* Default constructor
*/
public VoidResponse()
{
}
@Override
public String toString()
{
return "VoidResponse{" +
"relatedHTTPCode=" + relatedHTTPCode +
", exceptionClassName='" + exceptionClassName + '\'' +
", exceptionErrorMessage='" + exceptionErrorMessage + '\'' +
", exceptionSystemAction='" + exceptionSystemAction + '\'' +
", exceptionUserAction='" + exceptionUserAction + '\'' +
'}';
}
}
......@@ -27,6 +27,7 @@ import org.apache.atlas.ocf.properties.beans.ElementType;
import org.apache.atlas.ocf.properties.beans.Endpoint;
import org.apache.atlas.omag.configuration.registration.AccessServiceDescription;
import org.apache.atlas.omag.configuration.registration.AccessServiceOperationalStatus;
import org.apache.atlas.omag.configuration.registration.AccessServiceRegistration;
import org.apache.atlas.omrs.topicconnectors.kafka.KafkaOMRSTopicProvider;
import java.io.Serializable;
......@@ -70,19 +71,20 @@ public class AccessServiceConfig implements Serializable
/**
* Set up the default values for an access service using an access service description.
*
* @param accessServiceDescription - AccessServiceDescription enum
* @param accessServiceRegistration - AccessServiceDescription enum
*/
public AccessServiceConfig(AccessServiceDescription accessServiceDescription)
public AccessServiceConfig(AccessServiceRegistration accessServiceRegistration)
{
this.accessServiceId = accessServiceDescription.getAccessServiceCode();
this.accessServiceAdminClass = accessServiceDescription.getAccessServiceAdminClassName();
this.accessServiceName = accessServiceDescription.getAccessServiceDescription();
this.accessServiceWiki = accessServiceDescription.getAccessServiceWiki();
this.accessServiceOperationalStatus = accessServiceDescription.getAccessServiceOperationalStatus();
this.accessServiceId = accessServiceRegistration.getAccessServiceCode();
this.accessServiceName = accessServiceRegistration.getAccessServiceName();
this.accessServiceAdminClass = accessServiceRegistration.getAccessServiceAdminClassName();
this.accessServiceDescription = accessServiceRegistration.getAccessServiceDescription();
this.accessServiceWiki = accessServiceRegistration.getAccessServiceWiki();
this.accessServiceOperationalStatus = accessServiceRegistration.getAccessServiceOperationalStatus();
this.accessServiceInTopic = this.getDefaultTopicConnection(defaultInTopicName,
accessServiceDescription.getAccessServiceInTopic());
accessServiceRegistration.getAccessServiceInTopic());
this.accessServiceOutTopic = this.getDefaultTopicConnection(defaultOutTopicName,
accessServiceDescription.getAccessServiceOutTopic());
accessServiceRegistration.getAccessServiceOutTopic());
}
......
......@@ -44,7 +44,7 @@ import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_
* </li>
* <li>
* localServerType - descriptive type name for the local server. Again this is useful information for the
* administrator to understand which vendor implementation, or versionName of the vendor implementation, is
* administrator to understand which vendor implementation, or version of the vendor implementation, is
* in operation.
*
* The default value is "Open Metadata and Governance Server".
......
......@@ -17,9 +17,11 @@
*/
package org.apache.atlas.omag.configuration.registration;
import org.apache.atlas.ocf.properties.Connection;
import org.apache.atlas.omag.configuration.properties.AccessServiceConfig;
import org.apache.atlas.omag.ffdc.exception.OMAGConfigurationErrorException;
import org.apache.atlas.omrs.auditlog.OMRSAuditLog;
import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnector;
import org.apache.atlas.omrs.topicconnectors.OMRSTopicConnector;
/**
* AccessServiceAdmin is the interface that an access service implements to receive its configuration.
......@@ -31,22 +33,18 @@ public interface AccessServiceAdmin
/**
* Initialize the access service.
*
* @param configurationProperties - specific configuration properties for this access service.
* @throws OMAGConfigurationErrorException - invalid parameters in the configuration properties.
*/
void initialize(AccessServiceConfig configurationProperties,
Connection enterpriseOMRSTopicConnector) throws OMAGConfigurationErrorException;
/**
* Refresh the configuration in the access service.
*
* @param configurationProperties - specific configuration properties for this access service.
* @param accessServiceConfigurationProperties - specific configuration properties for this access service.
* @param enterpriseOMRSTopicConnector - connector for receiving OMRS Events from the cohorts
* @param enterpriseOMRSRepositoryConnector - connector for querying the cohort repositories
* @param auditLog - audit log component for logging messages.
* @param serverUserName - user id to use on OMRS calls where there is no end user.
* @throws OMAGConfigurationErrorException - invalid parameters in the configuration properties.
*/
void refreshConfiguration(AccessServiceConfig configurationProperties,
Connection enterpriseOMRSTopicConnector) throws OMAGConfigurationErrorException;
void initialize(AccessServiceConfig accessServiceConfigurationProperties,
OMRSTopicConnector enterpriseOMRSTopicConnector,
OMRSRepositoryConnector enterpriseOMRSRepositoryConnector,
OMRSAuditLog auditLog,
String serverUserName) throws OMAGConfigurationErrorException;
/**
......
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.omag.configuration.registration;
/**
* AccessServiceRegistration is used by an access service to register its admin interface
*/
public class AccessServiceRegistration
{
private static final long serialVersionUID = 1L;
private static final String defaultTopicRoot = "omag/omas/";
private static final String defaultInTopicLeaf = "/inTopic";
private static final String defaultOutTopicLeaf = "/outTopic";
private int accessServiceCode;
private String accessServiceName;
private String accessServiceDescription;
private String accessServiceWiki;
private AccessServiceOperationalStatus accessServiceOperationalStatus;
private String accessServiceAdminClassName;
/**
* Complete Constructor
*
* @param accessServiceCode - ordinal for this access service
* @param accessServiceName - symbolic name for this access service
* @param accessServiceDescription - short description for this access service
* @param accessServiceWiki - wiki page for the access service for this access service
* @param accessServiceOperationalStatus - default initial operational status for the access service
* @param accessServiceAdminClassName - class name of admin class
*/
public AccessServiceRegistration(int accessServiceCode,
String accessServiceName,
String accessServiceDescription,
String accessServiceWiki,
AccessServiceOperationalStatus accessServiceOperationalStatus,
String accessServiceAdminClassName)
{
/*
* Save the values supplied
*/
this.accessServiceCode = accessServiceCode;
this.accessServiceName = accessServiceName;
this.accessServiceDescription = accessServiceDescription;
this.accessServiceWiki = accessServiceWiki;
this.accessServiceOperationalStatus = accessServiceOperationalStatus;
this.accessServiceAdminClassName = accessServiceAdminClassName;
}
/**
* Default constructor
*/
public AccessServiceRegistration()
{
}
/**
* Return the code for this access service
*
* @return int - type code
*/
public int getAccessServiceCode()
{
return accessServiceCode;
}
/**
* Set up the code for this access service
*
* @param accessServiceCode int - type code
*/
public void setAccessServiceCode(int accessServiceCode)
{
this.accessServiceCode = accessServiceCode;
}
/**
* Return the default name for this access service.
*
* @return String - default name
*/
public String getAccessServiceName()
{
return accessServiceName;
}
/**
* Set up the default name for this access service.
*
* @param accessServiceName String - default name
*/
public void setAccessServiceName(String accessServiceName)
{
this.accessServiceName = accessServiceName;
}
/**
* Return the default description for the type for this access service.
*
* @return String - default description
*/
public String getAccessServiceDescription()
{
return accessServiceDescription;
}
/**
* Set up the default description for the type for this access service.
*
* @param accessServiceDescription String - default description
*/
public void setAccessServiceDescription(String accessServiceDescription)
{
this.accessServiceDescription = accessServiceDescription;
}
/**
* Return the URL for the wiki page describing this access service.
*
* @return String URL name for the wiki page
*/
public String getAccessServiceWiki()
{
return accessServiceWiki;
}
/**
* Set up the URL for the wiki page describing this access service.
*
* @param accessServiceWiki String URL name for the wiki page
*/
public void setAccessServiceWiki(String accessServiceWiki)
{
this.accessServiceWiki = accessServiceWiki;
}
/**
* Return the initial operational status for this access service.
*
* @return AccessServiceOperationalStatus enum
*/
public AccessServiceOperationalStatus getAccessServiceOperationalStatus()
{
return accessServiceOperationalStatus;
}
/**
* Set up the initial operational status for this access service.
*
* @param accessServiceOperationalStatus - AccessServiceOperationalStatus enum
*/
public void setAccessServiceOperationalStatus(AccessServiceOperationalStatus accessServiceOperationalStatus)
{
this.accessServiceOperationalStatus = accessServiceOperationalStatus;
}
/**
* Return the class name of the admin class that should be called during initialization and
* termination.
*
* @return class name
*/
public String getAccessServiceAdminClassName()
{
return accessServiceAdminClassName;
}
/**
* Set up the class name of the admin class that should be called during initialization and
* termination.
*
* @param accessServiceAdminClassName class name
*/
public void setAccessServiceAdminClassName(String accessServiceAdminClassName)
{
this.accessServiceAdminClassName = accessServiceAdminClassName;
}
/**
* Return the InTopic name for the access service.
*
* @return String topic name
*/
public String getAccessServiceInTopic()
{
return defaultTopicRoot + accessServiceName + defaultInTopicLeaf;
}
/**
* Return the OutTopic name for the access service.
*
* @return String topic name
*/
public String getAccessServiceOutTopic()
{
return defaultTopicRoot + accessServiceName + defaultOutTopicLeaf;
}
}
......@@ -116,8 +116,13 @@ public enum OMAGErrorCode
BAD_MAX_PAGE_SIZE(400, "OMAG-ADMIN-400-013 ",
"The OMAG server {0} has been passed an invalid maximum page size of {1}",
"The system has ignored this value.",
"The maximum page size must be a number greater than zero. Retry the request with a valid value.")
;
"The maximum page size must be a number greater than zero. Retry the request with a valid value."),
ENTERPRISE_TOPIC_START_FAILED(400, "OMAG-ADMIN-400-014 ",
"The OMAG server {0} is unable to start the enterprise OMRS topic connector, error message was {1}",
"The open metadata access services will not be able to receive events from the connected repositories.",
"Review the error messages and once the source of the problem is resolved, restart the server and retry the request.")
;
private int httpErrorCode;
private String errorMessageId;
......
......@@ -100,6 +100,18 @@
<dependency>
<groupId>org.apache.atlas</groupId>
<artifactId>omas-connectedasset</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.atlas</groupId>
<artifactId>omas-assetconsumer</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.atlas</groupId>
<artifactId>omag-api</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
......
......@@ -25,7 +25,9 @@ import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@SpringBootApplication
@ComponentScan({"org.apache.atlas.omag.admin.server", "org.apache.atlas.omrs.rest.server"})
@ComponentScan({"org.apache.atlas.omag.admin.server",
"org.apache.atlas.omrs.rest.server",
"org.apache.atlas.omas.*"})
@Configuration
public class OMAGApplication
......
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
# AssetConsumer Open Metadata Access Service (OMAS)
The AssetConsumer OMAS provides services for an application
accessing assets such as data stores, APIs or functions such as analytical services.
The AssetConsumer REST API supports the retrieval of connection metadata, the
adding of feedback to specific assets and an audit log for the asset.
The AssetConsumer Java client supports all of the operations of the REST API.
It adds the capability to act as a factory for connectors to assets.
The Java client takes the name or id of a connection, looks up the properties
of the connection and, using the Open Connector Framework (OCF), it creates a new
connector instance and returns it to the caller.
In addition it can add and remove feedback (tags, ratings, comments, likes) from
the asset description.
The caller can use the connector to access metadata about the
asset it is accessing. This service is provided by the ConnectedAsset OMAS.
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>apache-atlas</artifactId>
<groupId>org.apache.atlas</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>omas-assetconsumer</artifactId>
<name>Asset Consumer Open Metadata Access Service (OMAS)</name>
<description>APIs for tools and applications wishing to access data assets through Open Connector Framework (OCF) connectors.</description>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>1.5.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>1.5.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.atlas</groupId>
<artifactId>om-fwk-ocf</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.atlas</groupId>
<artifactId>omrs</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.atlas</groupId>
<artifactId>omag-api</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.atlas</groupId>
<artifactId>omas-connectedasset</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.2</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.omas.assetconsumer.admin;
import org.apache.atlas.omag.configuration.properties.AccessServiceConfig;
import org.apache.atlas.omag.configuration.registration.AccessServiceAdmin;
import org.apache.atlas.omag.ffdc.exception.OMAGConfigurationErrorException;
import org.apache.atlas.omas.assetconsumer.auditlog.AssetConsumerAuditCode;
import org.apache.atlas.omas.assetconsumer.listener.AssetConsumerOMRSTopicListener;
import org.apache.atlas.omas.assetconsumer.server.AssetConsumerRESTServices;
import org.apache.atlas.omrs.auditlog.OMRSAuditLog;
import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnector;
import org.apache.atlas.omrs.topicconnectors.OMRSTopicConnector;
public class AssetConsumerAdmin implements AccessServiceAdmin
{
private OMRSRepositoryConnector repositoryConnector = null;
private OMRSTopicConnector omrsTopicConnector = null;
private AccessServiceConfig accessServiceConfig = null;
private OMRSAuditLog auditLog = null;
private String serverUserName = null;
private AssetConsumerOMRSTopicListener omrsTopicListener = null;
/**
* Default constructor
*/
public AssetConsumerAdmin()
{
}
/**
* Initialize the access service.
*
* @param accessServiceConfigurationProperties - specific configuration properties for this access service.
* @param enterpriseOMRSTopicConnector - connector for receiving OMRS Events from the cohorts
* @param enterpriseOMRSRepositoryConnector - connector for querying the cohort repositories
* @param auditLog - audit log component for logging messages.
* @param serverUserName - user id to use on OMRS calls where there is no end user.
* @throws OMAGConfigurationErrorException - invalid parameters in the configuration properties.
*/
public void initialize(AccessServiceConfig accessServiceConfigurationProperties,
OMRSTopicConnector enterpriseOMRSTopicConnector,
OMRSRepositoryConnector enterpriseOMRSRepositoryConnector,
OMRSAuditLog auditLog,
String serverUserName) throws OMAGConfigurationErrorException
{
final String actionDescription = "initialize";
AssetConsumerAuditCode auditCode;
auditCode = AssetConsumerAuditCode.SERVICE_INITIALIZING;
auditLog.logRecord(actionDescription,
auditCode.getLogMessageId(),
auditCode.getSeverity(),
auditCode.getFormattedLogMessage(),
null,
auditCode.getSystemAction(),
auditCode.getUserAction());
this.repositoryConnector = enterpriseOMRSRepositoryConnector;
AssetConsumerRESTServices.setRepositoryConnector(accessServiceConfigurationProperties.getAccessServiceName(),
repositoryConnector);
this.accessServiceConfig = accessServiceConfigurationProperties;
this.omrsTopicConnector = enterpriseOMRSTopicConnector;
if (omrsTopicConnector != null)
{
auditCode = AssetConsumerAuditCode.SERVICE_REGISTERED_WITH_TOPIC;
auditLog.logRecord(actionDescription,
auditCode.getLogMessageId(),
auditCode.getSeverity(),
auditCode.getFormattedLogMessage(),
null,
auditCode.getSystemAction(),
auditCode.getUserAction());
omrsTopicListener = new AssetConsumerOMRSTopicListener(accessServiceConfig.getAccessServiceOutTopic(),
repositoryConnector.getRepositoryHelper(),
repositoryConnector.getRepositoryValidator(),
accessServiceConfig.getAccessServiceName());
omrsTopicConnector.registerListener(omrsTopicListener);
}
this.auditLog = auditLog;
this.serverUserName = serverUserName;
auditCode = AssetConsumerAuditCode.SERVICE_INITIALIZED;
auditLog.logRecord(actionDescription,
auditCode.getLogMessageId(),
auditCode.getSeverity(),
auditCode.getFormattedLogMessage(),
null,
auditCode.getSystemAction(),
auditCode.getUserAction());
}
/**
* Shutdown the access service.
*/
public void shutdown()
{
final String actionDescription = "shutdown";
AssetConsumerAuditCode auditCode;
auditCode = AssetConsumerAuditCode.SERVICE_SHUTDOWN;
auditLog.logRecord(actionDescription,
auditCode.getLogMessageId(),
auditCode.getSeverity(),
auditCode.getFormattedLogMessage(),
null,
auditCode.getSystemAction(),
auditCode.getUserAction());
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.omas.assetconsumer.auditlog;
import org.apache.atlas.omrs.auditlog.OMRSAuditLogRecordSeverity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.text.MessageFormat;
import java.util.Arrays;
/**
* The AssetConsumerAuditCode is used to define the message content for the OMRS Audit Log.
*
* The 5 fields in the enum are:
* <ul>
* <li>Log Message Id - to uniquely identify the message</li>
* <li>Severity - is this an event, decision, action, error or exception</li>
* <li>Log Message Text - includes placeholder to allow additional values to be captured</li>
* <li>Additional Information - further parameters and data relating to the audit message (optional)</li>
* <li>SystemAction - describes the result of the situation</li>
* <li>UserAction - describes how a user should correct the situation</li>
* </ul>
*/
public enum AssetConsumerAuditCode
{
SERVICE_INITIALIZING("OMAS-ASSET-CONSUMER-0001",
OMRSAuditLogRecordSeverity.INFO,
"The Asset Consumer Open Metadata Access Service (OMAS) is initializing",
"The local server has started up the Asset Consumer OMAS.",
"No action is required. This is part of the normal operation of the server."),
SERVICE_REGISTERED_WITH_TOPIC("OMAS-ASSET-CONSUMER-0002",
OMRSAuditLogRecordSeverity.INFO,
"The Asset Consumer Open Metadata Access Service (OMAS) is registering a listener with the OMRS Topic",
"The Asset Consumer OMAS is registering to receive events from the connected open metadata repositories.",
"No action is required. This is part of the normal operation of the server."),
SERVICE_INITIALIZED("OMAS-ASSET-CONSUMER-0003",
OMRSAuditLogRecordSeverity.INFO,
"The Asset Consumer Open Metadata Access Service (OMAS) is initialized",
"The Asset Consumer OMAS has completed initialization.",
"No action is required. This is part of the normal operation of the server."),
SERVICE_SHUTDOWN("OMAS-ASSET-CONSUMER-0004",
OMRSAuditLogRecordSeverity.INFO,
"The Asset Consumer Open Metadata Access Service (OMAS) is shutting down",
"The local server has requested shut down of the Asset Consumer OMAS.",
"No action is required. This is part of the normal operation of the server."),
;
private String logMessageId;
private OMRSAuditLogRecordSeverity severity;
private String logMessage;
private String systemAction;
private String userAction;
private static final Logger log = LoggerFactory.getLogger(AssetConsumerAuditCode.class);
/**
* The constructor for OMRSAuditCode expects to be passed one of the enumeration rows defined in
* OMRSAuditCode above. For example:
*
* OMRSAuditCode auditCode = OMRSAuditCode.SERVER_NOT_AVAILABLE;
*
* This will expand out to the 4 parameters shown below.
*
* @param messageId - unique Id for the message
* @param severity - severity of the message
* @param message - text for the message
* @param systemAction - description of the action taken by the system when the condition happened
* @param userAction - instructions for resolving the situation, if any
*/
AssetConsumerAuditCode(String messageId,
OMRSAuditLogRecordSeverity severity,
String message,
String systemAction,
String userAction)
{
this.logMessageId = messageId;
this.severity = severity;
this.logMessage = message;
this.systemAction = systemAction;
this.userAction = userAction;
}
/**
* Returns the unique identifier for the error message.
*
* @return logMessageId
*/
public String getLogMessageId()
{
return logMessageId;
}
/**
* Return the severity of the audit log record.
*
* @return OMRSAuditLogRecordSeverity enum
*/
public OMRSAuditLogRecordSeverity getSeverity()
{
return severity;
}
/**
* Returns the log message with the placeholders filled out with the supplied parameters.
*
* @param params - strings that plug into the placeholders in the logMessage
* @return logMessage (formatted with supplied parameters)
*/
public String getFormattedLogMessage(String... params)
{
if (log.isDebugEnabled())
{
log.debug(String.format("<== OMRS Audit Code.getMessage(%s)", Arrays.toString(params)));
}
MessageFormat mf = new MessageFormat(logMessage);
String result = mf.format(params);
if (log.isDebugEnabled())
{
log.debug(String.format("==> OMRS Audit Code.getMessage(%s): %s", Arrays.toString(params), result));
}
return result;
}
/**
* Returns a description of the action taken by the system when the condition that caused this exception was
* detected.
*
* @return systemAction String
*/
public String getSystemAction()
{
return systemAction;
}
/**
* Returns instructions of how to resolve the issue reported in this exception.
*
* @return userAction String
*/
public String getUserAction()
{
return userAction;
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.omas.assetconsumer.events;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.atlas.omas.assetconsumer.properties.Asset;
import java.io.Serializable;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
/**
* AssetConsumerEvent describes the structure of the events emitted by the Asset Consumer OMAS.
*/
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown=true)
public class AssetConsumerEvent implements Serializable
{
AssetConsumerEventType eventType = AssetConsumerEventType.UNKNOWN_ASSET_CONSUMER_EVENT;
Asset asset = null;
private static final long serialVersionUID = 1L;
/**
* Default constructor
*/
public AssetConsumerEvent()
{
}
/**
* Return the type of event.
*
* @return event type enum
*/
public AssetConsumerEventType getEventType()
{
return eventType;
}
/**
* Set up the type of event.
*
* @param eventType - event type enum
*/
public void setEventType(AssetConsumerEventType eventType)
{
this.eventType = eventType;
}
/**
* Return the asset description.
*
* @return properties about the asset
*/
public Asset getAsset()
{
return asset;
}
/**
* Set up the asset description.
*
* @param asset - properties about the asset.
*/
public void setAsset(Asset asset)
{
this.asset = asset;
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.omas.assetconsumer.events;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.io.Serializable;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
/**
* AssetConsumerEventType describes the different types of events produced by the AssetConsumer OMAS.
*/
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown=true)
public enum AssetConsumerEventType implements Serializable
{
UNKNOWN_ASSET_CONSUMER_EVENT (0, "UnknownAssetConsumerEvent", "An Asset Consumer event that is not recognized by the local server."),
NEW_ASSET_EVENT (1, "NewAsset", "A new asset has been defined."),
UPDATED_ASSET_EVENT (2, "UpdatedAsset", "An existing asset has been updated."),
DELETED_ASSET_EVENT (3, "DeletedAsset", "An existing asset has been deleted.");
private static final long serialVersionUID = 1L;
private int eventTypeCode;
private String eventTypeName;
private String eventTypeDescription;
/**
* Default Constructor - sets up the specific values for this instance of the enum.
*
* @param eventTypeCode - int identifier used for indexing based on the enum.
* @param eventTypeName - string name used for messages that include the enum.
* @param eventTypeDescription - default description for the enum value - used when natural resource
* bundle is not available.
*/
AssetConsumerEventType(int eventTypeCode, String eventTypeName, String eventTypeDescription)
{
this.eventTypeCode = eventTypeCode;
this.eventTypeName = eventTypeName;
this.eventTypeDescription = eventTypeDescription;
}
/**
* Return the int identifier used for indexing based on the enum.
*
* @return int identifier code
*/
public int getEventTypeCode()
{
return eventTypeCode;
}
/**
* Return the string name used for messages that include the enum.
*
* @return String name
*/
public String getEventTypeName()
{
return eventTypeName;
}
/**
* Return the default description for the enum value - used when natural resource
* bundle is not available.
*
* @return String default description
*/
public String getEventTypeDescription()
{
return eventTypeDescription;
}
}
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
# AssetConsumer OMAS FFDC
Package org.apache.atlas.omas.assetconsumer.ffdc provides the
first failure data capture support for the AssetConsumer OMAS module.
This includes an error code enum,
a runtime exception, a base class for checked exceptions plus
implementation of each specific checked exception.
The error code enum (AssetConsumerErrorCode) has an entry for each unique situation
where an exception is returned. Each entry defines:
* A unique id for the error
* An HTTP error code for rest calls
* A unique message Id
* Message text with place holders for specific values
* A description of the cause of the error and system action as a result.
* A description of how to correct the error (if known)
Each exception (whether a checked or runtime exception) has two constructors.
* The first constructor is used when a new error has been detected.
* The second constructor is used when another exception has been caught.
This caught exception is passed on the constructor so it is effectively
embedded in the AssetConsumer OMAS exception.
Both constructors take the values from the AssetConsumerErrorCode
enum to define the cause and resolution.
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.omas.assetconsumer.ffdc.exceptions;
/**
* The AmbiguousConnectionNameException is thrown by the Asset Consumer OMAS when a connection name used (typically the
* displayName) to request a connector instance is not unique and so the Asset Consumer OMAS is not able to determine
* which connection to use.
*/
public class AmbiguousConnectionNameException extends AssetConsumerCheckedExceptionBase
{
/**
* This is the typical constructor used for creating a AmbiguousConnectionNameException.
*
* @param httpCode - http response code to use if this exception flows over a rest call
* @param className - name of class reporting error
* @param actionDescription - description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
*/
public AmbiguousConnectionNameException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
{
super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
}
/**
* This is the constructor used for creating a AmbiguousConnectionNameException that resulted from a previous error.
*
* @param httpCode - http response code to use if this exception flows over a rest call
* @param className - name of class reporting error
* @param actionDescription - description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
* @param caughtError - the error that resulted in this exception.
* */
public AmbiguousConnectionNameException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
{
super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtError);
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.omas.assetconsumer.ffdc.exceptions;
/**
* AssetConsumerCheckedExceptionBase provides a checked exception for reporting errors found when using
* the Asset Consumer OMAS services.
*
* Typically these errors are either configuration or operational errors that can be fixed by an administrator
* or power AssetConsumerInterface. However, there may be the odd bug that surfaces here. The AssetConsumerErrorCode can be used with
* this exception to populate it with standard messages. The aim is to be able to uniquely identify the cause
* and remedy for the error.
*/
public class AssetConsumerCheckedExceptionBase extends Exception
{
/*
* These default values are only seen if this exception is initialized using one of its superclass constructors.
*/
private int reportedHTTPCode;
private String reportingClassName;
private String reportingActionDescription;
private String reportedErrorMessage;
private String reportedSystemAction;
private String reportedUserAction;
private Throwable reportedCaughtException = null;
/**
* This is the typical constructor used for creating a ConnectionCheckedException.
*
* @param httpCode - http response code to use if this exception flows over a rest call
* @param className - name of class reporting error
* @param actionDescription - description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
*/
public AssetConsumerCheckedExceptionBase(int httpCode,
String className,
String actionDescription,
String errorMessage,
String systemAction,
String userAction)
{
super(errorMessage);
this.reportedHTTPCode = httpCode;
this.reportingClassName = className;
this.reportingActionDescription = actionDescription;
this.reportedErrorMessage = errorMessage;
this.reportedSystemAction = systemAction;
this.reportedUserAction = userAction;
}
/**
* This is the constructor used for creating a ConnectionCheckedException that resulted from a previous error.
*
* @param httpCode - http response code to use if this exception flows over a rest call
* @param className - name of class reporting error
* @param actionDescription - description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
* @param caughtError - the error that resulted in this exception.
*/
public AssetConsumerCheckedExceptionBase(int httpCode,
String className,
String actionDescription,
String errorMessage,
String systemAction,
String userAction,
Throwable caughtError)
{
super(errorMessage, caughtError);
this.reportedHTTPCode = httpCode;
this.reportingClassName = className;
this.reportingActionDescription = actionDescription;
this.reportedErrorMessage = errorMessage;
this.reportedSystemAction = systemAction;
this.reportedUserAction = userAction;
this.reportedCaughtException = caughtError;
}
/**
* Return the HTTP response code to use with this exception.
*
* @return reportedHTTPCode
*/
public int getReportedHTTPCode()
{
return reportedHTTPCode;
}
/**
* The class that created this exception.
*
* @return reportingClassName
*/
public String getReportingClassName()
{
return reportingClassName;
}
/**
* The type of request that the class was performing when the condition occurred that resulted in this
* exception.
*
* @return reportingActionDescription
*/
public String getReportingActionDescription()
{
return reportingActionDescription;
}
/**
* A formatted short description of the cause of the condition that resulted in this exception.
*
* @return reportedErrorMessage
*/
public String getErrorMessage()
{
return reportedErrorMessage;
}
/**
* A description of the action that the system took as a result of the error condition.
*
* @return reportedSystemAction
*/
public String getReportedSystemAction()
{
return reportedSystemAction;
}
/**
* A description of the action necessary to correct the error.
*
* @return reportedUserAction
*/
public String getReportedUserAction()
{
return reportedUserAction;
}
/**
* An exception that was caught and wrapped by this exception. If a null is returned, then this exception is
* newly created and not the result of a previous exception.
*
* @return reportedCaughtException
*/
public Throwable getReportedCaughtException() { return reportedCaughtException; }
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.omas.assetconsumer.ffdc.exceptions;
/**
* AssetConsumerRuntimeException is used for all runtime exceptions generated by the connected asset OMAS.
* It is used in conjunction with the AssetConsumerErrorCode to provide first failure data capture for these errors.
*/
public class AssetConsumerRuntimeException extends RuntimeException
{
/*
* These default values are only seen if this exception is initialized using one of its superclass constructors.
*/
private int reportedHTTPCode = 500;
private String reportingClassName = "<Unknown>";
private String reportingActionDescription = "<Unknown>";
private String reportedErrorMessage = "<Unknown>";
private String reportedSystemAction = "<Unknown>";
private String reportedUserAction = "<Unknown>";
private Throwable reportedCaughtException = null;
/**
* This is the typical constructor used for creating an AssetConsumerRuntimeException.
*
* @param httpCode - http response code to use if this exception flows over a rest call
* @param className - name of class reporting error
* @param actionDescription - description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
*/
public AssetConsumerRuntimeException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
{
super(errorMessage);
this.reportedHTTPCode = httpCode;
this.reportingClassName = className;
this.reportingActionDescription = actionDescription;
this.reportedErrorMessage = errorMessage;
this.reportedSystemAction = systemAction;
this.reportedUserAction = userAction;
}
/**
* This is the constructor used for creating a AssetConsumerRuntimeException when an unexpected error has been
* caught.
*
* @param httpCode - http response code to use if this exception flows over a rest call
* @param className - name of class reporting error
* @param actionDescription - description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
* @param caughtError - previous error causing this exception
*/
public AssetConsumerRuntimeException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
{
super(errorMessage, caughtError);
this.reportedHTTPCode = httpCode;
this.reportingClassName = className;
this.reportingActionDescription = actionDescription;
this.reportedErrorMessage = errorMessage;
this.reportedSystemAction = systemAction;
this.reportedUserAction = userAction;
this.reportedCaughtException = caughtError;
}
/**
* Return the HTTP response code to use with this exception.
*
* @return reportedHTTPCode
*/
public int getReportedHTTPCode()
{
return reportedHTTPCode;
}
/**
* The class that created this exception.
*
* @return reportingClassName
*/
public String getReportingClassName()
{
return reportingClassName;
}
/**
* The type of request that the class was performing when the condition occurred that resulted in this
* exception.
*
* @return reportingActionDescription
*/
public String getReportingActionDescription()
{
return reportingActionDescription;
}
/**
* A formatted short description of the cause of the condition that resulted in this exception.
*
* @return reportedErrorMessage
*/
public String getErrorMessage()
{
return reportedErrorMessage;
}
/**
* A description of the action that the system took as a result of the error condition.
*
* @return reportedSystemAction
*/
public String getReportedSystemAction()
{
return reportedSystemAction;
}
/**
* A description of the action necessary to correct the error.
*
* @return reportedUserAction
*/
public String getReportedUserAction()
{
return reportedUserAction;
}
/**
* An exception that was caught and wrapped by this exception. If a null is returned, then this exception is
* newly created and not the result of a previous exception.
*
* @return reportedCaughtException
*/
public Throwable getReportedCaughtException() { return reportedCaughtException; }
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.omas.assetconsumer.ffdc.exceptions;
/**
* The InvalidParameterException is thrown by the Asset Consumer OMAS when a parameters is null or an invalid
* value.
*/
public class InvalidParameterException extends AssetConsumerCheckedExceptionBase
{
/**
* This is the typical constructor used for creating a InvalidParameterException.
*
* @param httpCode - http response code to use if this exception flows over a rest call
* @param className - name of class reporting error
* @param actionDescription - description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
*/
public InvalidParameterException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
{
super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
}
/**
* This is the constructor used for creating a InvalidParameterException that resulted from a previous error.
*
* @param httpCode - http response code to use if this exception flows over a rest call
* @param className - name of class reporting error
* @param actionDescription - description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
* @param caughtError - the error that resulted in this exception.
* */
public InvalidParameterException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
{
super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtError);
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.omas.assetconsumer.ffdc.exceptions;
/**
* The PropertyServerException is thrown by the Asset Consumer OMAS when it is not able to communicate with the
* property server.
*/
public class PropertyServerException extends AssetConsumerCheckedExceptionBase
{
/**
* This is the typical constructor used for creating a PropertyServerException.
*
* @param httpCode - http response code to use if this exception flows over a rest call
* @param className - name of class reporting error
* @param actionDescription - description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
*/
public PropertyServerException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
{
super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
}
/**
* This is the constructor used for creating a PropertyServerException that resulted from a previous error.
*
* @param httpCode - http response code to use if this exception flows over a rest call
* @param className - name of class reporting error
* @param actionDescription - description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
* @param caughtError - the error that resulted in this exception.
* */
public PropertyServerException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
{
super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtError);
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.omas.assetconsumer.ffdc.exceptions;
/**
* The UnrecognizedConnectionGUIDException is thrown by the Asset Consumer OMAS when the unique identifier (guid)
* used to request a connection object from the property server is either unrecognized, or is the identifier
* for a different type of object.
*/
public class UnrecognizedConnectionGUIDException extends AssetConsumerCheckedExceptionBase
{
/**
* This is the typical constructor used for creating a UnrecognizedConnectionGUIDException.
*
* @param httpCode - http response code to use if this exception flows over a rest call
* @param className - name of class reporting error
* @param actionDescription - description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
*/
public UnrecognizedConnectionGUIDException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
{
super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
}
/**
* This is the constructor used for creating a UnrecognizedConnectionGUIDException that resulted from a previous error.
*
* @param httpCode - http response code to use if this exception flows over a rest call
* @param className - name of class reporting error
* @param actionDescription - description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
* @param caughtError - the error that resulted in this exception.
*/
public UnrecognizedConnectionGUIDException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
{
super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtError);
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.omas.assetconsumer.ffdc.exceptions;
/**
* The UnrecognizedConnectionNameException is thrown by the Asset Consumer OMAS when a connection name used
* to request a Connection or Connector is not recognized and so the Asset Consumer OMAS is not able to determine
* which connection to use.
*/
public class UnrecognizedConnectionNameException extends AssetConsumerCheckedExceptionBase
{
/**
* This is the typical constructor used for creating a UnrecognizedConnectionNameException.
*
* @param httpCode - http response code to use if this exception flows over a rest call
* @param className - name of class reporting error
* @param actionDescription - description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
*/
public UnrecognizedConnectionNameException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
{
super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
}
/**
* This is the constructor used for creating a UnrecognizedConnectionNameException that resulted from a previous error.
*
* @param httpCode - http response code to use if this exception flows over a rest call
* @param className - name of class reporting error
* @param actionDescription - description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
* @param caughtError - the error that resulted in this exception.
*/
public UnrecognizedConnectionNameException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
{
super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtError);
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.omas.assetconsumer.ffdc.exceptions;
/**
* The UnrecognizedConnectionURLException is thrown by the Asset Consumer OMAS when a connection URL used
* to request a Connection or Connector is not recognized and so the Asset Consumer OMAS is not able to determine
* which connection to use.
*/
public class UnrecognizedConnectionURLException extends AssetConsumerCheckedExceptionBase
{
/**
* This is the typical constructor used for creating a UnrecognizedConnectionURLException.
*
* @param httpCode - http response code to use if this exception flows over a rest call
* @param className - name of class reporting error
* @param actionDescription - description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
*/
public UnrecognizedConnectionURLException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
{
super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
}
/**
* This is the constructor used for creating a UnrecognizedConnectionURLException that resulted from a previous error.
*
* @param httpCode - http response code to use if this exception flows over a rest call
* @param className - name of class reporting error
* @param actionDescription - description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
* @param caughtError - the error that resulted in this exception.
*/
public UnrecognizedConnectionURLException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
{
super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtError);
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.omas.assetconsumer.ffdc.exceptions;
/**
* The UserNotAuthorizedException is thrown by the Asset Consumer OMAS when a userId passed on a request is not
* authorized to perform the requested action.
*/
public class UserNotAuthorizedException extends AssetConsumerCheckedExceptionBase
{
/**
* This is the typical constructor used for creating a UserNotAuthorizedException.
*
* @param httpCode - http response code to use if this exception flows over a rest call
* @param className - name of class reporting error
* @param actionDescription - description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
*/
public UserNotAuthorizedException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
{
super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
}
/**
* This is the constructor used for creating a UserNotAuthorizedException that resulted from a previous error.
*
* @param httpCode - http response code to use if this exception flows over a rest call
* @param className - name of class reporting error
* @param actionDescription - description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
* @param caughtError - the error that resulted in this exception.
* */
public UserNotAuthorizedException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
{
super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtError);
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.omas.assetconsumer.listener;
import org.apache.atlas.ocf.properties.Connection;
import org.apache.atlas.omas.assetconsumer.publisher.AssetConsumerPublisher;
import org.apache.atlas.omrs.eventmanagement.events.OMRSEventOriginator;
import org.apache.atlas.omrs.eventmanagement.events.OMRSInstanceEvent;
import org.apache.atlas.omrs.eventmanagement.events.OMRSInstanceEventType;
import org.apache.atlas.omrs.eventmanagement.events.v1.OMRSEventV1;
import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryHelper;
import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryValidator;
import org.apache.atlas.omrs.topicconnectors.OMRSTopicListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class AssetConsumerOMRSTopicListener implements OMRSTopicListener
{
private static final Logger log = LoggerFactory.getLogger(AssetConsumerOMRSTopicListener.class);
private AssetConsumerPublisher publisher;
/**
* The constructor is given the connection to the out topic for Asset Consumer OMAS
* along with classes for testing and manipulating instances.
*
* @param assetConsumerOutTopic - connection to the out topic
* @param repositoryHelper - provides methods for working with metadata instances
* @param repositoryValidator - provides validation of metadata instance
* @param componentName - name of component
*/
public AssetConsumerOMRSTopicListener(Connection assetConsumerOutTopic,
OMRSRepositoryHelper repositoryHelper,
OMRSRepositoryValidator repositoryValidator,
String componentName)
{
publisher = new AssetConsumerPublisher(assetConsumerOutTopic,
repositoryHelper,
repositoryValidator,
componentName);
}
/**
* Method to pass an event received on topic.
*
* @param event - inbound event
*/
public void processEvent(OMRSEventV1 event)
{
/*
* The event should not be null but worth checking.
*/
if (event != null)
{
/*
* Determine the category of event to process.
*/
switch (event.getEventCategory())
{
case REGISTRY:
if (log.isDebugEnabled())
{
log.debug("Ignoring registry event: " + event.toString());
}
break;
case TYPEDEF:
if (log.isDebugEnabled())
{
log.debug("Ignoring type event: " + event.toString());
}
break;
case INSTANCE:
this.processInstanceEvent(new OMRSInstanceEvent(event));
break;
default:
if (log.isDebugEnabled())
{
log.debug("Unknown event received :|");
}
}
}
else
{
if (log.isDebugEnabled())
{
log.debug("Null OMRS Event received :(");
}
}
}
/**
* Unpack and deliver an instance event to the InstanceEventProcessor
*
* @param instanceEvent - event to unpack
*/
private void processInstanceEvent(OMRSInstanceEvent instanceEvent)
{
if (log.isDebugEnabled())
{
log.debug("Processing instance event", instanceEvent);
}
if (instanceEvent == null)
{
if (log.isDebugEnabled())
{
log.debug("Null instance event - ignoring event");
}
}
else
{
OMRSInstanceEventType instanceEventType = instanceEvent.getInstanceEventType();
OMRSEventOriginator instanceEventOriginator = instanceEvent.getEventOriginator();
if ((instanceEventType != null) && (instanceEventOriginator != null))
{
switch (instanceEventType)
{
case NEW_ENTITY_EVENT:
publisher.processNewEntity(instanceEvent.getEntity());
break;
case UPDATED_ENTITY_EVENT:
publisher.processUpdatedEntity(instanceEvent.getEntity());
break;
case CLASSIFIED_ENTITY_EVENT:
publisher.processUpdatedEntity(instanceEvent.getEntity());
break;
case RECLASSIFIED_ENTITY_EVENT:
publisher.processUpdatedEntity(instanceEvent.getEntity());
break;
case DECLASSIFIED_ENTITY_EVENT:
publisher.processUpdatedEntity(instanceEvent.getEntity());
break;
case DELETED_ENTITY_EVENT:
publisher.processDeletedEntity(instanceEvent.getEntity());
break;
case PURGED_ENTITY_EVENT:
if (log.isDebugEnabled())
{
log.debug("Ignoring entity purge events");
}
break;
case UNDONE_ENTITY_EVENT:
publisher.processUpdatedEntity(instanceEvent.getEntity());
break;
case RESTORED_ENTITY_EVENT:
publisher.processRestoredEntity(instanceEvent.getEntity());
break;
case REFRESH_ENTITY_REQUEST:
case REFRESHED_ENTITY_EVENT:
case RE_HOMED_ENTITY_EVENT:
case RETYPED_ENTITY_EVENT:
case RE_IDENTIFIED_ENTITY_EVENT:
if (log.isDebugEnabled())
{
log.debug("Ignoring entity repository maintenance events");
}
break;
case NEW_RELATIONSHIP_EVENT:
publisher.processNewRelationship(instanceEvent.getRelationship());
break;
case UPDATED_RELATIONSHIP_EVENT:
publisher.processUpdatedRelationship(instanceEvent.getRelationship());
break;
case UNDONE_RELATIONSHIP_EVENT:
publisher.processUpdatedRelationship(instanceEvent.getRelationship());
break;
case DELETED_RELATIONSHIP_EVENT:
publisher.processDeletedRelationship(instanceEvent.getRelationship());
break;
case PURGED_RELATIONSHIP_EVENT:
if (log.isDebugEnabled())
{
log.debug("Ignoring relationship purge events");
}
break;
case RESTORED_RELATIONSHIP_EVENT:
publisher.processRestoredRelationship(instanceEvent.getRelationship());
break;
case REFRESH_RELATIONSHIP_REQUEST:
case REFRESHED_RELATIONSHIP_EVENT:
case RE_IDENTIFIED_RELATIONSHIP_EVENT:
case RE_HOMED_RELATIONSHIP_EVENT:
case RETYPED_RELATIONSHIP_EVENT:
if (log.isDebugEnabled())
{
log.debug("Ignoring relationship repository maintenance events");
}
break;
case INSTANCE_ERROR_EVENT:
if (log.isDebugEnabled())
{
log.debug("Ignoring instance error events");
}
break;
}
}
else
{
if (log.isDebugEnabled())
{
log.debug("Ignored instance event - null type");
}
}
}
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.omas.assetconsumer.properties;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
/**
* Asset describes the basic properties of an Asset
*/
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown=true)
public class Asset
{
/*
* URL where the metadata about the asset is located. It remains null if no repository is known.
*/
/*
* Unique id for the asset.
*/
protected String url = null;
protected String guid = null;
protected String typeId = null;
protected String typeName = null;
protected long typeVersion = 0;
protected String typeDescription = null;
protected String qualifiedName = null;
protected String displayName = null;
protected String description = null;
protected String owner = null;
/**
* Default constructor
*/
public Asset()
{
}
public String getURL()
{
return url;
}
public void setURL(String url)
{
this.url = url;
}
public String getGUID()
{
return guid;
}
public void setGUID(String guid)
{
this.guid = guid;
}
public String getTypeId()
{
return typeId;
}
public void setTypeId(String typeId)
{
this.typeId = typeId;
}
public String getTypeName()
{
return typeName;
}
public void setTypeName(String typeName)
{
this.typeName = typeName;
}
public long getTypeVersion()
{
return typeVersion;
}
public void setTypeVersion(long typeVersion)
{
this.typeVersion = typeVersion;
}
public String getTypeDescription()
{
return typeDescription;
}
public void setTypeDescription(String typeDescription)
{
this.typeDescription = typeDescription;
}
public String getQualifiedName()
{
return qualifiedName;
}
public void setQualifiedName(String qualifiedName)
{
this.qualifiedName = qualifiedName;
}
public String getDisplayName()
{
return displayName;
}
public void setDisplayName(String displayName)
{
this.displayName = displayName;
}
public String getDescription()
{
return description;
}
public void setDescription(String description)
{
this.description = description;
}
public String getOwner()
{
return owner;
}
public void setOwner(String owner)
{
this.owner = owner;
}
@Override
public String toString()
{
return "Asset{" +
"url='" + url + '\'' +
", guid='" + guid + '\'' +
", typeId='" + typeId + '\'' +
", typeName='" + typeName + '\'' +
", typeVersion=" + typeVersion +
", typeDescription='" + typeDescription + '\'' +
", qualifiedName='" + qualifiedName + '\'' +
", displayName='" + displayName + '\'' +
", description='" + description + '\'' +
", owner='" + owner + '\'' +
", URL='" + getURL() + '\'' +
", GUID='" + getGUID() + '\'' +
'}';
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.omas.assetconsumer.server;
import org.apache.atlas.omas.assetconsumer.ffdc.AssetConsumerErrorCode;
import org.apache.atlas.omas.assetconsumer.ffdc.exceptions.InvalidParameterException;
import org.apache.atlas.omas.assetconsumer.ffdc.exceptions.PropertyServerException;
import org.apache.atlas.omas.assetconsumer.ffdc.exceptions.UserNotAuthorizedException;
import org.apache.atlas.omrs.metadatacollection.OMRSMetadataCollection;
import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnector;
/**
* AuditLogHandler manages the logging of audit records for the asset.
*/
public class AuditLogHandler
{
private String serviceName;
private OMRSRepositoryConnector repositoryConnector;
/**
* Construct the audit log handler with a link to the property server's connector and this access service's
* official name.
*
* @param serviceName - name of this service
* @param repositoryConnector - connector to the property server.
*/
public AuditLogHandler(String serviceName,
OMRSRepositoryConnector repositoryConnector)
{
this.serviceName = serviceName;
this.repositoryConnector = repositoryConnector;
}
/**
* Creates an Audit log record for the asset. This log record is stored in the Asset's Audit Log.
*
* @param userId - String - userId of user making request.
* @param assetGUID - String - unique id for the asset.
* @param connectorInstanceId - String - (optional) id of connector in use (if any).
* @param connectionName - String - (optional) name of the connection (extracted from the connector).
* @param connectorType - String - (optional) type of connector in use (if any).
* @param contextId - String - (optional) function name, or processId of the activity that the caller is performing.
* @param message - log record content.
*
* @throws InvalidParameterException - one of the parameters is null or invalid.
* @throws PropertyServerException - There is a problem adding the asset properties to
* the property server.
* @throws UserNotAuthorizedException - the requesting user is not authorized to issue this request.
*/
public void addLogMessageToAsset(String userId,
String assetGUID,
String connectorInstanceId,
String connectionName,
String connectorType,
String contextId,
String message) throws InvalidParameterException,
PropertyServerException,
UserNotAuthorizedException
{
// todo
}
/**
* Check that there is a repository connector.
*
* @param methodName - name of the method being called
* @return metadata collection that provides access to the properties in the property server
* @throws PropertyServerException - exception thrown if the repository connector
*/
private OMRSMetadataCollection validateRepositoryConnector(String methodName) throws PropertyServerException
{
if (this.repositoryConnector == null)
{
AssetConsumerErrorCode errorCode = AssetConsumerErrorCode.OMRS_NOT_INITIALIZED;
String errorMessage = errorCode.getErrorMessageId()
+ errorCode.getFormattedErrorMessage(methodName);
throw new PropertyServerException(errorCode.getHTTPErrorCode(),
this.getClass().getName(),
methodName,
errorMessage,
errorCode.getSystemAction(),
errorCode.getUserAction());
}
if (! this.repositoryConnector.isActive())
{
AssetConsumerErrorCode errorCode = AssetConsumerErrorCode.OMRS_NOT_AVAILABLE;
String errorMessage = errorCode.getErrorMessageId()
+ errorCode.getFormattedErrorMessage(methodName);
throw new PropertyServerException(errorCode.getHTTPErrorCode(),
this.getClass().getName(),
methodName,
errorMessage,
errorCode.getSystemAction(),
errorCode.getUserAction());
}
try
{
return repositoryConnector.getMetadataCollection();
}
catch (Throwable error)
{
AssetConsumerErrorCode errorCode = AssetConsumerErrorCode.NO_METADATA_COLLECTION;
String errorMessage = errorCode.getErrorMessageId() + errorCode.getFormattedErrorMessage(methodName);
throw new PropertyServerException(errorCode.getHTTPErrorCode(),
this.getClass().getName(),
methodName,
errorMessage,
errorCode.getSystemAction(),
errorCode.getUserAction());
}
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.omas.assetconsumer.server.properties;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
/**
* AssetConsumerOMASAPIResponse provides a common header for Asset Consumer OMAS managed responses to its REST API.
* It manages information about exceptions. If no exception has been raised exceptionClassName is null.
*/
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown=true)
public abstract class AssetConsumerOMASAPIResponse
{
protected int relatedHTTPCode = 200;
protected String exceptionClassName = null;
protected String exceptionErrorMessage = null;
protected String exceptionSystemAction = null;
protected String exceptionUserAction = null;
/**
* Default constructor
*/
public AssetConsumerOMASAPIResponse()
{
}
/**
* Return the HTTP Code to use if forwarding response to HTTP client.
*
* @return integer HTTP status code
*/
public int getRelatedHTTPCode()
{
return relatedHTTPCode;
}
/**
* Set up the HTTP Code to use if forwarding response to HTTP client.
*
* @param relatedHTTPCode - integer HTTP status code
*/
public void setRelatedHTTPCode(int relatedHTTPCode)
{
this.relatedHTTPCode = relatedHTTPCode;
}
/**
* Return the name of the Java class name to use to recreate the exception.
*
* @return String name of the fully-qualified java class name
*/
public String getExceptionClassName()
{
return exceptionClassName;
}
/**
* Set up the name of the Java class name to use to recreate the exception.
*
* @param exceptionClassName - String name of the fully-qualified java class name
*/
public void setExceptionClassName(String exceptionClassName)
{
this.exceptionClassName = exceptionClassName;
}
/**
* Return the error message associated with the exception.
*
* @return string error message
*/
public String getExceptionErrorMessage()
{
return exceptionErrorMessage;
}
/**
* Set up the error message associated with the exception.
*
* @param exceptionErrorMessage - string error message
*/
public void setExceptionErrorMessage(String exceptionErrorMessage)
{
this.exceptionErrorMessage = exceptionErrorMessage;
}
/**
* Return the description of the action taken by the system as a result of the exception.
*
* @return - string description of the action taken
*/
public String getExceptionSystemAction()
{
return exceptionSystemAction;
}
/**
* Set up the description of the action taken by the system as a result of the exception.
*
* @param exceptionSystemAction - string description of the action taken
*/
public void setExceptionSystemAction(String exceptionSystemAction)
{
this.exceptionSystemAction = exceptionSystemAction;
}
/**
* Return the action that a user should take to resolve the problem.
*
* @return string instructions
*/
public String getExceptionUserAction()
{
return exceptionUserAction;
}
/**
* Set up the action that a user should take to resolve the problem.
*
* @param exceptionUserAction - string instructions
*/
public void setExceptionUserAction(String exceptionUserAction)
{
this.exceptionUserAction = exceptionUserAction;
}
@Override
public String toString()
{
return "AssetConsumerOMASAPIResponse{" +
"relatedHTTPCode=" + relatedHTTPCode +
", exceptionClassName='" + exceptionClassName + '\'' +
", exceptionErrorMessage='" + exceptionErrorMessage + '\'' +
", exceptionSystemAction='" + exceptionSystemAction + '\'' +
", exceptionUserAction='" + exceptionUserAction + '\'' +
'}';
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.omas.assetconsumer.server.properties;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.atlas.ocf.properties.beans.Connection;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
/**
* ConnectionResponse is the response structure used on the Asset Consumer OMAS REST API calls that returns a
* Connection object as a response.
*/
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown=true)
public class ConnectionResponse extends AssetConsumerOMASAPIResponse
{
private Connection connection = null;
/**
* Default constructor
*/
public ConnectionResponse()
{
}
/**
* Return the Connection object.
*
* @return connection
*/
public Connection getConnection()
{
return connection;
}
/**
* Set up the Connection object.
*
* @param connection - connection object
*/
public void setConnection(Connection connection)
{
this.connection = connection;
}
@Override
public String toString()
{
return "ConnectionResponse{" +
"connection=" + connection +
", relatedHTTPCode=" + relatedHTTPCode +
", exceptionClassName='" + exceptionClassName + '\'' +
", exceptionErrorMessage='" + exceptionErrorMessage + '\'' +
", exceptionSystemAction='" + exceptionSystemAction + '\'' +
", exceptionUserAction='" + exceptionUserAction + '\'' +
'}';
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.omas.assetconsumer.server.properties;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
/**
* GUIDResponse is the response structure used on the Asset Consumer OMAS REST API calls that return a
* unique identifier (guid) object as a response.
*/
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown=true)
public class GUIDResponse extends AssetConsumerOMASAPIResponse
{
private String guid = null;
/**
* Default constructor
*/
public GUIDResponse()
{
}
/**
* Return the guid result.
*
* @return unique identifier
*/
public String getGUID()
{
return guid;
}
/**
* Set up the guid result.
*
* @param guid - unique identifier
*/
public void setGUID(String guid)
{
this.guid = guid;
}
@Override
public String toString()
{
return "GUIDResponse{" +
"guid='" + guid + '\'' +
", relatedHTTPCode=" + relatedHTTPCode +
", exceptionClassName='" + exceptionClassName + '\'' +
", exceptionErrorMessage='" + exceptionErrorMessage + '\'' +
", exceptionSystemAction='" + exceptionSystemAction + '\'' +
", exceptionUserAction='" + exceptionUserAction + '\'' +
'}';
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.omas.assetconsumer.server.properties;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY;
/**
* VoidResponse defines the response structure for the Asset Consumer OMAS REST API calls that returns a
* void as a response.
*/
@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE)
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown=true)
public class VoidResponse extends AssetConsumerOMASAPIResponse
{
/**
* Default constructor
*/
public VoidResponse()
{
}
@Override
public String toString()
{
return "VoidResponse{" +
"relatedHTTPCode=" + relatedHTTPCode +
", exceptionClassName='" + exceptionClassName + '\'' +
", exceptionErrorMessage='" + exceptionErrorMessage + '\'' +
", exceptionSystemAction='" + exceptionSystemAction + '\'' +
", exceptionUserAction='" + exceptionUserAction + '\'' +
'}';
}
}
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
# Connected Asset Open Metadata Access Service (OMAS)
The Connected Asset OMAS implements the ConnectedAssetProperties API that is
available on every **OCF connector**.
An OCF connector is a connector that supports the open connector framework (OCF).
It has 3 sets of APIs:
* An API to return properties about the connector and its connection
* An API to access the asset it connects to
* An API to access the metadata about the asset the connector is used to access
The Connected Asset OMAS is the third API on an OCF connector - the one for the metadata about the asset.
It is a generic API for all types of open metadata assets. However, it assumes the
asset's metadata model inherits from **Asset** (see model 0010 in Area 0).
The Connected Asset OMAS returns metadata about the asset at three levels of detail:
* getAssetSummary - returns the summary information organized in the assetSummary structure.
* getAssetDetail - returns detailed information about the asset organized in the assetDetail structure.
* getAssetUniverse - returns all of the common metadata properties connected to the asset such as its schma, meanings
and platform.
These structures are defined in the OCF module as POJO property objects.
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>apache-atlas</artifactId>
<groupId>org.apache.atlas</groupId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>omas-connectedasset</artifactId>
<name>Connected Asset Open Metadata Access Service (OMAS)</name>
<description>Connected Asset OMAS Module covering client, REST API, Event Listener and Event Publisher</description>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.apache.atlas</groupId>
<artifactId>om-fwk-ocf</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.atlas</groupId>
<artifactId>omrs</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.atlas</groupId>
<artifactId>omag-api</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-base</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>${javax-inject.version}</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.omas.connectedasset;
import org.apache.atlas.omas.connectedasset.ffdc.exceptions.InvalidParameterException;
import org.apache.atlas.omas.connectedasset.ffdc.exceptions.PropertyServerException;
import org.apache.atlas.omas.connectedasset.ffdc.exceptions.UnrecognizedConnectionGUIDException;
import org.apache.atlas.omas.connectedasset.ffdc.exceptions.UserNotAuthorizedException;
import org.apache.atlas.omas.connectedasset.properties.AssetUniverse;
/**
* ConnectedAssetInterface is the OMAS client interface of the Connected Asset OMAS.
*
*/
public interface ConnectedAssetInterface
{
/**
* Returns a comprehensive collection of properties about the requested asset.
*
* @param userId - String - userId of user making request.
* @param assetGUID - String - unique id for asset.
*
* @return AssetUniverse - a comprehensive collection of properties about the asset.
* @throws InvalidParameterException - one of the parameters is null or invalid.
* @throws PropertyServerException - There is a problem retrieving the asset properties from
* the property server.
* @throws UserNotAuthorizedException - the requesting user is not authorized to issue this request.
*/
AssetUniverse getAssetProperties(String userId,
String assetGUID) throws InvalidParameterException,
PropertyServerException,
UserNotAuthorizedException;
/**
* Returns a comprehensive collection of properties about the asset linked to the supplied connection.
*
* @param userId - identifier for calling user
* @param connectionGUID - uniqueId for the connection.
* @return AssetUniverse - a comprehensive collection of properties about the connected asset.
* @throws InvalidParameterException - one of the parameters is null or invalid.
* @throws PropertyServerException - There is a problem retrieving the connected asset properties from
* the property server.
* @throws UnrecognizedConnectionGUIDException - the supplied GUID is not recognized by the property server.
*/
AssetUniverse getAssetPropertiesByConnection(String userId,
String connectionGUID) throws InvalidParameterException,
UnrecognizedConnectionGUIDException,
PropertyServerException;
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.omas.connectedasset.admin;
import org.apache.atlas.omag.configuration.properties.AccessServiceConfig;
import org.apache.atlas.omag.configuration.registration.AccessServiceAdmin;
import org.apache.atlas.omag.ffdc.exception.OMAGConfigurationErrorException;
import org.apache.atlas.omrs.auditlog.OMRSAuditLog;
import org.apache.atlas.omrs.metadatacollection.repositoryconnector.OMRSRepositoryConnector;
import org.apache.atlas.omrs.topicconnectors.OMRSTopicConnector;
public class ConnectedAssetAdmin implements AccessServiceAdmin
{
private OMRSRepositoryConnector repositoryConnector = null;
private OMRSTopicConnector omrsTopicConnector = null;
private AccessServiceConfig accessServiceConfig = null;
private OMRSAuditLog auditLog = null;
private String serverUserName = null;
/**
* Default constructor
*/
public ConnectedAssetAdmin()
{
}
/**
* Initialize the access service.
*
* @param accessServiceConfigurationProperties - specific configuration properties for this access service.
* @param enterpriseOMRSTopicConnector - connector for receiving OMRS Events from the cohorts
* @param enterpriseOMRSRepositoryConnector - connector for querying the cohort repositories
* @param auditLog - audit log component for logging messages.
* @param serverUserName - user id to use on OMRS calls where there is no end user.
* @throws OMAGConfigurationErrorException - invalid parameters in the configuration properties.
*/
public void initialize(AccessServiceConfig accessServiceConfigurationProperties,
OMRSTopicConnector enterpriseOMRSTopicConnector,
OMRSRepositoryConnector enterpriseOMRSRepositoryConnector,
OMRSAuditLog auditLog,
String serverUserName) throws OMAGConfigurationErrorException
{
this.accessServiceConfig = accessServiceConfigurationProperties;
this.omrsTopicConnector = enterpriseOMRSTopicConnector;
this.repositoryConnector = enterpriseOMRSRepositoryConnector;
this.auditLog = auditLog;
this.serverUserName = serverUserName;
}
/**
* Shutdown the access service.
*/
public void shutdown()
{
/*
* Nothing to do until set up out topic.
*/
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.omas.connectedasset.client;
import org.apache.atlas.omas.connectedasset.ffdc.exceptions.InvalidParameterException;
import org.apache.atlas.omas.connectedasset.ffdc.exceptions.PropertyServerException;
import org.apache.atlas.omas.connectedasset.ffdc.exceptions.UnrecognizedConnectionGUIDException;
import org.apache.atlas.omas.connectedasset.ffdc.exceptions.UserNotAuthorizedException;
import org.apache.atlas.omas.connectedasset.properties.AssetUniverse;
import org.apache.atlas.omas.connectedasset.ConnectedAssetInterface;
/**
* ConnectedAsset is the OMAS client library implementation of the ConnectedAsset OMAS.
* ConnectedAsset provides the metadata for the ConnectedAssetProperties API that is
* supported by all Open Connector Framework (OCF)
* connectors. It provides access to the metadata about the Asset that the connector is linked to.
*/
public class ConnectedAsset implements ConnectedAssetInterface
{
/*
* The URL of the server where OMAS is active
*/
private String omasServerURL = null;
/**
* Default Constructor used once a connector is created.
*
* @param omasServerURL - unique id for the connector instance
*/
public ConnectedAsset(String omasServerURL)
{
/*
* Save OMAS Server URL
*/
this.omasServerURL = omasServerURL;
}
/**
* Returns a comprehensive collection of properties about the requested asset.
*
* @param userId - String - userId of user making request.
* @param assetGUID - String - unique id for asset.
*
* @return AssetUniverse - a comprehensive collection of properties about the asset.
* @throws InvalidParameterException - one of the parameters is null or invalid.
* @throws PropertyServerException - There is a problem retrieving the asset properties from
* the property server.
* @throws UserNotAuthorizedException - the requesting user is not authorized to issue this request.
*/
public AssetUniverse getAssetProperties(String userId,
String assetGUID) throws InvalidParameterException,
PropertyServerException,
UserNotAuthorizedException
{
return null;
}
/**
* Returns a comprehensive collection of properties about the asset linked to the supplied connection.
*
* @param connectionGUID - unique identifier for the connection
* @return AssetUniverse - a comprehensive collection of properties about the connected asset
* @throws PropertyServerException - There is a problem retrieving the connected asset properties from
* the metadata repository.
*/
public AssetUniverse getAssetPropertiesByConnection(String connectionGUID) throws PropertyServerException
{
AssetUniverse extractedAssetProperties = null;
/*
* Set up the OMAS URL in the asset universe
*/
return extractedAssetProperties;
}
/**
* Returns a comprehensive collection of properties about the asset linked to the supplied connection.
*
* @param connectionGUID - uniqueId for the connection.
* @return AssetUniverse - a comprehensive collection of properties about the connected asset.
* @throws InvalidParameterException - one of the parameters is null or invalid.
* @throws PropertyServerException - There is a problem retrieving the connected asset properties from
* the property server.
* @throws UnrecognizedConnectionGUIDException - the supplied GUID is not recognized by the property server.
*/
public AssetUniverse getAssetPropertiesByConnection(String userId,
String connectionGUID) throws InvalidParameterException,
UnrecognizedConnectionGUIDException,
PropertyServerException
{
return null;
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.omas.connectedasset.client;
import org.apache.atlas.ocf.ffdc.PropertyServerException;
import org.apache.atlas.ocf.properties.Classifications;
import org.apache.atlas.ocf.properties.ElementType;
import org.apache.atlas.ocf.properties.Connection;
import org.apache.atlas.omas.connectedasset.properties.AssetUniverse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* ConnectedAssetProperties is associated with a Connector. Connectors provide access to
* assets. ConnectedAssetProperties returns properties (metadata) about the connector's asset.
*
* It is a generic interface for all types of open metadata assets. However, it assumes the asset's metadata model
* inherits from <b>Asset</b> (see model 0010 in Area 0).
*
* The ConnectedAssetProperties returns metadata about the asset at three levels of detail:
* <ul>
* <li><b>assetSummary</b> - used for displaying details of the asset in summary lists or hover text</li>
* <li><b>assetDetail</b> - used to display all of the information known about the asset with summaries
* of the relationships to other metadata entities</li>
* <li><b>assetUniverse</b> - used to define the broader context for the asset</li>
* </ul>
*
* ConnectedAssetProperties is a base class for the connector's metadata API that returns null,
* for the asset's properties. Metadata repository implementations extend this class to add their
* implementation of the refresh() method that calls to the metadata repository to populate the metadata properties.
*/
public class ConnectedAssetProperties extends org.apache.atlas.ocf.properties.ConnectedAssetProperties
{
private String omasServerURL;
private String connectorInstanceId;
private Connection connection;
private String userId;
private ConnectedAsset connectedAsset;
private static final Logger log = LoggerFactory.getLogger(ConnectedAssetProperties.class);
/**
* Typical constructor.
*
* @param userId - identifier of calling user
* @param omasServerURL - url of server
* @param connectorInstanceId - unique identifier of connector.
* @param connection - connection information for connector.
*/
public ConnectedAssetProperties(String userId,
String omasServerURL,
String connectorInstanceId,
Connection connection)
{
super();
this.userId = userId;
this.omasServerURL = omasServerURL;
this.connectorInstanceId = connectorInstanceId;
this.connection = connection;
this.connectedAsset = new ConnectedAsset(omasServerURL);
}
/**
* Copy/clone constructor.
*
* @param templateProperties - template to copy.
*/
public ConnectedAssetProperties(ConnectedAssetProperties templateProperties)
{
super(templateProperties);
this.connection = templateProperties.connection;
this.connectorInstanceId = templateProperties.connectorInstanceId;
this.omasServerURL = templateProperties.omasServerURL;
this.userId = templateProperties.userId;
this.connectedAsset = new ConnectedAsset(omasServerURL);
}
/**
* Request the values in the ConnectedAssetProperties are refreshed with the current values from the
* metadata repository.
*
* @throws PropertyServerException - there is a problem connecting to the server to retrieve metadata.
*/
public void refresh() throws PropertyServerException
{
AssetUniverse assetUniverse = null;
try
{
assetUniverse = connectedAsset.getAssetPropertiesByConnection(connection.getGUID());
}
catch (Throwable error)
{
/*
* Construct PropertyErrorException
*/
}
if (assetUniverse == null)
{
super.assetProperties = null;
return;
}
ElementType elementType = null;
Classifications classifications = null;
if (assetUniverse.getType() != null)
{
elementType = new ElementType(assetUniverse.getType().getElementTypeId(),
assetUniverse.getType().getElementTypeName(),
assetUniverse.getType().getElementTypeVersion(),
assetUniverse.getType().getElementTypeDescription(),
assetUniverse.getType().getElementAccessServiceURL(),
assetUniverse.getType().getElementOrigin(),
assetUniverse.getType().getElementHomeMetadataCollectionId());
}
if (assetUniverse.getClassifications() != null)
{
}
super.assetProperties = new org.apache.atlas.ocf.properties.AssetUniverse(elementType,
assetUniverse.getGUID(),
assetUniverse.getURL(),
assetUniverse.getQualifiedName(),
assetUniverse.getDisplayName(),
assetUniverse.getShortDescription(),
assetUniverse.getDescription(),
assetUniverse.getOwner(),
classifications,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null);
}
}
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.omas.connectedasset.ffdc;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.text.MessageFormat;
import java.util.Arrays;
/**
* The ConnectedAssetErrorCode is used to define first failure data capture (FFDC) for errors that occur when
* working with
* OCF Connectors.
* It is used in conjunction with all Connected Asset OMAS Exceptions, both Checked and Runtime (unchecked).
*
* The 5 fields in the enum are:
* <ul>
* <li>HTTP Error Code - for translating between REST and JAVA - Typically the numbers used are:</li>
* <li><ul>
* <li>500 - internal error</li>
* <li>400 - invalid parameters</li>
* <li>404 - not found</li>
* <li>409 - data conflict errors - eg item already defined</li>
* </ul></li>
* <li>Error Message Id - to uniquely identify the message</li>
* <li>Error Message Text - includes placeholder to allow additional values to be captured</li>
* <li>SystemAction - describes the result of the error</li>
* <li>UserAction - describes how a user should correct the error</li>
* </ul>
*/
public enum ConnectedAssetErrorCode
{
SERVER_URL_NOT_SPECIFIED(400, "OMAS-CONNECTEDASSET-400-001",
"The OMAS Server URL is null",
"The system is unable to connect to the OMAS Server to populate the ConnectedAssetProperties object.",
"Retry the request when the OMAS Service is available."),
SERVER_URL_MALFORMED(400, "OMAS-CONNECTEDASSET-400-002",
"The OMAS Server URL {0} is not in a recognized format",
"The system is unable to connect to the OMAS Server to populate the ConnectedAssetProperties object.",
"Retry the request when the OMAS Service is available."),
NULL_CONNECTION(400, "OMAS-CONNECTEDASSET-400-003",
"The connection passed to OMASConnectedAssetProperties for connector {0} is null.",
"The system is unable to populate the ConnectedAssetProperties object because it needs the connection to identify the asset.",
"Look for other error messages to identify what caused this error. When the issue is resolved, retry the request."),
NULL_CONNECTION_ID(400, "OMAS-CONNECTEDASSET-400-004",
"The connection \'{0}\' passed to OMASConnectedAssetProperties has a null GUID inside it.",
"The system is unable to populate the ConnectedAssetProperties object because it needs the connection to identify the asset.",
"Look for other error messages to identify what caused this error. When the issue is resolved, retry the request."),
NULL_RELATED_ASSET(400, "OMAS-CONNECTEDASSET-400-005",
"The related asset is null.",
"The system is unable to populate the RelatedAssetProperties object because it needs the URL to identify the asset.",
"Look for other error messages to identify what caused this error. When the issue is resolved, retry the request."),
NULL_PROPERTY_NAME(400, "OMAS-CONNECTEDASSET-400-006 ",
"Null property name passed to operation {0} of type {1}",
"A request to set an additional property failed because the property name passed was null",
"Recode the call to the property object with a valid property name and retry."),
NULL_CLASSIFICATION_NAME(400, "OMAS-CONNECTEDASSET-400-007 ",
"No classification name for entity {0} of type {1}",
"A classification with a null name is assigned to an entity. This value should come from a metadata repository, and always be filled in.",
"Look for other error messages to identify the source of the problem. Identify the metadata repository where the asset came from. Correct the cause of the error and then retry."),
NULL_TAG_NAME(400, "OMAS-CONNECTEDASSET-400-008 ",
"Null tag name passed to operation {0} of type {1}",
"A request to set the name of an informal tag property failed because the name passed was null",
"Recode the call to the property object with a valid name and retry."),
SERVER_NOT_AVAILABLE(404, "OMAS-CONNECTEDASSET-404-001",
"The OMAS Server is not available",
"The system is unable to populate the ConnectedAssetProperties object.",
"Retry the request when the OMAS Service is available.")
;
private int httpErrorCode;
private String errorMessageId;
private String errorMessage;
private String systemAction;
private String userAction;
private static final Logger log = LoggerFactory.getLogger(ConnectedAssetErrorCode.class);
/**
* The constructor for ConnectedAssetErrorCode expects to be passed one of the enumeration rows defined in
* ConnectedAssetErrorCode above. For example:
*
* ConnectedAssetErrorCode errorCode = ConnectedAssetErrorCode.SERVER_NOT_AVAILABLE;
*
* This will expand out to the 5 parameters shown below.
*
* @param newHTTPErrorCode - error code to use over REST calls
* @param newErrorMessageId - unique Id for the message
* @param newErrorMessage - text for the message
* @param newSystemAction - description of the action taken by the system when the error condition happened
* @param newUserAction - instructions for resolving the error
*/
ConnectedAssetErrorCode(int newHTTPErrorCode, String newErrorMessageId, String newErrorMessage, String newSystemAction, String newUserAction)
{
this.httpErrorCode = newHTTPErrorCode;
this.errorMessageId = newErrorMessageId;
this.errorMessage = newErrorMessage;
this.systemAction = newSystemAction;
this.userAction = newUserAction;
}
public int getHTTPErrorCode()
{
return httpErrorCode;
}
/**
* Returns the unique identifier for the error message.
*
* @return errorMessageId
*/
public String getErrorMessageId()
{
return errorMessageId;
}
/**
* Returns the error message with placeholders for specific details.
*
* @return errorMessage (unformatted)
*/
public String getUnformattedErrorMessage()
{
return errorMessage;
}
/**
* Returns the error message with the placeholders filled out with the supplied parameters.
*
* @param params - strings that plug into the placeholders in the errorMessage
* @return errorMessage (formatted with supplied parameters)
*/
public String getFormattedErrorMessage(String... params)
{
if (log.isDebugEnabled())
{
log.debug(String.format("<== OCFErrorCode.getMessage(%s)", Arrays.toString(params)));
}
MessageFormat mf = new MessageFormat(errorMessage);
String result = mf.format(params);
if (log.isDebugEnabled())
{
log.debug(String.format("==> OCFErrorCode.getMessage(%s): %s", Arrays.toString(params), result));
}
return result;
}
/**
* Returns a description of the action taken by the system when the condition that caused this exception was
* detected.
*
* @return systemAction
*/
public String getSystemAction()
{
return systemAction;
}
/**
* Returns instructions of how to resolve the issue reported in this exception.
*
* @return userAction
*/
public String getUserAction()
{
return userAction;
}
}
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
# ConnectedAsset OMAS FFDC
Package org.apache.atlas.omas.connectedasset.ffdc provides the
first failure data capture support for the ConnectedAsset OMAS module.
This includes an error code enum,
a runtime exception, a base class for checked exceptions plus
implementation of each specific checked exception.
The error code enum (ConnectedAssetErrorCode) has an entry for each unique situation
where an exception is returned. Each entry defines:
* A unique id for the error
* An HTTP error code for rest calls
* A unique message Id
* Message text with place holders for specific values
* A description of the cause of the error and system action as a result.
* A description of how to correct the error (if known)
Each exception (whether a checked or runtime exception) has two constructors.
* The first constructor is used when a new error has been detected.
* The second constructor is used when another exception has been caught.
This caught exception is passed on the constructor so it is effectively
embedded in the ConnectedAsset OMAS exception.
Both constructors take the values from the ConnectedAssetErrorCode
enum to define the cause and resolution.
\ No newline at end of file
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.omas.connectedasset.ffdc.exceptions;
/**
* ConnectedAssetCheckedExceptionBase provides a checked exception for reporting errors found when using
* the Connected Asset OMAS services.
*
* Typically these errors are either configuration or operational errors that can be fixed by an administrator.
* However, there may be the odd bug that surfaces here.
* The ConnectedAssetErrorCode can be used with
* this exception to populate it with standard messages. The aim is to be able to uniquely identify the cause
* and remedy for the error.
*/
public class ConnectedAssetCheckedExceptionBase extends Exception
{
/*
* These default values are only seen if this exception is initialized using one of its superclass constructors.
*/
private int reportedHTTPCode;
private String reportingClassName;
private String reportingActionDescription;
private String reportedErrorMessage;
private String reportedSystemAction;
private String reportedUserAction;
private Throwable reportedCaughtException = null;
/**
* This is the typical constructor used for creating a ConnectedAssetCheckedExceptionBase.
*
* @param httpCode - http response code to use if this exception flows over a rest call
* @param className - name of class reporting error
* @param actionDescription - description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
*/
public ConnectedAssetCheckedExceptionBase(int httpCode,
String className,
String actionDescription,
String errorMessage,
String systemAction,
String userAction)
{
super(errorMessage);
this.reportedHTTPCode = httpCode;
this.reportingClassName = className;
this.reportingActionDescription = actionDescription;
this.reportedErrorMessage = errorMessage;
this.reportedSystemAction = systemAction;
this.reportedUserAction = userAction;
}
/**
* This is the constructor used for creating a ConnectedAssetCheckedExceptionBase
* that resulted from a previous error.
*
* @param httpCode - http response code to use if this exception flows over a rest call
* @param className - name of class reporting error
* @param actionDescription - description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
* @param caughtError - the error that resulted in this exception.
*/
public ConnectedAssetCheckedExceptionBase(int httpCode,
String className,
String actionDescription,
String errorMessage,
String systemAction,
String userAction,
Throwable caughtError)
{
super(errorMessage, caughtError);
this.reportedHTTPCode = httpCode;
this.reportingClassName = className;
this.reportingActionDescription = actionDescription;
this.reportedErrorMessage = errorMessage;
this.reportedSystemAction = systemAction;
this.reportedUserAction = userAction;
this.reportedCaughtException = caughtError;
}
/**
* Return the HTTP response code to use with this exception.
*
* @return reportedHTTPCode
*/
public int getReportedHTTPCode()
{
return reportedHTTPCode;
}
/**
* The class that created this exception.
*
* @return reportingClassName
*/
public String getReportingClassName()
{
return reportingClassName;
}
/**
* The type of request that the class was performing when the condition occurred that resulted in this
* exception.
*
* @return reportingActionDescription
*/
public String getReportingActionDescription()
{
return reportingActionDescription;
}
/**
* A formatted short description of the cause of the condition that resulted in this exception.
*
* @return reportedErrorMessage
*/
public String getErrorMessage()
{
return reportedErrorMessage;
}
/**
* A description of the action that the system took as a result of the error condition.
*
* @return reportedSystemAction
*/
public String getReportedSystemAction()
{
return reportedSystemAction;
}
/**
* A description of the action necessary to correct the error.
*
* @return reportedUserAction
*/
public String getReportedUserAction()
{
return reportedUserAction;
}
/**
* An exception that was caught and wrapped by this exception. If a null is returned, then this exception is
* newly created and not the result of a previous exception.
*
* @return reportedCaughtException
*/
public Throwable getReportedCaughtException() { return reportedCaughtException; }
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.omas.connectedasset.ffdc.exceptions;
/**
* ConnectedAssetRuntimeException is used for all runtime exceptions generated by the connected asset OMAS.
* It is used in conjunction with the ConnectedAssetErrorCode to provide first failure data capture for these errors.
*/
public class ConnectedAssetRuntimeException extends RuntimeException
{
/*
* These default values are only seen if this exception is initialized using one of its superclass constructors.
*/
private int reportedHTTPCode = 500;
private String reportingClassName = "<Unknown>";
private String reportingActionDescription = "<Unknown>";
private String reportedErrorMessage = "<Unknown>";
private String reportedSystemAction = "<Unknown>";
private String reportedUserAction = "<Unknown>";
private Throwable reportedCaughtException = null;
/**
* This is the typical constructor used for creating an ConnectedAssetRuntimeException.
*
* @param httpCode - http response code to use if this exception flows over a rest call
* @param className - name of class reporting error
* @param actionDescription - description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
*/
public ConnectedAssetRuntimeException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
{
super(errorMessage);
this.reportedHTTPCode = httpCode;
this.reportingClassName = className;
this.reportingActionDescription = actionDescription;
this.reportedErrorMessage = errorMessage;
this.reportedSystemAction = systemAction;
this.reportedUserAction = userAction;
}
/**
* This is the constructor used for creating a ConnectedAssetRuntimeException that is the result of
* another error being thrown.
*
* @param httpCode - http response code to use if this exception flows over a rest call
* @param className - name of class reporting error
* @param actionDescription - description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
* @param caughtError - previous error causing this exception
*/
public ConnectedAssetRuntimeException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
{
super(errorMessage, caughtError);
this.reportedHTTPCode = httpCode;
this.reportingClassName = className;
this.reportingActionDescription = actionDescription;
this.reportedErrorMessage = errorMessage;
this.reportedSystemAction = systemAction;
this.reportedUserAction = userAction;
this.reportedCaughtException = caughtError;
}
/**
* Return the HTTP response code to use with this exception.
*
* @return reportedHTTPCode
*/
public int getReportedHTTPCode()
{
return reportedHTTPCode;
}
/**
* The class that created this exception.
*
* @return reportingClassName
*/
public String getReportingClassName()
{
return reportingClassName;
}
/**
* The type of request that the class was performing when the condition occurred that resulted in this
* exception.
*
* @return reportingActionDescription
*/
public String getReportingActionDescription()
{
return reportingActionDescription;
}
/**
* A formatted short description of the cause of the condition that resulted in this exception.
*
* @return reportedErrorMessage
*/
public String getErrorMessage()
{
return reportedErrorMessage;
}
/**
* A description of the action that the system took as a result of the error condition.
*
* @return reportedSystemAction
*/
public String getReportedSystemAction()
{
return reportedSystemAction;
}
/**
* A description of the action necessary to correct the error.
*
* @return reportedUserAction
*/
public String getReportedUserAction()
{
return reportedUserAction;
}
/**
* An exception that was caught and wrapped by this exception. If a null is returned, then this exception is
* newly created and not the result of a previous exception.
*
* @return reportedCaughtException
*/
public Throwable getReportedCaughtException() { return reportedCaughtException; }
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.omas.connectedasset.ffdc.exceptions;
/**
* The InvalidParameterException is thrown by theConnectedAsset OMAS when a parameters is null or an invalid
* value.
*/
public class InvalidParameterException extends ConnectedAssetCheckedExceptionBase
{
/**
* This is the typical constructor used for creating a InvalidParameterException.
*
* @param httpCode - http response code to use if this exception flows over a rest call
* @param className - name of class reporting error
* @param actionDescription - description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
*/
public InvalidParameterException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
{
super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
}
/**
* This is the constructor used for creating a InvalidParameterException that resulted from a previous error.
*
* @param httpCode - http response code to use if this exception flows over a rest call
* @param className - name of class reporting error
* @param actionDescription - description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
* @param caughtError - the error that resulted in this exception.
* */
public InvalidParameterException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
{
super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtError);
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.omas.connectedasset.ffdc.exceptions;
/**
* The PropertyServerException is thrown by the Connected OMAS when it is not able to communicate with the
* property server.
*/
public class PropertyServerException extends ConnectedAssetCheckedExceptionBase
{
/**
* This is the typical constructor used for creating a PropertyServerException.
*
* @param httpCode - http response code to use if this exception flows over a rest call
* @param className - name of class reporting error
* @param actionDescription - description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
*/
public PropertyServerException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
{
super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
}
/**
* This is the constructor used for creating a PropertyServerException that resulted from a previous error.
*
* @param httpCode - http response code to use if this exception flows over a rest call
* @param className - name of class reporting error
* @param actionDescription - description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
* @param caughtError - the error that resulted in this exception.
* */
public PropertyServerException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
{
super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtError);
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.omas.connectedasset.ffdc.exceptions;
/**
* The UnrecognizedConnectionGUIDException is thrown by the Connected Asset OMAS when the unique identifier (guid)
* used to request a connection object from the property server is either unrecognized, or is the identifier
* for a different type of object.
*/
public class UnrecognizedConnectionGUIDException extends ConnectedAssetCheckedExceptionBase
{
/**
* This is the typical constructor used for creating a UnrecognizedConnectionGUIDException.
*
* @param httpCode - http response code to use if this exception flows over a rest call
* @param className - name of class reporting error
* @param actionDescription - description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
*/
public UnrecognizedConnectionGUIDException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
{
super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
}
/**
* This is the constructor used for creating a UnrecognizedConnectionGUIDException that resulted from a previous error.
*
* @param httpCode - http response code to use if this exception flows over a rest call
* @param className - name of class reporting error
* @param actionDescription - description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
* @param caughtError - the error that resulted in this exception.
*/
public UnrecognizedConnectionGUIDException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
{
super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtError);
}
}
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.atlas.omas.connectedasset.ffdc.exceptions;
/**
* The UserNotAuthorizedException is thrown by the Connected Asset OMAS when a userId passed on a request is not
* authorized to perform the requested action.
*/
public class UserNotAuthorizedException extends ConnectedAssetCheckedExceptionBase
{
/**
* This is the typical constructor used for creating a UserNotAuthorizedException.
*
* @param httpCode - http response code to use if this exception flows over a rest call
* @param className - name of class reporting error
* @param actionDescription - description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
*/
public UserNotAuthorizedException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction)
{
super(httpCode, className, actionDescription, errorMessage, systemAction, userAction);
}
/**
* This is the constructor used for creating a UserNotAuthorizedException that resulted from a previous error.
*
* @param httpCode - http response code to use if this exception flows over a rest call
* @param className - name of class reporting error
* @param actionDescription - description of function it was performing when error detected
* @param errorMessage - description of error
* @param systemAction - actions of the system as a result of the error
* @param userAction - instructions for correcting the error
* @param caughtError - the error that resulted in this exception.
* */
public UserNotAuthorizedException(int httpCode, String className, String actionDescription, String errorMessage, String systemAction, String userAction, Throwable caughtError)
{
super(httpCode, className, actionDescription, errorMessage, systemAction, userAction, caughtError);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment