2 commits - java/code
by Justin Sherrill
java/code/src/com/redhat/rhn/common/security/acl/test/AccessTest.java | 4
java/code/src/com/redhat/rhn/domain/action/Action_legacyUser.hbm.xml | 2
java/code/src/com/redhat/rhn/domain/kickstart/KickstartSession_legacyUser.hbm.xml | 2
java/code/src/com/redhat/rhn/domain/monitoring/notification/Filter_legacyUser.hbm.xml | 2
java/code/src/com/redhat/rhn/domain/monitoring/notification/Method_legacyUser.hbm.xml | 2
java/code/src/com/redhat/rhn/domain/org/CustomDataKey_legacyUser.hbm.xml | 4
java/code/src/com/redhat/rhn/domain/server/CustomDataValue_legacyUser.hbm.xml | 4
java/code/src/com/redhat/rhn/domain/server/Note_legacyUser.hbm.xml | 2
java/code/src/com/redhat/rhn/domain/server/ServerGroup.hbm.xml | 4
java/code/src/com/redhat/rhn/domain/server/ServerLock_legacyUser.hbm.xml | 2
java/code/src/com/redhat/rhn/domain/server/Server_legacyUser.hbm.xml | 4
java/code/src/com/redhat/rhn/domain/token/Token_legacyUser.hbm.xml | 2
java/code/src/com/redhat/rhn/domain/user/UserFactory.java | 8
java/code/src/com/redhat/rhn/domain/user/UserServerPreference.hbm.xml | 23
java/code/src/com/redhat/rhn/domain/user/UserServerPreference_legacyUser.hbm.xml | 23
java/code/src/com/redhat/rhn/domain/user/legacy/AddressImpl.hbm.xml | 32
java/code/src/com/redhat/rhn/domain/user/legacy/AddressImpl_legacyUser.hbm.xml | 32
java/code/src/com/redhat/rhn/domain/user/legacy/LegacyRhnUserImpl.java | 1187 ----------
java/code/src/com/redhat/rhn/domain/user/legacy/LegacyRhnUserImpl_legacyUser.hbm.xml | 137 -
java/code/src/com/redhat/rhn/domain/user/legacy/PersonalInfo.hbm.xml | 29
java/code/src/com/redhat/rhn/domain/user/legacy/PersonalInfo_legacyUser.hbm.xml | 29
java/code/src/com/redhat/rhn/domain/user/legacy/StateChange.hbm.xml | 31
java/code/src/com/redhat/rhn/domain/user/legacy/StateChange_legacyUser.hbm.xml | 31
java/code/src/com/redhat/rhn/domain/user/legacy/UserImpl.hbm.xml | 137 +
java/code/src/com/redhat/rhn/domain/user/legacy/UserImpl.java | 1187 ++++++++++
java/code/src/com/redhat/rhn/domain/user/legacy/UserInfo.hbm.xml | 30
java/code/src/com/redhat/rhn/domain/user/legacy/UserInfo_legacyUser.hbm.xml | 30
java/code/src/com/redhat/rhn/frontend/xmlrpc/kickstart/snippet/test/SnippetHandlerTest.java | 72
28 files changed, 1562 insertions(+), 1490 deletions(-)
New commits:
commit 02d7a5ea96e62c85dfd904890259c69b4b45fbe2
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Thu Feb 11 10:35:19 2010 -0500
adding snippet api unit tests
diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/kickstart/snippet/test/SnippetHandlerTest.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/kickstart/snippet/test/SnippetHandlerTest.java
new file mode 100644
index 0000000..a701a1a
--- /dev/null
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/kickstart/snippet/test/SnippetHandlerTest.java
@@ -0,0 +1,72 @@
+/**
+ * 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.frontend.xmlrpc.kickstart.snippet.test;
+
+import com.redhat.rhn.domain.kickstart.cobbler.CobblerSnippet;
+import com.redhat.rhn.frontend.xmlrpc.kickstart.snippet.SnippetHandler;
+import com.redhat.rhn.frontend.xmlrpc.test.BaseHandlerTestCase;
+
+import java.util.List;
+
+/**
+ * SnippetHandlerTest
+ * @version $Rev$
+ */
+public class SnippetHandlerTest extends BaseHandlerTestCase {
+
+ private SnippetHandler handler = new SnippetHandler();
+
+ public void testListAll() {
+ deleteAllSnippets();
+ assertTrue(handler.listAll(adminKey).isEmpty());
+ CobblerSnippet.createOrUpdate(true, "foo", "My foo snippet", admin.getOrg());
+ assertFalse(handler.listAll(adminKey).isEmpty());
+ }
+
+ public void testListCustom() {
+ deleteAllSnippets();
+ assertTrue(handler.listCustom(adminKey).isEmpty());
+ CobblerSnippet.createOrUpdate(true, "foo", "My foo snippet", admin.getOrg());
+ assertFalse(handler.listCustom(adminKey).isEmpty());
+ }
+
+
+ public void testCreateOrUpdate() {
+ deleteAllSnippets();
+ handler.createOrUpdate(adminKey, "foobar", "My Little foobar");
+ assertTrue(handler.listAll(adminKey).get(0).getName().equals("foobar"));
+ }
+
+ public void testDelete() {
+ deleteAllSnippets();
+ handler.createOrUpdate(adminKey, "foobar", "My Little foobar");
+ assertTrue(handler.listAll(adminKey).get(0).getName().equals("foobar"));
+ handler.delete(adminKey, "foobar");
+ assertTrue(handler.listCustom(adminKey).isEmpty());
+ }
+
+
+ private void deleteAllSnippets() {
+ List<CobblerSnippet> list = handler.listCustom(adminKey);
+ for (CobblerSnippet snip : list) {
+ snip.delete();
+ }
+ }
+
+
+
+
+
+}
commit 8caf52fd40673c284a6e41a9f27d786bec05f6d2
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Thu Feb 11 10:34:44 2010 -0500
refactoring out legacy stuff
diff --git a/java/code/src/com/redhat/rhn/common/security/acl/test/AccessTest.java b/java/code/src/com/redhat/rhn/common/security/acl/test/AccessTest.java
index 8fe686b..a361e7d 100644
--- a/java/code/src/com/redhat/rhn/common/security/acl/test/AccessTest.java
+++ b/java/code/src/com/redhat/rhn/common/security/acl/test/AccessTest.java
@@ -32,7 +32,7 @@ import com.redhat.rhn.domain.server.ServerConstants;
import com.redhat.rhn.domain.server.test.ServerFactoryTest;
import com.redhat.rhn.domain.user.User;
import com.redhat.rhn.domain.user.UserFactory;
-import com.redhat.rhn.domain.user.legacy.LegacyRhnUserImpl;
+import com.redhat.rhn.domain.user.legacy.UserImpl;
import com.redhat.rhn.testing.RhnBaseTestCase;
import com.redhat.rhn.testing.UserTestUtils;
@@ -323,7 +323,7 @@ public class AccessTest extends RhnBaseTestCase {
/**
* Override the methods in User that talk to the database
*/
- class MockUser extends LegacyRhnUserImpl {
+ class MockUser extends UserImpl {
private Set mockRoles;
public MockUser() {
diff --git a/java/code/src/com/redhat/rhn/domain/action/Action_legacyUser.hbm.xml b/java/code/src/com/redhat/rhn/domain/action/Action_legacyUser.hbm.xml
index aff608f..c8eb32f 100644
--- a/java/code/src/com/redhat/rhn/domain/action/Action_legacyUser.hbm.xml
+++ b/java/code/src/com/redhat/rhn/domain/action/Action_legacyUser.hbm.xml
@@ -26,7 +26,7 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
column="prerequisite" update="true" insert="true" cascade="all" />
<many-to-one name="schedulerUser"
- class="com.redhat.rhn.domain.user.legacy.LegacyRhnUserImpl"
+ class="com.redhat.rhn.domain.user.legacy.UserImpl"
column="scheduler" update="true" insert="true" cascade="all" />
<many-to-one name="actionType"
class="com.redhat.rhn.domain.action.ActionType"
diff --git a/java/code/src/com/redhat/rhn/domain/kickstart/KickstartSession_legacyUser.hbm.xml b/java/code/src/com/redhat/rhn/domain/kickstart/KickstartSession_legacyUser.hbm.xml
index 6087a12..9c66fb0 100644
--- a/java/code/src/com/redhat/rhn/domain/kickstart/KickstartSession_legacyUser.hbm.xml
+++ b/java/code/src/com/redhat/rhn/domain/kickstart/KickstartSession_legacyUser.hbm.xml
@@ -44,7 +44,7 @@
not-null="true"/>
<many-to-one name="user" column="scheduler" cascade="save-update"
- class="com.redhat.rhn.domain.user.legacy.LegacyRhnUserImpl"/>
+ class="com.redhat.rhn.domain.user.legacy.UserImpl"/>
<many-to-one name="action" class="com.redhat.rhn.domain.action.Action"
cascade="save-update" column="action_id"/>
diff --git a/java/code/src/com/redhat/rhn/domain/monitoring/notification/Filter_legacyUser.hbm.xml b/java/code/src/com/redhat/rhn/domain/monitoring/notification/Filter_legacyUser.hbm.xml
index 90b78ab..f2ecf6f 100644
--- a/java/code/src/com/redhat/rhn/domain/monitoring/notification/Filter_legacyUser.hbm.xml
+++ b/java/code/src/com/redhat/rhn/domain/monitoring/notification/Filter_legacyUser.hbm.xml
@@ -30,7 +30,7 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
type="long"/>
<property name="recurringFrequency" column="recurring_frequency"
type="long"/>
- <many-to-one name="user" class="com.redhat.rhn.domain.user.legacy.LegacyRhnUserImpl"
+ <many-to-one name="user" class="com.redhat.rhn.domain.user.legacy.UserImpl"
column="contact_id" update="true" insert="true" cascade="none"/>
<many-to-one name="org" column="customer_id"
class="com.redhat.rhn.domain.org.OrgImpl" outer-join="true"
diff --git a/java/code/src/com/redhat/rhn/domain/monitoring/notification/Method_legacyUser.hbm.xml b/java/code/src/com/redhat/rhn/domain/monitoring/notification/Method_legacyUser.hbm.xml
index 997dcdc..16f1e0b 100644
--- a/java/code/src/com/redhat/rhn/domain/monitoring/notification/Method_legacyUser.hbm.xml
+++ b/java/code/src/com/redhat/rhn/domain/monitoring/notification/Method_legacyUser.hbm.xml
@@ -40,7 +40,7 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
class="com.redhat.rhn.domain.monitoring.notification.MethodType"
column="method_type_id" update="true" insert="true" cascade="none"/>
<many-to-one name="user"
- class="com.redhat.rhn.domain.user.legacy.LegacyRhnUserImpl"
+ class="com.redhat.rhn.domain.user.legacy.UserImpl"
column="contact_id" update="true" insert="true" cascade="none"/>
<set name="contactGroupMembers" cascade="all-delete-orphan">
diff --git a/java/code/src/com/redhat/rhn/domain/org/CustomDataKey_legacyUser.hbm.xml b/java/code/src/com/redhat/rhn/domain/org/CustomDataKey_legacyUser.hbm.xml
index 5df5196..a7a7c91 100644
--- a/java/code/src/com/redhat/rhn/domain/org/CustomDataKey_legacyUser.hbm.xml
+++ b/java/code/src/com/redhat/rhn/domain/org/CustomDataKey_legacyUser.hbm.xml
@@ -16,8 +16,8 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
<property name="description" column="description" type="string"
length="4000" not-null="true"/>
- <many-to-one name="creator" column="created_by" class="com.redhat.rhn.domain.user.legacy.LegacyRhnUserImpl"/>
- <many-to-one name="lastModifier" column="last_modified_by" class="com.redhat.rhn.domain.user.legacy.LegacyRhnUserImpl"/>
+ <many-to-one name="creator" column="created_by" class="com.redhat.rhn.domain.user.legacy.UserImpl"/>
+ <many-to-one name="lastModifier" column="last_modified_by" class="com.redhat.rhn.domain.user.legacy.UserImpl"/>
<many-to-one name="org" column="org_id" class="com.redhat.rhn.domain.org.OrgImpl"
not-null="true"/>
diff --git a/java/code/src/com/redhat/rhn/domain/server/CustomDataValue_legacyUser.hbm.xml b/java/code/src/com/redhat/rhn/domain/server/CustomDataValue_legacyUser.hbm.xml
index a26b71b..16b160b 100644
--- a/java/code/src/com/redhat/rhn/domain/server/CustomDataValue_legacyUser.hbm.xml
+++ b/java/code/src/com/redhat/rhn/domain/server/CustomDataValue_legacyUser.hbm.xml
@@ -21,9 +21,9 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
<property name="value" column="value" type="string" length="4000"/>
<many-to-one name="creator" column="created_by"
- class="com.redhat.rhn.domain.user.legacy.LegacyRhnUserImpl"/>
+ class="com.redhat.rhn.domain.user.legacy.UserImpl"/>
<many-to-one name="lastModifier" column="last_modified_by"
- class="com.redhat.rhn.domain.user.legacy.LegacyRhnUserImpl"/>
+ class="com.redhat.rhn.domain.user.legacy.UserImpl"/>
<property name="created" column="created" type="timestamp"
insert="false" update="false"/>
diff --git a/java/code/src/com/redhat/rhn/domain/server/Note_legacyUser.hbm.xml b/java/code/src/com/redhat/rhn/domain/server/Note_legacyUser.hbm.xml
index f981073..3ef48f7 100644
--- a/java/code/src/com/redhat/rhn/domain/server/Note_legacyUser.hbm.xml
+++ b/java/code/src/com/redhat/rhn/domain/server/Note_legacyUser.hbm.xml
@@ -20,7 +20,7 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
insert="false" update="false"/>
<many-to-one name="creator"
- class="com.redhat.rhn.domain.user.legacy.LegacyRhnUserImpl"
+ class="com.redhat.rhn.domain.user.legacy.UserImpl"
column="creator"/>
<many-to-one name="server"
diff --git a/java/code/src/com/redhat/rhn/domain/server/ServerGroup.hbm.xml b/java/code/src/com/redhat/rhn/domain/server/ServerGroup.hbm.xml
index 320dc0b..6709d88 100644
--- a/java/code/src/com/redhat/rhn/domain/server/ServerGroup.hbm.xml
+++ b/java/code/src/com/redhat/rhn/domain/server/ServerGroup.hbm.xml
@@ -41,7 +41,7 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
cascade="save-update">
<key column="server_group_id"/>
<many-to-many
- class="com.redhat.rhn.domain.user.legacy.LegacyRhnUserImpl"
+ class="com.redhat.rhn.domain.user.legacy.UserImpl"
column="user_id"/>
</set>
</subclass>
@@ -101,7 +101,7 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
where
sg.id = :sgid
and sg.org_id = :org_id]]>
- <return alias="wc" class="com.redhat.rhn.domain.user.legacy.LegacyRhnUserImpl"/>
+ <return alias="wc" class="com.redhat.rhn.domain.user.legacy.UserImpl"/>
</sql-query>
diff --git a/java/code/src/com/redhat/rhn/domain/server/ServerLock_legacyUser.hbm.xml b/java/code/src/com/redhat/rhn/domain/server/ServerLock_legacyUser.hbm.xml
index ffd31d3..ce0fea9 100644
--- a/java/code/src/com/redhat/rhn/domain/server/ServerLock_legacyUser.hbm.xml
+++ b/java/code/src/com/redhat/rhn/domain/server/ServerLock_legacyUser.hbm.xml
@@ -16,7 +16,7 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
constrained="true"/>
<many-to-one name="locker"
column="LOCKER_ID"
- class="com.redhat.rhn.domain.user.legacy.LegacyRhnUserImpl" />
+ class="com.redhat.rhn.domain.user.legacy.UserImpl" />
<property name="reason" column="REASON" type="string" length="4000" />
<property name="created" column="CREATED" not-null="true" type="timestamp" insert="false" update="false"/>
</class>
diff --git a/java/code/src/com/redhat/rhn/domain/server/Server_legacyUser.hbm.xml b/java/code/src/com/redhat/rhn/domain/server/Server_legacyUser.hbm.xml
index 1fe9135..8f804ef 100644
--- a/java/code/src/com/redhat/rhn/domain/server/Server_legacyUser.hbm.xml
+++ b/java/code/src/com/redhat/rhn/domain/server/Server_legacyUser.hbm.xml
@@ -91,7 +91,7 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
<many-to-one name="org" class="com.redhat.rhn.domain.org.OrgImpl"
column="org_id" lazy="proxy"/>
- <many-to-one name="creator" class="com.redhat.rhn.domain.user.legacy.LegacyRhnUserImpl"
+ <many-to-one name="creator" class="com.redhat.rhn.domain.user.legacy.UserImpl"
column="creator_id" lazy="proxy"/>
<many-to-one name="serverArch"
@@ -227,7 +227,7 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
s.id = :sid
and s.org_id = :org_id
]]>
- <return alias="wc" class="com.redhat.rhn.domain.user.legacy.LegacyRhnUserImpl"/>
+ <return alias="wc" class="com.redhat.rhn.domain.user.legacy.UserImpl"/>
</sql-query>
<sql-query name="Server.findUngrouped">
diff --git a/java/code/src/com/redhat/rhn/domain/token/Token_legacyUser.hbm.xml b/java/code/src/com/redhat/rhn/domain/token/Token_legacyUser.hbm.xml
index 9f7ab65..dd57c35 100644
--- a/java/code/src/com/redhat/rhn/domain/token/Token_legacyUser.hbm.xml
+++ b/java/code/src/com/redhat/rhn/domain/token/Token_legacyUser.hbm.xml
@@ -19,7 +19,7 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
column="org_id"/>
<many-to-one name="creator"
- class="com.redhat.rhn.domain.user.legacy.LegacyRhnUserImpl"
+ class="com.redhat.rhn.domain.user.legacy.UserImpl"
column="user_id"/>
<many-to-one name="server" class="com.redhat.rhn.domain.server.Server"
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 c749f57..0c82636 100644
--- a/java/code/src/com/redhat/rhn/domain/user/UserFactory.java
+++ b/java/code/src/com/redhat/rhn/domain/user/UserFactory.java
@@ -26,7 +26,7 @@ import com.redhat.rhn.domain.org.OrgFactory;
import com.redhat.rhn.domain.role.Role;
import com.redhat.rhn.domain.role.RoleFactory;
import com.redhat.rhn.domain.server.Server;
-import com.redhat.rhn.domain.user.legacy.LegacyRhnUserImpl;
+import com.redhat.rhn.domain.user.legacy.UserImpl;
import com.redhat.rhn.manager.session.SessionManager;
import org.apache.commons.lang.StringUtils;
@@ -147,7 +147,7 @@ public class UserFactory extends HibernateFactory {
* @return the user created
*/
public static User createUser() {
- return new LegacyRhnUserImpl();
+ return new UserImpl();
}
/**
@@ -175,7 +175,7 @@ public class UserFactory extends HibernateFactory {
*/
public static User lookupById(Long id) {
Session session = HibernateFactory.getSession();
- User u = (User)session.get(LegacyRhnUserImpl.class, id);
+ User u = (User)session.get(UserImpl.class, id);
return u;
}
@@ -458,7 +458,7 @@ public class UserFactory extends HibernateFactory {
protected void syncUserPerms(User usr) {
// Here we are replacing the functionality in add/remove_from_usergroup
// and update_perms_for_user stored procedures
- LegacyRhnUserImpl uimpl = (LegacyRhnUserImpl) usr;
+ UserImpl uimpl = (UserImpl) usr;
boolean orgAdminChanged = false;
Boolean wasOrgAdmin = uimpl.wasOrgAdmin();
diff --git a/java/code/src/com/redhat/rhn/domain/user/UserServerPreference.hbm.xml b/java/code/src/com/redhat/rhn/domain/user/UserServerPreference.hbm.xml
new file mode 100644
index 0000000..507710c
--- /dev/null
+++ b/java/code/src/com/redhat/rhn/domain/user/UserServerPreference.hbm.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE hibernate-mapping
+PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping>
+ <class name="com.redhat.rhn.domain.user.UserServerPreference"
+ table="rhnUserServerprefs" >
+ <composite-id name="id" class="com.redhat.rhn.domain.user.UserServerPreferenceId">
+ <meta attribute="scope-set">protected</meta>
+ <key-property name="name"
+ column="name"/>
+ <key-many-to-one name="user"
+ class="com.redhat.rhn.domain.user.legacy.UserImpl"
+ column="user_id"/>
+ <key-many-to-one name="server"
+ class="com.redhat.rhn.domain.server.Server"
+ column="server_id" />
+ </composite-id>
+ <property name="value" column="VALUE" not-null="true" type="string" length="1" />
+ <property name="created" column="CREATED" not-null="true" type="timestamp" insert="false" update="false"/>
+ <property name="modified" column="MODIFIED" not-null="true" type="timestamp" insert="false" update="false"/>
+ </class>
+</hibernate-mapping>
diff --git a/java/code/src/com/redhat/rhn/domain/user/UserServerPreference_legacyUser.hbm.xml b/java/code/src/com/redhat/rhn/domain/user/UserServerPreference_legacyUser.hbm.xml
deleted file mode 100644
index 4ff7f01..0000000
--- a/java/code/src/com/redhat/rhn/domain/user/UserServerPreference_legacyUser.hbm.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE hibernate-mapping
-PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<hibernate-mapping>
- <class name="com.redhat.rhn.domain.user.UserServerPreference"
- table="rhnUserServerprefs" >
- <composite-id name="id" class="com.redhat.rhn.domain.user.UserServerPreferenceId">
- <meta attribute="scope-set">protected</meta>
- <key-property name="name"
- column="name"/>
- <key-many-to-one name="user"
- class="com.redhat.rhn.domain.user.legacy.LegacyRhnUserImpl"
- column="user_id"/>
- <key-many-to-one name="server"
- class="com.redhat.rhn.domain.server.Server"
- column="server_id" />
- </composite-id>
- <property name="value" column="VALUE" not-null="true" type="string" length="1" />
- <property name="created" column="CREATED" not-null="true" type="timestamp" insert="false" update="false"/>
- <property name="modified" column="MODIFIED" not-null="true" type="timestamp" insert="false" update="false"/>
- </class>
-</hibernate-mapping>
diff --git a/java/code/src/com/redhat/rhn/domain/user/legacy/AddressImpl.hbm.xml b/java/code/src/com/redhat/rhn/domain/user/legacy/AddressImpl.hbm.xml
new file mode 100644
index 0000000..87156d1
--- /dev/null
+++ b/java/code/src/com/redhat/rhn/domain/user/legacy/AddressImpl.hbm.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE hibernate-mapping
+PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping>
+ <class name="com.redhat.rhn.domain.user.AddressImpl"
+ table="WEB_USER_SITE_INFO">
+ <id name="id" type="long" column="id">
+ <meta attribute="scope-set">protected</meta>
+ <generator class="sequence">
+ <param name="sequence">WEB_USER_SITE_INFO_ID_SEQ</param>
+ </generator>
+ </id>
+ <property name="address1" column="address1" type="string" length="128" />
+ <property name="address2" column="address2" type="string" length="128" />
+ <property name="city" column="city" type="string" length="128" />
+ <property name="state" column="state" type="string" length="60" />
+ <property name="zip" column="zip" type="string" length="32" />
+ <property name="country" column="country" type="string" length="2" />
+ <property name="phone" column="phone" type="string" length="32" />
+ <property name="fax" column="fax" type="string" length="32" />
+ <property name="isPoBox" column="is_po_box" type="string" length="1" />
+ <property name="created" column="created" type="timestamp" insert="false" update="false"/>
+ <property name="modified" column="modified" type="timestamp" insert="false" update="false"/>
+ <property name="privType" column="type" type="string" length="1" />
+
+ </class>
+ <query name="Address.findById">
+ <![CDATA[from com.redhat.rhn.domain.user.AddressImpl as a where a.id = :id]]>
+ </query>
+
+</hibernate-mapping>
diff --git a/java/code/src/com/redhat/rhn/domain/user/legacy/AddressImpl_legacyUser.hbm.xml b/java/code/src/com/redhat/rhn/domain/user/legacy/AddressImpl_legacyUser.hbm.xml
deleted file mode 100644
index 87156d1..0000000
--- a/java/code/src/com/redhat/rhn/domain/user/legacy/AddressImpl_legacyUser.hbm.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE hibernate-mapping
-PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<hibernate-mapping>
- <class name="com.redhat.rhn.domain.user.AddressImpl"
- table="WEB_USER_SITE_INFO">
- <id name="id" type="long" column="id">
- <meta attribute="scope-set">protected</meta>
- <generator class="sequence">
- <param name="sequence">WEB_USER_SITE_INFO_ID_SEQ</param>
- </generator>
- </id>
- <property name="address1" column="address1" type="string" length="128" />
- <property name="address2" column="address2" type="string" length="128" />
- <property name="city" column="city" type="string" length="128" />
- <property name="state" column="state" type="string" length="60" />
- <property name="zip" column="zip" type="string" length="32" />
- <property name="country" column="country" type="string" length="2" />
- <property name="phone" column="phone" type="string" length="32" />
- <property name="fax" column="fax" type="string" length="32" />
- <property name="isPoBox" column="is_po_box" type="string" length="1" />
- <property name="created" column="created" type="timestamp" insert="false" update="false"/>
- <property name="modified" column="modified" type="timestamp" insert="false" update="false"/>
- <property name="privType" column="type" type="string" length="1" />
-
- </class>
- <query name="Address.findById">
- <![CDATA[from com.redhat.rhn.domain.user.AddressImpl as a where a.id = :id]]>
- </query>
-
-</hibernate-mapping>
diff --git a/java/code/src/com/redhat/rhn/domain/user/legacy/LegacyRhnUserImpl.java b/java/code/src/com/redhat/rhn/domain/user/legacy/LegacyRhnUserImpl.java
deleted file mode 100644
index edc4a82..0000000
--- a/java/code/src/com/redhat/rhn/domain/user/legacy/LegacyRhnUserImpl.java
+++ /dev/null
@@ -1,1187 +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.domain.user.legacy;
-
-import com.redhat.rhn.common.conf.Config;
-import com.redhat.rhn.common.conf.ConfigDefaults;
-import com.redhat.rhn.common.localization.LocalizationService;
-import com.redhat.rhn.common.util.MD5Crypt;
-import com.redhat.rhn.domain.BaseDomainHelper;
-import com.redhat.rhn.domain.org.Org;
-import com.redhat.rhn.domain.org.usergroup.UserGroup;
-import com.redhat.rhn.domain.role.Role;
-import com.redhat.rhn.domain.role.RoleFactory;
-import com.redhat.rhn.domain.server.Server;
-import com.redhat.rhn.domain.user.Address;
-import com.redhat.rhn.domain.user.EnterpriseUser;
-import com.redhat.rhn.domain.user.RhnTimeZone;
-import com.redhat.rhn.domain.user.StateChange;
-import com.redhat.rhn.domain.user.User;
-import com.redhat.rhn.domain.user.UserFactory;
-import com.redhat.rhn.manager.user.UserManager;
-
-import net.sf.jpam.Pam;
-import net.sf.jpam.PamReturnValue;
-
-import org.apache.commons.lang.builder.EqualsBuilder;
-import org.apache.commons.lang.builder.HashCodeBuilder;
-import org.apache.log4j.Logger;
-
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.TreeSet;
-
-/**
- * Class UserImpl that reflects the DB representation of web_contact
- * and ancillary tables.
- * DB table: web_contact
- * @version $Rev: 75755 $
- */
-public class LegacyRhnUserImpl extends BaseDomainHelper implements User {
-
-
- private static final Logger LOG = Logger.getLogger(LegacyRhnUserImpl.class);
-
- //private Address address;
- private EnterpriseUserImpl euser;
- private Long id;
- private String login;
- private String loginUc;
- private String password;
- private Set usergroups;
- private Org org;
- private Set stateChanges;
- private Set addresses;
- private Set hiddenPanes;
- private Set associatedServerGroups;
- private Set<Server> servers;
- // PersonalInfo sub-object object
- private PersonalInfo personalInfo;
- // UserInfo sub-object
- private UserInfo userInfo;
-
- // Keep track of whether the user used to be an org admin
- private Boolean wasOrgAdmin;
-
- // Set of com.redhat.rhn.monitoring.notification.Method instances
- private Set notificationMethods;
-
- /**
- * Create a new empty user
- */
- public LegacyRhnUserImpl() {
- usergroups = new HashSet();
- personalInfo = new PersonalInfo();
- personalInfo.setUser(this);
- userInfo = new UserInfo();
- userInfo.setUser(this);
- stateChanges = new TreeSet();
- addresses = new HashSet();
- hiddenPanes = new HashSet();
- associatedServerGroups = new HashSet();
- }
-
- /**
- * Gets the current value of id
- * @return long the current value
- */
- public Long getId() {
- return this.id;
- }
-
- /**
- * Sets the value of id to new value
- * @param idIn New value for id
- */
- public void setId(Long idIn) {
- this.id = idIn;
- }
-
- /**
- * Gets the current value of login
- * @return String the current value
- */
- public String getLogin() {
- return this.login;
- }
-
- /**
- * Sets the value of login to new value
- * @param loginIn New value for login
- */
- public void setLogin(String loginIn) {
- this.login = loginIn;
- setLoginUc(loginIn.toUpperCase());
- }
-
- /**
- * Gets the current value of loginUc
- * @return String the current value
- */
- public String getLoginUc() {
- return this.loginUc;
- }
-
- /**
- * Sets the value of loginUc to new value
- * @param loginUcIn New value for loginUc
- */
- public void setLoginUc(String loginUcIn) {
- this.loginUc = loginUcIn;
- }
-
- /**
- * Gets the current value of password
- * @return String the current value
- */
- public String getPassword() {
- return this.password;
- }
-
- /**
- * Sets the value of password to new value
- * @param passwordIn New value for password
- */
- public void setPassword(String passwordIn) {
- /**
- * If we're using encrypted passwords, encode the
- * password before setting it. Otherwise, just
- * set it.
- */
- if (Config.get().getBoolean(ConfigDefaults.WEB_ENCRYPTED_PASSWORDS)) {
- this.password = MD5Crypt.crypt(passwordIn);
- }
- else {
- this.password = passwordIn;
- }
- }
-
- /**
- * Set the usergroup set
- * @param ugIn The new Set of UserGroups to set
- */
- protected void setUsergroups(Set ugIn) {
- usergroups = ugIn;
- }
-
- /** get the set of usergroups
- * @return Set of UserGroups
- */
- protected Set getUsergroups() {
- return usergroups;
- }
-
- /** {@inheritDoc} */
- public Set getRoles() {
- Set userRoles = new HashSet();
- for (Iterator i = usergroups.iterator(); i.hasNext();) {
- UserGroup ug = (UserGroup)i.next();
- userRoles.add(ug.getRole());
- }
-
- if (userRoles.contains(RoleFactory.ORG_ADMIN)) {
- Set orgRoles = org.getRoles();
- Set localImplied = new HashSet();
- localImplied.addAll(UserFactory.IMPLIEDROLES);
- localImplied.retainAll(orgRoles);
- userRoles.addAll(localImplied);
- }
- return Collections.unmodifiableSet(userRoles);
- }
-
- /** {@inheritDoc} */
- public boolean hasRole(Role label) {
- // We use checkRoleSet to get the correct logic for the
- // implied roles.
- return getRoles().contains(label);
- }
-
- /** {@inheritDoc} */
- public void addRole(Role label) {
- checkOrgAdmin();
- UserGroup ug = org.getUserGroup(label);
- if (ug != null) {
- usergroups.add(ug);
- }
- else {
- throw new IllegalArgumentException("Org doesn't have role: " + label);
- }
- }
-
-
- /** {@inheritDoc} */
- public void removeRole(Role label) {
- checkOrgAdmin();
- UserGroup ug = org.getUserGroup(label);
- if (ug != null) {
- usergroups.remove(ug);
- }
- }
-
- /**
- * Determine if this was org admin.
- * @return Boolean
- */
- public Boolean wasOrgAdmin() {
- return wasOrgAdmin;
- }
-
- /**
- * Reset the wasOrgAdmin value.
- */
- public void resetWasOrgAdmin() {
- wasOrgAdmin = null;
- }
-
- private void checkOrgAdmin() {
- if (wasOrgAdmin == null) {
- wasOrgAdmin = Boolean.valueOf(hasRole(RoleFactory.ORG_ADMIN));
- }
- }
-
- /** {@inheritDoc} */
- public boolean authenticate(String thePassword) {
- String pamAuthService = Config.get().getString(ConfigDefaults.WEB_PAM_AUTH_SERVICE);
- boolean result = false;
- /*
- * If we have a valid pamAuthService and the user uses pam authentication,
- * authenticate via pam, otherwise, use the db.
- */
- if (pamAuthService != null && pamAuthService.trim().length() > 0 &&
- this.getUsePamAuthentication()) {
- Pam pam = new Pam(pamAuthService);
- PamReturnValue ret = pam.authenticate(getLogin(), thePassword);
- result = PamReturnValue.PAM_SUCCESS.equals(ret);
- if (!result) {
- LOG.warn("PAM login for user " + this + " failed with error " + ret);
- }
- }
- else {
- /**
- * If we're using encrypted passwords, check
- * thePassword encrypted, otherwise just do
- * a straight clear-text comparison.
- */
- boolean useEncrPasswds =
- Config.get().getBoolean(ConfigDefaults.WEB_ENCRYPTED_PASSWORDS);
- if (useEncrPasswds) {
- result = MD5Crypt.crypt(thePassword, password).equals(password);
- }
- else {
- result = password.equals(thePassword);
- }
- if (LOG.isDebugEnabled() && !useEncrPasswds) {
- String encr = useEncrPasswds ? "with" : "without";
- LOG.debug("DB login for user " + this + " " +
- encr + " encrypted passwords failed");
- }
- }
- if (LOG.isDebugEnabled() && result) {
- LOG.debug("PAM login for user " + this + " succeeded. ");
- }
- return result;
- }
-
- /**
- * Associates the user with an Org.
- * @param orgIn Org to be associated to this user.
- */
- public void setOrg(Org orgIn) {
- org = orgIn;
- }
-
- /** {@inheritDoc} */
- public Org getOrg() {
- return org;
- }
-
- /** {@inheritDoc} */
- public Set getDefaultSystemGroupIds() {
- return UserManager.getDefaultSystemGroupIds(this);
- }
-
- /** {@inheritDoc} */
- public void setDefaultSystemGroupIds(Set dsg) {
- UserManager.setDefaultSystemGroupIds(this, dsg);
- }
-
- /**
- * Return the PersonalInfo object
- * @return PersonalInfo object associated with this User
- */
- protected PersonalInfo getPersonalInfo() {
- if (personalInfo == null) {
- personalInfo = new PersonalInfo();
- }
- return personalInfo;
- }
-
- /**
- * Set the PersonalInfo object
- * @param persIn the PersonalInfo object
- */
- protected void setPersonalInfo(PersonalInfo persIn) {
- this.personalInfo = persIn;
- }
-
- /**
- * Set the UserInfo object
- * @param infoIn the UserInfo object
- */
- protected void setUserInfo(UserInfo infoIn) {
- this.userInfo = infoIn;
- }
-
- /**
- * Get the UserInfo sub object
- * @return UserInfo
- */
- public UserInfo getUserInfo() {
- return this.userInfo;
- }
-
-
- /**
- * Convenience method to determine whether a user is disabled
- * or not
- * @return Returns true if the user is disabled
- */
- public boolean isDisabled() {
- return UserFactory.isDisabled(this);
- }
-
- /**
- * {@inheritDoc}
- */
- public void addChange(StateChange change) {
- this.stateChanges.add(change);
- }
-
- /**
- * {@inheritDoc}
- */
- public Set getStateChanges() {
- return stateChanges;
- }
-
- /**
- * @param s The stateChanges to set.
- */
- public void setStateChanges(Set s) {
- this.stateChanges = s;
- }
-
- /************* UserInfo methods **************/
- /** {@inheritDoc} */
- public int getPageSize() {
- return this.userInfo.getPageSize();
- }
-
- /** {@inheritDoc} */
- public void setPageSize(int pageSizeIn) {
- this.userInfo.setPageSize(pageSizeIn);
- }
-
- /** {@inheritDoc} */
- public boolean getUsePamAuthentication() {
- return this.userInfo.getUsePamAuthentication();
- }
-
- /** {@inheritDoc} */
- public void setUsePamAuthentication(boolean usePamAuthenticationIn) {
- this.userInfo.setUsePamAuthentication(usePamAuthenticationIn);
- }
-
- /** {@inheritDoc} */
- public String getShowSystemGroupList() {
- return this.userInfo.getShowSystemGroupList();
- }
-
- /** {@inheritDoc} */
- public void setShowSystemGroupList(String showSystemGroupListIn) {
- this.userInfo.setShowSystemGroupList(showSystemGroupListIn);
- }
-
- /** {@inheritDoc} */
- public Date getLastLoggedIn() {
- return this.userInfo.getLastLoggedIn();
- }
-
- /** {@inheritDoc} */
- public void setLastLoggedIn(Date lastLoggedInIn) {
- this.userInfo.setLastLoggedIn(lastLoggedInIn);
- }
-
- /** {@inheritDoc} */
- public void setPreferredLocale(String locale) {
- this.userInfo.setPreferredLocale(locale);
- }
-
- /** {@inheritDoc} */
- public String getPreferredLocale() {
- return this.userInfo.getPreferredLocale();
- }
-
- /********* PersonalInfo Methods **********/
-
- /**
- * Gets the current value of prefix
- * @return String the current value
- */
- public String getPrefix() {
- return this.personalInfo.getPrefix();
- }
-
- /**
- * Sets the value of prefix to new value
- * @param prefixIn New value for prefix
- */
- public void setPrefix(String prefixIn) {
- this.personalInfo.setPrefix(prefixIn);
- }
-
- /**
- * Gets the current value of firstNames
- * @return String the current value
- */
- public String getFirstNames() {
- return this.personalInfo.getFirstNames();
- }
-
- /**
- * Sets the value of firstNames to new value
- * @param firstNamesIn New value for firstNames
- */
- public void setFirstNames(String firstNamesIn) {
- this.personalInfo.setFirstNames(firstNamesIn);
- }
-
- /**
- * Gets the current value of lastName
- * @return String the current value
- */
- public String getLastName() {
- return this.personalInfo.getLastName();
- }
-
- /**
- * Sets the value of lastName to new value
- * @param lastNameIn New value for lastName
- */
- public void setLastName(String lastNameIn) {
- this.personalInfo.setLastName(lastNameIn);
- }
-
- /**
- * Gets the current value of company
- * @return String the current value
- */
- public String getCompany() {
- return this.personalInfo.getCompany();
- }
-
- /**
- * Sets the value of company to new value
- * @param companyIn New value for company
- */
- public void setCompany(String companyIn) {
- this.personalInfo.setCompany(companyIn);
- }
-
- /**
- * Gets the current value of title
- * @return String the current value
- */
- public String getTitle() {
- return this.personalInfo.getTitle();
- }
-
- /**
- * Sets the value of title to new value
- * @param titleIn New value for title
- */
- public void setTitle(String titleIn) {
- this.personalInfo.setTitle(titleIn);
- }
-
- /**
- * Gets the current value of phone
- * @return String the current value
- */
- public String getPhone() {
- return getAddress().getPhone();
- }
-
- /**
- * Sets the value of phone to new value
- * @param phoneIn New value for phone
- */
- public void setPhone(String phoneIn) {
- getAddress().setPhone(phoneIn);
- }
-
- /**
- * Gets the current value of fax
- * @return String the current value
- */
- public String getFax() {
- return getAddress().getFax();
- }
-
- /**
- * Sets the value of fax to new value
- * @param faxIn New value for fax
- */
- public void setFax(String faxIn) {
- getAddress().setFax(faxIn);
- }
-
- /**
- * Gets the current value of email
- * @return String the current value
- */
- public String getEmail() {
- return this.personalInfo.getEmail();
- }
-
- /**
- * Sets the value of email to new value
- * @param emailIn New value for email
- */
- public void setEmail(String emailIn) {
- this.personalInfo.setEmail(emailIn);
- }
-
-
- /** {@inheritDoc} */
- public RhnTimeZone getTimeZone() {
- return this.userInfo.getTimeZone();
- }
-
- /** {@inheritDoc} */
- public void setTimeZone(RhnTimeZone timeZoneIn) {
- this.userInfo.setTimeZone(timeZoneIn);
- }
-
- /**
- * {@inheritDoc}
- */
- public Set getNotificationMethods() {
- return this.notificationMethods;
- }
-
- /**
- * {@inheritDoc}
- */
- public void setNotificationMethods(Set methodsIn) {
- this.notificationMethods = methodsIn;
- }
-
-
-
-
- /**
- * Output User to String for debugging
- * @return String output of the User
- */
- public String toString() {
- StringBuffer retval = new StringBuffer();
- retval.append(LocalizationService.getInstance().
- getDebugMessage("user"));
- retval.append(" ");
- retval.append(getLogin());
- retval.append(" (id ");
- retval.append(String.valueOf(getId()));
- retval.append(", org_id ");
- retval.append(String.valueOf(getOrg().getId()));
- retval.append(")");
- return retval.toString();
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean equals(Object other) {
- if (other == null || !(other instanceof User)) {
- return false;
- }
- User otherUser = (User) other;
- return new EqualsBuilder().append(login, otherUser.getLogin())
- .append(org, otherUser.getOrg())
- .append(id, otherUser.getId())
- .isEquals();
- }
-
- /**
- * {@inheritDoc}
- */
- public int hashCode() {
- return new HashCodeBuilder().append(login).append(org).append(id).toHashCode();
- }
-
- /**
- * Getter for address1
- * @return Address1
- */
- public String getAddress1() {
- return getAddress().getAddress1();
- }
-
- /**
- * Setter for address1
- * @param address1In New value for address1
- */
- public void setAddress1(String address1In) {
- getAddress().setAddress1(address1In);
- }
-
- /**
- * Getter for address2
- * @return Address2
- */
- public String getAddress2() {
- return getAddress().getAddress2();
- }
-
- /**
- * Setter for address2
- * @param address2In New value for address2
- */
- public void setAddress2(String address2In) {
- getAddress().setAddress2(address2In);
- }
-
- /**
- * Getter for city
- * @return City
- */
- public String getCity() {
- return getAddress().getCity();
- }
-
- /**
- * Setter for city
- * @param cityIn New value for city
- */
- public void setCity(String cityIn) {
- getAddress().setCity(cityIn);
- }
-
- /**
- * Getter for state
- * @return State
- */
- public String getState() {
- return getAddress().getState();
- }
-
- /**
- * Setter for state
- * @param stateIn New value for state
- */
- public void setState(String stateIn) {
- getAddress().setState(stateIn);
- }
-
- /**
- * Getter for zip
- * @return Zip
- */
- public String getZip() {
- return getAddress().getZip();
- }
-
- /**
- * Setter for zip
- * @param zipIn New value for zip
- */
- public void setZip(String zipIn) {
- getAddress().setZip(zipIn);
- }
-
- /**
- * Getter for country
- * @return Country
- */
- public String getCountry() {
- return getAddress().getCountry();
- }
-
- /**
- * Setter for country
- * @param countryIn New value for country
- */
- public void setCountry(String countryIn) {
- getAddress().setCountry(countryIn);
- }
-
-
- /**
- * Getter for isPoBox
- * @return isPoBox
- */
- public String getIsPoBox() {
- return getAddress().getIsPoBox();
- }
-
- /**
- * Setter for isPoBox
- * @param isPoBoxIn New value for isPoBox
- */
- public void setIsPoBox(String isPoBoxIn) {
- getAddress().setIsPoBox(isPoBoxIn);
- }
-
- /**
- * {@inheritDoc}
- */
- public EnterpriseUser getEnterpriseUser() {
- if (euser == null) {
- euser = new EnterpriseUserImpl();
- }
- return euser;
- }
-
- /**
- * {@inheritDoc}
- */
- public Set getHiddenPanes() {
- return hiddenPanes;
- }
-
- /**
- * {@inheritDoc}
- */
- public void setHiddenPanes(Set p) {
- hiddenPanes = p;
- }
-
- protected void setAddress(Address addIn) {
- addresses.clear();
- addresses.add(addIn);
- }
-
- protected Address getAddress() {
- Address baddr = null;
- Address addr = null;
- Address[] addrA = (Address[]) addresses.toArray(new Address[addresses.size()]);
- if (addresses.size() > 0) {
- for (int i = 0; i < addrA.length; i++) {
- if (addrA[i].getType().equals(Address.TYPE_MARKETING)) {
- addr = addrA[i];
- }
- if (addrA[i].getType().equals("B")) {
- baddr = addrA[i];
- }
- }
- }
- if (addr == null) {
- addr = UserFactory.createAddress();
- if (baddr != null) {
- addr.setAddress1(baddr.getAddress1());
- addr.setAddress2(baddr.getAddress2());
- addr.setCity(baddr.getCity());
- addr.setCountry(baddr.getCountry());
- addr.setFax(baddr.getFax());
- addr.setIsPoBox(baddr.getIsPoBox());
- addr.setPhone(baddr.getPhone());
- addr.setState(baddr.getState());
- addr.setZip(baddr.getZip());
- }
- addresses.add(addr);
- }
- return addr;
- }
-
- /**
- * Set the addresses.
- * @param s the set
- */
- protected void setAddresses(Set s) {
- addresses = s;
- }
-
- /**
- * Get the addresses
- * @return Set of addresses
- */
- protected Set getAddresses() {
- return addresses;
- }
-
- /**
- * Default POJO imple of EnterpriseUser done as an internal
- * class to facilitate compatibility between hosted/sat.
- * EnterpriseUserImpl
- * @version $Rev$
- */
- class EnterpriseUserImpl extends BaseDomainHelper
- implements EnterpriseUser {
-
- /**
- * Default constructor
- *
- */
- protected EnterpriseUserImpl() {
- }
-
- /**
- * Gets the current value of id
- * @return long the current value
- */
- public Long getId() {
- return id;
- }
-
- /**
- * Sets the value of id to new value
- * @param idIn New value for id
- */
- public void setId(Long idIn) {
- }
-
- /**
- * Add a User to this instance.
- *
- * @param u a User to add
- */
- public void addUser(User u) {
- }
-
- /**
- * Remove a User from this instance.
- *
- * @param u the User to remove
- */
- public void removeUser(User u) {
- }
-
- /**
- * Return an iterator over all Users associated with
- * this instance.
- *
- * @return Iterator an iterator over all users
- */
- public Iterator allUsers() {
- return null;
- }
-
- /**
- * Find the user having the id provided. Return null if
- * not found.
- * @param idIn id to use
- * @return User or null
- */
- public User findUserById(Long idIn) {
- return null;
- }
-
- /**
- * Gets the current value of login
- * @return String the current value
- */
- public String getLogin() {
- return login;
- }
-
- /**
- * Sets the value of login to new value
- * @param loginIn New value for login
- */
- public void setLogin(String loginIn) {
- login = loginIn;
- }
-
- /**
- * Gets the current value of password
- * @return String the current value
- */
- public String getPassword() {
- return password;
- }
-
- /**
- * Sets the value of password to new value
- * @param passwordIn New value for password
- */
- public void setPassword(String passwordIn) {
- /**
- * If we're using encrypted passwords, encode the
- * password before setting it. Otherwise, just
- * set it.
- */
- if (Config.get().getBoolean(ConfigDefaults.WEB_ENCRYPTED_PASSWORDS)) {
- password = MD5Crypt.crypt(passwordIn);
- }
- else {
- password = passwordIn;
- }
- }
-
- /**
- * Gets the current value of prefix
- * @return String the current value
- */
- public String getPrefix() {
- return personalInfo.getPrefix();
- }
-
- /**
- * Sets the value of prefix to new value
- * @param prefixIn New value for prefix
- */
- public void setPrefix(String prefixIn) {
- personalInfo.setPrefix(prefixIn);
- }
-
- /**
- * Gets the current value of firstNames
- * @return String the current value
- */
- public String getFirstNames() {
- return personalInfo.getFirstNames();
- }
-
- /**
- * Sets the value of firstNames to new value
- * @param firstNamesIn New value for firstNames
- */
- public void setFirstNames(String firstNamesIn) {
- personalInfo.setFirstNames(firstNamesIn);
- }
-
- /**
- * Gets the current value of lastName
- * @return String the current value
- */
- public String getLastName() {
- return personalInfo.getLastName();
- }
-
- /**
- * Sets the value of lastName to new value
- * @param lastNameIn New value for lastName
- */
- public void setLastName(String lastNameIn) {
- personalInfo.setLastName(lastNameIn);
- }
-
- /**
- * Gets the current value of title
- * @return String the current value
- */
- public String getTitle() {
- return personalInfo.getTitle();
- }
-
- /**
- * Sets the value of title to new value
- * @param titleIn New value for title
- */
- public void setTitle(String titleIn) {
- personalInfo.setTitle(titleIn);
- }
-
- /**
- * Gets the current value of email
- * @return String the current value
- */
- public String getEmail() {
- return personalInfo.getEmail();
- }
-
- /**
- * Sets the value of email to new value
- * @param emailIn New value for email
- */
- public void setEmail(String emailIn) {
- personalInfo.setEmail(emailIn);
- }
-
- /**
- * Getter for lastLoggedIn
- * @return lastLoggedIn
- */
- public Date getLastLoggedIn() {
- return userInfo.getLastLoggedIn();
- }
-
- /**
- * Setter for lastLoggedIn
- * @param lastLoggedInIn New value for lastLoggedIn
- */
- public void setLastLoggedIn(Date lastLoggedInIn) {
- userInfo.setLastLoggedIn(lastLoggedInIn);
- }
-
- /**
- * @inheritDoc
- * @param modifiedIn the modified date
- */
- public void setModified(Date modifiedIn) {
- }
-
- /**
- * @inheritDoc
- * @return date modified
- */
- public Date getModified() {
- return null;
- }
-
- /**
- * @inheritDoc
- * @param createdIn date created in
- */
- public void setCreated(Date createdIn) {
- }
-
- /**
- * @inheritDoc
- * @return date was created
- */
- public Date getCreated() {
- return null;
- }
-
- /**
- * @return Returns the timeZone.
- */
- public RhnTimeZone getTimeZone() {
- return userInfo.getTimeZone();
- }
- /**
- * @param timeZoneIn The timeZone to set.
- */
- public void setTimeZone(RhnTimeZone timeZoneIn) {
- userInfo.setTimeZone(timeZoneIn);
- }
-
- /**
- * Set the address of this enterprise user.
- * @param addressIn the address to set
- */
- public void setAddress(Address addressIn) {
- addresses.clear();
- addresses.add(addressIn);
- }
-
- /**
- *
- * @return returns the address info
- */
- public Address getAddress() {
- Address baddr = null;
- Address addr = null;
- Address[] addrA = (Address[]) addresses.toArray(new Address[addresses.size()]);
- if (addresses.size() > 0) {
- for (int i = 0; i < addrA.length; i++) {
- if (addrA[i].getType().equals(Address.TYPE_MARKETING)) {
- addr = addrA[i];
- }
- if (addrA[i].getType().equals("B")) {
- baddr = addrA[i];
- }
- }
- }
- if (addr == null) {
- addr = UserFactory.createAddress();
- if (baddr != null) {
- addr.setAddress1(baddr.getAddress1());
- addr.setAddress2(baddr.getAddress2());
- addr.setCity(baddr.getCity());
- addr.setCountry(baddr.getCountry());
- addr.setFax(baddr.getFax());
- addr.setIsPoBox(baddr.getIsPoBox());
- addr.setPhone(baddr.getPhone());
- addr.setState(baddr.getState());
- addr.setZip(baddr.getZip());
- }
- addresses.add(addr);
- }
- return addr;
- }
-
-
-
- /**
- *
- * @param companyIn the company value
- */
- public void setCompany(String companyIn) {
- personalInfo.setCompany(companyIn);
- }
-
- /**
- *
- * @return returns the company value
- */
- public String getCompany() {
- return personalInfo.getCompany();
- }
- }
-
- /** {@inheritDoc} */
- public void setEmailNotify(int emailNotifyIn) {
- this.userInfo.setEmailNotify(emailNotifyIn);
- }
-
- /** {@inheritDoc} */
- public int getEmailNotify() {
- return this.userInfo.getEmailNotify();
- }
-
- /**
- *
- * {@inheritDoc}
- */
- public Set getAssociatedServerGroups() {
- return associatedServerGroups;
- }
-
- /**
- * Sets the associatedServerGroups..
- * Meant for use by hibernate only (hence protected)
- * @param serverGroups the servergroups to set.
- */
- protected void setAssociatedServerGroups(Set serverGroups) {
- associatedServerGroups = serverGroups;
- }
-
- /** {@inheritDoc} */
- public Set<Server> getServers() {
- return servers;
- }
-
- private void setServers(Set<Server> serversIn) {
- this.servers = serversIn;
- }
-
- /** {@inheritDoc} */
- public void addServer(Server server) {
- servers.add(server);
- }
-
- /** {@inheritDoc} */
- public void removeServer(Server server) {
- servers.remove(server);
- }
-}
-
-
diff --git a/java/code/src/com/redhat/rhn/domain/user/legacy/LegacyRhnUserImpl_legacyUser.hbm.xml b/java/code/src/com/redhat/rhn/domain/user/legacy/LegacyRhnUserImpl_legacyUser.hbm.xml
deleted file mode 100644
index 7f74818..0000000
--- a/java/code/src/com/redhat/rhn/domain/user/legacy/LegacyRhnUserImpl_legacyUser.hbm.xml
+++ /dev/null
@@ -1,137 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE hibernate-mapping
-PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<hibernate-mapping>
- <class name="com.redhat.rhn.domain.user.legacy.LegacyRhnUserImpl"
- table="WEB_CONTACT">
- <id name="id" type="long" column="id">
- <meta attribute="scope-set">protected</meta>
- <generator class="sequence">
- <param name="sequence">WEB_CONTACT_ID_SEQ</param>
- </generator>
- </id>
- <property name="login" column="login" type="string" length="64" />
- <property name="loginUc" column="login_uc" type="string" length="64" />
- <!-- Make sure we set access=field on password, since the setPassword method of
- UserImpl encodes the password every time -->
- <property name="password" column="password" type="string" length="38" access="field" />
-
- <property name="created" column="created" type="timestamp"
- insert="false" update="false"/>
- <property name="modified" column="modified" type="timestamp"
- insert="false" update="false"/>
- <one-to-one name="personalInfo"
- class="com.redhat.rhn.domain.user.legacy.PersonalInfo"
- outer-join="true"
- cascade="all"
- constrained="true" />
- <one-to-one name="userInfo"
- class="com.redhat.rhn.domain.user.legacy.UserInfo"
- outer-join="true"
- cascade="all"
- constrained="true" />
- <many-to-one name="org"
- column="org_id"
- class="com.redhat.rhn.domain.org.OrgImpl"
- outer-join="true"
- not-null="true" />
- <set name="addresses" cascade="all">
- <key column="web_user_id"/>
- <one-to-many class="com.redhat.rhn.domain.user.AddressImpl" />
- </set>
- <set name="usergroups" outer-join="false" table="rhnUserGroupMembers">
- <key column="user_id" />
- <many-to-many column="user_group_id" outer-join="false"
- class="com.redhat.rhn.domain.org.usergroup.UserGroupImpl" />
- </set>
- <set name="notificationMethods" table="rhn_contact_methods" lazy="true"
- inverse="true" cascade="none">
- <key column="contact_id" />
- <one-to-many class="com.redhat.rhn.domain.monitoring.notification.Method"/>
- </set>
- <set name="stateChanges" lazy="true"
- cascade="save-update" sort="natural">
- <key column="web_contact_id"/>
- <one-to-many class="com.redhat.rhn.domain.user.StateChange" />
- </set>
- <set name = "hiddenPanes"
- table="RHNUSERINFOPANE"
- lazy="true"
- cascade="all">
- <key column="user_id"/>
- <many-to-many class ="com.redhat.rhn.domain.user.Pane" column="pane_id"/>
- </set>
- <set name="associatedServerGroups" lazy="true" table="rhnUserServerGroupPerms"
- cascade="save-update" inverse="true">
- <key column="user_id"/>
- <many-to-many
- class="com.redhat.rhn.domain.server.ServerGroup"
- column="server_group_id"
- />
- </set>
-
- <set name="servers" lazy="true" table="rhnUserServerPerms" cascade="all">
- <key column="user_id"/>
- <many-to-many class="com.redhat.rhn.domain.server.Server" column="server_id"/>
- </set>
-
- </class>
-
- <query name="User.findByLogin">
- <![CDATA[from com.redhat.rhn.domain.user.legacy.LegacyRhnUserImpl as u where u.loginUc = :loginUc]]>
- </query>
- <query name="User.findByLoginAndOrgId">
- <![CDATA[from com.redhat.rhn.domain.user.legacy.LegacyRhnUserImpl as u where u.loginUc = :loginUc and org_id = :orgId]]>
- </query>
- <query name="User.findByIdandOrgId">
- <![CDATA[from com.redhat.rhn.domain.user.legacy.LegacyRhnUserImpl as u where u.id = :uid and org_id = :orgId]]>
- </query>
- <query name="User.findByIds">
- <![CDATA[from com.redhat.rhn.domain.user.legacy.LegacyRhnUserImpl as u where u.id in (:userIds)]]>
- </query>
- <query name="User.findAllUsers">
- <![CDATA[from com.redhat.rhn.domain.user.legacy.LegacyRhnUserImpl]]>
- </query>
-
- <query name="User.findAllUsersByOrg">
- <![CDATA[from com.redhat.rhn.domain.user.legacy.LegacyRhnUserImpl as u where org_id = :org_id]]>
- </query>
-
- <query name="User.findAllOrgAdmins">
- <![CDATA[
- select u
- from com.redhat.rhn.domain.user.legacy.LegacyRhnUserImpl as u
- where exists (
- from com.redhat.rhn.domain.org.usergroup.UserGroupImpl as ug
- where ug.orgId = :org_id and
- ug.role.label = 'org_admin' and
- ug in elements(u.usergroups))
- ]]>
- </query>
- <sql-query name="User.findRandomOrgAdmin">
- <return-scalar type="long" column="user_id"/>
- SELECT ugm.user_id as user_id
- FROM rhnUserGroupMembers ugm, web_contact wc
- WHERE ugm.user_group_id = (SELECT id
- FROM rhnUserGroup
- WHERE org_id = :org_id
- AND group_type = :type_id)
- AND wc.id = ugm.user_id
- ORDER BY wc.id
- </sql-query>
-
- <sql-query name="User.findResponsibleUser">
- <return-scalar type="long" column="user_id"/>
- <return-scalar type="string" column="login"/>
- SELECT ugm.user_id as user_id, wc.login as login
- FROM rhnUserGroupMembers ugm,
- web_contact wc
- WHERE ugm.user_group_id = (SELECT id
- FROM rhnUserGroup
- WHERE org_id = :org_id
- AND group_type = :type_id)
- AND wc.id = ugm.user_id
-ORDER BY wc.id
- </sql-query>
-</hibernate-mapping>
diff --git a/java/code/src/com/redhat/rhn/domain/user/legacy/PersonalInfo.hbm.xml b/java/code/src/com/redhat/rhn/domain/user/legacy/PersonalInfo.hbm.xml
new file mode 100644
index 0000000..e24fac1
--- /dev/null
+++ b/java/code/src/com/redhat/rhn/domain/user/legacy/PersonalInfo.hbm.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE hibernate-mapping
+PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping>
+ <class name="com.redhat.rhn.domain.user.legacy.PersonalInfo"
+ table="WEB_USER_PERSONAL_INFO"
+ lazy="false">
+ <id name="webUserId" type="long" column="web_user_id">
+ <generator class="foreign">
+ <param name="property">user</param>
+ </generator>
+ </id>
+ <property name="prefix" column="prefix" type="string" length="12" />
+ <property name="firstNames" column="first_names" type="string" length="128" />
+ <property name="lastName" column="last_name" type="string" length="128" />
+ <property name="company" column="company" type="string" length="128" />
+ <property name="title" column="title" type="string" length="128" />
+ <property name="phone" column="phone" type="string" length="128" />
+ <property name="fax" column="fax" type="string" length="128" />
+ <property name="email" column="email" type="string" length="128" />
+ <property name="created" type="timestamp" insert="false" update="false" />
+ <property name="modified" type="timestamp" insert="false" update="false" />
+
+ <one-to-one name="user"
+ class="com.redhat.rhn.domain.user.legacy.UserImpl"
+ constrained="true" />
+ </class>
+</hibernate-mapping>
diff --git a/java/code/src/com/redhat/rhn/domain/user/legacy/PersonalInfo_legacyUser.hbm.xml b/java/code/src/com/redhat/rhn/domain/user/legacy/PersonalInfo_legacyUser.hbm.xml
deleted file mode 100644
index d08251b..0000000
--- a/java/code/src/com/redhat/rhn/domain/user/legacy/PersonalInfo_legacyUser.hbm.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE hibernate-mapping
-PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<hibernate-mapping>
- <class name="com.redhat.rhn.domain.user.legacy.PersonalInfo"
- table="WEB_USER_PERSONAL_INFO"
- lazy="false">
- <id name="webUserId" type="long" column="web_user_id">
- <generator class="foreign">
- <param name="property">user</param>
- </generator>
- </id>
- <property name="prefix" column="prefix" type="string" length="12" />
- <property name="firstNames" column="first_names" type="string" length="128" />
- <property name="lastName" column="last_name" type="string" length="128" />
- <property name="company" column="company" type="string" length="128" />
- <property name="title" column="title" type="string" length="128" />
- <property name="phone" column="phone" type="string" length="128" />
- <property name="fax" column="fax" type="string" length="128" />
- <property name="email" column="email" type="string" length="128" />
- <property name="created" type="timestamp" insert="false" update="false" />
- <property name="modified" type="timestamp" insert="false" update="false" />
-
- <one-to-one name="user"
- class="com.redhat.rhn.domain.user.legacy.LegacyRhnUserImpl"
- constrained="true" />
- </class>
-</hibernate-mapping>
diff --git a/java/code/src/com/redhat/rhn/domain/user/legacy/StateChange.hbm.xml b/java/code/src/com/redhat/rhn/domain/user/legacy/StateChange.hbm.xml
new file mode 100644
index 0000000..5474a0d
--- /dev/null
+++ b/java/code/src/com/redhat/rhn/domain/user/legacy/StateChange.hbm.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE hibernate-mapping
+PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping>
+ <class name="com.redhat.rhn.domain.user.StateChange"
+ table="rhnWebContactChangeLog">
+ <id name="id" type="long" column="id">
+ <meta attribute="scope-set">protected</meta>
+ <generator class="sequence">
+ <param name="sequence">RHN_WCON_DISABLED_SEQ</param>
+ </generator>
+ </id>
+ <!-- Let the db take care of setting this column -->
+ <property name="date" type="date" column="date_completed"
+ insert="false" update="false"/>
+
+ <many-to-one name="user" class="com.redhat.rhn.domain.user.legacy.UserImpl"
+ column="web_contact_id" not-null="true" />
+
+ <many-to-one name="changedBy"
+ class="com.redhat.rhn.domain.user.legacy.UserImpl"
+ column="web_contact_from_id" not-null="true" />
+
+ <many-to-one name="state" class="com.redhat.rhn.domain.user.State"
+ column="change_state_id" not-null="true" />
+ </class>
+ <query name="StateChanges.lookupByUserId">
+ <![CDATA[from com.redhat.rhn.domain.user.StateChange as s where s.user = :user order by s.id desc]]>
+ </query>
+</hibernate-mapping>
diff --git a/java/code/src/com/redhat/rhn/domain/user/legacy/StateChange_legacyUser.hbm.xml b/java/code/src/com/redhat/rhn/domain/user/legacy/StateChange_legacyUser.hbm.xml
deleted file mode 100644
index c0a8cf5..0000000
--- a/java/code/src/com/redhat/rhn/domain/user/legacy/StateChange_legacyUser.hbm.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE hibernate-mapping
-PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<hibernate-mapping>
- <class name="com.redhat.rhn.domain.user.StateChange"
- table="rhnWebContactChangeLog">
- <id name="id" type="long" column="id">
- <meta attribute="scope-set">protected</meta>
- <generator class="sequence">
- <param name="sequence">RHN_WCON_DISABLED_SEQ</param>
- </generator>
- </id>
- <!-- Let the db take care of setting this column -->
- <property name="date" type="date" column="date_completed"
- insert="false" update="false"/>
-
- <many-to-one name="user" class="com.redhat.rhn.domain.user.legacy.LegacyRhnUserImpl"
- column="web_contact_id" not-null="true" />
-
- <many-to-one name="changedBy"
- class="com.redhat.rhn.domain.user.legacy.LegacyRhnUserImpl"
- column="web_contact_from_id" not-null="true" />
-
- <many-to-one name="state" class="com.redhat.rhn.domain.user.State"
- column="change_state_id" not-null="true" />
- </class>
- <query name="StateChanges.lookupByUserId">
- <![CDATA[from com.redhat.rhn.domain.user.StateChange as s where s.user = :user order by s.id desc]]>
- </query>
-</hibernate-mapping>
diff --git a/java/code/src/com/redhat/rhn/domain/user/legacy/UserImpl.hbm.xml b/java/code/src/com/redhat/rhn/domain/user/legacy/UserImpl.hbm.xml
new file mode 100644
index 0000000..bb72456
--- /dev/null
+++ b/java/code/src/com/redhat/rhn/domain/user/legacy/UserImpl.hbm.xml
@@ -0,0 +1,137 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE hibernate-mapping
+PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping>
+ <class name="com.redhat.rhn.domain.user.legacy.UserImpl"
+ table="WEB_CONTACT">
+ <id name="id" type="long" column="id">
+ <meta attribute="scope-set">protected</meta>
+ <generator class="sequence">
+ <param name="sequence">WEB_CONTACT_ID_SEQ</param>
+ </generator>
+ </id>
+ <property name="login" column="login" type="string" length="64" />
+ <property name="loginUc" column="login_uc" type="string" length="64" />
+ <!-- Make sure we set access=field on password, since the setPassword method of
+ UserImpl encodes the password every time -->
+ <property name="password" column="password" type="string" length="38" access="field" />
+
+ <property name="created" column="created" type="timestamp"
+ insert="false" update="false"/>
+ <property name="modified" column="modified" type="timestamp"
+ insert="false" update="false"/>
+ <one-to-one name="personalInfo"
+ class="com.redhat.rhn.domain.user.legacy.PersonalInfo"
+ outer-join="true"
+ cascade="all"
+ constrained="true" />
+ <one-to-one name="userInfo"
+ class="com.redhat.rhn.domain.user.legacy.UserInfo"
+ outer-join="true"
+ cascade="all"
+ constrained="true" />
+ <many-to-one name="org"
+ column="org_id"
+ class="com.redhat.rhn.domain.org.OrgImpl"
+ outer-join="true"
+ not-null="true" />
+ <set name="addresses" cascade="all">
+ <key column="web_user_id"/>
+ <one-to-many class="com.redhat.rhn.domain.user.AddressImpl" />
+ </set>
+ <set name="usergroups" outer-join="false" table="rhnUserGroupMembers">
+ <key column="user_id" />
+ <many-to-many column="user_group_id" outer-join="false"
+ class="com.redhat.rhn.domain.org.usergroup.UserGroupImpl" />
+ </set>
+ <set name="notificationMethods" table="rhn_contact_methods" lazy="true"
+ inverse="true" cascade="none">
+ <key column="contact_id" />
+ <one-to-many class="com.redhat.rhn.domain.monitoring.notification.Method"/>
+ </set>
+ <set name="stateChanges" lazy="true"
+ cascade="save-update" sort="natural">
+ <key column="web_contact_id"/>
+ <one-to-many class="com.redhat.rhn.domain.user.StateChange" />
+ </set>
+ <set name = "hiddenPanes"
+ table="RHNUSERINFOPANE"
+ lazy="true"
+ cascade="all">
+ <key column="user_id"/>
+ <many-to-many class ="com.redhat.rhn.domain.user.Pane" column="pane_id"/>
+ </set>
+ <set name="associatedServerGroups" lazy="true" table="rhnUserServerGroupPerms"
+ cascade="save-update" inverse="true">
+ <key column="user_id"/>
+ <many-to-many
+ class="com.redhat.rhn.domain.server.ServerGroup"
+ column="server_group_id"
+ />
+ </set>
+
+ <set name="servers" lazy="true" table="rhnUserServerPerms" cascade="all">
+ <key column="user_id"/>
+ <many-to-many class="com.redhat.rhn.domain.server.Server" column="server_id"/>
+ </set>
+
+ </class>
+
+ <query name="User.findByLogin">
+ <![CDATA[from com.redhat.rhn.domain.user.legacy.UserImpl as u where u.loginUc = :loginUc]]>
+ </query>
+ <query name="User.findByLoginAndOrgId">
+ <![CDATA[from com.redhat.rhn.domain.user.legacy.UserImpl as u where u.loginUc = :loginUc and org_id = :orgId]]>
+ </query>
+ <query name="User.findByIdandOrgId">
+ <![CDATA[from com.redhat.rhn.domain.user.legacy.UserImpl as u where u.id = :uid and org_id = :orgId]]>
+ </query>
+ <query name="User.findByIds">
+ <![CDATA[from com.redhat.rhn.domain.user.legacy.UserImpl as u where u.id in (:userIds)]]>
+ </query>
+ <query name="User.findAllUsers">
+ <![CDATA[from com.redhat.rhn.domain.user.legacy.UserImpl]]>
+ </query>
+
+ <query name="User.findAllUsersByOrg">
+ <![CDATA[from com.redhat.rhn.domain.user.legacy.UserImpl as u where org_id = :org_id]]>
+ </query>
+
+ <query name="User.findAllOrgAdmins">
+ <![CDATA[
+ select u
+ from com.redhat.rhn.domain.user.legacy.UserImpl as u
+ where exists (
+ from com.redhat.rhn.domain.org.usergroup.UserGroupImpl as ug
+ where ug.orgId = :org_id and
+ ug.role.label = 'org_admin' and
+ ug in elements(u.usergroups))
+ ]]>
+ </query>
+ <sql-query name="User.findRandomOrgAdmin">
+ <return-scalar type="long" column="user_id"/>
+ SELECT ugm.user_id as user_id
+ FROM rhnUserGroupMembers ugm, web_contact wc
+ WHERE ugm.user_group_id = (SELECT id
+ FROM rhnUserGroup
+ WHERE org_id = :org_id
+ AND group_type = :type_id)
+ AND wc.id = ugm.user_id
+ ORDER BY wc.id
+ </sql-query>
+
+ <sql-query name="User.findResponsibleUser">
+ <return-scalar type="long" column="user_id"/>
+ <return-scalar type="string" column="login"/>
+ SELECT ugm.user_id as user_id, wc.login as login
+ FROM rhnUserGroupMembers ugm,
+ web_contact wc
+ WHERE ugm.user_group_id = (SELECT id
+ FROM rhnUserGroup
+ WHERE org_id = :org_id
+ AND group_type = :type_id)
+ AND wc.id = ugm.user_id
+ORDER BY wc.id
+ </sql-query>
+</hibernate-mapping>
diff --git a/java/code/src/com/redhat/rhn/domain/user/legacy/UserImpl.java b/java/code/src/com/redhat/rhn/domain/user/legacy/UserImpl.java
new file mode 100644
index 0000000..2e1c110
--- /dev/null
+++ b/java/code/src/com/redhat/rhn/domain/user/legacy/UserImpl.java
@@ -0,0 +1,1187 @@
+/**
+ * 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.domain.user.legacy;
+
+import com.redhat.rhn.common.conf.Config;
+import com.redhat.rhn.common.conf.ConfigDefaults;
+import com.redhat.rhn.common.localization.LocalizationService;
+import com.redhat.rhn.common.util.MD5Crypt;
+import com.redhat.rhn.domain.BaseDomainHelper;
+import com.redhat.rhn.domain.org.Org;
+import com.redhat.rhn.domain.org.usergroup.UserGroup;
+import com.redhat.rhn.domain.role.Role;
+import com.redhat.rhn.domain.role.RoleFactory;
+import com.redhat.rhn.domain.server.Server;
+import com.redhat.rhn.domain.user.Address;
+import com.redhat.rhn.domain.user.EnterpriseUser;
+import com.redhat.rhn.domain.user.RhnTimeZone;
+import com.redhat.rhn.domain.user.StateChange;
+import com.redhat.rhn.domain.user.User;
+import com.redhat.rhn.domain.user.UserFactory;
+import com.redhat.rhn.manager.user.UserManager;
+
+import net.sf.jpam.Pam;
+import net.sf.jpam.PamReturnValue;
+
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.log4j.Logger;
+
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.TreeSet;
+
+/**
+ * Class UserImpl that reflects the DB representation of web_contact
+ * and ancillary tables.
+ * DB table: web_contact
+ * @version $Rev: 75755 $
+ */
+public class UserImpl extends BaseDomainHelper implements User {
+
+
+ private static final Logger LOG = Logger.getLogger(UserImpl.class);
+
+ //private Address address;
+ private EnterpriseUserImpl euser;
+ private Long id;
+ private String login;
+ private String loginUc;
+ private String password;
+ private Set usergroups;
+ private Org org;
+ private Set stateChanges;
+ private Set addresses;
+ private Set hiddenPanes;
+ private Set associatedServerGroups;
+ private Set<Server> servers;
+ // PersonalInfo sub-object object
+ private PersonalInfo personalInfo;
+ // UserInfo sub-object
+ private UserInfo userInfo;
+
+ // Keep track of whether the user used to be an org admin
+ private Boolean wasOrgAdmin;
+
+ // Set of com.redhat.rhn.monitoring.notification.Method instances
+ private Set notificationMethods;
+
+ /**
+ * Create a new empty user
+ */
+ public UserImpl() {
+ usergroups = new HashSet();
+ personalInfo = new PersonalInfo();
+ personalInfo.setUser(this);
+ userInfo = new UserInfo();
+ userInfo.setUser(this);
+ stateChanges = new TreeSet();
+ addresses = new HashSet();
+ hiddenPanes = new HashSet();
+ associatedServerGroups = new HashSet();
+ }
+
+ /**
+ * Gets the current value of id
+ * @return long the current value
+ */
+ public Long getId() {
+ return this.id;
+ }
+
+ /**
+ * Sets the value of id to new value
+ * @param idIn New value for id
+ */
+ public void setId(Long idIn) {
+ this.id = idIn;
+ }
+
+ /**
+ * Gets the current value of login
+ * @return String the current value
+ */
+ public String getLogin() {
+ return this.login;
+ }
+
+ /**
+ * Sets the value of login to new value
+ * @param loginIn New value for login
+ */
+ public void setLogin(String loginIn) {
+ this.login = loginIn;
+ setLoginUc(loginIn.toUpperCase());
+ }
+
+ /**
+ * Gets the current value of loginUc
+ * @return String the current value
+ */
+ public String getLoginUc() {
+ return this.loginUc;
+ }
+
+ /**
+ * Sets the value of loginUc to new value
+ * @param loginUcIn New value for loginUc
+ */
+ public void setLoginUc(String loginUcIn) {
+ this.loginUc = loginUcIn;
+ }
+
+ /**
+ * Gets the current value of password
+ * @return String the current value
+ */
+ public String getPassword() {
+ return this.password;
+ }
+
+ /**
+ * Sets the value of password to new value
+ * @param passwordIn New value for password
+ */
+ public void setPassword(String passwordIn) {
+ /**
+ * If we're using encrypted passwords, encode the
+ * password before setting it. Otherwise, just
+ * set it.
+ */
+ if (Config.get().getBoolean(ConfigDefaults.WEB_ENCRYPTED_PASSWORDS)) {
+ this.password = MD5Crypt.crypt(passwordIn);
+ }
+ else {
+ this.password = passwordIn;
+ }
+ }
+
+ /**
+ * Set the usergroup set
+ * @param ugIn The new Set of UserGroups to set
+ */
+ protected void setUsergroups(Set ugIn) {
+ usergroups = ugIn;
+ }
+
+ /** get the set of usergroups
+ * @return Set of UserGroups
+ */
+ protected Set getUsergroups() {
+ return usergroups;
+ }
+
+ /** {@inheritDoc} */
+ public Set getRoles() {
+ Set userRoles = new HashSet();
+ for (Iterator i = usergroups.iterator(); i.hasNext();) {
+ UserGroup ug = (UserGroup)i.next();
+ userRoles.add(ug.getRole());
+ }
+
+ if (userRoles.contains(RoleFactory.ORG_ADMIN)) {
+ Set orgRoles = org.getRoles();
+ Set localImplied = new HashSet();
+ localImplied.addAll(UserFactory.IMPLIEDROLES);
+ localImplied.retainAll(orgRoles);
+ userRoles.addAll(localImplied);
+ }
+ return Collections.unmodifiableSet(userRoles);
+ }
+
+ /** {@inheritDoc} */
+ public boolean hasRole(Role label) {
+ // We use checkRoleSet to get the correct logic for the
+ // implied roles.
+ return getRoles().contains(label);
+ }
+
+ /** {@inheritDoc} */
+ public void addRole(Role label) {
+ checkOrgAdmin();
+ UserGroup ug = org.getUserGroup(label);
+ if (ug != null) {
+ usergroups.add(ug);
+ }
+ else {
+ throw new IllegalArgumentException("Org doesn't have role: " + label);
+ }
+ }
+
+
+ /** {@inheritDoc} */
+ public void removeRole(Role label) {
+ checkOrgAdmin();
+ UserGroup ug = org.getUserGroup(label);
+ if (ug != null) {
+ usergroups.remove(ug);
+ }
+ }
+
+ /**
+ * Determine if this was org admin.
+ * @return Boolean
+ */
+ public Boolean wasOrgAdmin() {
+ return wasOrgAdmin;
+ }
+
+ /**
+ * Reset the wasOrgAdmin value.
+ */
+ public void resetWasOrgAdmin() {
+ wasOrgAdmin = null;
+ }
+
+ private void checkOrgAdmin() {
+ if (wasOrgAdmin == null) {
+ wasOrgAdmin = Boolean.valueOf(hasRole(RoleFactory.ORG_ADMIN));
+ }
+ }
+
+ /** {@inheritDoc} */
+ public boolean authenticate(String thePassword) {
+ String pamAuthService = Config.get().getString(ConfigDefaults.WEB_PAM_AUTH_SERVICE);
+ boolean result = false;
+ /*
+ * If we have a valid pamAuthService and the user uses pam authentication,
+ * authenticate via pam, otherwise, use the db.
+ */
+ if (pamAuthService != null && pamAuthService.trim().length() > 0 &&
+ this.getUsePamAuthentication()) {
+ Pam pam = new Pam(pamAuthService);
+ PamReturnValue ret = pam.authenticate(getLogin(), thePassword);
+ result = PamReturnValue.PAM_SUCCESS.equals(ret);
+ if (!result) {
+ LOG.warn("PAM login for user " + this + " failed with error " + ret);
+ }
+ }
+ else {
+ /**
+ * If we're using encrypted passwords, check
+ * thePassword encrypted, otherwise just do
+ * a straight clear-text comparison.
+ */
+ boolean useEncrPasswds =
+ Config.get().getBoolean(ConfigDefaults.WEB_ENCRYPTED_PASSWORDS);
+ if (useEncrPasswds) {
+ result = MD5Crypt.crypt(thePassword, password).equals(password);
+ }
+ else {
+ result = password.equals(thePassword);
+ }
+ if (LOG.isDebugEnabled() && !useEncrPasswds) {
+ String encr = useEncrPasswds ? "with" : "without";
+ LOG.debug("DB login for user " + this + " " +
+ encr + " encrypted passwords failed");
+ }
+ }
+ if (LOG.isDebugEnabled() && result) {
+ LOG.debug("PAM login for user " + this + " succeeded. ");
+ }
+ return result;
+ }
+
+ /**
+ * Associates the user with an Org.
+ * @param orgIn Org to be associated to this user.
+ */
+ public void setOrg(Org orgIn) {
+ org = orgIn;
+ }
+
+ /** {@inheritDoc} */
+ public Org getOrg() {
+ return org;
+ }
+
+ /** {@inheritDoc} */
+ public Set getDefaultSystemGroupIds() {
+ return UserManager.getDefaultSystemGroupIds(this);
+ }
+
+ /** {@inheritDoc} */
+ public void setDefaultSystemGroupIds(Set dsg) {
+ UserManager.setDefaultSystemGroupIds(this, dsg);
+ }
+
+ /**
+ * Return the PersonalInfo object
+ * @return PersonalInfo object associated with this User
+ */
+ protected PersonalInfo getPersonalInfo() {
+ if (personalInfo == null) {
+ personalInfo = new PersonalInfo();
+ }
+ return personalInfo;
+ }
+
+ /**
+ * Set the PersonalInfo object
+ * @param persIn the PersonalInfo object
+ */
+ protected void setPersonalInfo(PersonalInfo persIn) {
+ this.personalInfo = persIn;
+ }
+
+ /**
+ * Set the UserInfo object
+ * @param infoIn the UserInfo object
+ */
+ protected void setUserInfo(UserInfo infoIn) {
+ this.userInfo = infoIn;
+ }
+
+ /**
+ * Get the UserInfo sub object
+ * @return UserInfo
+ */
+ public UserInfo getUserInfo() {
+ return this.userInfo;
+ }
+
+
+ /**
+ * Convenience method to determine whether a user is disabled
+ * or not
+ * @return Returns true if the user is disabled
+ */
+ public boolean isDisabled() {
+ return UserFactory.isDisabled(this);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addChange(StateChange change) {
+ this.stateChanges.add(change);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Set getStateChanges() {
+ return stateChanges;
+ }
+
+ /**
+ * @param s The stateChanges to set.
+ */
+ public void setStateChanges(Set s) {
+ this.stateChanges = s;
+ }
+
+ /************* UserInfo methods **************/
+ /** {@inheritDoc} */
+ public int getPageSize() {
+ return this.userInfo.getPageSize();
+ }
+
+ /** {@inheritDoc} */
+ public void setPageSize(int pageSizeIn) {
+ this.userInfo.setPageSize(pageSizeIn);
+ }
+
+ /** {@inheritDoc} */
+ public boolean getUsePamAuthentication() {
+ return this.userInfo.getUsePamAuthentication();
+ }
+
+ /** {@inheritDoc} */
+ public void setUsePamAuthentication(boolean usePamAuthenticationIn) {
+ this.userInfo.setUsePamAuthentication(usePamAuthenticationIn);
+ }
+
+ /** {@inheritDoc} */
+ public String getShowSystemGroupList() {
+ return this.userInfo.getShowSystemGroupList();
+ }
+
+ /** {@inheritDoc} */
+ public void setShowSystemGroupList(String showSystemGroupListIn) {
+ this.userInfo.setShowSystemGroupList(showSystemGroupListIn);
+ }
+
+ /** {@inheritDoc} */
+ public Date getLastLoggedIn() {
+ return this.userInfo.getLastLoggedIn();
+ }
+
+ /** {@inheritDoc} */
+ public void setLastLoggedIn(Date lastLoggedInIn) {
+ this.userInfo.setLastLoggedIn(lastLoggedInIn);
+ }
+
+ /** {@inheritDoc} */
+ public void setPreferredLocale(String locale) {
+ this.userInfo.setPreferredLocale(locale);
+ }
+
+ /** {@inheritDoc} */
+ public String getPreferredLocale() {
+ return this.userInfo.getPreferredLocale();
+ }
+
+ /********* PersonalInfo Methods **********/
+
+ /**
+ * Gets the current value of prefix
+ * @return String the current value
+ */
+ public String getPrefix() {
+ return this.personalInfo.getPrefix();
+ }
+
+ /**
+ * Sets the value of prefix to new value
+ * @param prefixIn New value for prefix
+ */
+ public void setPrefix(String prefixIn) {
+ this.personalInfo.setPrefix(prefixIn);
+ }
+
+ /**
+ * Gets the current value of firstNames
+ * @return String the current value
+ */
+ public String getFirstNames() {
+ return this.personalInfo.getFirstNames();
+ }
+
+ /**
+ * Sets the value of firstNames to new value
+ * @param firstNamesIn New value for firstNames
+ */
+ public void setFirstNames(String firstNamesIn) {
+ this.personalInfo.setFirstNames(firstNamesIn);
+ }
+
+ /**
+ * Gets the current value of lastName
+ * @return String the current value
+ */
+ public String getLastName() {
+ return this.personalInfo.getLastName();
+ }
+
+ /**
+ * Sets the value of lastName to new value
+ * @param lastNameIn New value for lastName
+ */
+ public void setLastName(String lastNameIn) {
+ this.personalInfo.setLastName(lastNameIn);
+ }
+
+ /**
+ * Gets the current value of company
+ * @return String the current value
+ */
+ public String getCompany() {
+ return this.personalInfo.getCompany();
+ }
+
+ /**
+ * Sets the value of company to new value
+ * @param companyIn New value for company
+ */
+ public void setCompany(String companyIn) {
+ this.personalInfo.setCompany(companyIn);
+ }
+
+ /**
+ * Gets the current value of title
+ * @return String the current value
+ */
+ public String getTitle() {
+ return this.personalInfo.getTitle();
+ }
+
+ /**
+ * Sets the value of title to new value
+ * @param titleIn New value for title
+ */
+ public void setTitle(String titleIn) {
+ this.personalInfo.setTitle(titleIn);
+ }
+
+ /**
+ * Gets the current value of phone
+ * @return String the current value
+ */
+ public String getPhone() {
+ return getAddress().getPhone();
+ }
+
+ /**
+ * Sets the value of phone to new value
+ * @param phoneIn New value for phone
+ */
+ public void setPhone(String phoneIn) {
+ getAddress().setPhone(phoneIn);
+ }
+
+ /**
+ * Gets the current value of fax
+ * @return String the current value
+ */
+ public String getFax() {
+ return getAddress().getFax();
+ }
+
+ /**
+ * Sets the value of fax to new value
+ * @param faxIn New value for fax
+ */
+ public void setFax(String faxIn) {
+ getAddress().setFax(faxIn);
+ }
+
+ /**
+ * Gets the current value of email
+ * @return String the current value
+ */
+ public String getEmail() {
+ return this.personalInfo.getEmail();
+ }
+
+ /**
+ * Sets the value of email to new value
+ * @param emailIn New value for email
+ */
+ public void setEmail(String emailIn) {
+ this.personalInfo.setEmail(emailIn);
+ }
+
+
+ /** {@inheritDoc} */
+ public RhnTimeZone getTimeZone() {
+ return this.userInfo.getTimeZone();
+ }
+
+ /** {@inheritDoc} */
+ public void setTimeZone(RhnTimeZone timeZoneIn) {
+ this.userInfo.setTimeZone(timeZoneIn);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Set getNotificationMethods() {
+ return this.notificationMethods;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setNotificationMethods(Set methodsIn) {
+ this.notificationMethods = methodsIn;
+ }
+
+
+
+
+ /**
+ * Output User to String for debugging
+ * @return String output of the User
+ */
+ public String toString() {
+ StringBuffer retval = new StringBuffer();
+ retval.append(LocalizationService.getInstance().
+ getDebugMessage("user"));
+ retval.append(" ");
+ retval.append(getLogin());
+ retval.append(" (id ");
+ retval.append(String.valueOf(getId()));
+ retval.append(", org_id ");
+ retval.append(String.valueOf(getOrg().getId()));
+ retval.append(")");
+ return retval.toString();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean equals(Object other) {
+ if (other == null || !(other instanceof User)) {
+ return false;
+ }
+ User otherUser = (User) other;
+ return new EqualsBuilder().append(login, otherUser.getLogin())
+ .append(org, otherUser.getOrg())
+ .append(id, otherUser.getId())
+ .isEquals();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int hashCode() {
+ return new HashCodeBuilder().append(login).append(org).append(id).toHashCode();
+ }
+
+ /**
+ * Getter for address1
+ * @return Address1
+ */
+ public String getAddress1() {
+ return getAddress().getAddress1();
+ }
+
+ /**
+ * Setter for address1
+ * @param address1In New value for address1
+ */
+ public void setAddress1(String address1In) {
+ getAddress().setAddress1(address1In);
+ }
+
+ /**
+ * Getter for address2
+ * @return Address2
+ */
+ public String getAddress2() {
+ return getAddress().getAddress2();
+ }
+
+ /**
+ * Setter for address2
+ * @param address2In New value for address2
+ */
+ public void setAddress2(String address2In) {
+ getAddress().setAddress2(address2In);
+ }
+
+ /**
+ * Getter for city
+ * @return City
+ */
+ public String getCity() {
+ return getAddress().getCity();
+ }
+
+ /**
+ * Setter for city
+ * @param cityIn New value for city
+ */
+ public void setCity(String cityIn) {
+ getAddress().setCity(cityIn);
+ }
+
+ /**
+ * Getter for state
+ * @return State
+ */
+ public String getState() {
+ return getAddress().getState();
+ }
+
+ /**
+ * Setter for state
+ * @param stateIn New value for state
+ */
+ public void setState(String stateIn) {
+ getAddress().setState(stateIn);
+ }
+
+ /**
+ * Getter for zip
+ * @return Zip
+ */
+ public String getZip() {
+ return getAddress().getZip();
+ }
+
+ /**
+ * Setter for zip
+ * @param zipIn New value for zip
+ */
+ public void setZip(String zipIn) {
+ getAddress().setZip(zipIn);
+ }
+
+ /**
+ * Getter for country
+ * @return Country
+ */
+ public String getCountry() {
+ return getAddress().getCountry();
+ }
+
+ /**
+ * Setter for country
+ * @param countryIn New value for country
+ */
+ public void setCountry(String countryIn) {
+ getAddress().setCountry(countryIn);
+ }
+
+
+ /**
+ * Getter for isPoBox
+ * @return isPoBox
+ */
+ public String getIsPoBox() {
+ return getAddress().getIsPoBox();
+ }
+
+ /**
+ * Setter for isPoBox
+ * @param isPoBoxIn New value for isPoBox
+ */
+ public void setIsPoBox(String isPoBoxIn) {
+ getAddress().setIsPoBox(isPoBoxIn);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public EnterpriseUser getEnterpriseUser() {
+ if (euser == null) {
+ euser = new EnterpriseUserImpl();
+ }
+ return euser;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Set getHiddenPanes() {
+ return hiddenPanes;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setHiddenPanes(Set p) {
+ hiddenPanes = p;
+ }
+
+ protected void setAddress(Address addIn) {
+ addresses.clear();
+ addresses.add(addIn);
+ }
+
+ protected Address getAddress() {
+ Address baddr = null;
+ Address addr = null;
+ Address[] addrA = (Address[]) addresses.toArray(new Address[addresses.size()]);
+ if (addresses.size() > 0) {
+ for (int i = 0; i < addrA.length; i++) {
+ if (addrA[i].getType().equals(Address.TYPE_MARKETING)) {
+ addr = addrA[i];
+ }
+ if (addrA[i].getType().equals("B")) {
+ baddr = addrA[i];
+ }
+ }
+ }
+ if (addr == null) {
+ addr = UserFactory.createAddress();
+ if (baddr != null) {
+ addr.setAddress1(baddr.getAddress1());
+ addr.setAddress2(baddr.getAddress2());
+ addr.setCity(baddr.getCity());
+ addr.setCountry(baddr.getCountry());
+ addr.setFax(baddr.getFax());
+ addr.setIsPoBox(baddr.getIsPoBox());
+ addr.setPhone(baddr.getPhone());
+ addr.setState(baddr.getState());
+ addr.setZip(baddr.getZip());
+ }
+ addresses.add(addr);
+ }
+ return addr;
+ }
+
+ /**
+ * Set the addresses.
+ * @param s the set
+ */
+ protected void setAddresses(Set s) {
+ addresses = s;
+ }
+
+ /**
+ * Get the addresses
+ * @return Set of addresses
+ */
+ protected Set getAddresses() {
+ return addresses;
+ }
+
+ /**
+ * Default POJO imple of EnterpriseUser done as an internal
+ * class to facilitate compatibility between hosted/sat.
+ * EnterpriseUserImpl
+ * @version $Rev$
+ */
+ class EnterpriseUserImpl extends BaseDomainHelper
+ implements EnterpriseUser {
+
+ /**
+ * Default constructor
+ *
+ */
+ protected EnterpriseUserImpl() {
+ }
+
+ /**
+ * Gets the current value of id
+ * @return long the current value
+ */
+ public Long getId() {
+ return id;
+ }
+
+ /**
+ * Sets the value of id to new value
+ * @param idIn New value for id
+ */
+ public void setId(Long idIn) {
+ }
+
+ /**
+ * Add a User to this instance.
+ *
+ * @param u a User to add
+ */
+ public void addUser(User u) {
+ }
+
+ /**
+ * Remove a User from this instance.
+ *
+ * @param u the User to remove
+ */
+ public void removeUser(User u) {
+ }
+
+ /**
+ * Return an iterator over all Users associated with
+ * this instance.
+ *
+ * @return Iterator an iterator over all users
+ */
+ public Iterator allUsers() {
+ return null;
+ }
+
+ /**
+ * Find the user having the id provided. Return null if
+ * not found.
+ * @param idIn id to use
+ * @return User or null
+ */
+ public User findUserById(Long idIn) {
+ return null;
+ }
+
+ /**
+ * Gets the current value of login
+ * @return String the current value
+ */
+ public String getLogin() {
+ return login;
+ }
+
+ /**
+ * Sets the value of login to new value
+ * @param loginIn New value for login
+ */
+ public void setLogin(String loginIn) {
+ login = loginIn;
+ }
+
+ /**
+ * Gets the current value of password
+ * @return String the current value
+ */
+ public String getPassword() {
+ return password;
+ }
+
+ /**
+ * Sets the value of password to new value
+ * @param passwordIn New value for password
+ */
+ public void setPassword(String passwordIn) {
+ /**
+ * If we're using encrypted passwords, encode the
+ * password before setting it. Otherwise, just
+ * set it.
+ */
+ if (Config.get().getBoolean(ConfigDefaults.WEB_ENCRYPTED_PASSWORDS)) {
+ password = MD5Crypt.crypt(passwordIn);
+ }
+ else {
+ password = passwordIn;
+ }
+ }
+
+ /**
+ * Gets the current value of prefix
+ * @return String the current value
+ */
+ public String getPrefix() {
+ return personalInfo.getPrefix();
+ }
+
+ /**
+ * Sets the value of prefix to new value
+ * @param prefixIn New value for prefix
+ */
+ public void setPrefix(String prefixIn) {
+ personalInfo.setPrefix(prefixIn);
+ }
+
+ /**
+ * Gets the current value of firstNames
+ * @return String the current value
+ */
+ public String getFirstNames() {
+ return personalInfo.getFirstNames();
+ }
+
+ /**
+ * Sets the value of firstNames to new value
+ * @param firstNamesIn New value for firstNames
+ */
+ public void setFirstNames(String firstNamesIn) {
+ personalInfo.setFirstNames(firstNamesIn);
+ }
+
+ /**
+ * Gets the current value of lastName
+ * @return String the current value
+ */
+ public String getLastName() {
+ return personalInfo.getLastName();
+ }
+
+ /**
+ * Sets the value of lastName to new value
+ * @param lastNameIn New value for lastName
+ */
+ public void setLastName(String lastNameIn) {
+ personalInfo.setLastName(lastNameIn);
+ }
+
+ /**
+ * Gets the current value of title
+ * @return String the current value
+ */
+ public String getTitle() {
+ return personalInfo.getTitle();
+ }
+
+ /**
+ * Sets the value of title to new value
+ * @param titleIn New value for title
+ */
+ public void setTitle(String titleIn) {
+ personalInfo.setTitle(titleIn);
+ }
+
+ /**
+ * Gets the current value of email
+ * @return String the current value
+ */
+ public String getEmail() {
+ return personalInfo.getEmail();
+ }
+
+ /**
+ * Sets the value of email to new value
+ * @param emailIn New value for email
+ */
+ public void setEmail(String emailIn) {
+ personalInfo.setEmail(emailIn);
+ }
+
+ /**
+ * Getter for lastLoggedIn
+ * @return lastLoggedIn
+ */
+ public Date getLastLoggedIn() {
+ return userInfo.getLastLoggedIn();
+ }
+
+ /**
+ * Setter for lastLoggedIn
+ * @param lastLoggedInIn New value for lastLoggedIn
+ */
+ public void setLastLoggedIn(Date lastLoggedInIn) {
+ userInfo.setLastLoggedIn(lastLoggedInIn);
+ }
+
+ /**
+ * @inheritDoc
+ * @param modifiedIn the modified date
+ */
+ public void setModified(Date modifiedIn) {
+ }
+
+ /**
+ * @inheritDoc
+ * @return date modified
+ */
+ public Date getModified() {
+ return null;
+ }
+
+ /**
+ * @inheritDoc
+ * @param createdIn date created in
+ */
+ public void setCreated(Date createdIn) {
+ }
+
+ /**
+ * @inheritDoc
+ * @return date was created
+ */
+ public Date getCreated() {
+ return null;
+ }
+
+ /**
+ * @return Returns the timeZone.
+ */
+ public RhnTimeZone getTimeZone() {
+ return userInfo.getTimeZone();
+ }
+ /**
+ * @param timeZoneIn The timeZone to set.
+ */
+ public void setTimeZone(RhnTimeZone timeZoneIn) {
+ userInfo.setTimeZone(timeZoneIn);
+ }
+
+ /**
+ * Set the address of this enterprise user.
+ * @param addressIn the address to set
+ */
+ public void setAddress(Address addressIn) {
+ addresses.clear();
+ addresses.add(addressIn);
+ }
+
+ /**
+ *
+ * @return returns the address info
+ */
+ public Address getAddress() {
+ Address baddr = null;
+ Address addr = null;
+ Address[] addrA = (Address[]) addresses.toArray(new Address[addresses.size()]);
+ if (addresses.size() > 0) {
+ for (int i = 0; i < addrA.length; i++) {
+ if (addrA[i].getType().equals(Address.TYPE_MARKETING)) {
+ addr = addrA[i];
+ }
+ if (addrA[i].getType().equals("B")) {
+ baddr = addrA[i];
+ }
+ }
+ }
+ if (addr == null) {
+ addr = UserFactory.createAddress();
+ if (baddr != null) {
+ addr.setAddress1(baddr.getAddress1());
+ addr.setAddress2(baddr.getAddress2());
+ addr.setCity(baddr.getCity());
+ addr.setCountry(baddr.getCountry());
+ addr.setFax(baddr.getFax());
+ addr.setIsPoBox(baddr.getIsPoBox());
+ addr.setPhone(baddr.getPhone());
+ addr.setState(baddr.getState());
+ addr.setZip(baddr.getZip());
+ }
+ addresses.add(addr);
+ }
+ return addr;
+ }
+
+
+
+ /**
+ *
+ * @param companyIn the company value
+ */
+ public void setCompany(String companyIn) {
+ personalInfo.setCompany(companyIn);
+ }
+
+ /**
+ *
+ * @return returns the company value
+ */
+ public String getCompany() {
+ return personalInfo.getCompany();
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void setEmailNotify(int emailNotifyIn) {
+ this.userInfo.setEmailNotify(emailNotifyIn);
+ }
+
+ /** {@inheritDoc} */
+ public int getEmailNotify() {
+ return this.userInfo.getEmailNotify();
+ }
+
+ /**
+ *
+ * {@inheritDoc}
+ */
+ public Set getAssociatedServerGroups() {
+ return associatedServerGroups;
+ }
+
+ /**
+ * Sets the associatedServerGroups..
+ * Meant for use by hibernate only (hence protected)
+ * @param serverGroups the servergroups to set.
+ */
+ protected void setAssociatedServerGroups(Set serverGroups) {
+ associatedServerGroups = serverGroups;
+ }
+
+ /** {@inheritDoc} */
+ public Set<Server> getServers() {
+ return servers;
+ }
+
+ private void setServers(Set<Server> serversIn) {
+ this.servers = serversIn;
+ }
+
+ /** {@inheritDoc} */
+ public void addServer(Server server) {
+ servers.add(server);
+ }
+
+ /** {@inheritDoc} */
+ public void removeServer(Server server) {
+ servers.remove(server);
+ }
+}
+
+
diff --git a/java/code/src/com/redhat/rhn/domain/user/legacy/UserInfo.hbm.xml b/java/code/src/com/redhat/rhn/domain/user/legacy/UserInfo.hbm.xml
new file mode 100644
index 0000000..7a5e329
--- /dev/null
+++ b/java/code/src/com/redhat/rhn/domain/user/legacy/UserInfo.hbm.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE hibernate-mapping
+PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping>
+ <class name="com.redhat.rhn.domain.user.legacy.UserInfo"
+ table="RHNUSERINFO"
+ lazy="false">
+ <id name="webUserId" type="long" column="user_id">
+ <generator class="foreign">
+ <param name="property">user</param>
+ </generator>
+ </id>
+ <property name="pageSize" column="page_size" type="int" />
+ <property name="usePamAuthentication" column="use_pam_authentication" type="yes_no" />
+ <property name="emailNotify" column="email_notify" type="int" />
+ <property name="showSystemGroupList" column="show_system_group_list" type="string" />
+ <property name="lastLoggedIn" column="last_logged_in" type="timestamp" />
+ <property name="created" type="timestamp" insert="false" update="false" />
+ <property name="modified" type="timestamp" insert="false" update="false" />
+ <property name="preferredLocale" column="preferred_locale" type="string" />
+
+ <many-to-one name="timeZone" column="timezone_id"
+ class="com.redhat.rhn.domain.user.RhnTimeZone" cascade="none" />
+
+ <one-to-one name="user"
+ class="com.redhat.rhn.domain.user.legacy.UserImpl"
+ constrained="true" />
+ </class>
+</hibernate-mapping>
diff --git a/java/code/src/com/redhat/rhn/domain/user/legacy/UserInfo_legacyUser.hbm.xml b/java/code/src/com/redhat/rhn/domain/user/legacy/UserInfo_legacyUser.hbm.xml
deleted file mode 100644
index 96a6d12..0000000
--- a/java/code/src/com/redhat/rhn/domain/user/legacy/UserInfo_legacyUser.hbm.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE hibernate-mapping
-PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<hibernate-mapping>
- <class name="com.redhat.rhn.domain.user.legacy.UserInfo"
- table="RHNUSERINFO"
- lazy="false">
- <id name="webUserId" type="long" column="user_id">
- <generator class="foreign">
- <param name="property">user</param>
- </generator>
- </id>
- <property name="pageSize" column="page_size" type="int" />
- <property name="usePamAuthentication" column="use_pam_authentication" type="yes_no" />
- <property name="emailNotify" column="email_notify" type="int" />
- <property name="showSystemGroupList" column="show_system_group_list" type="string" />
- <property name="lastLoggedIn" column="last_logged_in" type="timestamp" />
- <property name="created" type="timestamp" insert="false" update="false" />
- <property name="modified" type="timestamp" insert="false" update="false" />
- <property name="preferredLocale" column="preferred_locale" type="string" />
-
- <many-to-one name="timeZone" column="timezone_id"
- class="com.redhat.rhn.domain.user.RhnTimeZone" cascade="none" />
-
- <one-to-one name="user"
- class="com.redhat.rhn.domain.user.legacy.LegacyRhnUserImpl"
- constrained="true" />
- </class>
-</hibernate-mapping>
14 years, 3 months
Changes to 'refs/tags/spacewalk-web-0.8.17-1'
by Michael Mraka
Tag 'spacewalk-web-0.8.17-1' created by Michael Mraka <michael.mraka(a)redhat.com> at 2010-02-11 13:59 +0000
Tagging package [spacewalk-web] version [0.8.17-1] in directory [web/].
Changes since spacewalk-backend-0.8.45-1:
Justin Sherrill (2):
small perl fix
adding missing semicolon
Michael Mraka (1):
Automatic commit of package [spacewalk-web] release [0.8.17-1].
---
rel-eng/packages/spacewalk-web | 2 +-
web/modules/pxt/PXT/ApacheHandler.pm | 2 +-
web/modules/pxt/PXT/Debug.pm | 4 ++--
web/spacewalk-web.spec | 5 ++++-
4 files changed, 8 insertions(+), 5 deletions(-)
---
14 years, 3 months
Branch 'SPACEWALK-0.8' - 3 commits - rel-eng/packages web/modules web/spacewalk-web.spec
by Michael Mraka
rel-eng/packages/spacewalk-web | 2 +-
web/modules/pxt/PXT/ApacheHandler.pm | 2 +-
web/modules/pxt/PXT/Debug.pm | 4 ++--
web/spacewalk-web.spec | 5 ++++-
4 files changed, 8 insertions(+), 5 deletions(-)
New commits:
commit 9153de26ae3ea56ca5d816bb57e0d56509d1e613
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Feb 11 14:59:44 2010 +0100
Automatic commit of package [spacewalk-web] release [0.8.17-1].
diff --git a/rel-eng/packages/spacewalk-web b/rel-eng/packages/spacewalk-web
index 65c089e..7988baf 100644
--- a/rel-eng/packages/spacewalk-web
+++ b/rel-eng/packages/spacewalk-web
@@ -1 +1 @@
-0.8.16-1 web/
+0.8.17-1 web/
diff --git a/web/spacewalk-web.spec b/web/spacewalk-web.spec
index 45a483f..1422595 100644
--- a/web/spacewalk-web.spec
+++ b/web/spacewalk-web.spec
@@ -2,7 +2,7 @@ Name: spacewalk-web
Summary: Spacewalk Web site packages
Group: Applications/Internet
License: GPLv2
-Version: 0.8.16
+Version: 0.8.17
Release: 1%{?dist}
URL: https://fedorahosted.org/spacewalk
Source0: https://fedorahosted.org/releases/s/p/spacewalk/%{name}-%{version}.tar.gz
@@ -256,6 +256,9 @@ rm -rf $RPM_BUILD_ROOT
# $Id$
%changelog
+* Thu Feb 11 2010 Michael Mraka <michael.mraka(a)redhat.com> 0.8.17-1
+- fixed syntax error
+
* Wed Feb 10 2010 Michael Mraka <michael.mraka(a)redhat.com> 0.8.16-1
- bumped spacewalk version in web pages
commit 9692ebb27ec98fb923ebfe20796f19d32f341639
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Wed Feb 10 16:39:07 2010 -0500
adding missing semicolon
diff --git a/web/modules/pxt/PXT/ApacheHandler.pm b/web/modules/pxt/PXT/ApacheHandler.pm
index 72d7ac3..d09f10b 100644
--- a/web/modules/pxt/PXT/ApacheHandler.pm
+++ b/web/modules/pxt/PXT/ApacheHandler.pm
@@ -561,7 +561,7 @@ sub mail_traceback {
my $formvars;
my $pairs = join("\n", map { " $_ => " . $pxt->passthrough_param($_) } sort $pxt->param);
- $formvars = <<EOS
+ $formvars = <<EOS;
Form variables:
$pairs
EOS
commit 8db143cd6d6e505883fa9e8313078516c9522310
Author: Justin Sherrill <jsherril(a)redhat.com>
Date: Wed Feb 10 16:25:40 2010 -0500
small perl fix
diff --git a/web/modules/pxt/PXT/Debug.pm b/web/modules/pxt/PXT/Debug.pm
index d43c441..a00ba57 100644
--- a/web/modules/pxt/PXT/Debug.pm
+++ b/web/modules/pxt/PXT/Debug.pm
@@ -17,8 +17,8 @@ package PXT::Debug;
use strict;
-package PXT::Config ();
-package Data::Dumper ();
+use PXT::Config ();
+use Data::Dumper ();
sub log {
my $class = shift;
14 years, 3 months
rel-eng/push-packages-to-fedora.sh
by Miroslav Suchý
rel-eng/push-packages-to-fedora.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit dfbceb5ab7d12474a1d32adcde31485b155b6794
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Thu Feb 11 14:40:34 2010 +0100
revert accidental commit
diff --git a/rel-eng/push-packages-to-fedora.sh b/rel-eng/push-packages-to-fedora.sh
index abc37dc..17dd209 100755
--- a/rel-eng/push-packages-to-fedora.sh
+++ b/rel-eng/push-packages-to-fedora.sh
@@ -7,7 +7,7 @@ TOP_DIR_FEDORA=$1
# top dir of spacewalk git checkout
TOP_DIR_GIT=$2
-PACKAGE_LIST="nocpulse-common perl-Satcon perl-NOCpulse-CLAC perl-NOCpulse-Debug perl-NOCpulse-Gritch perl-NOCpulse-Object perl-NOCpulse-SetID perl-NOCpulse-Utils spacewalk-proxy-html spacewalk-proxy-docs"
+PACKAGE_LIST="rhnlib rhn-client-tools rhnsd yum-rhn-plugin rhncfg spacewalk-koan spacewalk-certs-tools rhnpush nocpulse-common perl-Satcon perl-NOCpulse-CLAC perl-NOCpulse-Debug perl-NOCpulse-Gritch perl-NOCpulse-Object perl-NOCpulse-SetID perl-NOCpulse-Utils spacewalk-proxy-html spacewalk-proxy-docs"
if [ -z "$TOP_DIR_FEDORA" -o ! -d "$TOP_DIR_FEDORA" ]; then
14 years, 3 months
Changes to 'refs/tags/nocpulse-common-2.1.19-1'
by Miroslav Suchý
Tag 'nocpulse-common-2.1.19-1' created by Miroslav Suchý <msuchy(a)redhat.com> at 2010-02-11 13:34 +0000
Tagging package [nocpulse-common] version [2.1.19-1] in directory [monitoring/nocpulse-common/].
Changes since spacewalk-repo-0.9-1:
Milan Zazrivec (1):
mechanism for updating existing sha256 packages
Miroslav Suchý (3):
script for pushing Spacewalk packages to Fedora rawhide
Fedora guys do not want to have migration code in theirs spec
Automatic commit of package [nocpulse-common] release [2.1.19-1].
---
backend/satellite_tools/updatePackages.py | 189 ++++++++++++++++++++++--
monitoring/nocpulse-common/nocpulse-common.spec | 12 +
rel-eng/packages/nocpulse-common | 2
rel-eng/push-packages-to-fedora.sh | 57 +++++++
4 files changed, 247 insertions(+), 13 deletions(-)
---
14 years, 3 months
2 commits - monitoring/nocpulse-common rel-eng/packages rel-eng/push-packages-to-fedora.sh
by Miroslav Suchý
monitoring/nocpulse-common/nocpulse-common.spec | 12 +++++++++++-
rel-eng/packages/nocpulse-common | 2 +-
rel-eng/push-packages-to-fedora.sh | 2 +-
3 files changed, 13 insertions(+), 3 deletions(-)
New commits:
commit 91c514a9a2bec8279d2332e392fe6f7db44e8ac8
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Thu Feb 11 14:34:42 2010 +0100
Automatic commit of package [nocpulse-common] release [2.1.19-1].
diff --git a/monitoring/nocpulse-common/nocpulse-common.spec b/monitoring/nocpulse-common/nocpulse-common.spec
index 3bfe112..9ac4687 100644
--- a/monitoring/nocpulse-common/nocpulse-common.spec
+++ b/monitoring/nocpulse-common/nocpulse-common.spec
@@ -1,5 +1,5 @@
Name: nocpulse-common
-Version: 2.1.18
+Version: 2.1.19
Release: 1%{?dist}
Summary: NOCpulse common
License: GPLv2
@@ -143,6 +143,9 @@ fi
rm -rf $RPM_BUILD_ROOT
%changelog
+* Thu Feb 11 2010 Miroslav Suchý <msuchy(a)redhat.com> 2.1.19-1
+- Fedora guys do not want to have migration code in theirs spec
+
* Thu Sep 17 2009 Miroslav Suchý <msuchy(a)redhat.com> 2.1.18-1
- 476851 - removal of tables: rhn_db_environment, rhn_environment
diff --git a/rel-eng/packages/nocpulse-common b/rel-eng/packages/nocpulse-common
index 40890fc..87f6ecb 100644
--- a/rel-eng/packages/nocpulse-common
+++ b/rel-eng/packages/nocpulse-common
@@ -1 +1 @@
-2.1.18-1 monitoring/nocpulse-common/
+2.1.19-1 monitoring/nocpulse-common/
commit bdd8eb6d795ad0d3bddecb4e910a231b5602500c
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Thu Feb 11 14:32:17 2010 +0100
Fedora guys do not want to have migration code in theirs spec
diff --git a/monitoring/nocpulse-common/nocpulse-common.spec b/monitoring/nocpulse-common/nocpulse-common.spec
index 80f089b..3bfe112 100644
--- a/monitoring/nocpulse-common/nocpulse-common.spec
+++ b/monitoring/nocpulse-common/nocpulse-common.spec
@@ -65,6 +65,8 @@ install -m 755 npConfigValue $RPM_BUILD_ROOT%{_bindir}/
# change nocpulse user & group to system user & group if needed
dirs="/home/nocpulse /opt/notification /opt/nocpulse /var/log/nocpulse /var/www/templates /var/tmp"
+# Fedora guys do not want this stuff
+%if ! 0%{?fedora}
if [ -d /home/nocpulse -a 0`id -u nocpulse 2> /dev/null` -ge 500 ]; then
if [ 0`id -g nocpulse` -ge 500 ]; then
groupmod -n nocpulse-old nocpulse
@@ -89,6 +91,8 @@ if [ -d /home/nocpulse -a 0`id -u nocpulse 2> /dev/null` -ge 500 ]; then
find $i -user $old_uid -exec chown nocpulse '{}' ';'
done
fi
+%endif
+
getent group %{package_name} >/dev/null || groupadd -r %{package_name}
getent passwd %{package_name} >/dev/null || \
@@ -99,6 +103,8 @@ useradd -r -g %{package_name} -G apache -d %{_var}/lib/%{package_name} -s /bin/b
getent group apache | grep nocpulse >/dev/null || usermod -G apache nocpulse
%post
+# Fedora guys do not want this stuff
+%if ! 0%{?fedora}
# migrate things from /home/nocpulse to /var/lib/nocpulse and /var/log/nocpulse
if [ `getent passwd nocpulse|awk -F ':' '{ print $6 }'` = "/home/nocpulse" ]; then
# /var/lib/nocpulse is new homedir for nocpulse user
@@ -112,6 +118,7 @@ if [ `getent passwd nocpulse|awk -F ':' '{ print $6 }'` = "/home/nocpulse" ]; th
mv /home/nocpulse/var/archives/* \
%{_var}/log/%{package_name} 2> /dev/null
fi
+%endif
if [ ! -f %{identity} ]
then
diff --git a/rel-eng/push-packages-to-fedora.sh b/rel-eng/push-packages-to-fedora.sh
index 17dd209..abc37dc 100755
--- a/rel-eng/push-packages-to-fedora.sh
+++ b/rel-eng/push-packages-to-fedora.sh
@@ -7,7 +7,7 @@ TOP_DIR_FEDORA=$1
# top dir of spacewalk git checkout
TOP_DIR_GIT=$2
-PACKAGE_LIST="rhnlib rhn-client-tools rhnsd yum-rhn-plugin rhncfg spacewalk-koan spacewalk-certs-tools rhnpush nocpulse-common perl-Satcon perl-NOCpulse-CLAC perl-NOCpulse-Debug perl-NOCpulse-Gritch perl-NOCpulse-Object perl-NOCpulse-SetID perl-NOCpulse-Utils spacewalk-proxy-html spacewalk-proxy-docs"
+PACKAGE_LIST="nocpulse-common perl-Satcon perl-NOCpulse-CLAC perl-NOCpulse-Debug perl-NOCpulse-Gritch perl-NOCpulse-Object perl-NOCpulse-SetID perl-NOCpulse-Utils spacewalk-proxy-html spacewalk-proxy-docs"
if [ -z "$TOP_DIR_FEDORA" -o ! -d "$TOP_DIR_FEDORA" ]; then
14 years, 3 months
Changes to 'refs/tags/spacewalk-backend-0.8.45-1'
by Milan Zazrivec
Tag 'spacewalk-backend-0.8.45-1' created by Milan Zazrivec <mzazrivec(a)redhat.com> at 2010-02-11 13:29 +0000
Tagging package [spacewalk-backend] version [0.8.45-1] in directory [backend/].
Changes since spacewalk-repo-0.8-1:
Milan Zazrivec (2):
mechanism for updating existing sha256 packages
Automatic commit of package [spacewalk-backend] release [0.8.45-1].
---
backend/satellite_tools/updatePackages.py | 189 ++++++++++++++++++++++++++++--
backend/spacewalk-backend.spec | 5
rel-eng/packages/spacewalk-backend | 2
3 files changed, 183 insertions(+), 13 deletions(-)
---
14 years, 3 months
Branch 'SPACEWALK-0.8' - backend/spacewalk-backend.spec rel-eng/packages
by Milan Zazrivec
backend/spacewalk-backend.spec | 5 ++++-
rel-eng/packages/spacewalk-backend | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)
New commits:
commit f4605bd7e55f313270b1771d3f1a990d5a2509c1
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Thu Feb 11 14:29:23 2010 +0100
Automatic commit of package [spacewalk-backend] release [0.8.45-1].
diff --git a/backend/spacewalk-backend.spec b/backend/spacewalk-backend.spec
index 934a281..1bea5c8 100644
--- a/backend/spacewalk-backend.spec
+++ b/backend/spacewalk-backend.spec
@@ -8,7 +8,7 @@ Name: spacewalk-backend
Summary: Common programs needed to be installed on the Spacewalk servers/proxies
Group: Applications/Internet
License: GPLv2
-Version: 0.8.44
+Version: 0.8.45
Release: 1%{?dist}
URL: https://fedorahosted.org/spacewalk
Source0: https://fedorahosted.org/releases/s/p/spacewalk/%{name}-%{version}.tar.gz
@@ -621,6 +621,9 @@ rm -f %{rhnconf}/rhnSecret.py*
# $Id$
%changelog
+* Thu Feb 11 2010 Milan Zazrivec <mzazrivec(a)redhat.com> 0.8.45-1
+- mechanism for updating existing sha256 packages
+
* Wed Feb 10 2010 Michael Mraka <michael.mraka(a)redhat.com> 0.8.44-1
- 562644 - added class to emulate mod_python's mp_table
diff --git a/rel-eng/packages/spacewalk-backend b/rel-eng/packages/spacewalk-backend
index e360f66..63bc5bd 100644
--- a/rel-eng/packages/spacewalk-backend
+++ b/rel-eng/packages/spacewalk-backend
@@ -1 +1 @@
-0.8.44-1 backend/
+0.8.45-1 backend/
14 years, 3 months
Branch 'SPACEWALK-0.8' - backend/satellite_tools
by Milan Zazrivec
backend/satellite_tools/updatePackages.py | 189 ++++++++++++++++++++++++++++--
1 file changed, 178 insertions(+), 11 deletions(-)
New commits:
commit 2575688e00aeb7cb0aab08c2c2e00ab87b9770bc
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Thu Feb 11 14:21:42 2010 +0100
mechanism for updating existing sha256 packages
With respect to SHA-256 related changes in Spacewalk, in Spacewalk 0.7 -> 0.8
upgrade course we need to take care of sha-256 capable packages that
have previously been pushed into Spacewalk instance:
* update package checksum of every sha-256 capable package
* update file checksums for every sha-256 capable package
* move every sha-256 capable package to a correct location on a filer
(cherry picked from commit 3a01e698e5a761e6c3dbc3db1106b76c5f1d4adb)
diff --git a/backend/satellite_tools/updatePackages.py b/backend/satellite_tools/updatePackages.py
index ed003ca..64b5356 100644
--- a/backend/satellite_tools/updatePackages.py
+++ b/backend/satellite_tools/updatePackages.py
@@ -28,9 +28,10 @@ from optparse import Option, OptionParser
from common import rhnLib, rhnLog, initLOG, CFG, initCFG
from spacewalk.common import rhn_rpm
from server.rhnLib import parseRPMFilename, get_package_path
-from server import rhnSQL
+from server import rhnSQL, rhnPackageUpload
from server.rhnServer import server_packages
from satellite_tools.progress_bar import ProgressBar
+from spacewalk.common.checksum import getFileChecksum
initCFG('server.satellite')
initLOG(CFG.LOG_FILE, CFG.DEBUG)
@@ -40,17 +41,22 @@ debug = 0
verbose = 0
options_table = [
- Option("-v", "--verbose", action="count",
+ Option("--update-sha256", action="store_true",
+ help="Update SHA-256 capable packages"),
+ Option("--update-filer", action="store_true",
+ help="Convert filer structure"),
+ Option("--update-kstrees", action="store_true",
+ help="Fix kickstart trees permissions"),
+ Option("-d", "--db", action="store", help="DB string to connect to"),
+ Option("-v", "--verbose", action="count",
help="Increase verbosity"),
- Option("-d", "--db", action="store",
- help="DB string to connect to"),
- Option( "--debug", action="store_true",
- help="logs the debug information to a log file"),
+ Option("--debug", action="store_true",
+ help="Log the debug information to a log file"),
]
def main():
- global options_table, debug
+ global options_table, debug, verbose
parser = OptionParser(option_list=options_table)
(options, args) = parser.parse_args()
@@ -73,10 +79,14 @@ def main():
print "Connecting to %s" % options.db
rhnSQL.initDB(options.db)
- process_package_data()
+ if options.update_filer:
+ process_package_data()
- process_kickstart_trees()
+ if options.update_sha256:
+ process_sha256_packages()
+ if options.update_kstrees:
+ process_kickstart_trees()
_get_path_query = """
select id, checksum_type, checksum, path, epoch, new_path
@@ -141,7 +151,7 @@ def process_package_data():
if nevra[1] in [ None, '']:
nevra[1] = path['epoch']
except:
- # probably not qan rpm skip
+ # probably not an rpm skip
if debug:
Log.writeMessage("Skipping: %s Not a valid rpm" \
% old_path_nvrea[-1])
@@ -215,7 +225,164 @@ def process_kickstart_trees():
for name in files:
os.chmod(root + '/' + name, 0644)
+_get_sha256_packages_query = """
+select p.id, p.path
+from rhnPackage p,
+ rhnPackageRequires pr,
+ rhnPackageCapability pc,
+ rhnChecksumView cv
+where pr.package_id = p.id and
+ pr.capability_id = pc.id and
+ pc.name = 'rpmlib(FileDigests)' and
+ pc.version = '4.6.0-1' and
+ cv.id = p.checksum_id and
+ cv.checksum_type = 'md5'
+"""
+
+_update_sha256_package = """
+update rhnPackage
+set checksum_id = lookup_checksum(:ctype, :csum),
+ path = :path
+where id = :id
+"""
+
+_select_checksum_type_id = """
+select id from rhnChecksumType where label = :ctype
+"""
+
+_update_package_files = """
+declare
+ checksum_id number;
+begin
+ begin
+ insert into rhnChecksum values (
+ rhnChecksum_seq.nextval,
+ :ctype_id,
+ :csum ) returning id into checksum_id;
+ exception when dup_val_on_index then
+ select c.id
+ into checksum_id
+ from rhnChecksum c
+ where c.checksum = :csum and
+ c.checksum_type_id = :ctype_id;
+ end;
+
+ update rhnPackageFile p
+ set p.checksum_id = checksum_id
+ where p.capability_id = (
+ select c.id
+ from rhnPackageCapability c
+ where p.package_id = :pid and
+ c.name = :filename
+ ) and p.package_id = :pid;
+end;
+"""
+
+def process_sha256_packages():
+ global verbose, debug
+
+ if debug:
+ Log = rhnLog.rhnLog('/var/log/rhn/update-packages.log', 5)
+
+ _get_sha256_packages_sql = rhnSQL.prepare(_get_sha256_packages_query)
+ _get_sha256_packages_sql.execute()
+ packages = _get_sha256_packages_sql.fetchall_dict()
+
+ if not packages:
+ print "No SHA256 capable packages to process."
+ if debug:
+ Log.writeMessage("No SHA256 capable packages to process.")
+
+ return
+
+ if verbose:
+ print "Processing %s SHA256 capable packages" % len(packages)
+
+ pb = ProgressBar(prompt='standby: ', endTag=' - Complete!', \
+ finalSize=len(packages), finalBarLength=40, stream=sys.stdout)
+ pb.printAll(1)
+
+ _update_sha256_package_sql = rhnSQL.prepare(_update_sha256_package)
+ _update_package_files_sql = rhnSQL.prepare(_update_package_files)
+
+ for package in packages:
+ pb.addTo(1)
+ pb.printIncrement()
+
+ old_abs_path = os.path.join(CFG.MOUNT_POINT, package['path'])
+ temp_file = open(old_abs_path, 'rb')
+ header, payload_stream, header_start, header_end = \
+ rhnPackageUpload.load_package(temp_file)
+ checksum_type = header.checksum_type()
+ checksum = getFileChecksum(checksum_type, file=temp_file)
+
+ old_path = package['path'].split('/')
+ nevra = parseRPMFilename(old_path[-1])
+ org_id = old_path[1]
+ new_path = get_package_path(nevra, org_id, prepend=old_path[0], checksum=checksum)
+ new_abs_path = os.path.join(CFG.MOUNT_POINT, new_path)
+
+ # Filer content relocation
+ try:
+ if old_abs_path != new_abs_path:
+ if debug:
+ Log.writeMessage("Relocating %s to %s on filer" % (old_abs_path, new_abs_path))
+
+ new_abs_dir = os.path.dirname(new_abs_path)
+ if not os.path.isdir(new_abs_dir):
+ os.makedirs(new_abs_dir)
+
+ # link() the old path to the new path
+ if not os.path.exists(new_abs_path):
+ os.link(old_abs_path, new_abs_path)
+ elif debug:
+ Log.writeMessage("File %s already exists" % new_abs_path)
+
+ # Make the new path readable
+ os.chmod(new_abs_path, 0644)
+ except OSError, e:
+ message = "Error when relocating %s to %s on filer: %s" % \
+ (old_abs_path, new_abs_path, str(e))
+ print message
+ if debug:
+ Log.writeMessage(message)
+ sys.exit(1)
+
+ # Update package checksum in the database
+ _update_sha256_package_sql.execute(ctype=checksum_type, csum=checksum,
+ path=new_path, id=package['id'])
+
+ _select_checksum_type_id_sql = rhnSQL.prepare(_select_checksum_type_id)
+ _select_checksum_type_id_sql.execute(ctype=checksum_type)
+ checksum_type_id =_select_checksum_type_id_sql.fetchone()[0]
+
+ # Update checksum of every single file in a package
+ for i, file in enumerate(header['filenames']):
+ csum = header['filemd5s'][i]
+
+ # Do not update checksums for directories & links
+ if not csum:
+ continue
+
+ _update_package_files_sql.execute(ctype_id=checksum_type_id, csum=csum,
+ pid=package['id'], filename=file)
+
+ rhnSQL.commit()
+
+ try:
+ if os.path.exists(old_abs_path):
+ os.unlink(old_abs_path)
+ if os.path.exists(os.path.dirname(old_abs_path)):
+ os.removedirs(os.path.dirname(old_abs_path))
+ except OSError, e:
+ message = "Error when removing %s: %s" % (old_abs_path, str(e))
+ print message
+ if debug:
+ Log.writeMessage(message)
+
+ sys.exit(1)
+
+ pb.printComplete()
if __name__ == '__main__':
main()
-
14 years, 3 months
backend/satellite_tools
by Milan Zazrivec
backend/satellite_tools/updatePackages.py | 189 ++++++++++++++++++++++++++++--
1 file changed, 178 insertions(+), 11 deletions(-)
New commits:
commit 3a01e698e5a761e6c3dbc3db1106b76c5f1d4adb
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Thu Feb 11 14:21:42 2010 +0100
mechanism for updating existing sha256 packages
With respect to SHA-256 related changes in Spacewalk, in Spacewalk 0.7 -> 0.8
upgrade course we need to take care of sha-256 capable packages that
have previously been pushed into Spacewalk instance:
* update package checksum of every sha-256 capable package
* update file checksums for every sha-256 capable package
* move every sha-256 capable package to a correct location on a filer
diff --git a/backend/satellite_tools/updatePackages.py b/backend/satellite_tools/updatePackages.py
index ed003ca..64b5356 100644
--- a/backend/satellite_tools/updatePackages.py
+++ b/backend/satellite_tools/updatePackages.py
@@ -28,9 +28,10 @@ from optparse import Option, OptionParser
from common import rhnLib, rhnLog, initLOG, CFG, initCFG
from spacewalk.common import rhn_rpm
from server.rhnLib import parseRPMFilename, get_package_path
-from server import rhnSQL
+from server import rhnSQL, rhnPackageUpload
from server.rhnServer import server_packages
from satellite_tools.progress_bar import ProgressBar
+from spacewalk.common.checksum import getFileChecksum
initCFG('server.satellite')
initLOG(CFG.LOG_FILE, CFG.DEBUG)
@@ -40,17 +41,22 @@ debug = 0
verbose = 0
options_table = [
- Option("-v", "--verbose", action="count",
+ Option("--update-sha256", action="store_true",
+ help="Update SHA-256 capable packages"),
+ Option("--update-filer", action="store_true",
+ help="Convert filer structure"),
+ Option("--update-kstrees", action="store_true",
+ help="Fix kickstart trees permissions"),
+ Option("-d", "--db", action="store", help="DB string to connect to"),
+ Option("-v", "--verbose", action="count",
help="Increase verbosity"),
- Option("-d", "--db", action="store",
- help="DB string to connect to"),
- Option( "--debug", action="store_true",
- help="logs the debug information to a log file"),
+ Option("--debug", action="store_true",
+ help="Log the debug information to a log file"),
]
def main():
- global options_table, debug
+ global options_table, debug, verbose
parser = OptionParser(option_list=options_table)
(options, args) = parser.parse_args()
@@ -73,10 +79,14 @@ def main():
print "Connecting to %s" % options.db
rhnSQL.initDB(options.db)
- process_package_data()
+ if options.update_filer:
+ process_package_data()
- process_kickstart_trees()
+ if options.update_sha256:
+ process_sha256_packages()
+ if options.update_kstrees:
+ process_kickstart_trees()
_get_path_query = """
select id, checksum_type, checksum, path, epoch, new_path
@@ -141,7 +151,7 @@ def process_package_data():
if nevra[1] in [ None, '']:
nevra[1] = path['epoch']
except:
- # probably not qan rpm skip
+ # probably not an rpm skip
if debug:
Log.writeMessage("Skipping: %s Not a valid rpm" \
% old_path_nvrea[-1])
@@ -215,7 +225,164 @@ def process_kickstart_trees():
for name in files:
os.chmod(root + '/' + name, 0644)
+_get_sha256_packages_query = """
+select p.id, p.path
+from rhnPackage p,
+ rhnPackageRequires pr,
+ rhnPackageCapability pc,
+ rhnChecksumView cv
+where pr.package_id = p.id and
+ pr.capability_id = pc.id and
+ pc.name = 'rpmlib(FileDigests)' and
+ pc.version = '4.6.0-1' and
+ cv.id = p.checksum_id and
+ cv.checksum_type = 'md5'
+"""
+
+_update_sha256_package = """
+update rhnPackage
+set checksum_id = lookup_checksum(:ctype, :csum),
+ path = :path
+where id = :id
+"""
+
+_select_checksum_type_id = """
+select id from rhnChecksumType where label = :ctype
+"""
+
+_update_package_files = """
+declare
+ checksum_id number;
+begin
+ begin
+ insert into rhnChecksum values (
+ rhnChecksum_seq.nextval,
+ :ctype_id,
+ :csum ) returning id into checksum_id;
+ exception when dup_val_on_index then
+ select c.id
+ into checksum_id
+ from rhnChecksum c
+ where c.checksum = :csum and
+ c.checksum_type_id = :ctype_id;
+ end;
+
+ update rhnPackageFile p
+ set p.checksum_id = checksum_id
+ where p.capability_id = (
+ select c.id
+ from rhnPackageCapability c
+ where p.package_id = :pid and
+ c.name = :filename
+ ) and p.package_id = :pid;
+end;
+"""
+
+def process_sha256_packages():
+ global verbose, debug
+
+ if debug:
+ Log = rhnLog.rhnLog('/var/log/rhn/update-packages.log', 5)
+
+ _get_sha256_packages_sql = rhnSQL.prepare(_get_sha256_packages_query)
+ _get_sha256_packages_sql.execute()
+ packages = _get_sha256_packages_sql.fetchall_dict()
+
+ if not packages:
+ print "No SHA256 capable packages to process."
+ if debug:
+ Log.writeMessage("No SHA256 capable packages to process.")
+
+ return
+
+ if verbose:
+ print "Processing %s SHA256 capable packages" % len(packages)
+
+ pb = ProgressBar(prompt='standby: ', endTag=' - Complete!', \
+ finalSize=len(packages), finalBarLength=40, stream=sys.stdout)
+ pb.printAll(1)
+
+ _update_sha256_package_sql = rhnSQL.prepare(_update_sha256_package)
+ _update_package_files_sql = rhnSQL.prepare(_update_package_files)
+
+ for package in packages:
+ pb.addTo(1)
+ pb.printIncrement()
+
+ old_abs_path = os.path.join(CFG.MOUNT_POINT, package['path'])
+ temp_file = open(old_abs_path, 'rb')
+ header, payload_stream, header_start, header_end = \
+ rhnPackageUpload.load_package(temp_file)
+ checksum_type = header.checksum_type()
+ checksum = getFileChecksum(checksum_type, file=temp_file)
+
+ old_path = package['path'].split('/')
+ nevra = parseRPMFilename(old_path[-1])
+ org_id = old_path[1]
+ new_path = get_package_path(nevra, org_id, prepend=old_path[0], checksum=checksum)
+ new_abs_path = os.path.join(CFG.MOUNT_POINT, new_path)
+
+ # Filer content relocation
+ try:
+ if old_abs_path != new_abs_path:
+ if debug:
+ Log.writeMessage("Relocating %s to %s on filer" % (old_abs_path, new_abs_path))
+
+ new_abs_dir = os.path.dirname(new_abs_path)
+ if not os.path.isdir(new_abs_dir):
+ os.makedirs(new_abs_dir)
+
+ # link() the old path to the new path
+ if not os.path.exists(new_abs_path):
+ os.link(old_abs_path, new_abs_path)
+ elif debug:
+ Log.writeMessage("File %s already exists" % new_abs_path)
+
+ # Make the new path readable
+ os.chmod(new_abs_path, 0644)
+ except OSError, e:
+ message = "Error when relocating %s to %s on filer: %s" % \
+ (old_abs_path, new_abs_path, str(e))
+ print message
+ if debug:
+ Log.writeMessage(message)
+ sys.exit(1)
+
+ # Update package checksum in the database
+ _update_sha256_package_sql.execute(ctype=checksum_type, csum=checksum,
+ path=new_path, id=package['id'])
+
+ _select_checksum_type_id_sql = rhnSQL.prepare(_select_checksum_type_id)
+ _select_checksum_type_id_sql.execute(ctype=checksum_type)
+ checksum_type_id =_select_checksum_type_id_sql.fetchone()[0]
+
+ # Update checksum of every single file in a package
+ for i, file in enumerate(header['filenames']):
+ csum = header['filemd5s'][i]
+
+ # Do not update checksums for directories & links
+ if not csum:
+ continue
+
+ _update_package_files_sql.execute(ctype_id=checksum_type_id, csum=csum,
+ pid=package['id'], filename=file)
+
+ rhnSQL.commit()
+
+ try:
+ if os.path.exists(old_abs_path):
+ os.unlink(old_abs_path)
+ if os.path.exists(os.path.dirname(old_abs_path)):
+ os.removedirs(os.path.dirname(old_abs_path))
+ except OSError, e:
+ message = "Error when removing %s: %s" % (old_abs_path, str(e))
+ print message
+ if debug:
+ Log.writeMessage(message)
+
+ sys.exit(1)
+
+ pb.printComplete()
if __name__ == '__main__':
main()
-
14 years, 3 months