http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddViewInstanceRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddViewInstanceRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddViewInstanceRequestAuditEvent.java new file mode 100644 index 0000000..6326338 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AddViewInstanceRequestAuditEvent.java @@ -0,0 +1,113 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.server.audit.event.request.event; + +import org.apache.ambari.server.audit.event.request.RequestAuditEvent; + +public class AddViewInstanceRequestAuditEvent extends RequestAuditEvent { + + public static class AddViewInstanceRequestAuditEventBuilder extends RequestAuditEventBuilder<AddViewInstanceRequestAuditEvent, AddViewInstanceRequestAuditEventBuilder> { + + private String description; + + private String name; + + private String type; + + private String displayName; + + private String version; + + public AddViewInstanceRequestAuditEventBuilder() { + super.withOperation("View addition"); + } + + @Override + protected AddViewInstanceRequestAuditEvent newAuditEvent() { + return new AddViewInstanceRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder.append(", Type(") + .append(type) + .append("), Version(") + .append(version) + .append("), Name(") + .append(name) + .append("), Display name(") + .append(displayName) + .append("), Description(") + .append(description) + .append(")"); + } + + public AddViewInstanceRequestAuditEventBuilder withDescription(String description) { + this.description = description; + return this; + } + + public AddViewInstanceRequestAuditEventBuilder withName(String name) { + this.name = name; + return this; + } + + public AddViewInstanceRequestAuditEventBuilder withType(String type) { + this.type = type; + return this; + } + + public AddViewInstanceRequestAuditEventBuilder withDisplayName(String displayName) { + this.displayName = displayName; + return this; + } + + public AddViewInstanceRequestAuditEventBuilder withVersion(String version) { + this.version = version; + return this; + } + } + + protected AddViewInstanceRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected AddViewInstanceRequestAuditEvent(AddViewInstanceRequestAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link AddViewInstanceRequestAuditEvent} + * + * @return a builder instance + */ + public static AddViewInstanceRequestAuditEventBuilder builder() { + return new AddViewInstanceRequestAuditEventBuilder(); + } + +}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AdminUserRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AdminUserRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AdminUserRequestAuditEvent.java new file mode 100644 index 0000000..72941e4 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/AdminUserRequestAuditEvent.java @@ -0,0 +1,89 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.server.audit.event.request.event; + +import org.apache.ambari.server.audit.event.request.RequestAuditEvent; + +public class AdminUserRequestAuditEvent extends RequestAuditEvent { + + public static class AdminUserRequestAuditEventBuilder extends RequestAuditEventBuilder<AdminUserRequestAuditEvent, AdminUserRequestAuditEventBuilder> { + + private boolean admin; + + private String username; + + public AdminUserRequestAuditEventBuilder() { + super.withOperation("Set user admin"); + } + + @Override + protected AdminUserRequestAuditEvent newAuditEvent() { + return new AdminUserRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder + .append(", Affeted username(") + .append(username) + .append("), ") + .append("Administrator(") + .append(admin ? "yes" : "no") + .append(")"); + } + + public AdminUserRequestAuditEventBuilder withAdmin(boolean admin) { + this.admin = admin; + return this; + } + + public AdminUserRequestAuditEventBuilder withAffectedUsername(String username) { + this.username = username; + return this; + } + + } + + protected AdminUserRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected AdminUserRequestAuditEvent(AdminUserRequestAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link AdminUserRequestAuditEvent} + * + * @return a builder instance + */ + public static AdminUserRequestAuditEventBuilder builder() { + return new AdminUserRequestAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/BlueprintExportRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/BlueprintExportRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/BlueprintExportRequestAuditEvent.java new file mode 100644 index 0000000..410b08e --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/BlueprintExportRequestAuditEvent.java @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.server.audit.event.request.event; + +import org.apache.ambari.server.audit.event.request.RequestAuditEvent; + +public class BlueprintExportRequestAuditEvent extends RequestAuditEvent { + + public static class BlueprintExportRequestAuditEventBuilder extends RequestAuditEventBuilder<BlueprintExportRequestAuditEvent, BlueprintExportRequestAuditEventBuilder> { + + public BlueprintExportRequestAuditEventBuilder() { + super.withOperation("Blueprint export"); + } + + @Override + protected BlueprintExportRequestAuditEvent newAuditEvent() { + return new BlueprintExportRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + } + } + + protected BlueprintExportRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected BlueprintExportRequestAuditEvent(BlueprintExportRequestAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link BlueprintExportRequestAuditEvent} + * + * @return a builder instance + */ + public static BlueprintExportRequestAuditEventBuilder builder() { + return new BlueprintExportRequestAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/ChangeAlertGroupRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/ChangeAlertGroupRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/ChangeAlertGroupRequestAuditEvent.java new file mode 100644 index 0000000..ad37b60 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/ChangeAlertGroupRequestAuditEvent.java @@ -0,0 +1,98 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.server.audit.event.request.event; + +import java.util.List; + +import org.apache.ambari.server.audit.event.request.RequestAuditEvent; +import org.apache.commons.lang.StringUtils; + +public class ChangeAlertGroupRequestAuditEvent extends RequestAuditEvent { + + public static class ChangeAlertGroupRequestAuditEventBuilder extends RequestAuditEventBuilder<ChangeAlertGroupRequestAuditEvent, ChangeAlertGroupRequestAuditEventBuilder> { + + private String name; + + private List<String> definitionIds; + + private List<String> notificationIds; + + public ChangeAlertGroupRequestAuditEventBuilder() { + super.withOperation("Alert group change"); + } + + @Override + protected ChangeAlertGroupRequestAuditEvent newAuditEvent() { + return new ChangeAlertGroupRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder.append(", Alert group name(") + .append(name) + .append("), Definition IDs(") + .append(StringUtils.join(definitionIds, ", ")) + .append("), Notification IDs(") + .append(StringUtils.join(notificationIds, ", ")) + .append(")"); + } + + public ChangeAlertGroupRequestAuditEventBuilder withName(String name) { + this.name = name; + return this; + } + + public ChangeAlertGroupRequestAuditEventBuilder withDefinitionIds(List<String> ids) { + this.definitionIds = ids; + return this; + } + + public ChangeAlertGroupRequestAuditEventBuilder withNotificationIds(List<String> ids) { + this.notificationIds = ids; + return this; + } + } + + protected ChangeAlertGroupRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected ChangeAlertGroupRequestAuditEvent(ChangeAlertGroupRequestAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link ChangeAlertGroupRequestAuditEvent} + * + * @return a builder instance + */ + public static ChangeAlertGroupRequestAuditEventBuilder builder() { + return new ChangeAlertGroupRequestAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/ChangeAlertTargetRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/ChangeAlertTargetRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/ChangeAlertTargetRequestAuditEvent.java new file mode 100644 index 0000000..0d98d68 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/ChangeAlertTargetRequestAuditEvent.java @@ -0,0 +1,134 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.server.audit.event.request.event; + +import java.util.List; + +import org.apache.ambari.server.audit.event.request.RequestAuditEvent; +import org.apache.commons.lang.StringUtils; + +public class ChangeAlertTargetRequestAuditEvent extends RequestAuditEvent { + + public static class ChangeAlertTargetRequestAuditEventBuilder extends RequestAuditEventBuilder<ChangeAlertTargetRequestAuditEvent, ChangeAlertTargetRequestAuditEventBuilder> { + + private String name; + private String description; + private String notificationType; + private List<String> groupIds; + private String emailFrom; + private List<String> emailRecipients; + private List<String> alertStates; + + public ChangeAlertTargetRequestAuditEventBuilder() { + super.withOperation("Notification change"); + } + + @Override + protected ChangeAlertTargetRequestAuditEvent newAuditEvent() { + return new ChangeAlertTargetRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder.append(", Notification name(") + .append(name) + .append("), Description(") + .append(description) + .append("), Notification type(") + .append(notificationType) + .append("), Group IDs(") + .append(StringUtils.join(groupIds, ", ")); + + if (emailFrom != null) { + builder.append("), Email from(") + .append(emailFrom); + } + + if (emailRecipients != null && !emailRecipients.isEmpty()) { + builder.append("), Email to(") + .append(StringUtils.join(emailRecipients, ", ")); + } + builder.append("), Alert states(") + .append(StringUtils.join(alertStates, ", ")) + .append(")"); + } + + public ChangeAlertTargetRequestAuditEventBuilder withName(String name) { + this.name = name; + return this; + } + + public ChangeAlertTargetRequestAuditEventBuilder withDescription(String description) { + this.description = description; + return this; + } + + public ChangeAlertTargetRequestAuditEventBuilder withNotificationType(String notificationType) { + this.notificationType = notificationType; + return this; + } + + public ChangeAlertTargetRequestAuditEventBuilder withGroupIds(List<String> groupIds) { + this.groupIds = groupIds; + return this; + } + + public ChangeAlertTargetRequestAuditEventBuilder withEmailFrom(String emailFrom) { + this.emailFrom = emailFrom; + return this; + } + + public ChangeAlertTargetRequestAuditEventBuilder withEmailRecipients(List<String> emailRecipients) { + this.emailRecipients = emailRecipients; + return this; + } + + public ChangeAlertTargetRequestAuditEventBuilder withAlertStates(List<String> alertStates) { + this.alertStates = alertStates; + return this; + } + } + + protected ChangeAlertTargetRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected ChangeAlertTargetRequestAuditEvent(ChangeAlertTargetRequestAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link ChangeAlertTargetRequestAuditEvent} + * + * @return a builder instance + */ + public static ChangeAlertTargetRequestAuditEventBuilder builder() { + return new ChangeAlertTargetRequestAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/ChangeRepositoryVersionRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/ChangeRepositoryVersionRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/ChangeRepositoryVersionRequestAuditEvent.java new file mode 100644 index 0000000..f39d55a --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/ChangeRepositoryVersionRequestAuditEvent.java @@ -0,0 +1,131 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.server.audit.event.request.event; + +import java.util.List; +import java.util.Map; + +import org.apache.ambari.server.audit.event.request.RequestAuditEvent; + +public class ChangeRepositoryVersionRequestAuditEvent extends RequestAuditEvent { + + public static class ChangeRepositoryVersionAuditEventBuilder extends RequestAuditEventBuilder<ChangeRepositoryVersionRequestAuditEvent, ChangeRepositoryVersionAuditEventBuilder> { + + private String stackName; + + private String displayName; + + private String stackVersion; + + private String repoVersion; + + private Map<String, List<Map<String, String>>> repos; + + public ChangeRepositoryVersionAuditEventBuilder() { + super.withOperation("Repository version change"); + } + + @Override + protected ChangeRepositoryVersionRequestAuditEvent newAuditEvent() { + return new ChangeRepositoryVersionRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder.append(", Stack(") + .append(stackName) + .append("), Stack version(") + .append(stackVersion) + .append("), Display name(") + .append(displayName) + .append("), Repo version(") + .append(repoVersion) + .append("), Repositories("); + + if (!repos.isEmpty()) { + builder.append(System.lineSeparator()); + } + + for (Map.Entry<String, List<Map<String, String>>> repo : repos.entrySet()) { + builder.append("Operating system: ").append(repo.getKey()); + builder.append(System.lineSeparator()); + for (Map<String, String> properties : repo.getValue()) { + builder.append(" Repository ID(").append(properties.get("repo_id")); + builder.append("), Repository name(").append(properties.get("repo_name")); + builder.append("), Base url(").append(properties.get("base_url")).append(")"); + builder.append(System.lineSeparator()); + } + } + + builder.append(")"); + } + + public ChangeRepositoryVersionAuditEventBuilder withStackName(String stackName) { + this.stackName = stackName; + return this; + } + + public ChangeRepositoryVersionAuditEventBuilder withDisplayName(String displayName) { + this.displayName = displayName; + return this; + } + + public ChangeRepositoryVersionAuditEventBuilder withStackVersion(String stackVersion) { + this.stackVersion = stackVersion; + return this; + } + + public ChangeRepositoryVersionAuditEventBuilder withRepoVersion(String repoVersion) { + this.repoVersion = repoVersion; + return this; + } + + public ChangeRepositoryVersionAuditEventBuilder withRepos(Map<String, List<Map<String, String>>> repos) { + this.repos = repos; + return this; + } + } + + protected ChangeRepositoryVersionRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected ChangeRepositoryVersionRequestAuditEvent(ChangeRepositoryVersionAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link ChangeRepositoryVersionRequestAuditEvent} + * + * @return a builder instance + */ + public static ChangeRepositoryVersionAuditEventBuilder builder() { + return new ChangeRepositoryVersionAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/ChangeViewInstanceRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/ChangeViewInstanceRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/ChangeViewInstanceRequestAuditEvent.java new file mode 100644 index 0000000..45e0141 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/ChangeViewInstanceRequestAuditEvent.java @@ -0,0 +1,113 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.server.audit.event.request.event; + +import org.apache.ambari.server.audit.event.request.RequestAuditEvent; + +public class ChangeViewInstanceRequestAuditEvent extends RequestAuditEvent { + + public static class ChangeViewInstanceRequestAuditEventBuilder extends RequestAuditEventBuilder<ChangeViewInstanceRequestAuditEvent, ChangeViewInstanceRequestAuditEventBuilder> { + + private String description; + + private String name; + + private String type; + + private String displayName; + + private String version; + + public ChangeViewInstanceRequestAuditEventBuilder() { + super.withOperation("View change"); + } + + @Override + protected ChangeViewInstanceRequestAuditEvent newAuditEvent() { + return new ChangeViewInstanceRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder.append(", Type(") + .append(type) + .append("), Version(") + .append(version) + .append("), Name(") + .append(name) + .append("), Display name(") + .append(displayName) + .append("), Description(") + .append(description) + .append(")"); + } + + public ChangeViewInstanceRequestAuditEventBuilder withDescription(String description) { + this.description = description; + return this; + } + + public ChangeViewInstanceRequestAuditEventBuilder withName(String name) { + this.name = name; + return this; + } + + public ChangeViewInstanceRequestAuditEventBuilder withType(String type) { + this.type = type; + return this; + } + + public ChangeViewInstanceRequestAuditEventBuilder withDisplayName(String displayName) { + this.displayName = displayName; + return this; + } + + public ChangeViewInstanceRequestAuditEventBuilder withVersion(String version) { + this.version = version; + return this; + } + } + + protected ChangeViewInstanceRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected ChangeViewInstanceRequestAuditEvent(ChangeViewInstanceRequestAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link ChangeViewInstanceRequestAuditEvent} + * + * @return a builder instance + */ + public static ChangeViewInstanceRequestAuditEventBuilder builder() { + return new ChangeViewInstanceRequestAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/ClientConfigDownloadRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/ClientConfigDownloadRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/ClientConfigDownloadRequestAuditEvent.java new file mode 100644 index 0000000..cfa3c27 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/ClientConfigDownloadRequestAuditEvent.java @@ -0,0 +1,88 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.server.audit.event.request.event; + +import org.apache.ambari.server.audit.event.request.RequestAuditEvent; + +public class ClientConfigDownloadRequestAuditEvent extends RequestAuditEvent { + + public static class ClientConfigDownloadRequestAuditEventBuilder extends RequestAuditEventBuilder<ClientConfigDownloadRequestAuditEvent, ClientConfigDownloadRequestAuditEventBuilder> { + + private String service; + + private String component; + + public ClientConfigDownloadRequestAuditEventBuilder() { + super.withOperation("Client config download"); + } + + @Override + protected ClientConfigDownloadRequestAuditEvent newAuditEvent() { + return new ClientConfigDownloadRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder.append(", Service(") + .append(service) + .append("), Component(") + .append(component) + .append(")"); + + } + + public ClientConfigDownloadRequestAuditEventBuilder withService(String service) { + this.service = service; + return this; + } + + public ClientConfigDownloadRequestAuditEventBuilder withComponent(String component) { + this.component = component; + return this; + } + + } + + protected ClientConfigDownloadRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected ClientConfigDownloadRequestAuditEvent(ClientConfigDownloadRequestAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link ClientConfigDownloadRequestAuditEvent} + * + * @return a builder instance + */ + public static ClientConfigDownloadRequestAuditEventBuilder builder() { + return new ClientConfigDownloadRequestAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/ClusterNameChangeRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/ClusterNameChangeRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/ClusterNameChangeRequestAuditEvent.java new file mode 100644 index 0000000..7ec140d --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/ClusterNameChangeRequestAuditEvent.java @@ -0,0 +1,91 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.server.audit.event.request.event; + +import org.apache.ambari.server.audit.event.request.RequestAuditEvent; + +/** + * Base class for start operation audit events. + */ +public class ClusterNameChangeRequestAuditEvent extends RequestAuditEvent { + + public static class ClusterNameChangeRequestAuditEventBuilder extends RequestAuditEventBuilder<ClusterNameChangeRequestAuditEvent, ClusterNameChangeRequestAuditEventBuilder> { + + private String oldName; + + private String newName; + + public ClusterNameChangeRequestAuditEventBuilder() { + super.withOperation("Cluster name change"); + } + + @Override + protected ClusterNameChangeRequestAuditEvent newAuditEvent() { + return new ClusterNameChangeRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder + .append(", Old name(") + .append(oldName) + .append("), New name(") + .append(newName) + .append(")"); + } + + public ClusterNameChangeRequestAuditEventBuilder withOldName(String oldName) { + this.oldName = oldName; + return this; + } + + public ClusterNameChangeRequestAuditEventBuilder withNewName(String newName) { + this.newName = newName; + return this; + } + + } + + protected ClusterNameChangeRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected ClusterNameChangeRequestAuditEvent(ClusterNameChangeRequestAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link ClusterNameChangeRequestAuditEvent} + * + * @return a builder instance + */ + public static ClusterNameChangeRequestAuditEventBuilder builder() { + return new ClusterNameChangeRequestAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/ClusterPrivilegeChangeRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/ClusterPrivilegeChangeRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/ClusterPrivilegeChangeRequestAuditEvent.java new file mode 100644 index 0000000..5516384 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/ClusterPrivilegeChangeRequestAuditEvent.java @@ -0,0 +1,111 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.server.audit.event.request.event; + +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.ambari.server.audit.event.request.RequestAuditEvent; +import org.apache.commons.lang.StringUtils; + +public class ClusterPrivilegeChangeRequestAuditEvent extends RequestAuditEvent { + + public static class ClusterPrivilegeChangeRequestAuditEventBuilder extends RequestAuditEventBuilder<ClusterPrivilegeChangeRequestAuditEvent, ClusterPrivilegeChangeRequestAuditEventBuilder> { + + private Map<String, List<String>> users; + private Map<String, List<String>> groups; + + public ClusterPrivilegeChangeRequestAuditEventBuilder() { + super.withOperation("Role change"); + } + + @Override + protected ClusterPrivilegeChangeRequestAuditEvent newAuditEvent() { + return new ClusterPrivilegeChangeRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + Set<String> roleSet = new HashSet<String>(); + roleSet.addAll(users.keySet()); + roleSet.addAll(groups.keySet()); + + builder.append(", Roles("); + if (!users.isEmpty() || !groups.isEmpty()) { + builder.append(System.lineSeparator()); + } + + List<String> lines = new LinkedList<String>(); + + for (String role : roleSet) { + lines.add(role + ": "); + if (users.get(role) != null && !users.get(role).isEmpty()) { + lines.add(" Users: " + StringUtils.join(users.get(role), ", ")); + } + if (groups.get(role) != null && !groups.get(role).isEmpty()) { + lines.add(" Groups: " + StringUtils.join(groups.get(role), ", ")); + } + } + + builder.append(StringUtils.join(lines, System.lineSeparator())); + + builder.append(")"); + } + + public ClusterPrivilegeChangeRequestAuditEventBuilder withUsers(Map<String, List<String>> users) { + this.users = users; + return this; + } + + public ClusterPrivilegeChangeRequestAuditEventBuilder withGroups(Map<String, List<String>> groups) { + this.groups = groups; + return this; + } + } + + protected ClusterPrivilegeChangeRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected ClusterPrivilegeChangeRequestAuditEvent(ClusterPrivilegeChangeRequestAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link ClusterPrivilegeChangeRequestAuditEvent} + * + * @return a builder instance + */ + public static ClusterPrivilegeChangeRequestAuditEventBuilder builder() { + return new ClusterPrivilegeChangeRequestAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/ConfigurationChangeRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/ConfigurationChangeRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/ConfigurationChangeRequestAuditEvent.java new file mode 100644 index 0000000..2225afd --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/ConfigurationChangeRequestAuditEvent.java @@ -0,0 +1,92 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.server.audit.event.request.event; + +import org.apache.ambari.server.audit.event.request.RequestAuditEvent; + +/** + * Base class for start operation audit events. + */ +public class ConfigurationChangeRequestAuditEvent extends RequestAuditEvent { + + public static class ConfigurationChangeRequestAuditEventBuilder extends RequestAuditEventBuilder<ConfigurationChangeRequestAuditEvent, ConfigurationChangeRequestAuditEventBuilder> { + + private String versionNumber; + + private String versionNote; + + public ConfigurationChangeRequestAuditEventBuilder() { + super.withOperation("Configuration change"); + } + + @Override + protected ConfigurationChangeRequestAuditEvent newAuditEvent() { + return new ConfigurationChangeRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder + .append(", VersionNumber(V") + .append(versionNumber) + .append("), ") + .append("VersionNote(") + .append(versionNote) + .append(")"); + } + + public ConfigurationChangeRequestAuditEventBuilder withVersionNumber(String versionNumber) { + this.versionNumber = versionNumber; + return this; + } + + public ConfigurationChangeRequestAuditEventBuilder withVersionNote(String versionNote) { + this.versionNote = versionNote; + return this; + } + + } + + protected ConfigurationChangeRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected ConfigurationChangeRequestAuditEvent(ConfigurationChangeRequestAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link ConfigurationChangeRequestAuditEvent} + * + * @return a builder instance + */ + public static ConfigurationChangeRequestAuditEventBuilder builder() { + return new ConfigurationChangeRequestAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/CreateGroupRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/CreateGroupRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/CreateGroupRequestAuditEvent.java new file mode 100644 index 0000000..c2149f4 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/CreateGroupRequestAuditEvent.java @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.server.audit.event.request.event; + +import org.apache.ambari.server.audit.event.request.RequestAuditEvent; + +public class CreateGroupRequestAuditEvent extends RequestAuditEvent { + + public static class CreateGroupRequestAuditEventBuilder extends RequestAuditEventBuilder<CreateGroupRequestAuditEvent, CreateGroupRequestAuditEventBuilder> { + + private String groupName; + + public CreateGroupRequestAuditEventBuilder() { + super.withOperation("Group create"); + } + + @Override + protected CreateGroupRequestAuditEvent newAuditEvent() { + return new CreateGroupRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder + .append(", Group(") + .append(groupName) + .append(")"); + } + + public CreateGroupRequestAuditEventBuilder withGroupName(String groupName) { + this.groupName = groupName; + return this; + } + + } + + protected CreateGroupRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected CreateGroupRequestAuditEvent(CreateGroupRequestAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link CreateGroupRequestAuditEvent} + * + * @return a builder instance + */ + public static CreateGroupRequestAuditEventBuilder builder() { + return new CreateGroupRequestAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/CreateUserRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/CreateUserRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/CreateUserRequestAuditEvent.java new file mode 100644 index 0000000..70ad317 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/CreateUserRequestAuditEvent.java @@ -0,0 +1,98 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.server.audit.event.request.event; + +import org.apache.ambari.server.audit.event.request.RequestAuditEvent; + +public class CreateUserRequestAuditEvent extends RequestAuditEvent { + + public static class CreateUserRequestAuditEventBuilder extends RequestAuditEventBuilder<CreateUserRequestAuditEvent, CreateUserRequestAuditEventBuilder> { + + private boolean admin; + + private boolean active; + + private String username; + + public CreateUserRequestAuditEventBuilder() { + super.withOperation("User create"); + } + + @Override + protected CreateUserRequestAuditEvent newAuditEvent() { + return new CreateUserRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder + .append(", Created Username(") + .append(username) + .append("), Active(") + .append(active ? "yes" : "no") + .append("), ") + .append("Administrator(") + .append(admin ? "yes" : "no") + .append(")"); + } + + public CreateUserRequestAuditEventBuilder withAdmin(boolean admin) { + this.admin = admin; + return this; + } + + public CreateUserRequestAuditEventBuilder withActive(boolean active) { + this.active = active; + return this; + } + + public CreateUserRequestAuditEventBuilder withCreatedUsername(String username) { + this.username = username; + return this; + } + + } + + protected CreateUserRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected CreateUserRequestAuditEvent(CreateUserRequestAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link CreateUserRequestAuditEvent} + * + * @return a builder instance + */ + public static CreateUserRequestAuditEventBuilder builder() { + return new CreateUserRequestAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/DeleteAlertGroupRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/DeleteAlertGroupRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/DeleteAlertGroupRequestAuditEvent.java new file mode 100644 index 0000000..dd6c9a0 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/DeleteAlertGroupRequestAuditEvent.java @@ -0,0 +1,77 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.server.audit.event.request.event; + +import org.apache.ambari.server.audit.event.request.RequestAuditEvent; + +public class DeleteAlertGroupRequestAuditEvent extends RequestAuditEvent { + + public static class DeleteAlertGroupRequestAuditEventBuilder extends RequestAuditEventBuilder<DeleteAlertGroupRequestAuditEvent, DeleteAlertGroupRequestAuditEventBuilder> { + + private String id; + + public DeleteAlertGroupRequestAuditEventBuilder() { + super.withOperation("Alert group removal"); + } + + @Override + protected DeleteAlertGroupRequestAuditEvent newAuditEvent() { + return new DeleteAlertGroupRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder.append(", Alert group ID(") + .append(id) + .append(")"); + } + + public DeleteAlertGroupRequestAuditEventBuilder withId(String id) { + this.id = id; + return this; + } + } + + protected DeleteAlertGroupRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected DeleteAlertGroupRequestAuditEvent(DeleteAlertGroupRequestAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link DeleteAlertGroupRequestAuditEvent} + * + * @return a builder instance + */ + public static DeleteAlertGroupRequestAuditEventBuilder builder() { + return new DeleteAlertGroupRequestAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/DeleteAlertTargetRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/DeleteAlertTargetRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/DeleteAlertTargetRequestAuditEvent.java new file mode 100644 index 0000000..793a6f0 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/DeleteAlertTargetRequestAuditEvent.java @@ -0,0 +1,77 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.server.audit.event.request.event; + +import org.apache.ambari.server.audit.event.request.RequestAuditEvent; + +public class DeleteAlertTargetRequestAuditEvent extends RequestAuditEvent { + + public static class DeleteAlertTargetRequestAuditEventBuilder extends RequestAuditEventBuilder<DeleteAlertTargetRequestAuditEvent, DeleteAlertTargetRequestAuditEventBuilder> { + + private String id; + + public DeleteAlertTargetRequestAuditEventBuilder() { + super.withOperation("Notification removal"); + } + + @Override + protected DeleteAlertTargetRequestAuditEvent newAuditEvent() { + return new DeleteAlertTargetRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder.append(", Notification ID(") + .append(id) + .append(")"); + } + + public DeleteAlertTargetRequestAuditEventBuilder withId(String id) { + this.id = id; + return this; + } + } + + protected DeleteAlertTargetRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected DeleteAlertTargetRequestAuditEvent(DeleteAlertTargetRequestAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link DeleteAlertTargetRequestAuditEvent} + * + * @return a builder instance + */ + public static DeleteAlertTargetRequestAuditEventBuilder builder() { + return new DeleteAlertTargetRequestAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/DeleteBlueprintRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/DeleteBlueprintRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/DeleteBlueprintRequestAuditEvent.java new file mode 100644 index 0000000..1aef3c1 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/DeleteBlueprintRequestAuditEvent.java @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.server.audit.event.request.event; + +import org.apache.ambari.server.audit.event.request.RequestAuditEvent; + +public class DeleteBlueprintRequestAuditEvent extends RequestAuditEvent { + + public static class DeleteBlueprintRequestAuditEventBuilder extends RequestAuditEventBuilder<DeleteBlueprintRequestAuditEvent, DeleteBlueprintRequestAuditEventBuilder> { + + private String blueprintName; + + public DeleteBlueprintRequestAuditEventBuilder() { + super.withOperation("Delete blueprint"); + } + + @Override + protected DeleteBlueprintRequestAuditEvent newAuditEvent() { + return new DeleteBlueprintRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder + .append(", Blueprint name(") + .append(blueprintName) + .append(")"); + } + + public DeleteBlueprintRequestAuditEventBuilder withBlueprintName(String blueprintName) { + this.blueprintName = blueprintName; + return this; + } + + } + + protected DeleteBlueprintRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected DeleteBlueprintRequestAuditEvent(DeleteBlueprintRequestAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link DeleteBlueprintRequestAuditEvent} + * + * @return a builder instance + */ + public static DeleteBlueprintRequestAuditEventBuilder builder() { + return new DeleteBlueprintRequestAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/DeleteGroupRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/DeleteGroupRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/DeleteGroupRequestAuditEvent.java new file mode 100644 index 0000000..9366d01 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/DeleteGroupRequestAuditEvent.java @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.server.audit.event.request.event; + +import org.apache.ambari.server.audit.event.request.RequestAuditEvent; + +public class DeleteGroupRequestAuditEvent extends RequestAuditEvent { + + public static class DeleteGroupRequestAuditEventBuilder extends RequestAuditEventBuilder<DeleteGroupRequestAuditEvent, DeleteGroupRequestAuditEventBuilder> { + + private String groupName; + + public DeleteGroupRequestAuditEventBuilder() { + super.withOperation("Group delete"); + } + + @Override + protected DeleteGroupRequestAuditEvent newAuditEvent() { + return new DeleteGroupRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder + .append(", Group(") + .append(groupName) + .append(")"); + } + + public DeleteGroupRequestAuditEventBuilder withGroupName(String groupName) { + this.groupName = groupName; + return this; + } + + } + + protected DeleteGroupRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected DeleteGroupRequestAuditEvent(DeleteGroupRequestAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link DeleteGroupRequestAuditEvent} + * + * @return a builder instance + */ + public static DeleteGroupRequestAuditEventBuilder builder() { + return new DeleteGroupRequestAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/DeleteHostRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/DeleteHostRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/DeleteHostRequestAuditEvent.java new file mode 100644 index 0000000..80f2c8e --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/DeleteHostRequestAuditEvent.java @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.server.audit.event.request.event; + +import org.apache.ambari.server.audit.event.request.RequestAuditEvent; + +public class DeleteHostRequestAuditEvent extends RequestAuditEvent { + + public static class DeleteHostRequestAuditEventBuilder extends RequestAuditEventBuilder<DeleteHostRequestAuditEvent, DeleteHostRequestAuditEventBuilder> { + + private String hostName; + + public DeleteHostRequestAuditEventBuilder() { + super.withOperation("Host deletion"); + } + + @Override + protected DeleteHostRequestAuditEvent newAuditEvent() { + return new DeleteHostRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder + .append(", Hostname(") + .append(hostName) + .append(")"); + } + + public DeleteHostRequestAuditEventBuilder withHostName(String groupName) { + this.hostName = groupName; + return this; + } + + } + + protected DeleteHostRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected DeleteHostRequestAuditEvent(DeleteHostRequestAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link DeleteHostRequestAuditEvent} + * + * @return a builder instance + */ + public static DeleteHostRequestAuditEventBuilder builder() { + return new DeleteHostRequestAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/DeleteRepositoryVersionRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/DeleteRepositoryVersionRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/DeleteRepositoryVersionRequestAuditEvent.java new file mode 100644 index 0000000..2bbf8a9 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/DeleteRepositoryVersionRequestAuditEvent.java @@ -0,0 +1,95 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.server.audit.event.request.event; + +import org.apache.ambari.server.audit.event.request.RequestAuditEvent; + +public class DeleteRepositoryVersionRequestAuditEvent extends RequestAuditEvent { + + public static class DeleteRepositoryVersionAuditEventBuilder extends RequestAuditEventBuilder<DeleteRepositoryVersionRequestAuditEvent, DeleteRepositoryVersionAuditEventBuilder> { + + private String stackName; + + private String stackVersion; + + private String repoVersion; + + public DeleteRepositoryVersionAuditEventBuilder() { + super.withOperation("Repository version removal"); + } + + @Override + protected DeleteRepositoryVersionRequestAuditEvent newAuditEvent() { + return new DeleteRepositoryVersionRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder.append(", Stack(") + .append(stackName) + .append("), Stack version(") + .append(stackVersion) + .append("), Repo version ID(") + .append(repoVersion) + .append(")"); + } + + public DeleteRepositoryVersionAuditEventBuilder withStackName(String stackName) { + this.stackName = stackName; + return this; + } + + public DeleteRepositoryVersionAuditEventBuilder withStackVersion(String stackVersion) { + this.stackVersion = stackVersion; + return this; + } + + public DeleteRepositoryVersionAuditEventBuilder withRepoVersion(String repoVersion) { + this.repoVersion = repoVersion; + return this; + } + } + + protected DeleteRepositoryVersionRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected DeleteRepositoryVersionRequestAuditEvent(DeleteRepositoryVersionAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link DeleteRepositoryVersionRequestAuditEvent} + * + * @return a builder instance + */ + public static DeleteRepositoryVersionAuditEventBuilder builder() { + return new DeleteRepositoryVersionAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/DeleteServiceRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/DeleteServiceRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/DeleteServiceRequestAuditEvent.java new file mode 100644 index 0000000..c768606 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/DeleteServiceRequestAuditEvent.java @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.server.audit.event.request.event; + +import org.apache.ambari.server.audit.event.request.RequestAuditEvent; + +public class DeleteServiceRequestAuditEvent extends RequestAuditEvent { + + public static class DeleteServiceRequestAuditEventBuilder extends RequestAuditEventBuilder<DeleteServiceRequestAuditEvent, DeleteServiceRequestAuditEventBuilder> { + + private String serviceName; + + public DeleteServiceRequestAuditEventBuilder() { + super.withOperation("Service deletion"); + } + + @Override + protected DeleteServiceRequestAuditEvent newAuditEvent() { + return new DeleteServiceRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder + .append(", Service(") + .append(serviceName) + .append(")"); + } + + public DeleteServiceRequestAuditEventBuilder withService(String service) { + this.serviceName = service; + return this; + } + + } + + protected DeleteServiceRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected DeleteServiceRequestAuditEvent(DeleteServiceRequestAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link DeleteServiceRequestAuditEvent} + * + * @return a builder instance + */ + public static DeleteServiceRequestAuditEventBuilder builder() { + return new DeleteServiceRequestAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/DeleteUserRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/DeleteUserRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/DeleteUserRequestAuditEvent.java new file mode 100644 index 0000000..7ef0788 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/DeleteUserRequestAuditEvent.java @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.server.audit.event.request.event; + +import org.apache.ambari.server.audit.event.request.RequestAuditEvent; + +public class DeleteUserRequestAuditEvent extends RequestAuditEvent { + + public static class DeleteUserRequestAuditEventBuilder extends RequestAuditEventBuilder<DeleteUserRequestAuditEvent, DeleteUserRequestAuditEventBuilder> { + + private String username; + + public DeleteUserRequestAuditEventBuilder() { + super.withOperation("User delete"); + } + + @Override + protected DeleteUserRequestAuditEvent newAuditEvent() { + return new DeleteUserRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder + .append(", Deleted Username(") + .append(username) + .append(")"); + } + + public DeleteUserRequestAuditEventBuilder withDeletedUsername(String username) { + this.username = username; + return this; + } + + } + + protected DeleteUserRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected DeleteUserRequestAuditEvent(DeleteUserRequestAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link DeleteUserRequestAuditEvent} + * + * @return a builder instance + */ + public static DeleteUserRequestAuditEventBuilder builder() { + return new DeleteUserRequestAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/DeleteViewInstanceRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/DeleteViewInstanceRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/DeleteViewInstanceRequestAuditEvent.java new file mode 100644 index 0000000..76a8778 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/DeleteViewInstanceRequestAuditEvent.java @@ -0,0 +1,95 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.server.audit.event.request.event; + +import org.apache.ambari.server.audit.event.request.RequestAuditEvent; + +public class DeleteViewInstanceRequestAuditEvent extends RequestAuditEvent { + + public static class DeleteViewInstanceRequestAuditEventBuilder extends RequestAuditEventBuilder<DeleteViewInstanceRequestAuditEvent, DeleteViewInstanceRequestAuditEventBuilder> { + + private String name; + + private String type; + + private String version; + + public DeleteViewInstanceRequestAuditEventBuilder() { + super.withOperation("View deletion"); + } + + @Override + protected DeleteViewInstanceRequestAuditEvent newAuditEvent() { + return new DeleteViewInstanceRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder.append(", Type(") + .append(type) + .append("), Version(") + .append(version) + .append("), Name(") + .append(name) + .append(")"); + } + + public DeleteViewInstanceRequestAuditEventBuilder withName(String name) { + this.name = name; + return this; + } + + public DeleteViewInstanceRequestAuditEventBuilder withType(String type) { + this.type = type; + return this; + } + + public DeleteViewInstanceRequestAuditEventBuilder withVersion(String version) { + this.version = version; + return this; + } + } + + protected DeleteViewInstanceRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected DeleteViewInstanceRequestAuditEvent(DeleteViewInstanceRequestAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link DeleteViewInstanceRequestAuditEvent} + * + * @return a builder instance + */ + public static DeleteViewInstanceRequestAuditEventBuilder builder() { + return new DeleteViewInstanceRequestAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/MembershipChangeRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/MembershipChangeRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/MembershipChangeRequestAuditEvent.java new file mode 100644 index 0000000..aab0208 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/MembershipChangeRequestAuditEvent.java @@ -0,0 +1,96 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.server.audit.event.request.event; + +import java.util.List; + +import org.apache.ambari.server.audit.event.request.RequestAuditEvent; +import org.apache.commons.lang.StringUtils; + +public class MembershipChangeRequestAuditEvent extends RequestAuditEvent { + + public static class AddUserToGroupRequestAuditEventBuilder extends RequestAuditEventBuilder<MembershipChangeRequestAuditEvent, AddUserToGroupRequestAuditEventBuilder> { + + private List<String> userNameList; + + private String groupName; + + public AddUserToGroupRequestAuditEventBuilder() { + super.withOperation("Membership change"); + } + + @Override + protected MembershipChangeRequestAuditEvent newAuditEvent() { + return new MembershipChangeRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder.append(", Group(") + .append(groupName) + .append("), Members("); + + if (userNameList.isEmpty()) { + builder.append("<empty>"); + } + + StringUtils.join(userNameList, ", "); + + builder.append(")"); + } + + public AddUserToGroupRequestAuditEventBuilder withUserNameList(List<String> users) { + this.userNameList = users; + return this; + } + + public AddUserToGroupRequestAuditEventBuilder withGroupName(String groupName) { + this.groupName = groupName; + return this; + } + + } + + protected MembershipChangeRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected MembershipChangeRequestAuditEvent(AddUserToGroupRequestAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link MembershipChangeRequestAuditEvent} + * + * @return a builder instance + */ + public static AddUserToGroupRequestAuditEventBuilder builder() { + return new AddUserToGroupRequestAuditEventBuilder(); + } + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/PrivilegeChangeRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/PrivilegeChangeRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/PrivilegeChangeRequestAuditEvent.java new file mode 100644 index 0000000..35c9eab --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/event/request/event/PrivilegeChangeRequestAuditEvent.java @@ -0,0 +1,98 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ambari.server.audit.event.request.event; + +import org.apache.ambari.server.audit.event.request.RequestAuditEvent; + +public class PrivilegeChangeRequestAuditEvent extends RequestAuditEvent { + + public static class PrivilegeChangeRequestAuditEventBuilder extends RequestAuditEventBuilder<PrivilegeChangeRequestAuditEvent, PrivilegeChangeRequestAuditEventBuilder> { + + private String user; + + private String group; + + private String role; + + public PrivilegeChangeRequestAuditEventBuilder() { + super.withOperation("Role change"); + } + + @Override + protected PrivilegeChangeRequestAuditEvent newAuditEvent() { + return new PrivilegeChangeRequestAuditEvent(this); + } + + /** + * Appends to the event the details of the incoming request. + * + * @param builder builder for the audit event details. + */ + @Override + protected void buildAuditMessage(StringBuilder builder) { + super.buildAuditMessage(builder); + + builder.append(", Role(") + .append(role) + .append(")"); + + if (user != null) { + builder.append(", User(").append(user).append(")"); + } + if (group != null) { + builder.append(", Group(").append(group).append(")"); + } + } + + public PrivilegeChangeRequestAuditEventBuilder withUser(String user) { + this.user = user; + return this; + } + + public PrivilegeChangeRequestAuditEventBuilder withGroup(String group) { + this.group = group; + return this; + } + + public PrivilegeChangeRequestAuditEventBuilder withRole(String role) { + this.role = role; + return this; + } + } + + protected PrivilegeChangeRequestAuditEvent() { + } + + /** + * {@inheritDoc} + */ + protected PrivilegeChangeRequestAuditEvent(PrivilegeChangeRequestAuditEventBuilder builder) { + super(builder); + } + + /** + * Returns an builder for {@link PrivilegeChangeRequestAuditEvent} + * + * @return a builder instance + */ + public static PrivilegeChangeRequestAuditEventBuilder builder() { + return new PrivilegeChangeRequestAuditEventBuilder(); + } + +}