http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchive.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchive.java b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchive.java index 58c5c2a..35e3a85 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchive.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchive.java @@ -17,6 +17,13 @@ */ package org.apache.atlas.omrs.archivemanager.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; + /** * OpenMetadataArchive defines the structure of the properties inside of an open metadata archive. * There are 3 sections: @@ -32,6 +39,9 @@ package org.apache.atlas.omrs.archivemanager.properties; * </li> * </ul> */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) public class OpenMetadataArchive { private OpenMetadataArchiveProperties archiveProperties = null;
http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveInstanceStore.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveInstanceStore.java b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveInstanceStore.java index 1d9b79b..0283fb4 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveInstanceStore.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveInstanceStore.java @@ -18,15 +18,25 @@ package org.apache.atlas.omrs.archivemanager.properties; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; import org.apache.atlas.omrs.metadatacollection.properties.instances.EntityDetail; import org.apache.atlas.omrs.metadatacollection.properties.instances.Relationship; import java.util.ArrayList; +import java.util.List; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; /** * OpenMetadataArchiveInstanceStore defines the contents of the InstanceStore in an open metadata archive. It * consists of a list of entities and a list of relationships. */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) public class OpenMetadataArchiveInstanceStore { private ArrayList<EntityDetail> entities = null; @@ -46,9 +56,16 @@ public class OpenMetadataArchiveInstanceStore * * @return list of entities */ - public ArrayList<EntityDetail> getEntities() + public List<EntityDetail> getEntities() { - return entities; + if (entities == null) + { + return null; + } + else + { + return new ArrayList<>(entities); + } } @@ -57,9 +74,16 @@ public class OpenMetadataArchiveInstanceStore * * @param entities - list of entities */ - public void setEntities(ArrayList<EntityDetail> entities) + public void setEntities(List<EntityDetail> entities) { - this.entities = entities; + if (entities == null) + { + this.entities = null; + } + else + { + this.entities = new ArrayList<>(entities); + } } @@ -68,9 +92,16 @@ public class OpenMetadataArchiveInstanceStore * * @return list of relationships */ - public ArrayList<Relationship> getRelationships() + public List<Relationship> getRelationships() { - return relationships; + if (relationships == null) + { + return null; + } + else + { + return new ArrayList<>(relationships); + } } @@ -79,8 +110,15 @@ public class OpenMetadataArchiveInstanceStore * * @param relationships - list of relationship objects */ - public void setRelationships(ArrayList<Relationship> relationships) + public void setRelationships(List<Relationship> relationships) { - this.relationships = relationships; + if (relationships == null) + { + this.relationships = null; + } + else + { + this.relationships = new ArrayList<>(relationships); + } } } http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveProperties.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveProperties.java b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveProperties.java index 3ebb17a..e8a8fab 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveProperties.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveProperties.java @@ -18,8 +18,16 @@ package org.apache.atlas.omrs.archivemanager.properties; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + import java.util.ArrayList; import java.util.Date; +import java.util.List; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; /** * OpenMetadataArchiveProperties defines the properties of an open metadata archive. This includes the following @@ -48,15 +56,19 @@ import java.util.Date; * </li> * </ul> */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) public class OpenMetadataArchiveProperties { - private String archiveGUID = null; - private String archiveName = null; - private String archiveDescription = null; - private OpenMetadataArchiveType archiveType = null; - private String originatorName = null; - private Date creationDate = null; - private ArrayList<String> dependsOnArchives = null; + private String archiveGUID = null; + private String archiveName = null; + private String archiveDescription = null; + private OpenMetadataArchiveType archiveType = null; + private String originatorName = null; + private String originatorOrganization = null; + private Date creationDate = null; + private ArrayList<String> dependsOnArchives = null; /** @@ -156,7 +168,8 @@ public class OpenMetadataArchiveProperties /** - * Return the name of the originator of this open metadata archive (persona or organization). + * Return the name of the originator of this open metadata archive This will be used as the name of the + * creator for each element in the archive. * * @return String name */ @@ -167,7 +180,8 @@ public class OpenMetadataArchiveProperties /** - * Set up the name of the originator of this open metadata archive (persona or organization). + * Set up the name of the originator of this open metadata archive. This will be used as the name of the + * creator for each element in the archive. * * @param originatorName - String name */ @@ -178,6 +192,27 @@ public class OpenMetadataArchiveProperties /** + * Return the name of the organization that provided this archive. + * + * @return String organization name + */ + public String getOriginatorOrganization() + { + return originatorOrganization; + } + + /** + * Set up the name of the organization that provided this archive. + * + * @param originatorOrganization - String name + */ + public void setOriginatorOrganization(String originatorOrganization) + { + this.originatorOrganization = originatorOrganization; + } + + + /** * Return the date that this open metadata archive was created. * * @return Date object @@ -204,9 +239,16 @@ public class OpenMetadataArchiveProperties * * @return list of guids */ - public ArrayList<String> getDependsOnArchives() + public List<String> getDependsOnArchives() { - return dependsOnArchives; + if (dependsOnArchives == null) + { + return null; + } + else + { + return new ArrayList<>(dependsOnArchives); + } } @@ -215,8 +257,15 @@ public class OpenMetadataArchiveProperties * * @param dependsOnArchives - list of guids */ - public void setDependsOnArchives(ArrayList<String> dependsOnArchives) + public void setDependsOnArchives(List<String> dependsOnArchives) { - this.dependsOnArchives = dependsOnArchives; + if (dependsOnArchives == null) + { + this.dependsOnArchives = null; + } + else + { + this.dependsOnArchives = new ArrayList<>(dependsOnArchives); + } } } http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveType.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveType.java b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveType.java index fc764b6..abe7358 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveType.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveType.java @@ -17,6 +17,21 @@ */ package org.apache.atlas.omrs.archivemanager.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; + +/** + * OpenMetadataArchiveType defines the origin of the open metadata archive. Content pack means tha the archive contains + * pre-defined types and instances for a particular use case. Metadata export is a collection of types and instances + * from a particular metadata server. + */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) public enum OpenMetadataArchiveType { CONTENT_PACK (1, "ContentPack", http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveTypeStore.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveTypeStore.java b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveTypeStore.java index d170ff2..f46677c 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveTypeStore.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/properties/OpenMetadataArchiveTypeStore.java @@ -17,11 +17,18 @@ */ package org.apache.atlas.omrs.archivemanager.properties; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; import org.apache.atlas.omrs.metadatacollection.properties.typedefs.AttributeTypeDef; import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDef; import org.apache.atlas.omrs.metadatacollection.properties.typedefs.TypeDefPatch; import java.util.ArrayList; +import java.util.List; + +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; /** @@ -29,6 +36,9 @@ import java.util.ArrayList; * contains a list of types used for attributes, a list of type definition (TypeDef) patches to update existing types * and a list of TypeDefs for new types of classifications, entities and relationships. */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) public class OpenMetadataArchiveTypeStore { private ArrayList<AttributeTypeDef> attributeTypeDefs = null; @@ -49,9 +59,16 @@ public class OpenMetadataArchiveTypeStore * * @return list of AttributeTypeDef objects */ - public ArrayList<AttributeTypeDef> getAttributeTypeDefs() + public List<AttributeTypeDef> getAttributeTypeDefs() { - return attributeTypeDefs; + if (attributeTypeDefs == null) + { + return null; + } + else + { + return new ArrayList<>(attributeTypeDefs); + } } @@ -60,9 +77,16 @@ public class OpenMetadataArchiveTypeStore * * @param attributeTypeDefs - list of AttributeTypeDef objects */ - public void setAttributeTypeDefs(ArrayList<AttributeTypeDef> attributeTypeDefs) + public void setAttributeTypeDefs(List<AttributeTypeDef> attributeTypeDefs) { - this.attributeTypeDefs = attributeTypeDefs; + if (attributeTypeDefs == null) + { + this.attributeTypeDefs = null; + } + else + { + this.attributeTypeDefs = new ArrayList<>(attributeTypeDefs); + } } @@ -71,9 +95,16 @@ public class OpenMetadataArchiveTypeStore * * @return list of TypeDef objects */ - public ArrayList<TypeDefPatch> getTypeDefPatches() + public List<TypeDefPatch> getTypeDefPatches() { - return typeDefPatches; + if (typeDefPatches == null) + { + return null; + } + else + { + return new ArrayList<>(typeDefPatches); + } } @@ -82,9 +113,16 @@ public class OpenMetadataArchiveTypeStore * * @param typeDefPatches - list of TypeDef objects */ - public void setTypeDefPatches(ArrayList<TypeDefPatch> typeDefPatches) + public void setTypeDefPatches(List<TypeDefPatch> typeDefPatches) { - this.typeDefPatches = typeDefPatches; + if (typeDefPatches == null) + { + this.typeDefPatches = null; + } + else + { + this.typeDefPatches = new ArrayList<>(typeDefPatches); + } } @@ -93,9 +131,16 @@ public class OpenMetadataArchiveTypeStore * * @return list of TypeDef objects */ - public ArrayList<TypeDef> getNewTypeDefs() + public List<TypeDef> getNewTypeDefs() { - return newTypeDefs; + if (newTypeDefs == null) + { + return null; + } + else + { + return new ArrayList<>(newTypeDefs); + } } @@ -104,8 +149,15 @@ public class OpenMetadataArchiveTypeStore * * @param newTypeDefs - list of TypeDef objects */ - public void setNewTypeDefs(ArrayList<TypeDef> newTypeDefs) + public void setNewTypeDefs(List<TypeDef> newTypeDefs) { - this.newTypeDefs = newTypeDefs; + if (newTypeDefs == null) + { + this.newTypeDefs = null; + } + else + { + this.newTypeDefs = new ArrayList<>(newTypeDefs); + } } } http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/store/OpenMetadataArchiveStore.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/store/OpenMetadataArchiveStore.java b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/store/OpenMetadataArchiveStore.java index ac5dfd6..510fd70 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/store/OpenMetadataArchiveStore.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/store/OpenMetadataArchiveStore.java @@ -44,12 +44,6 @@ import org.apache.atlas.omrs.archivemanager.properties.OpenMetadataArchive; public interface OpenMetadataArchiveStore { /** - * Open the archive and retrieve archive contents (if any) - */ - void openArchive(); - - - /** * Return the contents of the archive. * * @return OpenMetadataArchive object @@ -63,10 +57,4 @@ public interface OpenMetadataArchiveStore * @param archiveContents - OpenMetadataArchive object */ void setArchiveContents(OpenMetadataArchive archiveContents); - - - /** - * Close the archive - this releases the connection and any resources held. - */ - void closeArchive(); } http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/store/OpenMetadataArchiveStoreConnector.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/store/OpenMetadataArchiveStoreConnector.java b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/store/OpenMetadataArchiveStoreConnector.java new file mode 100644 index 0000000..0de3e33 --- /dev/null +++ b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/store/OpenMetadataArchiveStoreConnector.java @@ -0,0 +1,27 @@ +/* + * 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.omrs.archivemanager.store; + +import org.apache.atlas.ocf.ConnectorBase; + +/** + * OpenMetadataArchiveStoreConnector is the base class for connectors that support the OpenMetadataArchiveStore + */ +public abstract class OpenMetadataArchiveStoreConnector extends ConnectorBase implements OpenMetadataArchiveStore +{ +} http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/store/OpenMetadataArchiveStoreConnectorBase.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/store/OpenMetadataArchiveStoreConnectorBase.java b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/store/OpenMetadataArchiveStoreConnectorBase.java deleted file mode 100644 index b0bd643..0000000 --- a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/store/OpenMetadataArchiveStoreConnectorBase.java +++ /dev/null @@ -1,27 +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.omrs.archivemanager.store; - -import org.apache.atlas.ocf.ConnectorBase; - -/** - * OpenMetadataArchiveStoreConnectorBase is the base class for connectors that support the OpenMetadataArchiveStore - */ -public abstract class OpenMetadataArchiveStoreConnectorBase extends ConnectorBase implements OpenMetadataArchiveStore -{ -} http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/store/file/FileBasedOpenMetadataArchiveStoreConnector.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/store/file/FileBasedOpenMetadataArchiveStoreConnector.java b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/store/file/FileBasedOpenMetadataArchiveStoreConnector.java new file mode 100644 index 0000000..e4828f3 --- /dev/null +++ b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/store/file/FileBasedOpenMetadataArchiveStoreConnector.java @@ -0,0 +1,183 @@ +/* + * 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.omrs.archivemanager.store.file; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.atlas.ocf.ffdc.ConnectorCheckedException; +import org.apache.atlas.ocf.properties.Connection; +import org.apache.atlas.ocf.properties.Endpoint; +import org.apache.atlas.omrs.archivemanager.properties.OpenMetadataArchive; +import org.apache.atlas.omrs.archivemanager.store.OpenMetadataArchiveStoreConnector; +import org.apache.commons.io.FileUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.io.IOException; + +public class FileBasedOpenMetadataArchiveStoreConnector extends OpenMetadataArchiveStoreConnector +{ + /* + * This is the default name of the open metadata archive file that is used if there is no file name in the connection. + */ + private static final String defaultFilename = "open.metadata.archive"; + + /* + * Variables used in writing to the file. + */ + private String archiveStoreName = null; + + /* + * Variables used for logging and debug. + */ + private static final Logger log = LoggerFactory.getLogger(FileBasedOpenMetadataArchiveStoreConnector.class); + + + /** + * Default constructor + */ + public FileBasedOpenMetadataArchiveStoreConnector() + { + } + + + @Override + public void initialize(String connectorInstanceId, Connection connection) + { + super.initialize(connectorInstanceId, connection); + + Endpoint endpoint = connection.getEndpoint(); + + if (endpoint != null) + { + archiveStoreName = endpoint.getAddress(); + } + + if (archiveStoreName == null) + { + archiveStoreName = defaultFilename; + } + } + + + /** + * Return the contents of the archive. + * + * @return OpenMetadataArchive object + */ + public OpenMetadataArchive getArchiveContents() + { + File archiveStoreFile = new File(archiveStoreName); + OpenMetadataArchive newOpenMetadataArchive; + + try + { + if (log.isDebugEnabled()) + { + log.debug("Retrieving server configuration properties"); + } + + String configStoreFileContents = FileUtils.readFileToString(archiveStoreFile, "UTF-8"); + + ObjectMapper objectMapper = new ObjectMapper(); + + newOpenMetadataArchive = objectMapper.readValue(configStoreFileContents, OpenMetadataArchive.class); + } + catch (IOException ioException) + { + /* + * The config file is not found, create a new one ... + */ + + if (log.isDebugEnabled()) + { + log.debug("New server config Store", ioException); + } + + newOpenMetadataArchive = new OpenMetadataArchive(); + } + + return newOpenMetadataArchive; + } + + + /** + * Set new contents into the archive. This overrides any content previously stored. + * + * @param archiveContents - OpenMetadataArchive object + */ + public void setArchiveContents(OpenMetadataArchive archiveContents) + { + File archiveStoreFile = new File(archiveStoreName); + + try + { + if (log.isDebugEnabled()) + { + log.debug("Writing open metadata archive store properties: " + archiveContents); + } + + if (archiveContents == null) + { + archiveStoreFile.delete(); + } + else + { + ObjectMapper objectMapper = new ObjectMapper(); + + String archiveStoreFileContents = objectMapper.writeValueAsString(archiveContents); + + FileUtils.writeStringToFile(archiveStoreFile, archiveStoreFileContents, false); + } + } + catch (IOException ioException) + { + if (log.isDebugEnabled()) + { + log.debug("Unusable Server config Store :(", ioException); + } + } + } + + + /** + * Indicates that the connector is completely configured and can begin processing. + * + * @throws ConnectorCheckedException - there is a problem within the connector. + */ + public void start() throws ConnectorCheckedException + { + super.start(); + } + + + /** + * Free up any resources held since the connector is no longer needed. + * + * @throws ConnectorCheckedException - there is a problem within the connector. + */ + public void disconnect() throws ConnectorCheckedException + { + super.disconnect(); + + if (log.isDebugEnabled()) + { + log.debug("Closing Config Store."); + } + } +} http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/store/file/FileBasedOpenMetadataArchiveStoreProvider.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/store/file/FileBasedOpenMetadataArchiveStoreProvider.java b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/store/file/FileBasedOpenMetadataArchiveStoreProvider.java new file mode 100644 index 0000000..c7eb414 --- /dev/null +++ b/omrs/src/main/java/org/apache/atlas/omrs/archivemanager/store/file/FileBasedOpenMetadataArchiveStoreProvider.java @@ -0,0 +1,37 @@ +/* + * 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.omrs.archivemanager.store.file; + +import org.apache.atlas.omrs.archivemanager.store.OpenMetadataArchiveStoreProviderBase; + +/** + * FileBasedOpenMetadataArchiveStoreProvider is the OCF connector provider for the file based server configuration store. + */ +public class FileBasedOpenMetadataArchiveStoreProvider extends OpenMetadataArchiveStoreProviderBase +{ + /** + * Constructor used to initialize the ConnectorProviderBase with the Java class name of the specific + * configuration store implementation. + */ + public FileBasedOpenMetadataArchiveStoreProvider() + { + Class connectorClass = FileBasedOpenMetadataArchiveStoreConnector.class; + + super.setConnectorClassName(connectorClass.getName()); + } +} http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/auditlog/OMRSAuditCode.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/auditlog/OMRSAuditCode.java b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/OMRSAuditCode.java index 8e66f8b..304dde2 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/auditlog/OMRSAuditCode.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/OMRSAuditCode.java @@ -112,23 +112,69 @@ public enum OMRSAuditCode "No action is required. This is part of the normal operation of the server."), NO_LOCAL_REPOSITORY("OMRS-AUDIT-0012", - OMRSAuditLogRecordSeverity.INFO, - "No events will be sent to the open metadata repository cohort {0} because the local metadata collection id is null.", - "The local server will not send outbound events because there is no local metadata repository.", - "Validate that the server is configured without a local metadata repository. " + + OMRSAuditLogRecordSeverity.INFO, + "No events will be sent to the open metadata repository cohort {0} because the local metadata collection id is null.", + "The local server will not send outbound events because there is no local metadata repository.", + "Validate that the server is configured without a local metadata repository. " + "If there should be a metadata repository then, verify the server configuration is" + "correct and look for errors that have occurred during server start up." + "If necessary, correct the configuration and restart the server."), - NULL_TOPIC_CONNECTOR("OMRS-AUDIT-0013", - OMRSAuditLogRecordSeverity.EXCEPTION, - "Unable to send or receive events for cohort {0} because the connector to the OMRS Topic failed to initialize", - "The local server will not connect to the cohort.", - "The connection to the connector is configured in the server configuration. " + + LOCAL_REPOSITORY_FAILED_TO_START("OMRS-AUDIT-0013", + OMRSAuditLogRecordSeverity.EXCEPTION, + "Unable to start processing in the local repository due to error {0}", + "The local server will not process events.", + "Review previous error messages to determine the precise error in the " + + "start up configuration. " + + "Correct the configuration and restart the server. "), + + LOCAL_REPOSITORY_FAILED_TO_DISCONNECT("OMRS-AUDIT-0014", + OMRSAuditLogRecordSeverity.EXCEPTION, + "Unable to disconnect processing in the local repository due to error {0}", + "The local server may not shutdown cleanly.", + "Review previous error messages to determine the precise error. Correct the cause and restart the server. "), + + NULL_TOPIC_CONNECTOR("OMRS-AUDIT-0015", + OMRSAuditLogRecordSeverity.EXCEPTION, + "Unable to send or receive events for cohort {0} because the connector to the OMRS Topic failed to initialize", + "The local server will not connect to the cohort.", + "The connection to the connector is configured in the server configuration. " + "Review previous error messages to determine the precise error in the " + "start up configuration. " + "Correct the configuration and reconnect the server to the cohort. "), + PROCESSING_ARCHIVE("OMRS-AUDIT-0050", + OMRSAuditLogRecordSeverity.INFO, + "The Open Metadata Repository Services (OMRS) is about to process open metadata archive {0}.", + "The local server is about to local types and instances from an open metadata archive.", + "No action is required. This is part of the normal operation of the server."), + + EMPTY_ARCHIVE("OMRS-AUDIT-0051", + OMRSAuditLogRecordSeverity.ERROR, + "The Open Metadata Repository Services (OMRS) is unable to process an open metadata archive because it is empty.", + "The local server is skipping an open metadata archive because it is empty.", + "Review the list of archives for the server and determine which archive is in error. " + + "Request a new version of the archive or remove it from the server's archive list."), + + NULL_PROPERTIES_IN_ARCHIVE("OMRS-AUDIT-0052", + OMRSAuditLogRecordSeverity.ERROR, + "The Open Metadata Repository Services (OMRS) is unable to process an open metadata archive because it is empty.", + "The local server is skipping an open metadata archive because it is empty.", + "Review the list of archives for the server and determine which archive is in error. " + + "Request a new version of the archive or remove it from the server's archive list."), + + COMPLETED_ARCHIVE("OMRS-AUDIT-0053", + OMRSAuditLogRecordSeverity.INFO, + "The Open Metadata Repository Services (OMRS) has loaded {0} types and {1} instances from open metadata archive {2}.", + "The local server has completed the processing of the open metadata archive.", + "No action is required. This is part of the normal operation of the server."), + + EVENT_PROCESSING_ERROR("OMRS-AUDIT-0100", + OMRSAuditLogRecordSeverity.EXCEPTION, + "Unable process an incoming event {0} due to exception {1}", + "The information in the event is not available to the server.", + "Review the exception to determine the source of the error and correct it. "), + REGISTERED_WITH_COHORT("OMRS-AUDIT-0101", OMRSAuditLogRecordSeverity.INFO, "Registering with open metadata repository cohort {0} using metadata collection id {1}", @@ -323,6 +369,38 @@ public enum OMRSAuditCode "It is necessary to update the TypeDef to remove the conflict before the local server will " + "exchange metadata with the remote server."), + NEW_TYPE_ADDED("OMRS-AUDIT-0301", + OMRSAuditLogRecordSeverity.INFO, + "The local server has added a new type called {0} with a unique identifier of {1} and a version number of {2} from {3}", + "The local server will be able to manage metadata instances of this type.", + "No action required. This message is for information only."), + + NEW_TYPE_NOT_SUPPORTED("OMRS-AUDIT-0302", + OMRSAuditLogRecordSeverity.INFO, + "The local server is unable to add a new type called {0} with a unique identifier of {1} and a version number of {2} because the server does not support this feature", + "The local server will be able to manage metadata instances of this type.", + "No action required. This message is for information only."), + + TYPE_UPDATED("OMRS-AUDIT-0303", + OMRSAuditLogRecordSeverity.INFO, + "The local server has updated an existing type called {0} with a unique identifier of {1} to version number of {2} from {3}", + "The local server will be able to manage metadata instances of this latest version of the type.", + "No action required. This message is for information only."), + + TYPE_REMOVED("OMRS-AUDIT-0304", + OMRSAuditLogRecordSeverity.INFO, + "The local server has removed an existing type called {0} with a unique identifier of {1} to version number of {2}", + "The local server will be no longer be able to manage metadata instances of this type.", + "No action required. This message is for information only."), + + TYPE_IDENTIFIER_MISMATCH("OMRS-AUDIT-0305", + OMRSAuditLogRecordSeverity.ERROR, + "The local server has detected a conflict with an existing type called {0} with a unique identifier of {1}. This does not match the type name {2} and unique identifier {3} passed to it on a request", + "The local server will be no longer be able to manage metadata instances of this type.", + "This is a serious error since it may cause metadata to be corrupted. " + + "First check the caller to ensure it is operating properly. " + + "Then investigate the source of the type and any other errors."), + PROCESS_UNKNOWN_EVENT("OMRS-AUDIT-8001", OMRSAuditLogRecordSeverity.EVENT, "Received unknown event: {0}", @@ -334,17 +412,17 @@ public enum OMRSAuditCode "Verify that the event is a new event type introduced after this server was written."), NULL_OMRS_EVENT_RECEIVED("OMRS-AUDIT-9002", - OMRSAuditLogRecordSeverity.EXCEPTION, - "Unable to process a received event because its content is null", - "The system is unable to process an incoming event.", - "This may be caused by an internal logic error or the receipt of an incompatible OMRSEvent"), + OMRSAuditLogRecordSeverity.EXCEPTION, + "Unable to process a received event because its content is null", + "The system is unable to process an incoming event.", + "This may be caused by an internal logic error or the receipt of an incompatible OMRSEvent"), SEND_TYPEDEF_EVENT_ERROR("OMRS-AUDIT-9003", - OMRSAuditLogRecordSeverity.EXCEPTION, - "Unable to send a TypeDef event for cohort {0} due to an error in the OMRS Topic Connector", - "The local server is unable to properly manage TypeDef events for the metadata " + + OMRSAuditLogRecordSeverity.EXCEPTION, + "Unable to send a TypeDef event for cohort {0} due to an error in the OMRS Topic Connector", + "The local server is unable to properly manage TypeDef events for the metadata " + "repository cohort. The cause of the error is recorded in the accompanying exception.", - "Review the exception and resolve the issue it documents. " + + "Review the exception and resolve the issue it documents. " + "Then disconnect and reconnect this server to the cohort."), SEND_INSTANCE_EVENT_ERROR("OMRS-AUDIT-9005", @@ -388,7 +466,17 @@ public enum OMRSAuditCode "Unable to send an event because the event is of an unknown type", "The local server may not be communicating properly with other servers in " + "the metadata repository cohort.", - "This is an internal logic error. Raise a JIRA, including the audit log, to get this fixed.") + "This is an internal logic error. Raise a JIRA, including the audit log, to get this fixed."), + UNEXPECTED_EXCEPTION_FROM_EVENT("OMRS-AUDIT-9011", + OMRSAuditLogRecordSeverity.EXCEPTION, + "An incoming event of type {0} from {1} ({2}) generated an exception with message {3}", + "The contents of the event were not accepted by the local repository.", + "Review the exception and resolve the issue it documents."), + ENTERPRISE_TOPIC_DISCONNECT_ERROR("OMRS-AUDIT-9012", + OMRSAuditLogRecordSeverity.EXCEPTION, + "Disconnecting from the enterprise topic connector generated an exception with message {0}", + "The server may not have disconnected from the topic cleanly.", + "Review the exception and resolve the issue it documents.") ; http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/auditlog/OMRSAuditLog.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/auditlog/OMRSAuditLog.java b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/OMRSAuditLog.java index 5f63c92..1c9991e 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/auditlog/OMRSAuditLog.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/OMRSAuditLog.java @@ -26,6 +26,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.ArrayList; +import java.util.List; /** * OMRSAuditLog is a class for managing the audit logging of activity for the OMRS components. Each auditing component @@ -40,11 +41,11 @@ import java.util.ArrayList; public class OMRSAuditLog { static private final OMRSAuditLogRecordOriginator originator = new OMRSAuditLogRecordOriginator(); - static private OMRSAuditLogStore auditLogStore = null; + static private ArrayList<OMRSAuditLogStore> auditLogStores = null; private static final Logger log = LoggerFactory.getLogger(OMRSAuditLog.class); - private OMRSAuditLogReportingComponent reportingComponent = null; + private OMRSAuditLogReportingComponent reportingComponent; /* Initialized in the constructor */ /** @@ -54,18 +55,21 @@ public class OMRSAuditLog * @param localServerName - name of the local server * @param localServerType - type of the local server * @param localOrganizationName - name of the organization that owns the local server - * @param auditLogStore - destination for the audit log records + * @param auditLogStores - list of destinations for the audit log records */ - public static void initialize(String localServerName, - String localServerType, - String localOrganizationName, - OMRSAuditLogStore auditLogStore) + public static void initialize(String localServerName, + String localServerType, + String localOrganizationName, + List<OMRSAuditLogStore> auditLogStores) { OMRSAuditLog.originator.setServerName(localServerName); OMRSAuditLog.originator.setServerType(localServerType); OMRSAuditLog.originator.setOrganizationName(localOrganizationName); - OMRSAuditLog.auditLogStore = auditLogStore; + if (auditLogStores != null) + { + OMRSAuditLog.auditLogStores = new ArrayList<>(auditLogStores); + } } @@ -118,11 +122,11 @@ public class OMRSAuditLog { if ((severity == OMRSAuditLogRecordSeverity.ERROR) || (severity == OMRSAuditLogRecordSeverity.EXCEPTION)) { - log.error("New Audit Log Record", actionDescription, logMessageId, severity, logMessage, additionalInformation, systemAction, userAction); + log.error(logMessageId + " " + logMessage, actionDescription, logMessageId, severity, logMessage, additionalInformation, systemAction, userAction); } else { - log.info("New Audit Log Record", actionDescription, logMessageId, severity, logMessage, additionalInformation, systemAction, userAction); + log.info(logMessageId + " " + logMessage, actionDescription, logMessageId, severity, logMessage, additionalInformation, systemAction, userAction); } } else @@ -130,35 +134,42 @@ public class OMRSAuditLog severity = OMRSAuditLogRecordSeverity.UNKNOWN; } - if (auditLogStore != null) + if (auditLogStores != null) { - ArrayList<String> additionalInformationArray = null; - - if (additionalInformation != null) + for (OMRSAuditLogStore auditLogStore : auditLogStores) { - additionalInformationArray = new ArrayList<>(); - additionalInformationArray.add(additionalInformation); - } - - OMRSAuditLogRecord logRecord = new OMRSAuditLogRecord(originator, - reportingComponent, - severity.getSeverityName(), - logMessageId, - logMessage, - additionalInformationArray, - systemAction, - userAction); - try - { - auditLogStore.storeLogRecord(logRecord); - } - catch (Throwable error) - { - log.error("Error writing audit log: ", logRecord, error); + if (auditLogStore != null) + { + ArrayList<String> additionalInformationArray = null; + + if (additionalInformation != null) + { + additionalInformationArray = new ArrayList<>(); + additionalInformationArray.add(additionalInformation); + } + + OMRSAuditLogRecord logRecord = new OMRSAuditLogRecord(originator, + reportingComponent, + severity.getSeverityName(), + logMessageId, + logMessage, + additionalInformationArray, + systemAction, + userAction); + try + { + auditLogStore.storeLogRecord(logRecord); + } + catch (Throwable error) + { + log.error("Error writing audit log: ", logRecord, error); + } + } } } } + /** * Log details of an unexpected exception detected by the OMRS. These exceptions typically mean that the local * server is not configured correctly, or there is a logic error in the code. When exceptions are logged, it is http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogRecord.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogRecord.java b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogRecord.java index 90aa7ac..fca5773 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogRecord.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogRecord.java @@ -17,13 +17,24 @@ */ package org.apache.atlas.omrs.auditlog.store; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; + import java.util.ArrayList; import java.util.Date; +import java.util.List; import java.util.UUID; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; +import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.PUBLIC_ONLY; + /** * OMRSAuditLogRecord provides a carrier for details about a single log record in the OMRS audit log. */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) public class OMRSAuditLogRecord { private String guid = null; @@ -39,6 +50,14 @@ public class OMRSAuditLogRecord /** + * Default constructor + */ + public OMRSAuditLogRecord() + { + } + + + /** * Audit log records are immutable so the only way to update the values is through the constructor. * * @param originator - details of the originating server @@ -72,7 +91,7 @@ public class OMRSAuditLogRecord } /** - * Return the unique Id of the audit log record + * Return the unique Id of the audit log record. * * @return String guid */ @@ -83,6 +102,17 @@ public class OMRSAuditLogRecord /** + * Set up the unique Id of the audit log record. + * + * @param guid - String guid + */ + public void setGUID(String guid) + { + this.guid = guid; + } + + + /** * Return the time stamp for when the audit log record was created. * * @return Date object @@ -153,22 +183,91 @@ public class OMRSAuditLogRecord * * @return String additional information */ - public ArrayList<String> getAdditionalInformation() + public List<String> getAdditionalInformation() { return additionalInformation; } + + + + public void setTimeStamp(Date timeStamp) + { + this.timeStamp = timeStamp; + } + + public void setOriginator(OMRSAuditLogRecordOriginator originator) + { + this.originator = originator; + } + + public void setSeverity(String severity) + { + this.severity = severity; + } + + public void setReportingComponent(OMRSAuditLogReportingComponent reportingComponent) + { + this.reportingComponent = reportingComponent; + } + + public void setMessageId(String messageId) + { + this.messageId = messageId; + } + + public void setMessageText(String messageText) + { + this.messageText = messageText; + } + + public void setAdditionalInformation(ArrayList<String> additionalInformation) + { + this.additionalInformation = additionalInformation; + } + + + public String getSystemAction() { return systemAction; } + + /** + * Set up the description of the actions taken by the local server as a result of the reported situation. + * + * @param systemAction + */ + public void setSystemAction(String systemAction) + { + this.systemAction = systemAction; + } + + + /** + * Return details of the actions (if any) that a user can take in response to the reported situation. + * + * @return String instructions + */ public String getUserAction() { return userAction; } + + /** + * Set up details of the actions (if any) that a user can take in response to the reported situation. + * + * @param userAction - String instructions + */ + public void setUserAction(String userAction) + { + this.userAction = userAction; + } + + @Override public String toString() { http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogRecordOriginator.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogRecordOriginator.java b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogRecordOriginator.java index e69e5b1..42cffb7 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogRecordOriginator.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogRecordOriginator.java @@ -17,10 +17,20 @@ */ package org.apache.atlas.omrs.auditlog.store; +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; + /** * OMRSAuditLogRecordOriginator describes the server that originated an audit log record. This is useful if * an organization is aggregating messages from different servers together. */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) public class OMRSAuditLogRecordOriginator { private String metadataCollectionId = null; http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogReportingComponent.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogReportingComponent.java b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogReportingComponent.java index a5077ab..47cc2cf 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogReportingComponent.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogReportingComponent.java @@ -17,9 +17,19 @@ */ package org.apache.atlas.omrs.auditlog.store; +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; + /** * OMRSAuditLogReportingComponent describes the component issuing the audit log record. */ +@JsonAutoDetect(getterVisibility=PUBLIC_ONLY, setterVisibility=PUBLIC_ONLY, fieldVisibility=NONE) +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown=true) public class OMRSAuditLogReportingComponent { private int componentId = 0; http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogStore.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogStore.java b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogStore.java index 650cd74..8c5e7d8 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogStore.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogStore.java @@ -18,10 +18,10 @@ package org.apache.atlas.omrs.auditlog.store; import org.apache.atlas.omrs.ffdc.exception.PagingErrorException; -import org.apache.atlas.omrs.ffdc.exception.PropertyErrorException; +import org.apache.atlas.omrs.ffdc.exception.InvalidParameterException; -import java.util.ArrayList; import java.util.Date; +import java.util.List; /** * OMRSAuditLogStore is the specialized data API for an Audit Log connector. @@ -33,9 +33,9 @@ public interface OMRSAuditLogStore * * @param logRecord - log record to store * @return unique identifier assigned to the log record - * @throws PropertyErrorException - indicates that the logRecord parameter is invalid. + * @throws InvalidParameterException - indicates that the logRecord parameter is invalid. */ - String storeLogRecord(OMRSAuditLogRecord logRecord) throws PropertyErrorException; + String storeLogRecord(OMRSAuditLogRecord logRecord) throws InvalidParameterException; /** @@ -43,9 +43,9 @@ public interface OMRSAuditLogStore * * @param logRecordId - unique identifier for the log record * @return requested audit log record - * @throws PropertyErrorException - indicates that the logRecordId parameter is invalid. + * @throws InvalidParameterException - indicates that the logRecordId parameter is invalid. */ - OMRSAuditLogRecord getAuditLogRecord(String logRecordId) throws PropertyErrorException; + OMRSAuditLogRecord getAuditLogRecord(String logRecordId) throws InvalidParameterException; /** @@ -57,14 +57,14 @@ public interface OMRSAuditLogStore * @param offset - offset of full collection to begin the return results * @param maximumRecords - maximum number of log records to return * @return list of log records from the specified time period - * @throws PropertyErrorException - indicates that the start and/or end date parameters are invalid. + * @throws InvalidParameterException - indicates that the start and/or end date parameters are invalid. * @throws PagingErrorException - indicates that the offset or the maximumRecords parameters are invalid. */ - ArrayList<OMRSAuditLogRecord> getAuditLogRecordsByTimeStamp(Date startDate, - Date endDate, - int offset, - int maximumRecords) throws PropertyErrorException, - PagingErrorException; + List<OMRSAuditLogRecord> getAuditLogRecordsByTimeStamp(Date startDate, + Date endDate, + int offset, + int maximumRecords) throws InvalidParameterException, + PagingErrorException; /** * Retrieve a list of log records that have specific severity. The offset and maximumRecords @@ -76,15 +76,15 @@ public interface OMRSAuditLogStore * @param offset - offset of full collection to begin the return results * @param maximumRecords - maximum number of log records to return * @return list of log records from the specified time period - * @throws PropertyErrorException - indicates that the severity, start and/or end date parameters are invalid. + * @throws InvalidParameterException - indicates that the severity, start and/or end date parameters are invalid. * @throws PagingErrorException - indicates that the offset or the maximumRecords parameters are invalid. */ - ArrayList<OMRSAuditLogRecord> getAuditLogRecordsBySeverity(String severity, - Date startDate, - Date endDate, - int offset, - int maximumRecords) throws PropertyErrorException, - PagingErrorException; + List<OMRSAuditLogRecord> getAuditLogRecordsBySeverity(String severity, + Date startDate, + Date endDate, + int offset, + int maximumRecords) throws InvalidParameterException, + PagingErrorException; /** * Retrieve a list of log records written by a specific component. The offset and maximumRecords @@ -96,13 +96,13 @@ public interface OMRSAuditLogStore * @param offset - offset of full collection to begin the return results * @param maximumRecords - maximum number of log records to return * @return list of log records from the specified time period - * @throws PropertyErrorException - indicates that the component, start and/or end date parameters are invalid. + * @throws InvalidParameterException - indicates that the component, start and/or end date parameters are invalid. * @throws PagingErrorException - indicates that the offset or the maximumRecords parameters are invalid. */ - ArrayList<OMRSAuditLogRecord> getAuditLogRecordsByComponent(String component, - Date startDate, - Date endDate, - int offset, - int maximumRecords) throws PropertyErrorException, - PagingErrorException; + List<OMRSAuditLogRecord> getAuditLogRecordsByComponent(String component, + Date startDate, + Date endDate, + int offset, + int maximumRecords) throws InvalidParameterException, + PagingErrorException; } http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogStoreConnectorBase.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogStoreConnectorBase.java b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogStoreConnectorBase.java index 6e30716..eb95e57 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogStoreConnectorBase.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/OMRSAuditLogStoreConnectorBase.java @@ -20,7 +20,7 @@ package org.apache.atlas.omrs.auditlog.store; import org.apache.atlas.ocf.ConnectorBase; /** - * OMRSAuditLogStoreConnectorBase is the base calss for connectors that support the OMRSAuditLog + * OMRSAuditLogStoreConnectorBase is the base class for connectors that support the OMRSAuditLog */ public abstract class OMRSAuditLogStoreConnectorBase extends ConnectorBase implements OMRSAuditLogStore { http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/file/FileBasedAuditLogStoreConnector.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/file/FileBasedAuditLogStoreConnector.java b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/file/FileBasedAuditLogStoreConnector.java index ede85bb..0eda0c9 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/file/FileBasedAuditLogStoreConnector.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/auditlog/store/file/FileBasedAuditLogStoreConnector.java @@ -17,15 +17,17 @@ */ package org.apache.atlas.omrs.auditlog.store.file; +import org.apache.atlas.ocf.ffdc.ConnectorCheckedException; import org.apache.atlas.omrs.auditlog.store.OMRSAuditLogRecord; import org.apache.atlas.omrs.auditlog.store.OMRSAuditLogStoreConnectorBase; import org.apache.atlas.omrs.ffdc.exception.PagingErrorException; -import org.apache.atlas.omrs.ffdc.exception.PropertyErrorException; +import org.apache.atlas.omrs.ffdc.exception.InvalidParameterException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.Date; +import java.util.List; /** * FileBasedAuditLogStoreConnector provides a connector implementation for a file based audit log. @@ -50,9 +52,9 @@ public class FileBasedAuditLogStoreConnector extends OMRSAuditLogStoreConnectorB * * @param logRecord - log record to store * @return unique identifier assigned to the log record - * @throws PropertyErrorException - indicates that the logRecord parameter is invalid. + * @throws InvalidParameterException - indicates that the logRecord parameter is invalid. */ - public String storeLogRecord(OMRSAuditLogRecord logRecord) throws PropertyErrorException + public String storeLogRecord(OMRSAuditLogRecord logRecord) throws InvalidParameterException { if (logRecord == null) { @@ -61,7 +63,7 @@ public class FileBasedAuditLogStoreConnector extends OMRSAuditLogStoreConnectorB if (log.isDebugEnabled()) { - log.debug("AuditLogRecord: ", logRecord.toString()); + log.debug("AuditLogRecord: " + logRecord.toString()); } return null; @@ -73,9 +75,9 @@ public class FileBasedAuditLogStoreConnector extends OMRSAuditLogStoreConnectorB * * @param logRecordId - unique identifier for the log record * @return requested audit log record - * @throws PropertyErrorException - indicates that the logRecordId parameter is invalid. + * @throws InvalidParameterException - indicates that the logRecordId parameter is invalid. */ - public OMRSAuditLogRecord getAuditLogRecord(String logRecordId) throws PropertyErrorException + public OMRSAuditLogRecord getAuditLogRecord(String logRecordId) throws InvalidParameterException { if (logRecordId == null) { @@ -95,13 +97,13 @@ public class FileBasedAuditLogStoreConnector extends OMRSAuditLogStoreConnectorB * @param offset - offset of full collection to begin the return results * @param maximumRecords - maximum number of log records to return * @return list of log records from the specified time period - * @throws PropertyErrorException - indicates that the start and/or end date parameters are invalid. + * @throws InvalidParameterException - indicates that the start and/or end date parameters are invalid. * @throws PagingErrorException - indicates that the offset or the maximumRecords parameters are invalid. */ public ArrayList<OMRSAuditLogRecord> getAuditLogRecordsByTimeStamp(Date startDate, Date endDate, int offset, - int maximumRecords) throws PropertyErrorException, + int maximumRecords) throws InvalidParameterException, PagingErrorException { return null; @@ -117,14 +119,14 @@ public class FileBasedAuditLogStoreConnector extends OMRSAuditLogStoreConnectorB * @param offset - offset of full collection to begin the return results * @param maximumRecords - maximum number of log records to return * @return list of log records from the specified time period - * @throws PropertyErrorException - indicates that the severity, start and/or end date parameters are invalid. + * @throws InvalidParameterException - indicates that the severity, start and/or end date parameters are invalid. * @throws PagingErrorException - indicates that the offset or the maximumRecords parameters are invalid. */ public ArrayList<OMRSAuditLogRecord> getAuditLogRecordsBySeverity(String severity, Date startDate, Date endDate, int offset, - int maximumRecords) throws PropertyErrorException, + int maximumRecords) throws InvalidParameterException, PagingErrorException { return null; @@ -141,24 +143,38 @@ public class FileBasedAuditLogStoreConnector extends OMRSAuditLogStoreConnectorB * @param offset - offset of full collection to begin the return results * @param maximumRecords - maximum number of log records to return * @return list of log records from the specified time period - * @throws PropertyErrorException - indicates that the component, start and/or end date parameters are invalid. + * @throws InvalidParameterException - indicates that the component, start and/or end date parameters are invalid. * @throws PagingErrorException - indicates that the offset or the maximumRecords parameters are invalid. */ - public ArrayList<OMRSAuditLogRecord> getAuditLogRecordsByComponent(String component, - Date startDate, - Date endDate, - int offset, - int maximumRecords) throws PropertyErrorException, - PagingErrorException + public List<OMRSAuditLogRecord> getAuditLogRecordsByComponent(String component, + Date startDate, + Date endDate, + int offset, + int maximumRecords) throws InvalidParameterException, + PagingErrorException { return null; } /** + * Indicates that the connector is completely configured and can begin processing. + * + * @throws ConnectorCheckedException - there is a problem within the connector. + */ + public void start() throws ConnectorCheckedException + { + super.start(); + } + + + /** * Free up any resources held since the connector is no longer needed. + * + * @throws ConnectorCheckedException - there is a problem within the connector. */ - public void disconnect() + public void disconnect() throws ConnectorCheckedException { + super.disconnect(); } } http://git-wip-us.apache.org/repos/asf/atlas/blob/a1fd4068/omrs/src/main/java/org/apache/atlas/omrs/enterprise/connectormanager/OMRSConnectionConsumer.java ---------------------------------------------------------------------- diff --git a/omrs/src/main/java/org/apache/atlas/omrs/enterprise/connectormanager/OMRSConnectionConsumer.java b/omrs/src/main/java/org/apache/atlas/omrs/enterprise/connectormanager/OMRSConnectionConsumer.java index 7ef18bd..2a7e6e8 100644 --- a/omrs/src/main/java/org/apache/atlas/omrs/enterprise/connectormanager/OMRSConnectionConsumer.java +++ b/omrs/src/main/java/org/apache/atlas/omrs/enterprise/connectormanager/OMRSConnectionConsumer.java @@ -32,6 +32,9 @@ public interface OMRSConnectionConsumer * open metadata repository cohort. * * @param cohortName - name of the cohort adding the remote connection. + * @param remoteServerName - name of the remote server for this connection. + * @param remoteServerType - type of the remote server. + * @param owningOrganizationName - name of the organization the owns the remote server. * @param metadataCollectionId - Unique identifier for the metadata collection * @param remoteConnection - Connection object providing properties necessary to create an * OMRSRepositoryConnector for the remote repository. @@ -39,6 +42,9 @@ public interface OMRSConnectionConsumer * @throws ConnectorCheckedException - there is a problem initializing the Connector */ void addRemoteConnection(String cohortName, + String remoteServerName, + String remoteServerType, + String owningOrganizationName, String metadataCollectionId, Connection remoteConnection) throws ConnectionCheckedException, ConnectorCheckedException;