java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java
| 28 --------
java/code/src/com/redhat/rhn/domain/channel/ContentSource.hbm.xml
| 6 -
java/code/src/com/redhat/rhn/frontend/action/channel/manage/RepositoriesAction.java
| 2
java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/ChannelSoftwareHandler.java
| 33 ++++++----
java/code/src/com/redhat/rhn/manager/channel/repo/BaseRepoCommand.java
| 2
5 files changed, 26 insertions(+), 45 deletions(-)
New commits:
commit da076f44e18e1e446966df03788d3806f335f23b
Author: Tomas Lestach <tlestach(a)redhat.com>
Date: Mon Oct 24 15:30:12 2011 +0200
682845 - get rid of ChannelFactory.lookupContentSource(id) method without org param
diff --git a/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java
b/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java
index a551e53..7c338ca 100644
--- a/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java
+++ b/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java
@@ -118,18 +118,6 @@ public class ChannelFactory extends HibernateFactory {
}
/**
- * Lookup a content source by id
- * @param id the id to lookup
- * @return the ContentSource
- */
- public static ContentSource lookupContentSource(Long id) {
- Map params = new HashMap();
- params.put("id", id);
- return (ContentSource) singleton.lookupObjectByNamedQuery(
- "ContentSource.findById", params);
- }
-
- /**
* Lookup a content source by org
* @param org the org to lookup
* @return the ContentSource(s)
diff --git a/java/code/src/com/redhat/rhn/domain/channel/ContentSource.hbm.xml
b/java/code/src/com/redhat/rhn/domain/channel/ContentSource.hbm.xml
index 6c36fc6..c4bd583 100644
--- a/java/code/src/com/redhat/rhn/domain/channel/ContentSource.hbm.xml
+++ b/java/code/src/com/redhat/rhn/domain/channel/ContentSource.hbm.xml
@@ -41,9 +41,6 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
<query name="ContentSource.findByIdandOrg">
<![CDATA[from com.redhat.rhn.domain.channel.ContentSource as c where c.id =
:id and c.org = :org]]>
</query>
- <query name="ContentSource.findById">
- <![CDATA[from com.redhat.rhn.domain.channel.ContentSource as c where c.id =
:id]]>
- </query>
<query name="ContentSource.findByOrg">
<![CDATA[from com.redhat.rhn.domain.channel.ContentSource as c where c.org =
:org]]>
</query>
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/RepositoriesAction.java
b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/RepositoriesAction.java
index e707762..18a6056 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/RepositoriesAction.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/RepositoriesAction.java
@@ -88,7 +88,7 @@ public class RepositoriesAction extends RhnAction implements Listable {
Set <String> set = helper.getSet();
for (String id : set) {
Long sgid = Long.valueOf(id);
- ContentSource tmp = ChannelFactory.lookupContentSource(sgid);
+ ContentSource tmp = ChannelFactory.lookupContentSource(sgid,
user.getOrg());
foo.add(tmp);
}
diff --git
a/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/ChannelSoftwareHandler.java
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/ChannelSoftwareHandler.java
index 9fd893b..48aaff8 100644
---
a/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/ChannelSoftwareHandler.java
+++
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/ChannelSoftwareHandler.java
@@ -2390,7 +2390,8 @@ public class ChannelSoftwareHandler extends BaseHandler {
**/
public Integer removeRepo(String sessionKey, Integer id) {
User user = getLoggedInUser(sessionKey);
- ContentSource repo = ChannelFactory.lookupContentSource(new
Long(id.longValue()));
+ ContentSource repo = ChannelFactory.lookupContentSource(new
Long(id.longValue()),
+ user.getOrg());
ChannelFactory.remove(repo);
return 1;
@@ -2485,7 +2486,8 @@ public class ChannelSoftwareHandler extends BaseHandler {
**/
public ContentSource updateRepoUrl(String sessionKey, Integer id, String url) {
User user = getLoggedInUser(sessionKey);
- ContentSource repo = ChannelFactory.lookupContentSource(new
Long(id.longValue()));
+ ContentSource repo = ChannelFactory.lookupContentSource(new
Long(id.longValue()),
+ user.getOrg());
repo.setSourceUrl(url);
ChannelFactory.save(repo);
return repo;
@@ -2528,7 +2530,8 @@ public class ChannelSoftwareHandler extends BaseHandler {
**/
public ContentSource updateRepoLabel(String sessionKey, Integer id, String label) {
User user = getLoggedInUser(sessionKey);
- ContentSource repo = ChannelFactory.lookupContentSource(new
Long(id.longValue()));
+ ContentSource repo = ChannelFactory.lookupContentSource(new
Long(id.longValue()),
+ user.getOrg());
repo.setLabel(label);
ChannelFactory.save(repo);
return repo;
@@ -2552,7 +2555,8 @@ public class ChannelSoftwareHandler extends BaseHandler {
public ContentSource updateRepo(String sessionKey, Integer id, String label,
String url) {
User user = getLoggedInUser(sessionKey);
- ContentSource repo = ChannelFactory.lookupContentSource(new
Long(id.longValue()));
+ ContentSource repo = ChannelFactory.lookupContentSource(new
Long(id.longValue()),
+ user.getOrg());
repo.setLabel(label);
repo.setSourceUrl(url);
ChannelFactory.save(repo);
@@ -2589,7 +2593,8 @@ public class ChannelSoftwareHandler extends BaseHandler {
* $ContentSourceSerializer
*/
public ContentSource getRepoDetails(String sessionKey, Integer id) {
- return ChannelFactory.lookupContentSource(new Long(id.longValue()));
+ User user = getLoggedInUser(sessionKey);
+ return ChannelFactory.lookupContentSource(new Long(id.longValue()),
user.getOrg());
}
/**
commit 2d9649abe87b899e976992491e1faa6e4c39b5f5
Author: Tomas Lestach <tlestach(a)redhat.com>
Date: Mon Oct 24 14:55:36 2011 +0200
682845 - get rid of ChannelFactory.lookupContentSource(label) method without org
param
diff --git a/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java
b/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java
index 24467c3..a551e53 100644
--- a/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java
+++ b/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java
@@ -130,18 +130,6 @@ public class ChannelFactory extends HibernateFactory {
}
/**
- * Lookup a content source by label
- * @param label the label to lookup
- * @return the ContentSource
- */
- public static ContentSource lookupContentSource(String label) {
- Map params = new HashMap();
- params.put("label", label);
- return (ContentSource) singleton.lookupObjectByNamedQuery(
- "ContentSource.findByLabel", params);
- }
-
- /**
* Lookup a content source by org
* @param org the org to lookup
* @return the ContentSource(s)
@@ -173,12 +161,12 @@ public class ChannelFactory extends HibernateFactory {
* @param label repo label
* @return the ContentSource(s)
*/
- public static List<ContentSource> lookupContentSourceByOrgAndLabel(Org org,
+ public static ContentSource lookupContentSourceByOrgAndLabel(Org org,
String label) {
Map params = new HashMap();
params.put("org", org);
params.put("label", label);
- return singleton.listObjectsByNamedQuery(
+ return (ContentSource) singleton.lookupObjectByNamedQuery(
"ContentSource.findByOrgAndLabel", params);
}
diff --git a/java/code/src/com/redhat/rhn/domain/channel/ContentSource.hbm.xml
b/java/code/src/com/redhat/rhn/domain/channel/ContentSource.hbm.xml
index 79ad517..6c36fc6 100644
--- a/java/code/src/com/redhat/rhn/domain/channel/ContentSource.hbm.xml
+++ b/java/code/src/com/redhat/rhn/domain/channel/ContentSource.hbm.xml
@@ -44,9 +44,6 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
<query name="ContentSource.findById">
<![CDATA[from com.redhat.rhn.domain.channel.ContentSource as c where c.id =
:id]]>
</query>
- <query name="ContentSource.findByLabel">
- <![CDATA[from com.redhat.rhn.domain.channel.ContentSource as c where c.label =
:label]]>
- </query>
<query name="ContentSource.findByOrg">
<![CDATA[from com.redhat.rhn.domain.channel.ContentSource as c where c.org =
:org]]>
</query>
diff --git
a/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/ChannelSoftwareHandler.java
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/ChannelSoftwareHandler.java
index 4076167..9fd893b 100644
---
a/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/ChannelSoftwareHandler.java
+++
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/ChannelSoftwareHandler.java
@@ -2372,7 +2372,8 @@ public class ChannelSoftwareHandler extends BaseHandler {
repoCmd.store();
- ContentSource repo = ChannelFactory.lookupContentSource(label);
+ ContentSource repo = ChannelFactory.lookupContentSourceByOrgAndLabel(
+ user.getOrg(), label);
return repo;
}
@@ -2408,7 +2409,8 @@ public class ChannelSoftwareHandler extends BaseHandler {
**/
public Integer removeRepo(String sessionKey, String label) {
User user = getLoggedInUser(sessionKey);
- ContentSource repo = ChannelFactory.lookupContentSource(label);
+ ContentSource repo =
ChannelFactory.lookupContentSourceByOrgAndLabel(user.getOrg(),
+ label);
ChannelFactory.remove(repo);
return 1;
@@ -2430,7 +2432,8 @@ public class ChannelSoftwareHandler extends BaseHandler {
public Channel associateRepo(String sessionKey, String chanLabel, String repoLabel)
{
User user = getLoggedInUser(sessionKey);
Channel channel = lookupChannelByLabel(user, chanLabel);
- ContentSource repo = ChannelFactory.lookupContentSource(repoLabel);
+ ContentSource repo =
ChannelFactory.lookupContentSourceByOrgAndLabel(user.getOrg(),
+ repoLabel);
Set<ContentSource> set = channel.getSources();
set.add(repo);
@@ -2455,7 +2458,8 @@ public class ChannelSoftwareHandler extends BaseHandler {
public Channel disassociateRepo(String sessionKey, String chanLabel, String
repoLabel) {
User user = getLoggedInUser(sessionKey);
Channel channel = lookupChannelByLabel(user, chanLabel);
- ContentSource repo = ChannelFactory.lookupContentSource(repoLabel);
+ ContentSource repo =
ChannelFactory.lookupContentSourceByOrgAndLabel(user.getOrg(),
+ repoLabel);
Set<ContentSource> set = channel.getSources();
set.remove(repo);
@@ -2502,7 +2506,8 @@ public class ChannelSoftwareHandler extends BaseHandler {
**/
public ContentSource updateRepoUrl(String sessionKey, String label, String url) {
User user = getLoggedInUser(sessionKey);
- ContentSource repo = ChannelFactory.lookupContentSource(label);
+ ContentSource repo =
ChannelFactory.lookupContentSourceByOrgAndLabel(user.getOrg(),
+ label);
repo.setSourceUrl(url);
ChannelFactory.save(repo);
return repo;
@@ -2567,7 +2572,8 @@ public class ChannelSoftwareHandler extends BaseHandler {
* $ContentSourceSerializer
*/
public ContentSource getRepoDetails(String sessionKey, String repoLabel) {
- return ChannelFactory.lookupContentSource(repoLabel);
+ User user = getLoggedInUser(sessionKey);
+ return ChannelFactory.lookupContentSourceByOrgAndLabel(user.getOrg(),
repoLabel);
}
/**
diff --git a/java/code/src/com/redhat/rhn/manager/channel/repo/BaseRepoCommand.java
b/java/code/src/com/redhat/rhn/manager/channel/repo/BaseRepoCommand.java
index 849459e..b0b9050 100644
--- a/java/code/src/com/redhat/rhn/manager/channel/repo/BaseRepoCommand.java
+++ b/java/code/src/com/redhat/rhn/manager/channel/repo/BaseRepoCommand.java
@@ -102,7 +102,7 @@ public class BaseRepoCommand {
repo.setType(ChannelFactory.CONTENT_SOURCE_TYPE_YUM);
if (!this.label.equals(repo.getLabel())) {
- if (!ChannelFactory.lookupContentSourceByOrgAndLabel(org, label).isEmpty())
{
+ if (ChannelFactory.lookupContentSourceByOrgAndLabel(org, label) != null) {
throw new InvalidRepoLabelException(label);
}
repo.setLabel(this.label);