java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml | 7 +
java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java | 19 ++++
java/code/src/com/redhat/rhn/taskomatic/task/repomd/RepositoryWriter.java | 44
+++++-----
3 files changed, 50 insertions(+), 20 deletions(-)
New commits:
commit 5b0da627a2788330dfd60ef04b072b4dea416d05
Author: Tomas Lestach <tlestach(a)redhat.com>
Date: Wed May 5 17:08:54 2010 +0200
585901 - recursive comps search
diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
b/java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
index fb73c8f..ca4de55 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
@@ -1184,6 +1184,13 @@ GROUP BY C.id, C.name
</query>
</mode>
+<mode name="cloned_original_id">
+ <query params="cid">
+ SELECT original_id AS id
+ FROM rhnChannelCloned
+ WHERE id = :cid
+ </query>
+</mode>
</datasource_modes>
diff --git a/java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java
b/java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java
index a16baee..3544c67 100644
--- a/java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java
+++ b/java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java
@@ -2697,6 +2697,25 @@ public class ChannelManager extends BaseManager {
}
/**
+ * Returns an id of the original channel
+ * @param channel The cloned channel
+ * @return A original channel id
+ */
+ public static Long lookupOriginalId(Channel channel) {
+ Map params = new HashMap();
+ params.put("cid", channel.getId());
+
+ SelectMode mode = ModeFactory.getMode(
+ "Channel_queries", "cloned_original_id");
+ List<Map> list = (List) mode.execute(params);
+ if (!list.isEmpty()) {
+ Map map = list.get(0);
+ return (Long) map.get("id");
+ }
+ return null;
+ }
+
+ /**
* List errata that is within a channel that needs to be resynced
* This is determined by the packages in the channel
*
diff --git a/java/code/src/com/redhat/rhn/taskomatic/task/repomd/RepositoryWriter.java
b/java/code/src/com/redhat/rhn/taskomatic/task/repomd/RepositoryWriter.java
index 5b59397..f125e73 100644
--- a/java/code/src/com/redhat/rhn/taskomatic/task/repomd/RepositoryWriter.java
+++ b/java/code/src/com/redhat/rhn/taskomatic/task/repomd/RepositoryWriter.java
@@ -18,8 +18,9 @@ import com.redhat.rhn.common.conf.Config;
import com.redhat.rhn.common.conf.ConfigDefaults;
import com.redhat.rhn.common.util.StringUtil;
import com.redhat.rhn.domain.channel.Channel;
-import com.redhat.rhn.domain.channel.ClonedChannel;
+import com.redhat.rhn.domain.channel.ChannelFactory;
import com.redhat.rhn.frontend.dto.PackageDto;
+import com.redhat.rhn.manager.channel.ChannelManager;
import com.redhat.rhn.manager.rhnpackage.PackageManager;
import com.redhat.rhn.manager.task.TaskManager;
@@ -249,7 +250,27 @@ public class RepositoryWriter {
" seconds");
}
-
+ private String getCompsRelativeFilename(Channel channel) {
+ String relativeFilename = null;
+
+ if (channel.getComps() == null) {
+ relativeFilename = getCompsFilePath(channel);
+ }
+ else {
+ relativeFilename = channel.getComps().getRelativeFilename();
+ }
+
+ // if we didn't find anything, let's check channel's original
+ if (relativeFilename == null && channel.isCloned()) {
+ // use a hack not to use ClonedChannel and it's getOriginal() method
+ Long originalChannelId = ChannelManager.lookupOriginalId(channel);
+ Channel originalChannel = ChannelFactory.lookupById(originalChannelId);
+ return getCompsRelativeFilename(originalChannel);
+ }
+
+ return relativeFilename;
+ }
+
/**
*
* @param channel channel indo
@@ -257,18 +278,8 @@ public class RepositoryWriter {
* @return repomd index for given channel
*/
private RepomdIndexData loadCompsFile(Channel channel, String checksumAlgo) {
- String relativeFilename;
String compsMount = Config.get().getString(ConfigDefaults.MOUNT_POINT);
-
- if (channel.getComps() == null) {
- relativeFilename = getCompsFilePath(channel);
- if (relativeFilename == null) {
- return null;
- }
- }
- else {
- relativeFilename = channel.getComps().getRelativeFilename();
- }
+ String relativeFilename = getCompsRelativeFilename(channel);
File compsFile = new File(compsMount + File.separator + relativeFilename);
FileInputStream stream;
@@ -345,13 +356,6 @@ public class RepositoryWriter {
if (compsMapping.containsKey(channel.getLabel())) {
compsPath = compsMapping.get(channel.getLabel());
}
- else if (channel.isCloned()) {
- // If its a cloned channel see if we can get the comps
- // from the original channel.
- ClonedChannel clonedCh = (ClonedChannel) channel;
- Channel origChannel = clonedCh.getOriginal();
- compsPath = compsMapping.get(origChannel.getLabel());
- }
return compsPath;
}
Show replies by thread