java/spacewalk-java.spec rel-eng/packages
by Tomas Lestach
java/spacewalk-java.spec | 93 +++++++++++++++++++++++++++++++++++++++-
rel-eng/packages/spacewalk-java | 2
2 files changed, 93 insertions(+), 2 deletions(-)
New commits:
commit feecebe98979d33df7087e62d19f1650385f56aa
Author: Tomas Lestach <tlestach(a)redhat.com>
Date: Thu Jul 1 14:39:35 2010 +0200
Automatic commit of package [spacewalk-java] release [1.1.17-1].
diff --git a/java/spacewalk-java.spec b/java/spacewalk-java.spec
index cc3fffa..ee2b43c 100644
--- a/java/spacewalk-java.spec
+++ b/java/spacewalk-java.spec
@@ -19,7 +19,7 @@ Name: spacewalk-java
Summary: Spacewalk Java site packages
Group: Applications/Internet
License: GPLv2
-Version: 1.1.16
+Version: 1.1.17
Release: 1%{?dist}
URL: https://fedorahosted.org/spacewalk
Source0: https://fedorahosted.org/releases/s/p/spacewalk/%{name}-%{version}.tar.gz
@@ -321,6 +321,97 @@ fi
%{jardir}/postgresql-jdbc.jar
%changelog
+* Thu Jul 01 2010 Tomas Lestach <tlestach(a)redhat.com> 1.1.17-1
+- replacing ExceptionTranslator for SqlExceptionTranslator and its convert()
+ method for sqlException() (tlestach(a)redhat.com)
+- Added a sat scrubber test that wipes out old test artifactsw
+ (paji(a)redhat.com)
+- Added an automatic db test cleanup script as a part of tests
+ (paji(a)redhat.com)
+- fix bug Validation i18n key (shughes(a)redhat.com)
+- bug fixing for reposync (shughes(a)redhat.com)
+- junit modification for repo sync (shughes(a)redhat.com)
+- checkstyle fix, extra java import (shughes(a)redhat.com)
+- hook to call create repo sync task in taskomatic (shughes(a)redhat.com)
+- remove call to repo task from the channel edit/update cmds
+ (shughes(a)redhat.com)
+- add last log repo sync to edit channel (shughes(a)redhat.com)
+- remove old repo fields from channel edit page, clean up i18n strings
+ (shughes(a)redhat.com)
+- making links between repo objects and taskomatic (shughes(a)redhat.com)
+- lots of checkstyle fixes (shughes(a)redhat.com)
+- add channel count access for repo objects (shughes(a)redhat.com)
+- general repo cleanup, bugfixing (shughes(a)redhat.com)
+- new page: list of repos to sync (session sets) (shughes(a)redhat.com)
+- struts support for repo sync action (shughes(a)redhat.com)
+- adding new sync nav, moving add/remove to new tab (shughes(a)redhat.com)
+- remove debug messages, add extra i18n update string (shughes(a)redhat.com)
+- db mapping logic for channel repos (shughes(a)redhat.com)
+- preselect set channel repo logic (shughes(a)redhat.com)
+- initial jsp support for channel to repo mapping (shughes(a)redhat.com)
+- change from rhnset to sessionset for repo maps (shughes(a)redhat.com)
+- intial strut action for channel repository mapping (shughes(a)redhat.com)
+- strut support for channel repository mapping (shughes(a)redhat.com)
+- channel nav support for repository mapping (shughes(a)redhat.com)
+- modify verbage for repo list summary (shughes(a)redhat.com)
+- logic to delete content sources from db (shughes(a)redhat.com)
+- minor syntax issue with i18n repo delete strings (shughes(a)redhat.com)
+- initial files to support Repo delete (shughes(a)redhat.com)
+- bug fixes for EditRepo, strut path fixes (shughes(a)redhat.com)
+- RepoEdit page cleanup, jsp fixes (shughes(a)redhat.com)
+- fix hibernate content obj named queries for Edit Repo (shughes(a)redhat.com)
+- starting checking content objects off id and org for security; also fix query
+ for taskomatic (shughes(a)redhat.com)
+- commit before master merge (shughes(a)redhat.com)
+- adding repo edit commands (shughes(a)redhat.com)
+- refactoring repo commands to use base class (shughes(a)redhat.com)
+- more repo content obj clean up (shughes(a)redhat.com)
+- fix link for repo edit (shughes(a)redhat.com)
+- quick fix to remove sync query from content source obj (shughes(a)redhat.com)
+- update channel to handle sync date; remove from content source
+ (shughes(a)redhat.com)
+- fix incorrect reference to sync column of content source (shughes(a)redhat.com)
+- adding org id mapping to content source objects (shughes(a)redhat.com)
+- ise fixes for repo create (shughes(a)redhat.com)
+- adding url field to repo details form/jsp (shughes(a)redhat.com)
+- pushing changes to prepare for master merge (shughes(a)redhat.com)
+- fixed incorrect url syntax for repocreate (shughes(a)redhat.com)
+- adding repo domain creation logic to manager/action layer
+ (shughes(a)redhat.com)
+- pushing minor changes before master merge (shughes(a)redhat.com)
+- repo struts action fnd jsp or creating repo objects. (shughes(a)redhat.com)
+- support classes for adding a Repo object (shughes(a)redhat.com)
+- repo validation xsd schema (shughes(a)redhat.com)
+- adding nav entries for repo create and edit (shughes(a)redhat.com)
+- struts entries for repo create and edit pages (shughes(a)redhat.com)
+- adding dynaform for content source creation (shughes(a)redhat.com)
+- fixing toolbar syntax for repo (shughes(a)redhat.com)
+- minor tweaks to struts url path and hibernate fix (shughes(a)redhat.com)
+- adding repolist page to struts (shughes(a)redhat.com)
+- datasource queries for repolist listtag page (shughes(a)redhat.com)
+- adding ContentSource DTO object for repo listtags (shughes(a)redhat.com)
+- setting up ContentSource queries (shughes(a)redhat.com)
+- fixing compile errors on RepoLister (shughes(a)redhat.com)
+- initial classes for Repolisting (shughes(a)redhat.com)
+- adding repo list jsp page (shughes(a)redhat.com)
+- Revert "fixing accidental branch creation, removing cobbler stubs"
+ (shughes(a)redhat.com)
+- fixing accidental branch creation, removing cobbler stubs
+ (shughes(a)redhat.com)
+- new jsp for the repo list (shughes(a)redhat.com)
+- adding nav menu for external repo management (shughes(a)redhat.com)
+- minor changes to tests (shughes(a)redhat.com)
+- more compiliation fixes to support many2many (shughes(a)redhat.com)
+- fixing breakage after adding many2many objects for yum repo sync
+ (shughes(a)redhat.com)
+- minor updates to Channel object to add repos (shughes(a)redhat.com)
+- initial hibernate changes to support many2many relationships of channel to
+ repos (shughes(a)redhat.com)
+- hibernate changes for existing content source objects (shughes(a)redhat.com)
+- Fixed some checkstyle errors (paji(a)redhat.com)
+- 605383 - fixing issue where adding errata to a channel with 'package
+ association' unchecked wouldn't handle arches correctly (jsherril(a)redhat.com)
+
* Wed Jun 30 2010 Tomas Lestach <tlestach(a)redhat.com> 1.1.16-1
- 591291 - fix also mergeErrata with given start and end date
(tlestach(a)redhat.com)
diff --git a/rel-eng/packages/spacewalk-java b/rel-eng/packages/spacewalk-java
index d300df0..4a9275f 100644
--- a/rel-eng/packages/spacewalk-java
+++ b/rel-eng/packages/spacewalk-java
@@ -1 +1 @@
-1.1.16-1 java/
+1.1.17-1 java/
13 years, 9 months
java/code
by Tomas Lestach
java/code/src/com/redhat/rhn/common/db/NamedPreparedStatement.java | 14 -
java/code/src/com/redhat/rhn/common/db/datasource/CachedStatement.java | 10
java/code/src/com/redhat/rhn/common/hibernate/HibernateHelper.java | 7
java/code/src/com/redhat/rhn/common/translation/ExceptionTranslator.java | 109 ----------
java/code/src/com/redhat/rhn/common/translation/SqlExceptionTranslator.java | 87 +++++++
java/code/src/com/redhat/rhn/common/translation/test/ExceptionsWrapperTest.java | 10
6 files changed, 109 insertions(+), 128 deletions(-)
New commits:
commit dcbe302ca869e7511b92be74563f5bec204fe601
Author: Tomas Lestach <tlestach(a)redhat.com>
Date: Thu Jul 1 14:22:18 2010 +0200
replacing ExceptionTranslator for SqlExceptionTranslator and its convert() method for sqlException()
ExceptionTranslator.convert() cycled because this function was picked up as the best candidate for exception translation (1 param, returns RuntimeException)
diff --git a/java/code/src/com/redhat/rhn/common/db/NamedPreparedStatement.java b/java/code/src/com/redhat/rhn/common/db/NamedPreparedStatement.java
index 2f780a7..e24b8f4 100644
--- a/java/code/src/com/redhat/rhn/common/db/NamedPreparedStatement.java
+++ b/java/code/src/com/redhat/rhn/common/db/NamedPreparedStatement.java
@@ -14,7 +14,7 @@
*/
package com.redhat.rhn.common.db;
-import com.redhat.rhn.common.translation.ExceptionTranslator;
+import com.redhat.rhn.common.translation.SqlExceptionTranslator;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
@@ -106,16 +106,17 @@ public final class NamedPreparedStatement {
* @param outParams A map of parameter name to Integer object of
* SQL Types representing the type of data to be returned.
* @return true if CallableStatement executed without error, false otherwise.
+ * @throws RuntimeException in case of SQLException
*/
public static boolean execute(CallableStatement cs, Map parameterMap,
- Map inParams, Map outParams) {
+ Map inParams, Map outParams) throws RuntimeException {
try {
setVars(cs, parameterMap, inParams);
setOutputVars(cs, parameterMap, outParams);
return cs.execute();
}
catch (SQLException e) {
- throw ExceptionTranslator.convert(e);
+ throw SqlExceptionTranslator.sqlException(e);
}
}
@@ -128,6 +129,7 @@ public final class NamedPreparedStatement {
* @see java.sql.PreparedStatement#execute()
* @return true if PreparedStatement received a result set
* false if PreparedStatement received an update count
+ * @throws RuntimeException in case of SQLException
*/
public static boolean execute(PreparedStatement ps,
Map parameterMap,
@@ -137,7 +139,7 @@ public final class NamedPreparedStatement {
return ps.execute();
}
catch (SQLException e) {
- throw ExceptionTranslator.convert(e);
+ throw SqlExceptionTranslator.sqlException(e);
}
}
@@ -193,7 +195,7 @@ public final class NamedPreparedStatement {
}
}
catch (SQLException e) {
- throw ExceptionTranslator.convert(e);
+ throw SqlExceptionTranslator.sqlException(e);
}
}
}
@@ -217,7 +219,7 @@ public final class NamedPreparedStatement {
cs.registerOutParameter(pos.intValue(), type.intValue());
}
catch (SQLException e) {
- throw ExceptionTranslator.convert(e);
+ throw SqlExceptionTranslator.sqlException(e);
}
}
}
diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/CachedStatement.java b/java/code/src/com/redhat/rhn/common/db/datasource/CachedStatement.java
index 58d73ee..530c15d 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/CachedStatement.java
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/CachedStatement.java
@@ -19,7 +19,7 @@ import com.redhat.rhn.common.db.NamedPreparedStatement;
import com.redhat.rhn.common.hibernate.HibernateFactory;
import com.redhat.rhn.common.hibernate.HibernateHelper;
import com.redhat.rhn.common.hibernate.HibernateRuntimeException;
-import com.redhat.rhn.common.translation.ExceptionTranslator;
+import com.redhat.rhn.common.translation.SqlExceptionTranslator;
import com.redhat.rhn.common.util.MethodUtil;
import com.redhat.rhn.common.util.StringUtil;
@@ -463,7 +463,7 @@ public class CachedStatement {
return new Integer(ps.getUpdateCount());
}
catch (SQLException e) {
- throw ExceptionTranslator.convert(e);
+ throw SqlExceptionTranslator.sqlException(e);
}
catch (HibernateException he) {
throw new
@@ -509,7 +509,7 @@ public class CachedStatement {
return processOutputParams(cs, outParams);
}
catch (SQLException e) {
- throw ExceptionTranslator.convert(e);
+ throw SqlExceptionTranslator.sqlException(e);
}
catch (HibernateException he) {
throw new
@@ -618,7 +618,7 @@ public class CachedStatement {
return dr;
}
catch (SQLException e) {
- throw ExceptionTranslator.convert(e);
+ throw SqlExceptionTranslator.sqlException(e);
}
catch (ClassNotFoundException e) {
throw new ObjectCreateWrapperException("Could not create " +
@@ -788,7 +788,7 @@ public class CachedStatement {
return columns;
}
catch (SQLException e) {
- throw ExceptionTranslator.convert(e);
+ throw SqlExceptionTranslator.sqlException(e);
}
}
diff --git a/java/code/src/com/redhat/rhn/common/hibernate/HibernateHelper.java b/java/code/src/com/redhat/rhn/common/hibernate/HibernateHelper.java
index d080415..c9356a3 100644
--- a/java/code/src/com/redhat/rhn/common/hibernate/HibernateHelper.java
+++ b/java/code/src/com/redhat/rhn/common/hibernate/HibernateHelper.java
@@ -14,7 +14,7 @@
*/
package com.redhat.rhn.common.hibernate;
-import com.redhat.rhn.common.translation.ExceptionTranslator;
+import com.redhat.rhn.common.translation.SqlExceptionTranslator;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -51,8 +51,9 @@ public class HibernateHelper {
* Helper function for cleaning up all DB objects
* @param rs The resultSet to close
* @param stmt The preparedStatement to close
+ * @throws RuntimeException in case of SQLException
*/
- public static void cleanupDB(ResultSet rs, Statement stmt) {
+ public static void cleanupDB(ResultSet rs, Statement stmt) throws RuntimeException {
SQLException caught = null;
try {
if (rs != null) {
@@ -73,7 +74,7 @@ public class HibernateHelper {
}
if (caught != null) {
- throw ExceptionTranslator.convert(caught);
+ throw SqlExceptionTranslator.sqlException(caught);
}
}
}
diff --git a/java/code/src/com/redhat/rhn/common/translation/ExceptionTranslator.java b/java/code/src/com/redhat/rhn/common/translation/ExceptionTranslator.java
deleted file mode 100644
index 8ed073c..0000000
--- a/java/code/src/com/redhat/rhn/common/translation/ExceptionTranslator.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/**
- * Copyright (c) 2009--2010 Red Hat, Inc.
- *
- * This software is licensed to you under the GNU General Public License,
- * version 2 (GPLv2). There is NO WARRANTY for this software, express or
- * implied, including the implied warranties of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
- * along with this software; if not, see
- * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
- *
- * Red Hat trademarks are not licensed under GPLv2. No permission is
- * granted to use or replicate Red Hat trademarks that are incorporated
- * in this software or its documentation.
- */
-
-package com.redhat.rhn.common.translation;
-
-import com.redhat.rhn.common.conf.ConfigDefaults;
-import com.redhat.rhn.common.db.ConstraintViolationException;
-import com.redhat.rhn.common.db.WrappedSQLException;
-
-import java.sql.SQLException;
-
-/**
- * Translator The class that actually does the object translations for us.
- *
- * @version $Rev$
- */
-
-public class ExceptionTranslator extends Translations {
-
- private ExceptionTranslator() {
- }
-
- /**
- * Translate from from one object type to another.
- * @param have The object to convert
- * @return The translated RuntimeException, which includes a reference to
- * the passed in exception.
- */
- public static RuntimeException convert(Object have) {
- RuntimeException e = (RuntimeException)convert(ExceptionTranslator.class,
- have, RuntimeException.class);
- postProcess(e);
- return e;
- }
-
- // Remove any translation stackElements from the exception that is created.
- private static void postProcess(RuntimeException e) {
- Throwable cause = e.getCause();
- if (cause == null) {
- return;
- }
- e.setStackTrace(cause.getStackTrace());
- }
-
- /**
- * Gets the appropriate runtime exception depending on whether the DB is oracle ornot
- * @param e the exception
- * @return the RuntimeExcetoion of the wrapped exception
- */
- public static RuntimeException sqlException(SQLException e) {
- if (ConfigDefaults.get().isOracle()) {
- return oracleSQLException(e);
- }
- else {
- return postgreSqlException(e);
- }
- }
-
- /**
- * Convert from PSQLException to some RuntimeException sub-class.
- *
- * @param e Exception to translate.
- * @return Translated RuntimeException with reference to the original.
- */
- private static RuntimeException postgreSqlException(SQLException e) {
- return new WrappedSQLException(e.getMessage(), e);
- }
-
- // This will currently only work for SQLException's that come from
- // Oracle. To add more Databases, make this a private method, add a
- // public method with a different name, but the same signature, in the
- // new method, determine DB type, and call the correct translator.
-
- /**
- * Convert from SQLException to some other Exception type
- * @param e The SQLException to translate
- * @return The translated RuntimeException, which includes a reference
- * to the SQLException that was passed in.
- */
- private static RuntimeException oracleSQLException(SQLException e) {
- int code = e.getErrorCode();
- String msg = e.getMessage();
- switch(code) {
- case 1:
- int ind = msg.indexOf("(") + 1;
- String desc = msg.substring(ind, msg.indexOf(")", ind));
- return new ConstraintViolationException(
- ExceptionConstants.VALUE_TOO_LARGE, desc, msg, e);
- case 1401:
- case 12899:
- return new ConstraintViolationException(
- ExceptionConstants.VALUE_TOO_LARGE, null, msg, e);
- default:
- return new WrappedSQLException(e.getMessage(), e);
- }
- }
-}
diff --git a/java/code/src/com/redhat/rhn/common/translation/SqlExceptionTranslator.java b/java/code/src/com/redhat/rhn/common/translation/SqlExceptionTranslator.java
new file mode 100644
index 0000000..1bbb93c
--- /dev/null
+++ b/java/code/src/com/redhat/rhn/common/translation/SqlExceptionTranslator.java
@@ -0,0 +1,87 @@
+/**
+ * Copyright (c) 2009--2010 Red Hat, Inc.
+ *
+ * This software is licensed to you under the GNU General Public License,
+ * version 2 (GPLv2). There is NO WARRANTY for this software, express or
+ * implied, including the implied warranties of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+ * along with this software; if not, see
+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+ *
+ * Red Hat trademarks are not licensed under GPLv2. No permission is
+ * granted to use or replicate Red Hat trademarks that are incorporated
+ * in this software or its documentation.
+ */
+
+package com.redhat.rhn.common.translation;
+
+import com.redhat.rhn.common.conf.ConfigDefaults;
+import com.redhat.rhn.common.db.ConstraintViolationException;
+import com.redhat.rhn.common.db.WrappedSQLException;
+
+import java.sql.SQLException;
+
+/**
+ * Translator The class that actually does the object translations for us.
+ *
+ * @version $Rev$
+ */
+
+public class SqlExceptionTranslator extends Translations {
+
+ private SqlExceptionTranslator() {
+ }
+
+ /**
+ * Gets the appropriate runtime exception depending on whether the DB is oracle ornot
+ * @param e the exception
+ * @return the RuntimeExcetoion of the wrapped exception
+ */
+ public static RuntimeException sqlException(SQLException e) {
+ if (ConfigDefaults.get().isOracle()) {
+ return oracleSQLException(e);
+ }
+ else {
+ return postgreSqlException(e);
+ }
+ }
+
+ /**
+ * Convert from PSQLException to some RuntimeException sub-class.
+ *
+ * @param e Exception to translate.
+ * @return Translated RuntimeException with reference to the original.
+ */
+ private static RuntimeException postgreSqlException(SQLException e) {
+ return new WrappedSQLException(e.getMessage(), e);
+ }
+
+ // This will currently only work for SQLException's that come from
+ // Oracle. To add more Databases, make this a private method, add a
+ // public method with a different name, but the same signature, in the
+ // new method, determine DB type, and call the correct translator.
+
+ /**
+ * Convert from SQLException to some other Exception type
+ * @param e The SQLException to translate
+ * @return The translated RuntimeException, which includes a reference
+ * to the SQLException that was passed in.
+ */
+ private static RuntimeException oracleSQLException(SQLException e) {
+ int code = e.getErrorCode();
+ String msg = e.getMessage();
+ switch(code) {
+ case 1:
+ int ind = msg.indexOf("(") + 1;
+ String desc = msg.substring(ind, msg.indexOf(")", ind));
+ return new ConstraintViolationException(
+ ExceptionConstants.VALUE_TOO_LARGE, desc, msg, e);
+ case 1401:
+ case 12899:
+ return new ConstraintViolationException(
+ ExceptionConstants.VALUE_TOO_LARGE, null, msg, e);
+ default:
+ return new WrappedSQLException(e.getMessage(), e);
+ }
+ }
+}
diff --git a/java/code/src/com/redhat/rhn/common/translation/test/ExceptionsWrapperTest.java b/java/code/src/com/redhat/rhn/common/translation/test/ExceptionsWrapperTest.java
index ed16b89..bea267d 100644
--- a/java/code/src/com/redhat/rhn/common/translation/test/ExceptionsWrapperTest.java
+++ b/java/code/src/com/redhat/rhn/common/translation/test/ExceptionsWrapperTest.java
@@ -19,7 +19,7 @@ import com.redhat.rhn.common.db.WrappedSQLException;
import com.redhat.rhn.common.hibernate.HibernateFactory;
import com.redhat.rhn.common.hibernate.HibernateHelper;
import com.redhat.rhn.common.translation.ExceptionConstants;
-import com.redhat.rhn.common.translation.ExceptionTranslator;
+import com.redhat.rhn.common.translation.SqlExceptionTranslator;
import org.apache.log4j.Logger;
import org.hibernate.Session;
@@ -61,7 +61,7 @@ public class ExceptionsWrapperTest extends TestCase {
}
catch (SQLException e) {
try {
- throw ExceptionTranslator.convert(e);
+ throw SqlExceptionTranslator.sqlException(e);
}
catch (ConstraintViolationException c) {
assertNull(c.getConstraint());
@@ -88,7 +88,7 @@ public class ExceptionsWrapperTest extends TestCase {
}
catch (SQLException e) {
try {
- throw ExceptionTranslator.convert(e);
+ throw SqlExceptionTranslator.sqlException(e);
}
catch (ConstraintViolationException c) {
assertTrue(c.getConstraint().indexOf("EXCEPTIONS_TEST_PK") >= 0);
@@ -115,7 +115,7 @@ public class ExceptionsWrapperTest extends TestCase {
}
catch (SQLException e) {
try {
- throw ExceptionTranslator.convert(e);
+ throw SqlExceptionTranslator.sqlException(e);
}
catch (WrappedSQLException c) {
// Expected WrappedSQLException
@@ -142,7 +142,7 @@ public class ExceptionsWrapperTest extends TestCase {
}
catch (SQLException e) {
try {
- throw ExceptionTranslator.convert(e);
+ throw SqlExceptionTranslator.sqlException(e);
}
catch (WrappedSQLException c) {
StackTraceElement[] elements = c.getStackTrace();
13 years, 9 months
backend/server
by Jan Pazdziora
backend/server/rhnSQL/__init__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit d45dd7ff3e00efb6988a93372d00c3925c3ad27b
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Thu Jul 1 10:14:19 2010 +0200
We need to force port into integer.
Otherwise we get
server.rhnSQL.sql_base.SQLConnectError: (-1, 'an integer is required', 'spaceschema')
diff --git a/backend/server/rhnSQL/__init__.py b/backend/server/rhnSQL/__init__.py
index 12fe17f..87b2afd 100644
--- a/backend/server/rhnSQL/__init__.py
+++ b/backend/server/rhnSQL/__init__.py
@@ -108,7 +108,7 @@ def initDB(dsn=None, backend=None, host="localhost", port=None, username=None,
elif k == 'host':
host = v
elif k == 'port':
- port = v
+ port = int(v)
else:
raise rhnException("Unknown piece in default_db string", i)
13 years, 9 months
java/code
by Partha Aji
java/code/src/com/redhat/rhn/common/db/datasource/xml/test_queries.xml | 16 +-
java/code/src/com/redhat/rhn/domain/user/UserFactory.java | 12 +
java/code/src/com/redhat/rhn/frontend/xmlrpc/test/SatScrubberTest.java | 74 +++++-----
java/code/src/com/redhat/rhn/manager/user/UserManager.java | 16 --
4 files changed, 72 insertions(+), 46 deletions(-)
New commits:
commit a823d1955b0a45e66e83b165876291208e770394
Author: Partha Aji <paji(a)redhat.com>
Date: Wed Jun 30 21:07:08 2010 -0400
Added a sat scrubber test that wipes out old test artifactsw
diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/test_queries.xml b/java/code/src/com/redhat/rhn/common/db/datasource/xml/test_queries.xml
index c6a729c..5735de1 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/test_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/test_queries.xml
@@ -456,12 +456,26 @@ SELECT * FROM time_series order by entry_time
</query>
</mode>
+<mode name="get_test_users">
+ <query params="">
+SELECT id from web_customer where UPPER(name) like 'TEST%'
+ </query>
+</mode>
+
+
<mode name="get_test_orgs">
<query params="">
SELECT id from web_customer where UPPER(name) like 'TESTORG%'
</query>
</mode>
+<mode name="get_test_servers">
+ <query params="">
+SELECT id from rhnServer where name like 'serverfactorytest%'
+ </query>
+</mode>
+
+
<mode name="select_in">
<query params="">
SELECT name FROM web_customer WHERE id IN (%s)
@@ -492,6 +506,4 @@ SELECT name FROM web_customer WHERE id IN (%s) AND name = :name
SELECT data FROM time_series WHERE data = :data
</query>
</mode>
-
-
</datasource_modes>
diff --git a/java/code/src/com/redhat/rhn/domain/user/UserFactory.java b/java/code/src/com/redhat/rhn/domain/user/UserFactory.java
index 0c82636..82bca48 100644
--- a/java/code/src/com/redhat/rhn/domain/user/UserFactory.java
+++ b/java/code/src/com/redhat/rhn/domain/user/UserFactory.java
@@ -711,4 +711,16 @@ public class UserFactory extends HibernateFactory {
return (List<User>)listObjectsByNamedQuery("User.findAllOrgAdmins", params);
}
+ /**
+ * @param userId the user id
+ */
+ public static void deleteUser(Long userId) {
+ CallableMode m = ModeFactory.getCallableMode("User_queries",
+ "delete_user");
+ Map inParams = new HashMap();
+ Map outParams = new HashMap();
+ inParams.put("user_id", userId);
+ m.execute(inParams, outParams);
+ }
+
}
diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/test/SatScrubberTest.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/test/SatScrubberTest.java
index 9643bb5..da0c2d0 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/test/SatScrubberTest.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/test/SatScrubberTest.java
@@ -22,7 +22,6 @@ import com.redhat.rhn.domain.channel.ChannelFactory;
import com.redhat.rhn.domain.kickstart.KickstartData;
import com.redhat.rhn.domain.kickstart.KickstartFactory;
import com.redhat.rhn.domain.kickstart.KickstartableTree;
-import com.redhat.rhn.domain.org.Org;
import com.redhat.rhn.domain.org.OrgFactory;
import com.redhat.rhn.domain.user.User;
import com.redhat.rhn.domain.user.UserFactory;
@@ -30,7 +29,6 @@ import com.redhat.rhn.frontend.dto.kickstart.KickstartDto;
import com.redhat.rhn.frontend.dto.kickstart.KickstartableTreeDto;
import com.redhat.rhn.manager.channel.ChannelManager;
import com.redhat.rhn.manager.kickstart.KickstartLister;
-import com.redhat.rhn.manager.user.UserManager;
import com.redhat.rhn.testing.RhnBaseTestCase;
import com.redhat.rhn.testing.TestUtils;
@@ -52,7 +50,12 @@ public class SatScrubberTest extends RhnBaseTestCase {
private static Logger log = Logger.getLogger(SatScrubberTest.class);
public void testNothing() throws Exception {
- // Test nothing.
+ cleanupKickstarts();
+ cleanupChannels();
+ cleanupServers();
+ cleanupUsers();
+ cleanupOrgs();
+
}
public void cleanupKickstarts() throws Exception {
@@ -99,48 +102,35 @@ public class SatScrubberTest extends RhnBaseTestCase {
public void cleanupUsers() throws Exception {
- orgAdmin = UserFactory.findRandomOrgAdmin(OrgFactory.getSatelliteOrg());
- List users = UserManager.usersInOrg(orgAdmin, null, Map.class);
- for (int i = 0; i < users.size(); i++) {
- Map row = (Map) users.get(i);
- String login = (String) row.get("login");
- if (login.indexOf("test") > -1) {
- User lookedup = UserFactory.lookupByLogin(login);
- UserManager.deleteUser(orgAdmin, lookedup.getId());
+ DataResult dr = TestUtils.runTestQuery("get_test_users", new HashMap());
+ for (int i = 0; i < dr.size(); i++) {
+ Long uid = (Long) ((Map) dr.get(i)).get("id");
+ try {
+ UserFactory.deleteUser(uid);
+ }
+ catch (Exception e) {
+ log.warn("Error deleting user: " + uid, e);
}
if (i % 100 == 0) {
log.debug("Deleted [" + i + "] users");
commitAndCloseSession();
}
+
+
}
commitAndCloseSession();
}
public void cleanupServers() throws Exception {
-
- List orgs = OrgFactory.lookupAllOrgs();
+ DataResult dr = TestUtils.runTestQuery("get_test_servers", new HashMap());
int numdeleted = 0;
- for (int x = 0; x < orgs.size(); x++) {
- Org org = (Org) orgs.get(x);
- orgAdmin = UserFactory.findRandomOrgAdmin(org);
- if (orgAdmin != null) {
- List systems = UserManager.visibleSystemsAsMaps(orgAdmin);
- for (int i = 0; i < systems.size(); i++) {
- Long sid = (Long) ((Map) systems.get(i)).get("id");
- String name = (String) ((Map) systems.get(i)).get("name");
- if (name.startsWith("serverfactorytest")) {
- CallableMode m = ModeFactory.
- getCallableMode("System_queries", "delete_server");
- Map in = new HashMap();
- in.put("server_id", sid);
- m.execute(in, new HashMap());
- numdeleted++;
- }
- if (i % 100 == 0) {
- log.debug("Deleted [" + numdeleted + "] systems");
- commitAndCloseSession();
- }
- }
+ for (int i = 0; i < dr.size(); i++) {
+ Long sid = (Long) ((Map) dr.get(i)).get("id");
+ deleteServer(sid);
+ numdeleted++;
+ if (i % 100 == 0) {
+ log.debug("Deleted [" + numdeleted + "] systems");
+ commitAndCloseSession();
}
}
@@ -148,6 +138,20 @@ public class SatScrubberTest extends RhnBaseTestCase {
log.debug("Done deleting [" + numdeleted + "] systems");
}
+ /**
+ * @param sid
+ */
+ private void deleteServer(Long sid) {
+ CallableMode m = ModeFactory.
+ getCallableMode("System_queries", "delete_server");
+ Map in = new HashMap();
+ in.put("server_id", sid);
+ m.execute(in, new HashMap());
+ }
+
+
+
+
public void cleanupOrgs() throws Exception {
// testOrg
DataResult dr = TestUtils.runTestQuery("get_test_orgs", new HashMap());
@@ -159,7 +163,7 @@ public class SatScrubberTest extends RhnBaseTestCase {
OrgFactory.deleteOrg(new Long(id.longValue()));
}
catch (Exception e) {
- log.debug("Error deleting org: " + id);
+ log.warn("Error deleting org: " + id, e);
}
if (i % 10 == 0) {
log.debug("Deleted [" + i + "] orgs");
diff --git a/java/code/src/com/redhat/rhn/manager/user/UserManager.java b/java/code/src/com/redhat/rhn/manager/user/UserManager.java
index 3720d2e..7052d0b 100644
--- a/java/code/src/com/redhat/rhn/manager/user/UserManager.java
+++ b/java/code/src/com/redhat/rhn/manager/user/UserManager.java
@@ -37,6 +37,7 @@ import com.redhat.rhn.domain.user.UserServerPreference;
import com.redhat.rhn.frontend.dto.SystemGroupOverview;
import com.redhat.rhn.frontend.dto.SystemOverview;
import com.redhat.rhn.frontend.dto.SystemSearchResult;
+import com.redhat.rhn.frontend.dto.UserOverview;
import com.redhat.rhn.frontend.listview.PageControl;
import com.redhat.rhn.frontend.taglibs.list.decorators.PageSizeDecorator;
import com.redhat.rhn.manager.BaseManager;
@@ -461,12 +462,7 @@ public class UserManager extends BaseManager {
}
}
- CallableMode m = ModeFactory.getCallableMode("User_queries",
- "delete_user");
- Map inParams = new HashMap();
- Map outParams = new HashMap();
- inParams.put("user_id", targetUid);
- m.execute(inParams, outParams);
+ UserFactory.deleteUser(targetUid);
}
/**
@@ -563,7 +559,7 @@ public class UserManager extends BaseManager {
* @param pc The details of which results to return.
* @return A DataResult containing the specified number of users.
*/
- public static DataResult usersInOrg(User user, PageControl pc) {
+ public static DataResult <UserOverview> usersInOrg(User user, PageControl pc) {
SelectMode m = ModeFactory.getMode("User_queries", "users_in_org");
return getUsersInOrg(user, pc, m);
}
@@ -576,7 +572,8 @@ public class UserManager extends BaseManager {
* @param clazz The class you want the returned DataResult to contain.
* @return A DataResult containing the specified number of users.
*/
- public static DataResult usersInOrg(User user, PageControl pc, Class clazz) {
+ public static DataResult usersInOrg(User user,
+ PageControl pc, Class clazz) {
SelectMode m = ModeFactory.getMode("User_queries", "users_in_org", clazz);
return getUsersInOrg(user, pc, m);
}
@@ -588,7 +585,8 @@ public class UserManager extends BaseManager {
* @param m The select mode.
* @return A list containing the specified number of users.
*/
- private static DataResult getUsersInOrg(User user, PageControl pc, SelectMode m) {
+ private static DataResult getUsersInOrg(User user,
+ PageControl pc, SelectMode m) {
if (!user.hasRole(RoleFactory.ORG_ADMIN)) {
//Throw an exception with a nice error message so the user
//knows what went wrong.
13 years, 9 months