http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/ClusterNameChangeRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/ClusterNameChangeRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/ClusterNameChangeRequestAuditEvent.java deleted file mode 100644 index c247750..0000000 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/ClusterNameChangeRequestAuditEvent.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ambari.server.audit.request.event; - -import org.apache.ambari.server.audit.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/request/event/ClusterPrivilegeChangeRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/ClusterPrivilegeChangeRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/ClusterPrivilegeChangeRequestAuditEvent.java deleted file mode 100644 index b3d61be..0000000 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/ClusterPrivilegeChangeRequestAuditEvent.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ambari.server.audit.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.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/request/event/ConfigurationChangeRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/ConfigurationChangeRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/ConfigurationChangeRequestAuditEvent.java deleted file mode 100644 index 5be9d7e..0000000 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/ConfigurationChangeRequestAuditEvent.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ambari.server.audit.request.event; - -import org.apache.ambari.server.audit.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/request/event/CreateGroupRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/CreateGroupRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/CreateGroupRequestAuditEvent.java deleted file mode 100644 index bd897a7..0000000 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/CreateGroupRequestAuditEvent.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ambari.server.audit.request.event; - -import org.apache.ambari.server.audit.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/request/event/CreateUserRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/CreateUserRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/CreateUserRequestAuditEvent.java deleted file mode 100644 index 300ed9b..0000000 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/CreateUserRequestAuditEvent.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ambari.server.audit.request.event; - -import org.apache.ambari.server.audit.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/request/event/DeleteAlertGroupRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/DeleteAlertGroupRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/DeleteAlertGroupRequestAuditEvent.java deleted file mode 100644 index 95b223d..0000000 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/DeleteAlertGroupRequestAuditEvent.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ambari.server.audit.request.event; - -import org.apache.ambari.server.audit.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/request/event/DeleteAlertTargetRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/DeleteAlertTargetRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/DeleteAlertTargetRequestAuditEvent.java deleted file mode 100644 index 9dae221..0000000 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/DeleteAlertTargetRequestAuditEvent.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ambari.server.audit.request.event; - -import org.apache.ambari.server.audit.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/request/event/DeleteBlueprintRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/DeleteBlueprintRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/DeleteBlueprintRequestAuditEvent.java deleted file mode 100644 index b8ada1e..0000000 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/DeleteBlueprintRequestAuditEvent.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ambari.server.audit.request.event; - -import org.apache.ambari.server.audit.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/request/event/DeleteGroupRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/DeleteGroupRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/DeleteGroupRequestAuditEvent.java deleted file mode 100644 index 3241976..0000000 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/DeleteGroupRequestAuditEvent.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ambari.server.audit.request.event; - -import org.apache.ambari.server.audit.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/request/event/DeleteHostRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/DeleteHostRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/DeleteHostRequestAuditEvent.java deleted file mode 100644 index aa982d4..0000000 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/DeleteHostRequestAuditEvent.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ambari.server.audit.request.event; - -import org.apache.ambari.server.audit.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/request/event/DeleteRepositoryVersionRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/DeleteRepositoryVersionRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/DeleteRepositoryVersionRequestAuditEvent.java deleted file mode 100644 index 8e97fbd..0000000 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/DeleteRepositoryVersionRequestAuditEvent.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ambari.server.audit.request.event; - -import org.apache.ambari.server.audit.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/request/event/DeleteServiceRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/DeleteServiceRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/DeleteServiceRequestAuditEvent.java deleted file mode 100644 index 6b5b262..0000000 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/DeleteServiceRequestAuditEvent.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ambari.server.audit.request.event; - -import org.apache.ambari.server.audit.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/request/event/DeleteUserRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/DeleteUserRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/DeleteUserRequestAuditEvent.java deleted file mode 100644 index 59be3f7..0000000 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/DeleteUserRequestAuditEvent.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ambari.server.audit.request.event; - -import org.apache.ambari.server.audit.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/request/event/DeleteViewInstanceRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/DeleteViewInstanceRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/DeleteViewInstanceRequestAuditEvent.java deleted file mode 100644 index 4d14321..0000000 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/DeleteViewInstanceRequestAuditEvent.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ambari.server.audit.request.event; - -import org.apache.ambari.server.audit.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/request/event/MembershipChangeRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/MembershipChangeRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/MembershipChangeRequestAuditEvent.java deleted file mode 100644 index 3bc5013..0000000 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/MembershipChangeRequestAuditEvent.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ambari.server.audit.request.event; - -import java.util.List; - -import org.apache.ambari.server.audit.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/request/event/PrivilegeChangeRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/PrivilegeChangeRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/PrivilegeChangeRequestAuditEvent.java deleted file mode 100644 index 5820ee4..0000000 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/PrivilegeChangeRequestAuditEvent.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ambari.server.audit.request.event; - -import org.apache.ambari.server.audit.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(); - } - -} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/RemoveUserFromGroupRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/RemoveUserFromGroupRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/RemoveUserFromGroupRequestAuditEvent.java deleted file mode 100644 index 34a2493..0000000 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/RemoveUserFromGroupRequestAuditEvent.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ambari.server.audit.request.event; - -import org.apache.ambari.server.audit.request.RequestAuditEvent; - -public class RemoveUserFromGroupRequestAuditEvent extends RequestAuditEvent { - - public static class AddUserToGroupRequestAuditEventBuilder extends RequestAuditEventBuilder<RemoveUserFromGroupRequestAuditEvent, AddUserToGroupRequestAuditEventBuilder> { - - private String groupName; - private String affectedUserName; - - public AddUserToGroupRequestAuditEventBuilder() { - super.withOperation("User removal from group"); - } - - @Override - protected RemoveUserFromGroupRequestAuditEvent newAuditEvent() { - return new RemoveUserFromGroupRequestAuditEvent(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("); - builder.append(groupName); - builder.append("), Affected username("); - builder.append(affectedUserName); - builder.append(")"); - } - - public AddUserToGroupRequestAuditEventBuilder withGroupName(String groupName) { - this.groupName = groupName; - return this; - } - - public AddUserToGroupRequestAuditEventBuilder withAffectedUserName(String userName) { - this.affectedUserName = userName; - return this; - } - } - - protected RemoveUserFromGroupRequestAuditEvent() { - } - - /** - * {@inheritDoc} - */ - protected RemoveUserFromGroupRequestAuditEvent(AddUserToGroupRequestAuditEventBuilder builder) { - super(builder); - } - - /** - * Returns an builder for {@link RemoveUserFromGroupRequestAuditEvent} - * @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/request/event/UpdateRepositoryRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/UpdateRepositoryRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/UpdateRepositoryRequestAuditEvent.java deleted file mode 100644 index a44d50e..0000000 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/UpdateRepositoryRequestAuditEvent.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ambari.server.audit.request.event; - -import org.apache.ambari.server.audit.request.RequestAuditEvent; - -public class UpdateRepositoryRequestAuditEvent extends RequestAuditEvent { - - public static class UpdateRepositoryRequestAuditEventBuilder extends RequestAuditEventBuilder<UpdateRepositoryRequestAuditEvent, UpdateRepositoryRequestAuditEventBuilder> { - - private String repo; - - private String stackName; - - private String osType; - - private String baseUrl; - - private String stackVersion; - - public UpdateRepositoryRequestAuditEventBuilder() { - super.withOperation("Repository update"); - } - - @Override - protected UpdateRepositoryRequestAuditEvent newAuditEvent() { - return new UpdateRepositoryRequestAuditEvent(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("), OS(") - .append(osType) - .append("), Repo id(") - .append(repo) - .append("), Base URL(") - .append(baseUrl) - .append(")"); - } - - public UpdateRepositoryRequestAuditEventBuilder withRepo(String repo) { - this.repo = repo; - return this; - } - - public UpdateRepositoryRequestAuditEventBuilder withStackName(String stackName) { - this.stackName = stackName; - return this; - } - - public UpdateRepositoryRequestAuditEventBuilder withOsType(String osType) { - this.osType = osType; - return this; - } - - public UpdateRepositoryRequestAuditEventBuilder withBaseUrl(String baseUrl) { - this.baseUrl = baseUrl; - return this; - } - - public UpdateRepositoryRequestAuditEventBuilder withStackVersion(String stackVersion) { - this.stackVersion = stackVersion; - return this; - } - } - - protected UpdateRepositoryRequestAuditEvent() { - } - - /** - * {@inheritDoc} - */ - protected UpdateRepositoryRequestAuditEvent(UpdateRepositoryRequestAuditEventBuilder builder) { - super(builder); - } - - /** - * Returns an builder for {@link UpdateRepositoryRequestAuditEvent} - * @return a builder instance - */ - public static UpdateRepositoryRequestAuditEventBuilder builder() { - return new UpdateRepositoryRequestAuditEventBuilder(); - } - -} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/UpdateUpgradeItemRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/UpdateUpgradeItemRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/UpdateUpgradeItemRequestAuditEvent.java deleted file mode 100644 index e622937..0000000 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/UpdateUpgradeItemRequestAuditEvent.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ambari.server.audit.request.event; - -import org.apache.ambari.server.audit.request.RequestAuditEvent; - -public class UpdateUpgradeItemRequestAuditEvent extends RequestAuditEvent { - - public static class UpdateUpgradeItemRequestAuditEventBuilder extends RequestAuditEventBuilder<UpdateUpgradeItemRequestAuditEvent, UpdateUpgradeItemRequestAuditEventBuilder> { - - private String stageId; - private String status; - private String requestId; - - - public UpdateUpgradeItemRequestAuditEventBuilder() { - super.withOperation("Action confirmation by the user"); - } - - @Override - protected UpdateUpgradeItemRequestAuditEvent newAuditEvent() { - return new UpdateUpgradeItemRequestAuditEvent(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(", Stage id(") - .append(stageId) - .append("), Status(") - .append(status) - .append("), Request id(") - .append(requestId) - .append(")"); - } - - public UpdateUpgradeItemRequestAuditEventBuilder withStageId(String stageId) { - this.stageId = stageId; - return this; - } - - public UpdateUpgradeItemRequestAuditEventBuilder withStatus(String status) { - this.status = status; - return this; - } - - public UpdateUpgradeItemRequestAuditEventBuilder withRequestId(String requestId) { - this.requestId = requestId; - return this; - } - } - - protected UpdateUpgradeItemRequestAuditEvent() { - } - - /** - * {@inheritDoc} - */ - protected UpdateUpgradeItemRequestAuditEvent(UpdateUpgradeItemRequestAuditEventBuilder builder) { - super(builder); - } - - /** - * Returns an builder for {@link UpdateUpgradeItemRequestAuditEvent} - * @return a builder instance - */ - public static UpdateUpgradeItemRequestAuditEventBuilder builder() { - return new UpdateUpgradeItemRequestAuditEventBuilder(); - } - -} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/UserPasswordChangeRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/UserPasswordChangeRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/UserPasswordChangeRequestAuditEvent.java deleted file mode 100644 index 40f5b55..0000000 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/UserPasswordChangeRequestAuditEvent.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ambari.server.audit.request.event; - -import org.apache.ambari.server.audit.request.RequestAuditEvent; - -public class UserPasswordChangeRequestAuditEvent extends RequestAuditEvent { - - public static class UserPasswordChangeRequestAuditEventBuilder extends RequestAuditEventBuilder<UserPasswordChangeRequestAuditEvent, UserPasswordChangeRequestAuditEventBuilder> { - - private String username; - - public UserPasswordChangeRequestAuditEventBuilder() { - super.withOperation("Password change"); - } - - @Override - protected UserPasswordChangeRequestAuditEvent newAuditEvent() { - return new UserPasswordChangeRequestAuditEvent(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(", Affected username(") - .append(username) - .append(")"); - } - - - public UserPasswordChangeRequestAuditEventBuilder withAffectedUsername(String username) { - this.username = username; - return this; - } - } - - protected UserPasswordChangeRequestAuditEvent() { - } - - /** - * {@inheritDoc} - */ - protected UserPasswordChangeRequestAuditEvent(UserPasswordChangeRequestAuditEventBuilder builder) { - super(builder); - } - - /** - * Returns an builder for {@link UserPasswordChangeRequestAuditEvent} - * @return a builder instance - */ - public static UserPasswordChangeRequestAuditEventBuilder builder() { - return new UserPasswordChangeRequestAuditEventBuilder(); - } - -} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/ViewPrivilegeChangeRequestAuditEvent.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/ViewPrivilegeChangeRequestAuditEvent.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/ViewPrivilegeChangeRequestAuditEvent.java deleted file mode 100644 index 55d1b96..0000000 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/event/ViewPrivilegeChangeRequestAuditEvent.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ambari.server.audit.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.request.RequestAuditEvent; -import org.apache.commons.lang.StringUtils; - -public class ViewPrivilegeChangeRequestAuditEvent extends RequestAuditEvent { - - public static class ViewPrivilegeChangeRequestAuditEventBuilder extends RequestAuditEventBuilder<ViewPrivilegeChangeRequestAuditEvent, ViewPrivilegeChangeRequestAuditEventBuilder> { - - private Map<String, List<String>> users; - private Map<String, List<String>> groups; - - private String name; - - private String type; - - private String version; - - - public ViewPrivilegeChangeRequestAuditEventBuilder() { - super.withOperation("View permission change"); - } - - @Override - protected ViewPrivilegeChangeRequestAuditEvent newAuditEvent() { - return new ViewPrivilegeChangeRequestAuditEvent(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(")"); - - Set<String> roleSet = new HashSet<String>(); - roleSet.addAll(users.keySet()); - roleSet.addAll(groups.keySet()); - - builder.append(", Permissions("); - 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 ViewPrivilegeChangeRequestAuditEventBuilder withName(String name) { - this.name = name; - return this; - } - - public ViewPrivilegeChangeRequestAuditEventBuilder withType(String type) { - this.type = type; - return this; - } - - public ViewPrivilegeChangeRequestAuditEventBuilder withVersion(String version) { - this.version = version; - return this; - } - - public ViewPrivilegeChangeRequestAuditEventBuilder withUsers(Map<String, List<String>> users) { - this.users = users; - return this; - } - - public ViewPrivilegeChangeRequestAuditEventBuilder withGroups(Map<String, List<String>> groups) { - this.groups = groups; - return this; - } - } - - protected ViewPrivilegeChangeRequestAuditEvent() { - } - - /** - * {@inheritDoc} - */ - protected ViewPrivilegeChangeRequestAuditEvent(ViewPrivilegeChangeRequestAuditEventBuilder builder) { - super(builder); - } - - /** - * Returns an builder for {@link ViewPrivilegeChangeRequestAuditEvent} - * @return a builder instance - */ - public static ViewPrivilegeChangeRequestAuditEventBuilder builder() { - return new ViewPrivilegeChangeRequestAuditEventBuilder(); - } - -} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/AlertGroupEventCreator.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/AlertGroupEventCreator.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/AlertGroupEventCreator.java deleted file mode 100644 index c4f2b9d..0000000 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/AlertGroupEventCreator.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ambari.server.audit.request.eventcreator; - -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.apache.ambari.server.api.services.Request; -import org.apache.ambari.server.api.services.Result; -import org.apache.ambari.server.api.services.ResultStatus; -import org.apache.ambari.server.audit.AuditEvent; -import org.apache.ambari.server.audit.request.RequestAuditEventCreator; -import org.apache.ambari.server.audit.request.event.AddAlertGroupRequestAuditEvent; -import org.apache.ambari.server.audit.request.event.ChangeAlertGroupRequestAuditEvent; -import org.apache.ambari.server.audit.request.event.DeleteAlertGroupRequestAuditEvent; -import org.apache.ambari.server.controller.spi.Resource; -import org.apache.ambari.server.controller.utilities.PropertyHelper; -import org.joda.time.DateTime; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.security.core.userdetails.User; - -/** - * This creator handles alert group requests - * For resource type {@link Resource.Type#AlertGroup} - * and request types {@link Request.Type#POST}, {@link Request.Type#PUT} and {@link Request.Type#DELETE} - */ -public class AlertGroupEventCreator implements RequestAuditEventCreator { - - /** - * Set of {@link Request.Type}s that are handled by this plugin - */ - private Set<Request.Type> requestTypes = new HashSet<Request.Type>(); - - { - requestTypes.add(Request.Type.PUT); - requestTypes.add(Request.Type.POST); - requestTypes.add(Request.Type.DELETE); - } - - /** - * {@inheritDoc} - */ - @Override - public Set<Request.Type> getRequestTypes() { - return requestTypes; - } - - /** - * {@inheritDoc} - */ - @Override - public Set<Resource.Type> getResourceTypes() { - return Collections.singleton(Resource.Type.AlertGroup); - } - - /** - * {@inheritDoc} - */ - @Override - public Set<ResultStatus.STATUS> getResultStatuses() { - return null; - } - - @Override - public AuditEvent createAuditEvent(Request request, Result result) { - String username = ((User) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getUsername(); - - switch(request.getRequestType()) { - case POST: - return AddAlertGroupRequestAuditEvent.builder() - .withTimestamp(DateTime.now()) - .withRequestType(request.getRequestType()) - .withResultStatus(result.getStatus()) - .withUrl(request.getURI()) - .withRemoteIp(request.getRemoteAddress()) - .withUserName(username) - .withName(getName(request)) - .withDefinitionIds(getDefinitionIds(request)) - .withNotificationIds(getNotificationIds(request)) - .build(); - case PUT: - return ChangeAlertGroupRequestAuditEvent.builder() - .withTimestamp(DateTime.now()) - .withRequestType(request.getRequestType()) - .withResultStatus(result.getStatus()) - .withUrl(request.getURI()) - .withRemoteIp(request.getRemoteAddress()) - .withUserName(username) - .withName(getName(request)) - .withDefinitionIds(getDefinitionIds(request)) - .withNotificationIds(getNotificationIds(request)) - .build(); - case DELETE: - return DeleteAlertGroupRequestAuditEvent.builder() - .withTimestamp(DateTime.now()) - .withRequestType(request.getRequestType()) - .withResultStatus(result.getStatus()) - .withUrl(request.getURI()) - .withRemoteIp(request.getRemoteAddress()) - .withUserName(username) - .withId(request.getResource().getKeyValueMap().get(Resource.Type.AlertGroup)) - .build(); - default: - return null; - } - } - - private String getName(Request request) { - if(!request.getBody().getNamedPropertySets().isEmpty()) { - return String.valueOf(request.getBody().getNamedPropertySets().iterator().next().getProperties().get(PropertyHelper.getPropertyId("AlertGroup","name"))); - } - return null; - } - - private List<String> getDefinitionIds(Request request) { - if(!request.getBody().getNamedPropertySets().isEmpty()) { - List<String> list = (List<String>) request.getBody().getNamedPropertySets().iterator().next().getProperties().get(PropertyHelper.getPropertyId("AlertGroup", "definitions")); - if (list != null) { - return list; - } - } - return Collections.emptyList(); - } - - private List<String> getNotificationIds(Request request) { - if(!request.getBody().getNamedPropertySets().isEmpty()) { - List<String> list = (List<String>) request.getBody().getNamedPropertySets().iterator().next().getProperties().get(PropertyHelper.getPropertyId("AlertGroup", "targets")); - if (list != null) { - return list; - } - } - return Collections.emptyList(); - } -} http://git-wip-us.apache.org/repos/asf/ambari/blob/1b1b3bc6/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/AlertTargetEventCreator.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/AlertTargetEventCreator.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/AlertTargetEventCreator.java deleted file mode 100644 index aa462cc..0000000 --- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/AlertTargetEventCreator.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ambari.server.audit.request.eventcreator; - -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.apache.ambari.server.api.services.Request; -import org.apache.ambari.server.api.services.Result; -import org.apache.ambari.server.api.services.ResultStatus; -import org.apache.ambari.server.audit.AuditEvent; -import org.apache.ambari.server.audit.request.RequestAuditEventCreator; -import org.apache.ambari.server.audit.request.event.AddAlertTargetRequestAuditEvent; -import org.apache.ambari.server.audit.request.event.ChangeAlertTargetRequestAuditEvent; -import org.apache.ambari.server.audit.request.event.DeleteAlertTargetRequestAuditEvent; -import org.apache.ambari.server.controller.spi.Resource; -import org.apache.ambari.server.controller.utilities.PropertyHelper; -import org.joda.time.DateTime; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.security.core.userdetails.User; - -/** - * This creator handles alert target requests - * For resource type {@link Resource.Type#AlertTarget} - * and request types {@link Request.Type#POST}, {@link Request.Type#PUT} and {@link Request.Type#DELETE} - */ -public class AlertTargetEventCreator implements RequestAuditEventCreator { - - /** - * Set of {@link Request.Type}s that are handled by this plugin - */ - private Set<Request.Type> requestTypes = new HashSet<Request.Type>(); - - { - requestTypes.add(Request.Type.PUT); - requestTypes.add(Request.Type.POST); - requestTypes.add(Request.Type.DELETE); - } - - /** - * {@inheritDoc} - */ - @Override - public Set<Request.Type> getRequestTypes() { - return requestTypes; - } - - /** - * {@inheritDoc} - */ - @Override - public Set<Resource.Type> getResourceTypes() { - return Collections.singleton(Resource.Type.AlertTarget); - } - - /** - * {@inheritDoc} - */ - @Override - public Set<ResultStatus.STATUS> getResultStatuses() { - return null; - } - - @Override - public AuditEvent createAuditEvent(Request request, Result result) { - String username = ((User) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getUsername(); - - switch(request.getRequestType()) { - case POST: - return AddAlertTargetRequestAuditEvent.builder() - .withTimestamp(DateTime.now()) - .withRequestType(request.getRequestType()) - .withResultStatus(result.getStatus()) - .withUrl(request.getURI()) - .withRemoteIp(request.getRemoteAddress()) - .withUserName(username) - .withName(getProperty(request, "name")) - .withDescription(getProperty(request, "description")) - .withAlertStates(getPropertyList(request, "alert_states")) - .withGroupIds(getPropertyList(request, "groups")) - .withNotificationType(getProperty(request, "notification_type")) - .withEmailFrom(getProperty(request, "properties/mail.smtp.from")) - .withEmailRecipients(getPropertyList(request, "properties/ambari.dispatch.recipients")) - .build(); - case PUT: - return ChangeAlertTargetRequestAuditEvent.builder() - .withTimestamp(DateTime.now()) - .withRequestType(request.getRequestType()) - .withResultStatus(result.getStatus()) - .withUrl(request.getURI()) - .withRemoteIp(request.getRemoteAddress()) - .withUserName(username) - .withName(getProperty(request, "name")) - .withDescription(getProperty(request, "description")) - .withAlertStates(getPropertyList(request, "alert_states")) - .withGroupIds(getPropertyList(request, "groups")) - .withNotificationType(getProperty(request, "notification_type")) - .withEmailFrom(getProperty(request, "properties/mail.smtp.from")) - .withEmailRecipients(getPropertyList(request, "properties/ambari.dispatch.recipients")) - .build(); - case DELETE: - return DeleteAlertTargetRequestAuditEvent.builder() - .withTimestamp(DateTime.now()) - .withRequestType(request.getRequestType()) - .withResultStatus(result.getStatus()) - .withUrl(request.getURI()) - .withRemoteIp(request.getRemoteAddress()) - .withUserName(username) - .withId(request.getResource().getKeyValueMap().get(Resource.Type.AlertTarget)) - .build(); - default: - return null; - } - } - - private List<String> getPropertyList(Request request, String propertyName) { - if(!request.getBody().getNamedPropertySets().isEmpty()) { - List<String> list = (List<String>) request.getBody().getNamedPropertySets().iterator().next().getProperties().get(PropertyHelper.getPropertyId("AlertTarget",propertyName)); - if (list != null) { - return list; - } - } - return Collections.emptyList(); - } - - private String getProperty(Request request, String propertyName) { - if(!request.getBody().getPropertySets().isEmpty()) { - return String.valueOf(request.getBody().getPropertySets().iterator().next().get(PropertyHelper.getPropertyId("AlertTarget",propertyName))); - } - return null; - } -}
