From: <ma...@rh...> - 2009-07-03 02:48:04
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><style type="text/css"><!-- #msg DL { border : 1px #006 solid; background-color : #369; padding : 6px; color : #fff; } #msg DT { float : left; width : 6em; font-weight : bold; } #msg DL, #msg DT, #msg UL, #msg LI { font-family : arial,helvetica,sans-serif; font-size : 10pt; } h3 { font-family : arial,helvetica,sans-serif; font-size : 10pt; font-weight : bold; } #msg PRE { overflow : auto; white-space : normal; background-color : #ffc; border : 1px #fc0 solid; padding : 6px; } #msg UL, PRE, .diff { overflow : auto; } #patch h4 { font-family : arial,helvetica,sans-serif; font-size : 10pt; } #patch h4 { padding: 8px; background : #369; color : #fff; margin : 0; } #patch .propset h4, #patch .binary h4 {margin: 0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {background:#eeeeee;padding: 0 0 10px 0;} #patch .propset .diff, #patch .binary .diff {padding: 10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch .add {background:#ddffdd;} #patch .rem {background:#ffdddd;} #patch .lines, .info {color:#888888;background:#ffffff;} .diff { width : 100%; } #msg DL { border : 1px #006 solid; background-color : #369; padding : 6px; color : #fff; } #msg DT { float : left; width : 6em; font-weight : bold; } #msg DL, #msg DT, #msg UL, #msg LI { font-family : arial,helvetica,sans-serif; font-size : 10pt; } h3 { font-family : arial,helvetica,sans-serif; font-size : 10pt; font-weight : bold; } #msg PRE { overflow : auto; white-space : normal; background-color : #ffc; border : 1px #fc0 solid; padding : 6px; } #msg UL, PRE, .diff { overflow : auto; } #patch h4 { font-family : arial,helvetica,sans-serif; font-size : 10pt; } #patch h4 { padding: 8px; background : #369; color : #fff; margin : 0; } #patch .propset h4, #patch .binary h4 {margin: 0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {background:#eeeeee;padding: 0 0 10px 0;} #patch .propset .diff, #patch .binary .diff {padding: 10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch .add {background:#ddffdd;} #patch .rem {background:#ffdddd;} #patch .lines, .info {color:#888888;background:#ffffff;} .diff { width : 100%; } --></style> <title>[rhq-project.org rhq] [4250] svn merger from trunk svn rev 4249</title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>4250</dd> <dt>Author</dt> <dd>mazz</dd> <dt>Date</dt> <dd>2009-07-02 20:47:54 -0500 (Thu, 02 Jul 2009)</dd> </dl> <h3>Log Message</h3> <pre>svn merger from trunk svn rev 4249</pre> <h3>Modified Paths</h3> <ul> <li><a href="#rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulescoredomainsrcmainjavaorgrhqcoredomainutilQueryGeneratorjava">rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/core/domain/src/main/java/org/rhq/core/domain/util/QueryGenerator.java</a></li> <li><a href="#rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulesenterpriseclientsrcmainjavaorgrhqenterpriseclientClientMainjava">rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/ClientMain.java</a></li> <li><a href="#rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulesenterpriseclientsrcmainjavaorgrhqenterpriseclientcommandsClientCommandjava">rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/commands/ClientCommand.java</a></li> <li><a href="#rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulesenterpriseclientsrcmainjavaorgrhqenterpriseclientcommandsScriptCommandjava">rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/commands/ScriptCommand.java</a></li> <li><a href="#rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulesenterpriseguiportalwarsrcmainjavaorgrhqenterpriseguiadminuserAddUserRolesActionjava">rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/user/AddUserRolesAction.java</a></li> <li><a href="#rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulesenterpriseguiportalwarsrcmainjavaorgrhqenterpriseguiadminuserAddUserRolesFormPrepareActionjava">rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/user/AddUserRolesFormPrepareAction.java</a></li> <li><a href="#rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulesenterpriseguiportalwarsrcmainjavaorgrhqenterpriseguiadminuserEditPasswordActionjava">rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/user/EditPasswordAction.java</a></li> <li><a href="#rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulesenterpriseguiportalwarsrcmainjavaorgrhqenterpriseguiadminuserUserAdminPortalActionjava">rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/user/UserAdminPortalAction.java</a></li> <li><a href="#rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulesenterpriseguiportalwarsrcmainjavaorgrhqenterpriseguiadminuserViewRolesActionjava">rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/admin/user/ViewRolesAction.java</a></li> <li><a href="#rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulesenterpriseserverjarsrcmainjavaorgrhqenterpriseserverauthSessionManagerjava">rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SessionManager.java</a></li> <li><a href="#rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulesenterpriseserverjarsrcmainjavaorgrhqenterpriseserverauthSubjectManagerBeanjava">rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerBean.java</a></li> <li><a href="#rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulesenterpriseserverjarsrcmainjavaorgrhqenterpriseserverauthSubjectManagerLocaljava">rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerLocal.java</a></li> <li><a href="#rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulesenterpriseserverjarsrcmainjavaorgrhqenterpriseserverauthSubjectManagerRemotejava">rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/auth/SubjectManagerRemote.java</a></li> <li><a href="#rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulesenterpriseserverjarsrcmainjavaorgrhqenterpriseserverauthzRoleManagerBeanjava">rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/RoleManagerBean.java</a></li> <li><a href="#rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulesenterpriseserverjarsrcmainjavaorgrhqenterpriseserverconfigurationjobAbstractAggregateConfigurationUpdateJobjava">rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/job/AbstractAggregateConfigurationUpdateJob.java</a></li> <li><a href="#rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulesenterpriseserverjarsrcmainjavaorgrhqenterpriseserverdiscoveryDiscoveryBossBeanjava">rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryBossBean.java</a></li> <li><a href="#rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulesenterpriseserverjarsrcmainjavaorgrhqenterpriseserveroperationOperationManagerBeanjava">rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java</a></li> <li><a href="#rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulesenterpriseserverjarsrctestjavaorgrhqenterpriseserverauthtestSubjectManagerBeanTestjava">rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/auth/test/SubjectManagerBeanTest.java</a></li> <li><a href="#rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulesenterpriseserverjarsrctestjavaorgrhqenterpriseservertestTestRemoteInterfacejava">rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/TestRemoteInterface.java</a></li> </ul> <h3>Removed Paths</h3> <ul> <li><a href="#rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulesenterpriseclientsrcmainjavaorgrhqenterpriseclientcommandsCreateUserCommandjava">rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/commands/CreateUserCommand.java</a></li> <li><a href="#rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulesenterpriseclientsrcmainjavaorgrhqenterpriseclientcommandsDeleteUserCommandjava">rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/commands/DeleteUserCommand.java</a></li> <li><a href="#rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulesenterpriseclientsrcmainjavaorgrhqenterpriseclientcommandsFindGroupsCommandjava">rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/commands/FindGroupsCommand.java</a></li> <li><a href="#rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulesenterpriseclientsrcmainjavaorgrhqenterpriseclientcommandsFindResourcesCommandjava">rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/commands/FindResourcesCommand.java</a></li> <li><a href="#rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulesenterpriseclientsrcmainjavaorgrhqenterpriseclientcommandsFindUserAccountsCommandjava">rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/commands/FindUserAccountsCommand.java</a></li> <li><a href="#rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulesenterpriseclientsrcmainjavaorgrhqenterpriseclientcommandsStartJBossAsCommandjava">rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/commands/StartJBossAsCommand.java</a></li> <li><a href="#rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulesenterpriseclientsrcmainjavaorgrhqenterpriseclientcommandsStopJBossAsCommandjava">rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/commands/StopJBossAsCommand.java</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulescoredomainsrcmainjavaorgrhqcoredomainutilQueryGeneratorjava"></a> <div class="modfile"><h4>Modified: rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/core/domain/src/main/java/org/rhq/core/domain/util/QueryGenerator.java (4249 => 4250)</h4> <pre class="diff"> <span class="info">--- rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/core/domain/src/main/java/org/rhq/core/domain/util/QueryGenerator.java 2009-07-02 22:36:24 UTC (rev 4249) +++ rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/core/domain/src/main/java/org/rhq/core/domain/util/QueryGenerator.java 2009-07-03 01:47:54 UTC (rev 4250) </span><span class="lines">@@ -1,6 +1,7 @@ </span><span class="cx"> package org.rhq.core.domain.util; import java.lang.reflect.Field; </span><span class="add">+import java.lang.reflect.InvocationTargetException; </span><span class="cx"> import java.lang.reflect.Method; import java.util.Arrays; import java.util.HashMap; </span><span class="lines">@@ -63,13 +64,19 @@ </span><span class="cx"> this.alias = aliasBuilder.toString(); } </span><span class="rem">- public String getQueryString() throws Exception { </span><span class="add">+ // for testing purposes only, should use getQuery(EntityManager) or getCountQuery(EntityManager) instead + public String getQueryString(boolean countQuery) { </span><span class="cx"> StringBuilder results = new StringBuilder(); </span><span class="rem">- results.append("SELECT ").append(alias).append(NL); </span><span class="add">+ results.append("SELECT "); + if (countQuery) { + results.append(" COUNT(").append(alias).append(")").append(NL); + } else { + results.append(alias).append(NL); + } </span><span class="cx"> results.append("FROM ").append(className).append(' ').append(alias).append(NL); for (String fetchJoin : relationsToFetch) { if (!isEntityCollectionPersistence(fetchJoin)) { </span><span class="rem">- throw new Exception("Can not fetchJoin '" + fetchJoin + "'."); </span><span class="add">+ throw new IllegalArgumentException("Can not fetchJoin '" + fetchJoin + "'."); </span><span class="cx"> } results.append("LEFT JOIN FETCH ").append(alias).append('.').append(fetchJoin).append(NL); </span><span class="lines">@@ -92,43 +99,52 @@ </span><span class="cx"> results.append(alias).append('.').append(critField.getKey() + " = :" + critField.getKey() + " "); } </span><span class="rem">- boolean first = true; - for (OrderingField orderingField : pageControl.getOrderingFields()) { - //verify persistency - if (!isEntityFieldPersistence(orderingField.getField())) { - throw new Exception("Can not order by '" + orderingField.getField() + "'."); - } </span><span class="add">+ if (countQuery == false) { + boolean first = true; + for (OrderingField orderingField : pageControl.getOrderingFields()) { + //verify persistency + if (!isEntityFieldPersistence(orderingField.getField())) { + throw new IllegalArgumentException("Can not order by '" + orderingField.getField() + "'."); + } </span><span class="cx"> </span><span class="rem">- if (first) { - results.append(NL).append("ORDER BY "); - first = false; - } else { - results.append(", "); </span><span class="add">+ if (first) { + results.append(NL).append("ORDER BY "); + first = false; + } else { + results.append(", "); + } + results.append(alias).append('.').append(orderingField.getField()); + results.append(' ').append(orderingField.getOrdering()); </span><span class="cx"> } </span><span class="rem">- results.append(alias).append('.').append(orderingField.getField()); - results.append(' ').append(orderingField.getOrdering()); </span><span class="cx"> } return results.append(NL).toString(); } </span><span class="rem">- public Query getQuery(EntityManager em) throws Exception { - Query q = em.createQuery(getQueryString()); </span><span class="add">+ public Query getQuery(EntityManager em) { + String queryString = getQueryString(false); + Query query = em.createQuery(queryString); + setCriteriaValues(query, false); + PersistenceUtility.setDataPage(query, pageControl); + return query; + } </span><span class="cx"> </span><span class="rem">- return getQuery(q); </span><span class="add">+ public Query getCountQuery(EntityManager em) { + String countQueryString = getQueryString(true); + Query query = em.createQuery(countQueryString); + setCriteriaValues(query, false); + return query; </span><span class="cx"> } </span><span class="rem">- public Query getQuery(Query q) throws Exception { </span><span class="add">+ private void setCriteriaValues(Query query, boolean countQuery) { </span><span class="cx"> for (Map.Entry<String, Object> critField : getEntityPersistenceFields(criteriaObject).entrySet()) { </span><span class="rem">- q.setParameter(critField.getKey(), critField.getValue()); </span><span class="add">+ query.setParameter(critField.getKey(), critField.getValue()); </span><span class="cx"> } </span><span class="rem">- - PersistenceUtility.setDataPage(q, pageControl); - return q; </span><span class="cx"> } //helper </span><span class="rem">- private boolean isEntityCollectionPersistence(String fieldName) throws NoSuchMethodException, NoSuchFieldException { </span><span class="add">+ private boolean isEntityCollectionPersistence(String fieldName) { + </span><span class="cx"> if (entityAnnotationMethod == EntityAnnotationsMethod.FIELD) { Field field = getFieldOfCriteriaClass(fieldName); return ((field.isAnnotationPresent(ManyToMany.class)) || (field.isAnnotationPresent(OneToMany.class))); </span><span class="lines">@@ -140,7 +156,7 @@ </span><span class="cx"> return false; } </span><span class="rem">- private boolean isEntityFieldPersistence(String fieldName) throws NoSuchFieldException { </span><span class="add">+ private boolean isEntityFieldPersistence(String fieldName) { </span><span class="cx"> Field field = getFieldOfCriteriaClass(fieldName); return isEntityFieldPersistence(field); </span><span class="lines">@@ -160,9 +176,9 @@ </span><span class="cx"> return clazz.isAnnotationPresent(Entity.class); } </span><span class="rem">- private Map<String, Object> getEntityPersistenceFields(Object entityClass) throws Exception { </span><span class="add">+ private Map<String, Object> getEntityPersistenceFields(Object entityClass) { </span><span class="cx"> if (!isEntity(entityClass.getClass())) { </span><span class="rem">- throw new Exception("The specified class is not an EJB3 persistence entity"); </span><span class="add">+ throw new IllegalArgumentException("The specified class is not an EJB3 persistence entity"); </span><span class="cx"> } Map<String, Object> entityPersistenceProperties = new HashMap<String, Object>(); </span><span class="lines">@@ -173,7 +189,12 @@ </span><span class="cx"> //get its value currField.setAccessible(true); </span><span class="rem">- Object fieldValue = currField.get(entityClass); </span><span class="add">+ Object fieldValue = null; + try { + fieldValue = currField.get(entityClass); + } catch (IllegalAccessException iae) { + throw new RuntimeException(iae); + } </span><span class="cx"> if ((fieldValue != null) && isEntityFieldPersistence(currField)) { //if field is @id, make sure it's not 0 as most of the entities ID is a primitive int if (currField.isAnnotationPresent(Id.class)) { </span><span class="lines">@@ -201,7 +222,14 @@ </span><span class="cx"> if (isEntityMethodPersistence(currMethod)) { //get its value </span><span class="rem">- Object methodValue = currMethod.invoke(entityClass); </span><span class="add">+ Object methodValue = null; + try { + methodValue = currMethod.invoke(entityClass); + } catch (IllegalAccessException iae) { + throw new RuntimeException(iae); + } catch (InvocationTargetException ite) { + throw new RuntimeException(ite); + } </span><span class="cx"> if ((methodValue != null) && isEntityMethodPersistence(currMethod)) { //if field is @id, make sure it's not 0 as most of the entities ID is a primitive int if (currMethod.isAnnotationPresent(Id.class)) { </span><span class="lines">@@ -238,25 +266,25 @@ </span><span class="cx"> return "get" + property.substring(0, 1).toUpperCase() + property.substring(1, property.length()); } </span><span class="rem">- private Method getMethodOfCriteriaClass(String methodName) throws NoSuchMethodException { </span><span class="add">+ private Method getMethodOfCriteriaClass(String methodName) { </span><span class="cx"> try { Method method = criteriaObject.getClass().getDeclaredMethod(methodName); return method; </span><span class="rem">- } catch (NoSuchMethodException e) { - throw e; </span><span class="add">+ } catch (NoSuchMethodException nsme) { + throw new RuntimeException(nsme); </span><span class="cx"> } } </span><span class="rem">- private Field getFieldOfCriteriaClass(String fieldName) throws NoSuchFieldException { </span><span class="add">+ private Field getFieldOfCriteriaClass(String fieldName) { </span><span class="cx"> try { Field field = criteriaObject.getClass().getDeclaredField(fieldName); return field; </span><span class="rem">- } catch (NoSuchFieldException e) { - throw e; </span><span class="add">+ } catch (NoSuchFieldException nsfe) { + throw new RuntimeException(nsfe); </span><span class="cx"> } } </span><span class="rem">- public static void main(String[] args) throws Exception { </span><span class="add">+ public static void main(String[] args) { </span><span class="cx"> PageControl pc = PageControl.getUnlimitedInstance(); pc.addDefaultOrderingField("firstName", PageOrdering.ASC); pc.addDefaultOrderingField("lastName", PageOrdering.DESC); </span><span class="lines">@@ -270,6 +298,6 @@ </span><span class="cx"> QueryGenerator a = new QueryGenerator(s, rtf, pc); </span><span class="rem">- System.out.println(a.getQueryString()); </span><span class="add">+ System.out.println(a.getQueryString(false)); </span><span class="cx"> } } \ No newline at end of file </span></pre></div> <a id="rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulesenterpriseclientsrcmainjavaorgrhqenterpriseclientClientMainjava"></a> <div class="modfile"><h4>Modified: rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/ClientMain.java (4249 => 4250)</h4> <pre class="diff"> <span class="info">--- rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/ClientMain.java 2009-07-02 22:36:24 UTC (rev 4249) +++ rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/ClientMain.java 2009-07-03 01:47:54 UTC (rev 4250) </span><span class="lines">@@ -240,7 +240,9 @@ </span><span class="cx"> return; } </span><span class="rem">- private boolean executePromptCommand(String[] args) throws Exception { </span><span class="add">+ // private boolean executePromptCommand(String[] args) throws Exception { + // public boolean executePromptCommand(String[] args, PrintWriter pw) throws Exception { + public boolean executePromptCommand(String[] args) throws Exception { </span><span class="cx"> String cmd = args[0]; if (commands.containsKey(cmd)) { ClientCommand command = commands.get(cmd); </span><span class="lines">@@ -284,7 +286,8 @@ </span><span class="cx"> * the command line * @return the array of command line arguments */ </span><span class="rem">- private String[] parseCommandLine(String cmdLine) { </span><span class="add">+ public String[] parseCommandLine(String cmdLine) { + // private String[] parseCommandLine(String cmdLine) { </span><span class="cx"> ByteArrayInputStream in = new ByteArrayInputStream(cmdLine.getBytes()); StreamTokenizer strtok = new StreamTokenizer(new InputStreamReader(in)); List<String> args = new ArrayList<String>(); </span><span class="lines">@@ -403,9 +406,9 @@ </span><span class="cx"> this.remoteClient = remoteClient; setHttps(false); </span><span class="rem">- remoteClient.reinitialize(); </span><span class="add">+ </span><span class="cx"> if (remoteClient != null) { </span><span class="rem">- </span><span class="add">+ remoteClient.reinitialize(); </span><span class="cx"> // change the set of completers for a logged in session, now make available direct // invocation of the remote API. consoleReader.addCompletor(new ArgumentCompletor(new Completor[] { </span><span class="lines">@@ -462,6 +465,10 @@ </span><span class="cx"> return outputWriter; } </span><span class="add">+ public void setPrintWriter(PrintWriter writer) { + this.outputWriter = writer; + } + </span><span class="cx"> public int getConsoleWidth() { return this.consoleReader.getTermwidth(); } </span></pre></div> <a id="rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulesenterpriseclientsrcmainjavaorgrhqenterpriseclientcommandsClientCommandjava"></a> <div class="modfile"><h4>Modified: rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/commands/ClientCommand.java (4249 => 4250)</h4> <pre class="diff"> <span class="info">--- rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/commands/ClientCommand.java 2009-07-02 22:36:24 UTC (rev 4249) +++ rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/commands/ClientCommand.java 2009-07-03 01:47:54 UTC (rev 4250) </span><span class="lines">@@ -27,12 +27,8 @@ </span><span class="cx"> public interface ClientCommand { @SuppressWarnings("unchecked") </span><span class="rem">- public static Class<ClientCommand>[] COMMANDS = new Class[] { - FindResourcesCommand.class, - // FindGroupsCommand.class, - HelpCommand.class, LoginCommand.class, LogoutCommand.class, CreateUserCommand.class, - FindUserAccountsCommand.class, DeleteUserCommand.class, StartJBossAsCommand.class, StopJBossAsCommand.class, - QuitCommand.class, ScriptCommand.class }; </span><span class="add">+ public static Class<ClientCommand>[] COMMANDS = new Class[] { HelpCommand.class, LoginCommand.class, + LogoutCommand.class, QuitCommand.class, ScriptCommand.class }; </span><span class="cx"> /** * All implementations must indicate what the prompt command is that will trigger its execution. This method returns </span></pre></div> <a id="rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulesenterpriseclientsrcmainjavaorgrhqenterpriseclientcommandsCreateUserCommandjava"></a> <div class="delfile"><h4>Deleted: rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/commands/CreateUserCommand.java (4249 => 4250)</h4> <pre class="diff"> <span class="info">--- rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/commands/CreateUserCommand.java 2009-07-02 22:36:24 UTC (rev 4249) +++ rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/commands/CreateUserCommand.java 2009-07-03 01:47:54 UTC (rev 4250) </span><span class="lines">@@ -1,76 +0,0 @@ </span><span class="rem">-package org.rhq.enterprise.client.commands; - -import org.rhq.core.domain.auth.Subject; -import org.rhq.enterprise.client.ClientMain; -import org.rhq.enterprise.client.RemoteClient; -import org.rhq.enterprise.server.auth.SubjectManagerRemote; - -public class CreateUserCommand implements ClientCommand { - - public boolean execute(ClientMain client, String[] args) { - try { - // check to see if user logged in - if (client.getSubject() == null) { - client.getPrintWriter().println("Unable to create accounts until successfully logged in"); - return true; - } - - // Retrieve the parameters passed in - // String example="Ex. createAccount user1 pass1 TestFName TestLName active te...@no..."; - // String syntax = "createAccount (*)user (*)pass (*)[FirstName] (*)[LastName] (*)active|inactive"; - // syntax+=" [emailAddress]"; - String user = args[1] + ""; - String pass = args[2] + ""; - String fName = args[3] + ""; - String lName = args[4] + ""; - String active = args[5] + ""; - String email = args[6] + ""; - - // retrieve RHQRegistry object - RemoteClient registry = client.getRemoteClient(); - Subject loggedInUser = client.getSubject(); - // Now make the connection successfully and store values - // instantiate SLSB - SubjectManagerRemote subjectManager = registry.getSubjectManagerRemote(); - // DURING POPULATION we should catch some type errors or insert more rigorous checking here - // Populate Subject then Create account - Subject account = new Subject(); - account.setName(user); - account.setFirstName(fName); - account.setLastName(lName); - account.setFactive(active.equalsIgnoreCase("active")); - account.setEmailAddress(email); - subjectManager.createSubject(loggedInUser, account); - // TODO: something weird here ... :-/ - // //Now update the account with the password. - // subjectManager.changePassword(loggedInUser, user, pass); - - client.getPrintWriter().println("Account creation successful"); - } catch (Exception e) { - client.getPrintWriter().println("Account creation failed: " + e.getMessage()); - } - - return true; - } - - public String getDetailedHelp() { - return ""; - } - - public String getHelp() { - return "Creates a new account with supplied account details"; - } - - public String getPromptCommandString() { - return "createAccount"; - } - - public String getSyntax() { - String example = "Ex. createAccount user1 pass1 TestFName TestLName active te...@no..."; - String syntax = "createAccount (*)user (*)pass (*)[FirstName] (*)[LastName] (*)active|inactive"; - syntax += " [emailAddress]"; - - return example + "\n" + syntax; - } - -} </span></pre></div> <a id="rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulesenterpriseclientsrcmainjavaorgrhqenterpriseclientcommandsDeleteUserCommandjava"></a> <div class="delfile"><h4>Deleted: rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/commands/DeleteUserCommand.java (4249 => 4250)</h4> <pre class="diff"> <span class="info">--- rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/commands/DeleteUserCommand.java 2009-07-02 22:36:24 UTC (rev 4249) +++ rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/commands/DeleteUserCommand.java 2009-07-03 01:47:54 UTC (rev 4250) </span><span class="lines">@@ -1,67 +0,0 @@ </span><span class="rem">-package org.rhq.enterprise.client.commands; - -import java.util.ArrayList; -import java.util.List; - -import org.rhq.core.domain.auth.Subject; -import org.rhq.enterprise.client.ClientMain; -import org.rhq.enterprise.client.RemoteClient; -import org.rhq.enterprise.server.auth.SubjectManagerRemote; - -public class DeleteUserCommand implements ClientCommand { - - public boolean execute(ClientMain client, String[] args) { - try { - // check to see if user logged in - if (client.getSubject() == null) { - client.getPrintWriter().println("Unable to delete accounts until successfully logged in"); - return true; - } - - // Retrieve the parameters passed in - // String example="Ex. deleteAccount 09875"; - // String syntax = "deleteAccount (*)user"; - String userIdValue = args[1] + ""; - // do type checking - int userId = Integer.valueOf(userIdValue); - - // retrieve RHQRegistry object - RemoteClient registry = client.getRemoteClient(); - Subject loggedInUser = client.getSubject(); - // Now make the connection successfully and store values - // instantiate SLSB - SubjectManagerRemote subjectManager = registry.getSubjectManagerRemote(); - List<Integer> userToDelete = new ArrayList<Integer>(); - userToDelete.add(userId); - Integer[] usersToDelete = new Integer[userId]; - // subjectManager.deleteUsers(loggedInUser, userToDelete); - subjectManager.deleteSubjects(loggedInUser, usersToDelete); - - client.getPrintWriter().println("Account deletion successful"); - } catch (Exception e) { - client.getPrintWriter().println("Account deletion failed: " + e.getMessage()); - } - - return true; - } - - public String getDetailedHelp() { - return ""; - } - - public String getHelp() { - return "Deletes existing account provided logged in user has perissions"; - } - - public String getPromptCommandString() { - return "deleteAccount"; - } - - public String getSyntax() { - String example = "Ex. deleteAccount 198564"; - String syntax = "deleteAccount (*)user.id"; - - return example + "\n" + syntax; - } - -} </span></pre></div> <a id="rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulesenterpriseclientsrcmainjavaorgrhqenterpriseclientcommandsFindGroupsCommandjava"></a> <div class="delfile"><h4>Deleted: rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/commands/FindGroupsCommand.java (4249 => 4250)</h4> <pre class="diff"> <span class="info">--- rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/commands/FindGroupsCommand.java 2009-07-02 22:36:24 UTC (rev 4249) +++ rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/commands/FindGroupsCommand.java 2009-07-03 01:47:54 UTC (rev 4250) </span><span class="lines">@@ -1,77 +0,0 @@ </span><span class="rem">-///* -// * RHQ Management Platform -// * Copyright (C) 2005-2008 Red Hat, Inc. -// * All rights reserved. -// * -// * This program is free software; you can redistribute it and/or modify -// * it under the terms of the GNU General Public License as published by -// * the Free Software Foundation version 2 of the License. -// * -// * This program is distributed in the hope that it will be useful, -// * but WITHOUT ANY WARRANTY; without even the implied warranty of -// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// * GNU General Public License for more details. -// * -// * You should have received a copy of the GNU General Public License -// * along with this program; if not, write to the Free Software -// * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -// */ -//package org.rhq.enterprise.client.commands; -// -//import org.rhq.enterprise.client.ClientMain; -//import org.rhq.enterprise.client.TabularWriter; -//import org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal; -//import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite; -//import org.rhq.core.domain.resource.group.GroupCategory; -//import org.rhq.core.domain.util.PageList; -//import org.rhq.core.domain.util.PageControl; -// -///** -// * @author Greg Hinkle -// */ -//public class FindGroupsCommand implements ClientCommand { -// -// public String getPromptCommandString() { -// return "findGroups"; -// } -// -// public boolean execute(ClientMain client, String[] args) { -// -// String search = args[1]; -// -// ResourceGroupManagerLocal gm = client.getRemoteClient().getResourceGroupManager(); -// -// PageList<ResourceGroupComposite> list = -// gm.getAllResourceGroups(client.getSubject(), GroupCategory.COMPATIBLE, null, null, search, PageControl.getUnlimitedInstance()); -// -// -// String[][] data = new String[list.size()][4]; -// int i = 0; -// for (ResourceGroupComposite group : list) { -// data[i++] = new String[] { -// String.valueOf(group.getResourceGroup().getId()), -// group.getResourceGroup().getName(), -// group.getResourceGroup().getResourceType().getPlugin() + ":" + group.getResourceGroup().getResourceType().getName(), -// String.valueOf(group.getMemberCount()), -// "[" + (group.getAvailability() * 100.0) + "%]" }; -// } -// TabularWriter tw = new TabularWriter(client.getPrintWriter(),"Id", "Name", "Type", "Members", "Availability"); -// tw.setWidth(client.getConsoleWidth()); -// tw.print( data); -// -// return true; -// } -// -// -// public String getSyntax() { -// return "findGroups searchString"; -// } -// -// public String getHelp() { -// return "Search for groups in inventory by string"; -// } -// -// public String getDetailedHelp() { -// return null; -// } -//} </span><span class="cx">\ No newline at end of file </span></pre></div> <a id="rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulesenterpriseclientsrcmainjavaorgrhqenterpriseclientcommandsFindResourcesCommandjava"></a> <div class="delfile"><h4>Deleted: rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/commands/FindResourcesCommand.java (4249 => 4250)</h4> <pre class="diff"> <span class="info">--- rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/commands/FindResourcesCommand.java 2009-07-02 22:36:24 UTC (rev 4249) +++ rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/commands/FindResourcesCommand.java 2009-07-03 01:47:54 UTC (rev 4250) </span><span class="lines">@@ -1,113 +0,0 @@ </span><span class="rem">-/* - * RHQ Management Platform - * Copyright (C) 2005-2008 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.client.commands; - -import java.util.List; - -import org.rhq.core.domain.resource.ResourceCategory; -import org.rhq.core.domain.resource.composite.ResourceComposite; -import org.rhq.core.domain.util.PageControl; -import org.rhq.enterprise.client.ClientMain; -import org.rhq.enterprise.client.TabularWriter; -import org.rhq.enterprise.server.resource.ResourceManagerRemote; - -/** - * @author Greg Hinkle - * @author Simeon Pinder - */ -public class FindResourcesCommand implements ClientCommand { - - public String getPromptCommandString() { - return "findResources"; - } - - public boolean execute(ClientMain client, String[] args) { - - String search = args[1]; - PageControl pc = new PageControl(); - pc.setPageSize(-1); - ResourceCategory rc = null; - String empty = null; - ResourceManagerRemote res = client.getRemoteClient().getResourceManagerRemote(); - List<ResourceComposite> list = res.findResourceComposites(client.getSubject(), rc, empty, 0, search, pc); - - String[][] data = new String[list.size()][4]; - int i = 0; - boolean missingData = false; - for (ResourceComposite resource : list) { - // initialize the sensible defaults? - String rId = "(unavailable)"; - String rName = "(unavailable)"; - String rTypePlugin = "(unavailable)"; - String rTypeName = "(unavailable)"; - String rAvailability = "(unavailable)"; - if ((resource != null) && resource.getResource() != null) { - rId = String.valueOf(resource.getResource().getId()); - rName = resource.getResource().getName(); - if (resource.getResource().getResourceType() != null) { - rTypePlugin = resource.getResource().getResourceType().getPlugin(); - rTypeName = resource.getResource().getResourceType().getName(); - } else { - missingData = true; - } - if (resource.getAvailability() != null) { - rAvailability = resource.getAvailability().name(); - } else { - missingData = true; - } - } - - // trim name data down so more data visible - int fieldLength = 25; - if (rName.length() > fieldLength) { - rName = rName.substring(0, fieldLength - 1); - } - // data[i++] = new String[] { - // String.valueOf(resource.getResource().getId()), - // resource.getResource().getName(), - // resource.getResource().getResourceType().getPlugin() + ":" - // + resource.getResource().getResourceType().getName(), - // "[" + resource.getAvailability().name() + "]" }; - data[i++] = new String[] { rId, rName, rTypePlugin + ":" + rTypeName, "[" + rAvailability + "]" }; - // "[" + resource.getAvailability().getName() + "]" }; - } - // Generate data in table format - TabularWriter tw = new TabularWriter(client.getPrintWriter(), "Id", "Name", "Type", "Availability"); - tw.setWidth(client.getConsoleWidth()); - tw.print(data); - if (missingData) { - client - .addMenuNote("Data for some of the objects was unavailable. Contact the System Administrator if that a problem."); - } - - return true; - } - - public String getSyntax() { - return "findResources searchString"; - } - - public String getHelp() { - return "Search for resources in inventory by string"; - } - - public String getDetailedHelp() { - return null; - } -} </span></pre></div> <a id="rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulesenterpriseclientsrcmainjavaorgrhqenterpriseclientcommandsFindUserAccountsCommandjava"></a> <div class="delfile"><h4>Deleted: rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/commands/FindUserAccountsCommand.java (4249 => 4250)</h4> <pre class="diff"> <span class="info">--- rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/commands/FindUserAccountsCommand.java 2009-07-02 22:36:24 UTC (rev 4249) +++ rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/commands/FindUserAccountsCommand.java 2009-07-03 01:47:54 UTC (rev 4250) </span><span class="lines">@@ -1,63 +0,0 @@ </span><span class="rem">-package org.rhq.enterprise.client.commands; - -import org.rhq.core.domain.auth.Subject; -import org.rhq.enterprise.client.ClientMain; -import org.rhq.enterprise.client.RemoteClient; -import org.rhq.enterprise.server.auth.SubjectManagerRemote; - -public class FindUserAccountsCommand implements ClientCommand { - - public boolean execute(ClientMain client, String[] args) { - try { - // check to see if user logged in - if (client.getSubject() == null) { - client.getPrintWriter().println("Unable to view accounts until successfully logged in"); - return true; - } - - // Retrieve the parameters passed in - // String example="Ex. findAccounts user1"; - // String syntax = "findAccounts (*)user "; - String user = args[1] + ""; - - RemoteClient registry = client.getRemoteClient(); - Subject loggedInUser = client.getSubject(); - // Now make the connection successfully and store values - // instantiate SLSB - SubjectManagerRemote subjectManager = registry.getSubjectManagerRemote(); - // DURING POPULATION we should catch some type errors or insert more rigorous checking here - Subject located = subjectManager.getSubjectByName(loggedInUser, user); - - client.getPrintWriter().println("Account search successful."); - if (located != null) { - client.getPrintWriter().println("Account '" + user + "' located with id: " + located.getId()); - } else { - client.getPrintWriter().println("No account located with id: '" + user + "'"); - } - } catch (Exception e) { - client.getPrintWriter().println("Account search failed: " + e.getMessage()); - } - - return true; - } - - public String getDetailedHelp() { - return ""; - } - - public String getHelp() { - return "Locates an account using supplied account name"; - } - - public String getPromptCommandString() { - return "findAccount"; - } - - public String getSyntax() { - String example = "Ex. findAccount user1"; - String syntax = "findAccount (*)account.name"; - - return example + "\n" + syntax; - } - -} </span></pre></div> <a id="rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulesenterpriseclientsrcmainjavaorgrhqenterpriseclientcommandsScriptCommandjava"></a> <div class="modfile"><h4>Modified: rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/commands/ScriptCommand.java (4249 => 4250)</h4> <pre class="diff"> <span class="info">--- rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/commands/ScriptCommand.java 2009-07-02 22:36:24 UTC (rev 4249) +++ rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/commands/ScriptCommand.java 2009-07-03 01:47:54 UTC (rev 4250) </span><span class="lines">@@ -18,6 +18,11 @@ </span><span class="cx"> */ package org.rhq.enterprise.client.commands; </span><span class="add">+import java.io.BufferedReader; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; + </span><span class="cx"> import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import javax.script.ScriptException; </span><span class="lines">@@ -37,7 +42,7 @@ </span><span class="cx"> public ScriptCommand() { sem = new ScriptEngineManager(); </span><span class="rem">- // sem.getBindings().put("unlimitedPC", PageControl.getUnlimitedInstance()); </span><span class="add">+ // sem.getBindings().put("unlimitedPC", PageControl.getUnlimitedInstance()); </span><span class="cx"> PageControl pc = new PageControl(); pc.setPageNumber(-1); sem.getBindings().put("unlimitedPC", pc); </span><span class="lines">@@ -50,13 +55,54 @@ </span><span class="cx"> public boolean execute(ClientMain client, String[] args) { </span><span class="rem">- // These are prepared on every call in case the user logs out and logs into another server </span><span class="add">+ // check to see if user logged in + if (client.getSubject() == null) { + client.getPrintWriter().println("Unable to execute scripts until successfully logged in."); + return true; + } + + // These are prepared on every call in case the user logs out and logs into another server </span><span class="cx"> sem.getBindings().put("subject", client.getSubject()); sem.getBindings().putAll(client.getRemoteClient().getManagers()); TabularWriter tw = new TabularWriter(client.getPrintWriter()); tw.setWidth(client.getConsoleWidth()); sem.getBindings().put("pretty", tw); </span><span class="add">+ // parse arg 1 for -f + if ((args != null) && (args.length == 3)) { + if ((args[1].trim().equalsIgnoreCase("-f")) && (args[2].trim().length() > 0)) { + try { + BufferedReader ir = new BufferedReader(new FileReader(args[2])); + Object result = null; + String line = null; + // iterate through the lines of script and execute + boolean can_continue = true; + while ((ir != null) && ((line = ir.readLine()) != null) && (line.trim().length() > 0) + && can_continue) { + // parse the command into separate arguments and execute + String[] cmd_args = client.parseCommandLine(line); + can_continue = client.executePromptCommand(cmd_args); + } + if (result != null) { + client.getPrintWriter().print("result: "); + client.getPrintWriter().print(result); + } + return true; + // TODO: figure out what to do with exceptions.. too ugly, nicer info and log details? + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (ScriptException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + + // stop execution after custom script run/loaded + return true; + } + } </span><span class="cx"> StringBuilder script = new StringBuilder(); for (int i = ("exec".equals(args[0]) ? 1 : 0); i < args.length; i++) { script.append(args[i]); </span><span class="lines">@@ -82,7 +128,12 @@ </span><span class="cx"> } public String getSyntax() { </span><span class="rem">- return "exec <scripting code>"; </span><span class="add">+ String example = "Ex. exec 2 + 2"; + example += "\n" + "Ex2. exec -f (path to file)"; + String syntax = "exec <scripting code>"; + + return example + "\n" + syntax; + </span><span class="cx"> } public String getHelp() { </span></pre></div> <a id="rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulesenterpriseclientsrcmainjavaorgrhqenterpriseclientcommandsStartJBossAsCommandjava"></a> <div class="delfile"><h4>Deleted: rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/commands/StartJBossAsCommand.java (4249 => 4250)</h4> <pre class="diff"> <span class="info">--- rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/commands/StartJBossAsCommand.java 2009-07-02 22:36:24 UTC (rev 4249) +++ rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/commands/StartJBossAsCommand.java 2009-07-03 01:47:54 UTC (rev 4250) </span><span class="lines">@@ -1,79 +0,0 @@ </span><span class="rem">-package org.rhq.enterprise.client.commands; - -import org.rhq.core.domain.measurement.AvailabilityType; -import org.rhq.core.domain.resource.Resource; -import org.rhq.enterprise.client.ClientMain; -import org.rhq.enterprise.server.operation.OperationManagerRemote; -import org.rhq.enterprise.server.operation.ResourceOperationSchedule; -import org.rhq.enterprise.server.resource.ResourceManagerRemote; - -public class StartJBossAsCommand implements ClientCommand { - - public boolean execute(ClientMain client, String[] args) { - try { - // check to see if user logged in - if (client.getSubject() == null) { - client.getPrintWriter().println("Unable to start JBossAS instances until successfully logged in"); - return true; - } - - // Retrieve the parameters passed in - // String example="Ex. startJBossAS 09875"; - // String syntax = "startJBossAS (*)resource.id"; - String applicationServerResourcecId = args[1] + ""; - // do type checking - int asId = Integer.valueOf(applicationServerResourcecId); - - // instantiate SLSB ref - ResourceManagerRemote res = client.getRemoteClient().getResourceManagerRemote(); - OperationManagerRemote operationManager = client.getRemoteClient().getOperationManagerRemote(); - ResourceOperationSchedule schedule = null; - // check for instance - Resource resource = res.getResource(client.getSubject(), asId); - if ((resource != null) && (resource.getCurrentAvailability() != null)) { - // check for down - if (resource.getCurrentAvailability().getAvailabilityType().compareTo(AvailabilityType.DOWN) == 0) { - // send the command - try { - schedule = operationManager.scheduleResourceOperation(client.getSubject(), resource.getId(), - "start", 0L, 0L, 0, 0, null, "Remote Client from:" + client.getHost()); - } catch (Exception ex) { - // TODO: fix .. eat for now. - } - client.getPrintWriter().println( - "The command to start JBossAS instance with id '" + asId - + "' has been sent. Please allow a few moments for the requested action to occur."); - } else {// Instance already has availability status of DOWN - client.getPrintWriter().println( - "The JBossAS instance with id '" + asId + "' is already started. No action taken."); - return true; - } - } - } catch (Exception e) { - client.getPrintWriter().println("Attempt to start JBossAS instance failed: " + e.getMessage()); - } - - return true; - } - - public String getDetailedHelp() { - String detailed = ""; - return detailed; - } - - public String getHelp() { - return "Starts a stopped (non-RHQ) AS instance."; - } - - public String getPromptCommandString() { - return "startJBossAS"; - } - - public String getSyntax() { - String example = "Ex. startJBossAS 09875"; - String syntax = "startJBossAS (*)resource.id"; - - return example + "\n" + syntax; - } - -} </span></pre></div> <a id="rhqbranchesAGENT_PLUGIN_CLASSLOADINGmodulesenterpriseclientsrcmainjavaorgrhqenterpriseclientcommandsStopJBossAsCommandjava"></a> <div class="delfile"><h4>Deleted: rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/commands/StopJBossAsCommand.java (4249 => 4250)</h4> <pre class="diff"> <span class="info">--- rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/commands/StopJBossAsCommand.java 2009-07-02 22:36:24 UTC (rev 4249) +++ rhq/branches/AGENT_PLUGIN_CLASSLOADING/modules/enterprise/client/src/main/java/org/rhq/enterprise/client/commands/StopJBossAsCommand.java 2009-07-03 01:47:54 UTC (rev 4250) </span><span class="lines">@@ -1,84 +0,0 @@ </span><span class="rem">-package org.rhq.enterprise.client.commands; - -import org.rhq.core.domain.auth.Subject; -import org.rhq.core.domain.measurement.AvailabilityType; -import org.rhq.core.domain.resource.Resource; -import org.rhq.enterprise.client.ClientMain; -import org.rhq.enterprise.client.RemoteClient; -import org.rhq.enterprise.server.operation.OperationManagerRemote; -import org.rhq.enterprise.server.operation.ResourceOperationSchedule; -import org.rhq.enterprise.server.resource.ResourceManagerRemote; - -public class StopJBossAsCommand implements ClientCommand { - - public boolean execute(ClientMain client, String[] args) { - try { - // check to see if user logged in - if (client.getSubject() == null) { - client.getPrintWriter().println("Unable to stop JBossAS instances until successfully logged in"); - return true; - } - - // Retrieve the parameters passed in - // String example="Ex. stopJBossAS 09875"; - // String syntax = "stopJBossAS (*)resource.id"; - String applicationServerResourcecId = args[1] + ""; - // do type checking - int asId = Integer.valueOf(applicationServerResourcecId); - - // retrieve RHQRegistry object - RemoteClient registry = client.getRemoteClient(); - Subject loggedInUser = client.getSubject(); - // instantiate SLSB - ResourceManagerRemote res = client.getRemoteClient().getResourceManagerRemote(); - OperationManagerRemote operationManager = client.getRemoteClient().getOperationManagerRemote(); - ResourceOperationSchedule schedule = null; - // check for instance - Resource resource = res.getResource(client.getSubject(), asId); - if ((resource != null) && (resource.getCurrentAvailability() != null)) { - // check for up - if (resource.getCurrentAvailability().getAvailabilityType().compareTo(AvailabilityType.UP) == 0) { - // send the command - try { - schedule = operationManager.scheduleResourceOperation(client.getSubject(), resource.getId(), - "shutdown", 0L, 0L, 0, 0, null, "Remote Client from:" + client.getHost()); - } catch (Exception ex) { - // TODO: fix .. eat for now. - } - client.getPrintWriter().println( - "The command to shutdown JBossAS instance with id '" + asId - + "' has been sent. Please allow for a few moments for the server to... [truncated message content] |