Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/master' into bug/1076104
Browse files Browse the repository at this point in the history
  • Loading branch information
metlos committed Apr 22, 2014
2 parents a5e6b36 + 79ef6b8 commit 8eaa888
Show file tree
Hide file tree
Showing 193 changed files with 14,949 additions and 10,156 deletions.
2 changes: 1 addition & 1 deletion .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@
<classpathentry exported="true" kind="var" path="M2_REPO/mc4j/org-mc4j-ems/1.3/org-mc4j-ems-1.3.jar" sourcepath="/M2_REPO/mc4j/org-mc4j-ems/1.3/org-mc4j-ems-1.3-sources.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/opensymphony/quartz/quartz/1.6.5/quartz-1.6.5.jar" sourcepath="/M2_REPO/org/opensymphony/quartz/quartz/1.6.5/quartz-1.6.5-sources.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/javax/mail/mail/1.4.4/mail-1.4.4.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/commons-fileupload/commons-fileupload/1.2/commons-fileupload-1.2.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/commons-fileupload/commons-fileupload/1.3.1/commons-fileupload-1.3.1.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/richfaces/framework/richfaces-api/3.3.3.Final/richfaces-api-3.3.3.Final.jar" sourcepath="/M2_REPO/org/richfaces/framework/richfaces-api/3.1.3.GA/richfaces-api-3.1.3.GA-sources.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/richfaces/framework/richfaces-impl/3.3.3.Final/richfaces-impl-3.3.3.Final.jar" sourcepath="/M2_REPO/org/richfaces/framework/richfaces-impl/3.3.0.GA/richfaces-impl-3.3.0.GA-sources.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/richfaces/ui/richfaces-ui/3.3.3.Final/richfaces-ui-3.3.3.Final.jar" sourcepath="/M2_REPO/org/richfaces/ui/richfaces-ui/3.3.0.GA/richfaces-ui-3.3.0.GA-sources.jar"/>
Expand Down
18 changes: 10 additions & 8 deletions .settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
eclipse.preferences.version=1
encoding//modules/core/dbutils/src/main/java/org/rhq/core/db/DbUtilsI18NResourceKeys.java=UTF-8
encoding//modules/core/util/src/main/java/org/rhq/core/util/UtilI18NResourceKeys.java=UTF-8
encoding//modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/i18n/AgentI18NResourceKeys.java=UTF-8
encoding//modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/i18n/CommI18NResourceKeys.java=UTF-8
encoding//modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/MeasurementI18NResourceKeys.java=ISO-8859-1
encoding//modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/comm/ServerI18NFactory.java=UTF-8
encoding//modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/comm/ServerI18NResourceKeys.java=UTF-8
#Fri Apr 04 11:49:54 EDT 2014
eclipse.preferences.version=1
encoding//modules/core/dbutils/src/main/java/org/rhq/core/db/DbUtilsI18NResourceKeys.java=UTF-8
encoding//modules/core/util/src/main/java/org/rhq/core/util/UtilI18NResourceKeys.java=UTF-8
encoding//modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/i18n/AgentI18NResourceKeys.java=UTF-8
encoding//modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/i18n/CommI18NResourceKeys.java=UTF-8
encoding//modules/enterprise/gui/coregui/src/main/resources/org/rhq/coregui/client/Messages_cs.properties=UTF-8
encoding//modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/measurement/MeasurementI18NResourceKeys.java=ISO-8859-1
encoding//modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/comm/ServerI18NFactory.java=UTF-8
encoding//modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/comm/ServerI18NResourceKeys.java=UTF-8
33 changes: 33 additions & 0 deletions etc/greasemonkey/RHQ_login_monkey-before-4.11.user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// ==UserScript==
// @name RHQ login monkey old
// @namespace org.rhq.coregui
// @description Types in the credentials when pressing ALT+C on the login page. This script works also for Chrome/Chromium with the extension called Tampermonkey. This version works well with the RHQ 4.10 and lower.
// @include *:7080/coregui/*
// @include *:7080/coregui/#LogOut
// @exclude *:7080/coregui/login*
// @grant none
// @author Jiri Kremser <jkremser@redhat.com>
// @version 1.1
// ==/UserScript==

function fillTheCredentials() {
document.getElementsByName("user")[0].value="rhqadmin";
document.getElementsByName("password")[0].value="rhqadmin";
//document.forms[0].submit() doesn't work, SmartGWT uses internal logic
document.getElementsByName("password")[0].focus();
}

// register the function and the hot key
//GM_registerMenuCommand("Fill the credentials", function(e) {
// fillTheCredentials();
//}, "c", "alt", "c" );

// fallback solution, because the function above doesn't work in all browsers
(function(){
document.addEventListener('keydown', function(e) {
// pressed alt+c
if (e.keyCode == 67 && !e.shiftKey && !e.ctrlKey && e.altKey && !e.metaKey) {
fillTheCredentials();
}
}, false);
}());
33 changes: 16 additions & 17 deletions etc/greasemonkey/RHQ_login_monkey.user.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
// ==UserScript==
// @name RHQ login monkey
// @namespace org.rhq.coregui
// @description Types in the credentials when pressing ALT+C on the login page. This script works also for Chrome/Chromium with the extension called Tampermonkey.
// @include *:7080/coregui/*
// @include *:7080/coregui/#LogOut
// @description Types in the credentials when pressing ALT+C on the login page. This script works also for Chrome/Chromium with the extension called Tampermonkey. This script works with the new login screen that was added to RHQ 4.11
// @include *:7080/coregui/login*
// @grant none
// @author Jiri Kremser <jkremser@redhat.com>
// @version 1.1
// @version 1.2
// ==/UserScript==

function fillTheCredentials() {
document.getElementsByName("user")[0].value="rhqadmin";
document.getElementsByName("password")[0].value="rhqadmin";
//document.forms[0].submit() doesn't work, SmartGWT uses internal logic
document.getElementsByName("password")[0].focus();
// new UI
document.getElementById('inputUsername').value="rhqadmin";
document.getElementById('inputPassword').value="rhqadmin";
document.getElementById('loginForm').submit();
}

// register the function and the hot key
GM_registerMenuCommand("Fill the credentials", function(e) {
fillTheCredentials();
}, "c", "alt", "c" );
//GM_registerMenuCommand("Fill the credentials", function(e) {
// fillTheCredentials();
//}, "c", "alt", "c" );

// fallback solution, because the function above doesn't work in all browsers
(function(){
document.addEventListener('keydown', function(e) {
// pressed alt+c
if (e.keyCode == 67 && !e.shiftKey && !e.ctrlKey && e.altKey && !e.metaKey) {
fillTheCredentials();
}
}, false);
document.addEventListener('keydown', function(e) {
// pressed alt+c
if (e.keyCode == 67 && !e.shiftKey && !e.ctrlKey && e.altKey && !e.metaKey) {
fillTheCredentials();
}
}, false);
}());
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class RhqIrcBotListener extends ListenerAdapter<RhqIrcBot> {
private static final Pattern JIRA_PATTERN = Pattern.compile("(?i)(" + JIRA_PROJECT + "\\d{1,5})");
private static final Pattern COMMIT_PATTERN = Pattern.compile("(?i)(\\!commit|cm)[ ]*([0-9a-f]{3,40})");
private static final Pattern ECHO_PATTERN = Pattern.compile("(?i)echo[ ]+(.+)");
private static final String COMMIT_LINK = "https://git.fedorahosted.org/cgit/rhq/rhq.git/commit/?id=%s";
private static final String COMMIT_LINK = "https://github.com/rhq-project/rhq/commit/%s";
private static final String PTO_LINK = "https://mail.corp.redhat.com/home/ccrouch@redhat.com/JBoss%20ON%20OOO?fmt=rss&view=day&start=0day&end=0day";
private static final DateFormat monthFormat = new SimpleDateFormat("MMM");
private static final DateFormat dayInMonthFormat = new SimpleDateFormat("d");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
* Copyright (C) 2005-2008 Red Hat, Inc.
* Copyright (C) 2005-2014 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -159,6 +159,6 @@ public void setTimeout(Integer timeout) {
@Override
public String toString() {
return "CreateResourceRequest[RequestId=" + requestId + ",ParentResourceId=" + parentResourceId
+ ",ResourceType=" + resourceTypeName + ", PluginName=" + pluginName + "Timeout=" + timeout + "]";
+ ",ResourceType=" + resourceTypeName + ",PluginName=" + pluginName + ",Timeout=" + timeout + "]";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public String getComponentClass(ResourceType resourceType) throws ResourceTypeNo
PluginMetadataParser parser = this.parsersByPlugin.get(resourceType.getPlugin());
return (parser != null) ? parser.getComponentClass(resourceType) : null;
}

/**
* Transforms the pluginDescriptor into domain object form and stores into this object's type system.
*
Expand Down Expand Up @@ -549,4 +549,5 @@ public void cleanupDescriptors() {
parser.cleanDescriptor();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -44,13 +45,16 @@
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;

import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.maven.artifact.versioning.ComparableVersion;
import org.xml.sax.SAXException;

import org.rhq.core.clientapi.agent.PluginContainerException;
import org.rhq.core.clientapi.agent.metadata.PluginDependencyGraph;
import org.rhq.core.clientapi.agent.metadata.PluginDependencyGraph.PluginDependency;
import org.rhq.core.clientapi.descriptor.group.expressions.CannedGroupExpressions;
import org.rhq.core.clientapi.descriptor.plugin.ParentResourceType;
import org.rhq.core.clientapi.descriptor.plugin.PlatformDescriptor;
import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor;
Expand All @@ -59,7 +63,6 @@
import org.rhq.core.clientapi.descriptor.plugin.ServiceDescriptor;
import org.rhq.core.domain.plugin.Plugin;
import org.rhq.core.util.exception.WrappedRemotingException;
import org.xml.sax.SAXException;

/**
* Utilities for agent plugin descriptors.
Expand All @@ -72,6 +75,8 @@ public abstract class AgentPluginDescriptorUtil {

private static final String PLUGIN_DESCRIPTOR_PATH = "META-INF/rhq-plugin.xml";
private static final String PLUGIN_SCHEMA_PATH = "rhq-plugin.xsd";
private static final String CANNED_GROUP_EXPRESSION_SCHEMA_PATH="rhq-canned-groups.xsd";
private static final String CANNED_GROUP_EXPRESSION_DESCRIPTOR_PATH="META-INF/rhq-group-expressions.xml";

/**
* Determines which of the two plugins is obsolete - in other words, this determines which
Expand Down Expand Up @@ -283,6 +288,58 @@ private static void addOptionalDependency(String pluginName,
return;
}

/**
* Retrieves file content as string from given jar
* @param pluginJarFileUrl URL to a plugin jar file
* @param additionPath addition file path within JAR (eg. META-INF/mydescriptor.xml)
* @return content of additionPath file as String, or null if file does not exist in JAR
* @throws PluginContainerException if we fail to read content
*/
public static CannedGroupExpressions loadCannedExpressionsFromUrl(URL pluginJarFileUrl) throws PluginContainerException {
final Log logger = LogFactory.getLog(AgentPluginDescriptorUtil.class);

if (pluginJarFileUrl == null) {
throw new PluginContainerException("A valid plugin JAR URL must be supplied.");
}
logger.debug("Loading plugin additions from plugin jar at [" + pluginJarFileUrl + "]...");
ValidationEventCollector validationEventCollector = new ValidationEventCollector();
testPluginJarIsReadable(pluginJarFileUrl);

JarInputStream jis = null;
JarEntry descriptorEntry = null;
try {
jis = new JarInputStream(pluginJarFileUrl.openStream());
JarEntry nextEntry = jis.getNextJarEntry();
while (nextEntry != null && descriptorEntry == null) {
if (CANNED_GROUP_EXPRESSION_DESCRIPTOR_PATH.equals(nextEntry.getName())) {
descriptorEntry = nextEntry;
} else {
jis.closeEntry();
nextEntry = jis.getNextJarEntry();
}
}

if (descriptorEntry == null) {
logger.debug("Plugin additions not found");
// plugin additions are optional thing
return null;
}
return parseCannedGroupExpressionsDescriptor(jis, validationEventCollector);
} catch (Exception e) {
throw new PluginContainerException("Could not parse the plugin additions ["
+ CANNED_GROUP_EXPRESSION_DESCRIPTOR_PATH + "] found in plugin jar at [" + pluginJarFileUrl + "].",
new WrappedRemotingException(e));
} finally {
if (jis != null) {
try {
jis.close();
} catch (Exception e) {
logger.warn("Cannot close jar stream [" + pluginJarFileUrl + "]. Cause: " + e);
}
}
}
}

/**
* Loads a plugin descriptor from the given plugin jar and returns it.
*
Expand Down Expand Up @@ -359,8 +416,32 @@ public static PluginDescriptor parsePluginDescriptor(InputStream is) throws Plug
public static PluginDescriptor parsePluginDescriptor(InputStream is,
ValidationEventCollector validationEventCollector) throws PluginContainerException {
JAXBContext jaxbContext;
return (PluginDescriptor) parsePluginDescriptor(is, validationEventCollector, PLUGIN_SCHEMA_PATH, DescriptorPackages.PC_PLUGIN);
}

/**
* Parses a descriptor from InputStream without a validator.
* @param is input to check
* @return parsed PluginDescriptor
* @throws PluginContainerException if validation fails
*/
public static CannedGroupExpressions parseCannedGroupExpressionsDescriptor(InputStream is,
ValidationEventCollector validationEventCollector) throws PluginContainerException {
JAXBContext jaxbContext;
return (CannedGroupExpressions) parsePluginDescriptor(is, validationEventCollector, CANNED_GROUP_EXPRESSION_SCHEMA_PATH, DescriptorPackages.CANNED_EXPRESSIONS);
}

/**
* Parses a descriptor from InputStream without a validator.
* @param is input to check
* @return parsed PluginDescriptor
* @throws PluginContainerException if validation fails
*/
private static Object parsePluginDescriptor(InputStream is,
ValidationEventCollector validationEventCollector, String xsd, String jaxbPackage) throws PluginContainerException {
JAXBContext jaxbContext;
try {
jaxbContext = JAXBContext.newInstance(DescriptorPackages.PC_PLUGIN);
jaxbContext = JAXBContext.newInstance(jaxbPackage);
} catch (Exception e) {
throw new PluginContainerException("Failed to create JAXB Context.", new WrappedRemotingException(e));
}
Expand All @@ -369,14 +450,13 @@ public static PluginDescriptor parsePluginDescriptor(InputStream is,
try {
unmarshaller = jaxbContext.createUnmarshaller();
// Enable schema validation
URL pluginSchemaURL = AgentPluginDescriptorUtil.class.getClassLoader().getResource(PLUGIN_SCHEMA_PATH);
URL pluginSchemaURL = AgentPluginDescriptorUtil.class.getClassLoader().getResource(xsd);
Schema pluginSchema = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(
pluginSchemaURL);
unmarshaller.setSchema(pluginSchema);
unmarshaller.setEventHandler(validationEventCollector);

PluginDescriptor pluginDescriptor = (PluginDescriptor) unmarshaller.unmarshal(is);
return pluginDescriptor;
return unmarshaller.unmarshal(is);
} catch (JAXBException e) {
throw new PluginContainerException(e);
} catch (SAXException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@
public interface DescriptorPackages {
String CONFIGURATION = "org.rhq.core.clientapi.descriptor.configuration";
String PC_PLUGIN = "org.rhq.core.clientapi.descriptor.plugin";
String CANNED_EXPRESSIONS = "org.rhq.core.clientapi.descriptor.group.expressions";
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,19 @@
public class AgentRegistrationRequest implements Serializable {
private static final long serialVersionUID = 1L;

// This is the name of the system property that should be passed into an agent to identify its installation.
// Note that it purposefully does not start with "rhq.agent" or "rhq.communications" so it isn't persisted in agent config prefs.
public static final String SYSPROP_INSTALL_ID = "rhq.install.id";

private final String name;
private final String address;
private final int port;
private final String remoteEndpoint;
private final boolean regenerateTokenFlag;
private final String originalToken;
private final AgentVersion agentVersion;
private final String installId;
private final String installLocation;

/**
* Creates a new {@link AgentRegistrationRequest} object. Note that <code>address</code> and <code>port</code> must
Expand All @@ -58,16 +64,21 @@ public class AgentRegistrationRequest implements Serializable {
* and the agent already exists, its current token is returned.
* @param originalToken the agent's original token, if this is a re-registration (may be <code>null</code>)
* @param agentVersion the agent's version information
* @param installId if the agent was started with an install id, its value is passed here; otherwise, null
* @param installLocation location where the agent is installed - could be null if its not known or not applicable
*/
public AgentRegistrationRequest(String name, String address, int port, String remoteEndpoint,
boolean regenerateTokenFlag, String originalToken, AgentVersion agentVersion) {
boolean regenerateTokenFlag, String originalToken, AgentVersion agentVersion, String installId,
String installLocation) {
this.name = name;
this.address = address;
this.port = port;
this.remoteEndpoint = remoteEndpoint;
this.regenerateTokenFlag = regenerateTokenFlag;
this.originalToken = originalToken;
this.agentVersion = agentVersion;
this.installId = installId;
this.installLocation = installLocation;
}

/**
Expand Down Expand Up @@ -133,13 +144,32 @@ public boolean getRegenerateToken() {

/**
* Returns the information that identifies the version of the agent asking to be registered.
*
*
* @return agent version information
*/
public AgentVersion getAgentVersion() {
return agentVersion;
}

/**
* If the agent was given an install ID at startup, this is that ID. Otherwise, this will be null;
*
* @return agent installation ID
*/
public String getInstallId() {
return installId;
}

/**
* Returns the location of the agent install. If the agent doesn't know it or its not applicable for the agent,
* this can be null.
*
* @return location of the agent installation if known
*/
public String getInstallLocation() {
return installLocation;
}

/**
* @see java.lang.Object#toString()
*/
Expand All @@ -153,6 +183,8 @@ public String toString() {
str.append("]; regenerate-token=[" + this.regenerateTokenFlag);
str.append("]; original-token=[<was " + ((this.originalToken == null) ? "" : "not ") + "null>");
str.append("]; agent-version=[" + this.agentVersion);
str.append("]; install-id=[" + this.installId);
str.append("]; install-location=[" + this.installLocation);
str.append("]");
return str.toString();
}
Expand Down

0 comments on commit 8eaa888

Please sign in to comment.