http://git-wip-us.apache.org/repos/asf/atlas/blob/b0ecc36a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/README.md ---------------------------------------------------------------------- diff --git a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/README.md b/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/README.md deleted file mode 100644 index ae9feac..0000000 --- a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/README.md +++ /dev/null @@ -1,46 +0,0 @@ -<!-- - ~ 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
http://git-wip-us.apache.org/repos/asf/atlas/blob/b0ecc36a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/exceptions/AmbiguousConnectionNameException.java ---------------------------------------------------------------------- diff --git a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/exceptions/AmbiguousConnectionNameException.java b/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/exceptions/AmbiguousConnectionNameException.java deleted file mode 100644 index 1215eda..0000000 --- a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/exceptions/AmbiguousConnectionNameException.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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); - } -} http://git-wip-us.apache.org/repos/asf/atlas/blob/b0ecc36a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/exceptions/AssetConsumerCheckedExceptionBase.java ---------------------------------------------------------------------- diff --git a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/exceptions/AssetConsumerCheckedExceptionBase.java b/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/exceptions/AssetConsumerCheckedExceptionBase.java deleted file mode 100644 index 4e22fb8..0000000 --- a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/exceptions/AssetConsumerCheckedExceptionBase.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * 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; } -} http://git-wip-us.apache.org/repos/asf/atlas/blob/b0ecc36a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/exceptions/AssetConsumerRuntimeException.java ---------------------------------------------------------------------- diff --git a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/exceptions/AssetConsumerRuntimeException.java b/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/exceptions/AssetConsumerRuntimeException.java deleted file mode 100644 index d8444b4..0000000 --- a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/exceptions/AssetConsumerRuntimeException.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * 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; } -} http://git-wip-us.apache.org/repos/asf/atlas/blob/b0ecc36a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/exceptions/InvalidParameterException.java ---------------------------------------------------------------------- diff --git a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/exceptions/InvalidParameterException.java b/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/exceptions/InvalidParameterException.java deleted file mode 100644 index 084fb8b..0000000 --- a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/exceptions/InvalidParameterException.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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); - } -} http://git-wip-us.apache.org/repos/asf/atlas/blob/b0ecc36a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/exceptions/PropertyServerException.java ---------------------------------------------------------------------- diff --git a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/exceptions/PropertyServerException.java b/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/exceptions/PropertyServerException.java deleted file mode 100644 index fc74608..0000000 --- a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/exceptions/PropertyServerException.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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); - } -} http://git-wip-us.apache.org/repos/asf/atlas/blob/b0ecc36a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/exceptions/UnrecognizedConnectionGUIDException.java ---------------------------------------------------------------------- diff --git a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/exceptions/UnrecognizedConnectionGUIDException.java b/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/exceptions/UnrecognizedConnectionGUIDException.java deleted file mode 100644 index 3af8474..0000000 --- a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/exceptions/UnrecognizedConnectionGUIDException.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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); - } -} http://git-wip-us.apache.org/repos/asf/atlas/blob/b0ecc36a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/exceptions/UnrecognizedConnectionNameException.java ---------------------------------------------------------------------- diff --git a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/exceptions/UnrecognizedConnectionNameException.java b/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/exceptions/UnrecognizedConnectionNameException.java deleted file mode 100644 index 3e29fa5..0000000 --- a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/exceptions/UnrecognizedConnectionNameException.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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); - } -} http://git-wip-us.apache.org/repos/asf/atlas/blob/b0ecc36a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/exceptions/UnrecognizedConnectionURLException.java ---------------------------------------------------------------------- diff --git a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/exceptions/UnrecognizedConnectionURLException.java b/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/exceptions/UnrecognizedConnectionURLException.java deleted file mode 100644 index 668e28c..0000000 --- a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/exceptions/UnrecognizedConnectionURLException.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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); - } -} http://git-wip-us.apache.org/repos/asf/atlas/blob/b0ecc36a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/exceptions/UserNotAuthorizedException.java ---------------------------------------------------------------------- diff --git a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/exceptions/UserNotAuthorizedException.java b/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/exceptions/UserNotAuthorizedException.java deleted file mode 100644 index 9441940..0000000 --- a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/ffdc/exceptions/UserNotAuthorizedException.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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); - } -} http://git-wip-us.apache.org/repos/asf/atlas/blob/b0ecc36a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/listener/AssetConsumerOMRSTopicListener.java ---------------------------------------------------------------------- diff --git a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/listener/AssetConsumerOMRSTopicListener.java b/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/listener/AssetConsumerOMRSTopicListener.java deleted file mode 100644 index 3eb4cad..0000000 --- a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/listener/AssetConsumerOMRSTopicListener.java +++ /dev/null @@ -1,249 +0,0 @@ -/* - * 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"); - } - } - } - } -} http://git-wip-us.apache.org/repos/asf/atlas/blob/b0ecc36a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/properties/Asset.java ---------------------------------------------------------------------- diff --git a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/properties/Asset.java b/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/properties/Asset.java deleted file mode 100644 index 7a69604..0000000 --- a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/properties/Asset.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * 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() + '\'' + - '}'; - } -} http://git-wip-us.apache.org/repos/asf/atlas/blob/b0ecc36a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/publisher/AssetConsumerPublisher.java ---------------------------------------------------------------------- diff --git a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/publisher/AssetConsumerPublisher.java b/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/publisher/AssetConsumerPublisher.java deleted file mode 100644 index d14fd1d..0000000 --- a/omas-assetconsumer/src/main/java/org/apache/atlas/omas/assetconsumer/publisher/AssetConsumerPublisher.java +++ /dev/null @@ -1,319 +0,0 @@ -/* - * 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.publisher; - - -import org.apache.atlas.ocf.properties.Connection; -import org.apache.atlas.omas.assetconsumer.properties.Asset; -import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryHelper; -import org.apache.atlas.omrs.localrepository.repositorycontentmanager.OMRSRepositoryValidator; -import org.apache.atlas.omrs.metadatacollection.properties.instances.*; -import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefLink; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.List; - -/** - * AssetConsumerPublisher is responsible for publishing events about assets. It is called - * when an interesting OMRS Event is added to the Enterprise OMRS Topic. It adds events to the Asset Consumer OMAS - * out topic. - */ -public class AssetConsumerPublisher -{ - private static final String assetTypeName = "Asset"; - private static final String assetPropertyNameQualifiedName = "qualifiedName"; - private static final String assetPropertyNameDisplayName = "name"; - private static final String assetPropertyNameOwner = "owner"; - private static final String assetPropertyNameDescription = "description"; - - private static final Logger log = LoggerFactory.getLogger(AssetConsumerPublisher.class); - - private Connection assetConsumerOutTopic; - private OMRSRepositoryHelper repositoryHelper; - private OMRSRepositoryValidator repositoryValidator; - private String componentName; - - - /** - * 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 AssetConsumerPublisher(Connection assetConsumerOutTopic, - OMRSRepositoryHelper repositoryHelper, - OMRSRepositoryValidator repositoryValidator, - String componentName) - { - this.assetConsumerOutTopic = assetConsumerOutTopic; - this.repositoryHelper = repositoryHelper; - this.repositoryValidator = repositoryValidator; - this.componentName = componentName; - } - - - /** - * Determine whether a new entity is an Asset. If it is then publish an Asset Consumer Event about it. - * - * @param entity - entity object that has just been created. - */ - public void processNewEntity(EntityDetail entity) - { - String assetType = getAssetType(entity); - - if (assetType != null) - { - this.processNewAsset(this.getAsset(entity)); - } - } - - - /** - * Determine whether an updated entity is an Asset. If it is then publish an Asset Consumer Event about it. - * - * @param entity - entity object that has just been updated. - */ - public void processUpdatedEntity(EntityDetail entity) - { - String assetType = getAssetType(entity); - - if (assetType != null) - { - this.processUpdatedAsset(this.getAsset(entity)); - } - } - - - /** - * Determine whether a deleted entity is an Asset. If it is then publish an Asset Consumer Event about it. - * - * @param entity - entity object that has just been deleted. - */ - public void processDeletedEntity(EntityDetail entity) - { - String assetType = getAssetType(entity); - - if (assetType != null) - { - this.processDeletedAsset(this.getAsset(entity)); - } - } - - - /** - * Determine whether a restored entity is an Asset. If it is then publish an Asset Consumer Event about it. - * - * @param entity - entity object that has just been restored. - */ - public void processRestoredEntity(EntityDetail entity) - { - String assetType = getAssetType(entity); - - if (assetType != null) - { - this.processRestoredAsset(this.getAsset(entity)); - } - } - - - /** - * Determine whether a new relationship is related to an Asset. - * If it is then publish an Asset Consumer Event about it. - * - * @param relationship - relationship object that has just been created. - */ - public void processNewRelationship(Relationship relationship) - { - // todo - } - - - /** - * Determine whether an updated relationship is related to an Asset. - * If it is then publish an Asset Consumer Event about it. - * - * @param relationship - relationship object that has just been updated. - */ - public void processUpdatedRelationship(Relationship relationship) - { - // todo - } - - - /** - * Determine whether a deleted relationship is related to an Asset. - * If it is then publish an Asset Consumer Event about it. - * - * @param relationship - relationship object that has just been deleted. - */ - public void processDeletedRelationship(Relationship relationship) - { - // todo - } - - - /** - * Determine whether a restored relationship is related to an Asset. - * If it is then publish an Asset Consumer Event about it. - * - * @param relationship - relationship object that has just been restored. - */ - public void processRestoredRelationship(Relationship relationship) - { - // todo - } - - - /** - * Return the name of the Asset type if this entity has a type that inherits from Asset. - * - * @param entity - entity to test - * @return String containing Asset type name, or null if not an Asset. - */ - private String getAssetType(EntityDetail entity) - { - final String methodName = "getAssetType"; - - if (repositoryValidator.isATypeOf(componentName, entity, assetTypeName, methodName)) - { - InstanceType entityType = entity.getType(); - - if (entityType != null) - { - return entityType.getTypeDefName(); - } - } - - return null; - } - - - /** - * Return an Asset object extracted from the supplied entity object - * @param entity - entity describing the asset - * @return Asset object - */ - private Asset getAsset(EntityDetail entity) - { - Asset asset = new Asset(); - - if (entity != null) - { - asset.setURL(entity.getInstanceURL()); - asset.setGUID(entity.getGUID()); - - InstanceType instanceType = entity.getType(); - if (instanceType != null) - { - asset.setTypeId(instanceType.getTypeDefGUID()); - asset.setTypeName(instanceType.getTypeDefName()); - asset.setTypeVersion(instanceType.getTypeDefVersion()); - asset.setTypeDescription(instanceType.getTypeDefDescription()); - } - - InstanceProperties instanceProperties = entity.getProperties(); - - if (instanceProperties != null) - { - InstancePropertyValue instancePropertyValue; - - instancePropertyValue = instanceProperties.getPropertyValue(assetPropertyNameQualifiedName); - - if (instancePropertyValue != null) - { - PrimitivePropertyValue primitivePropertyValue = (PrimitivePropertyValue)instancePropertyValue; - asset.setQualifiedName(primitivePropertyValue.toString()); - } - - instancePropertyValue = instanceProperties.getPropertyValue(assetPropertyNameDisplayName); - - if (instancePropertyValue != null) - { - PrimitivePropertyValue primitivePropertyValue = (PrimitivePropertyValue)instancePropertyValue; - asset.setDisplayName(primitivePropertyValue.toString()); - } - - instancePropertyValue = instanceProperties.getPropertyValue(assetPropertyNameOwner); - - if (instancePropertyValue != null) - { - PrimitivePropertyValue primitivePropertyValue = (PrimitivePropertyValue)instancePropertyValue; - asset.setOwner(primitivePropertyValue.toString()); - } - - instancePropertyValue = instanceProperties.getPropertyValue(assetPropertyNameDescription); - - if (instancePropertyValue != null) - { - PrimitivePropertyValue primitivePropertyValue = (PrimitivePropertyValue)instancePropertyValue; - asset.setDescription(primitivePropertyValue.toString()); - } - } - } - - return asset; - } - - - /** - * Publish event about a new asset. - * - * @param asset - asset to report on. - */ - private void processNewAsset(Asset asset) - { - log.info("Asset Consumer Event => New Asset: " + asset.toString()); - } - - - /** - * Publish event about an updated asset. - * - * @param asset - asset to report on. - */ - private void processUpdatedAsset(Asset asset) - { - log.info("Asset Consumer Event => Updated Asset: " + asset.toString()); - } - - - /** - * Publish event about a deleted asset. - * - * @param asset - asset to report on. - */ - private void processDeletedAsset(Asset asset) - { - log.info("Asset Consumer Event => Deleted Asset: " + asset.toString()); - } - - - /** - * Publish event about a restored asset. - * - * @param asset - asset to report on. - */ - private void processRestoredAsset(Asset asset) - { - log.info("Asset Consumer Event => Restored Asset: " + asset.toString()); - } -}