You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by st...@apache.org on 2016/04/12 16:27:46 UTC
ambari git commit: AMBARI-15804. Audit logging cleanup and tests
(part2). (Daniel Gergely via stoader)
Repository: ambari
Updated Branches:
refs/heads/trunk 6eeb1a65c -> e0bc22e18
AMBARI-15804. Audit logging cleanup and tests (part2). (Daniel Gergely via stoader)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/e0bc22e1
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/e0bc22e1
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/e0bc22e1
Branch: refs/heads/trunk
Commit: e0bc22e18b85e16800225076a60606f4e8f13e87
Parents: 6eeb1a6
Author: Toader, Sebastian <st...@hortonworks.com>
Authored: Tue Apr 12 16:26:59 2016 +0200
Committer: Toader, Sebastian <st...@hortonworks.com>
Committed: Tue Apr 12 16:27:25 2016 +0200
----------------------------------------------------------------------
.../audit/request/eventcreator/HostEventCreator.java | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/e0bc22e1/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/HostEventCreator.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/HostEventCreator.java b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/HostEventCreator.java
index 60fc77c..d05fe9d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/HostEventCreator.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/audit/request/eventcreator/HostEventCreator.java
@@ -57,6 +57,11 @@ public class HostEventCreator implements RequestAuditEventCreator {
private Set<Resource.Type> resourceTypes = ImmutableSet.<Resource.Type>builder().add(Resource.Type.Host).build();
/**
+ * Pattern to retrieve hostname from url
+ */
+ private static final Pattern HOSTNAME_PATTERN = Pattern.compile(".*" + HostResourceProvider.HOST_NAME_PROPERTY_ID + "\\s*=\\s*([^&\\s]+).*");
+
+ /**
* {@inheritDoc}
*/
@Override
@@ -146,13 +151,9 @@ public class HostEventCreator implements RequestAuditEventCreator {
* @return
*/
private String getHostNameFromQuery(Request request) {
- final String key = HostResourceProvider.HOST_NAME_PROPERTY_ID;
- if (request.getURI().contains(key)) {
- Pattern pattern = Pattern.compile(".*" + key + "\\s*=\\s*([^&\\s]+).*");
- Matcher matcher = pattern.matcher(request.getURI());
- if(matcher.find()) {
- return matcher.group(1);
- }
+ Matcher matcher = HOSTNAME_PATTERN.matcher(request.getURI());
+ if(matcher.find()) {
+ return matcher.group(1);
}
return null;
}