java/code/src/com/redhat/rhn/domain/channel/Channel.hbm.xml | 5 java/code/src/com/redhat/rhn/domain/channel/Channel.java | 39 ++- java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java | 58 +++-- java/code/src/com/redhat/rhn/domain/channel/test/ChannelFactoryTest.java | 16 + java/code/src/com/redhat/rhn/domain/common/ChecksumType.hbm.xml | 32 +++ java/code/src/com/redhat/rhn/domain/common/ChecksumType.java | 105 ++++++++++ java/code/src/com/redhat/rhn/domain/common/test/ChecksumTypeTest.java | 42 ++++ java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java | 46 ++-- java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml | 15 + java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java | 16 + java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java | 11 + java/code/src/com/redhat/rhn/taskomatic/task/repomd/RepomdIndexData.java | 8 java/code/src/com/redhat/rhn/taskomatic/task/repomd/RepositoryWriter.java | 28 ++ java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp | 13 + java/code/webapp/WEB-INF/struts-config.xml | 1 schema/spacewalk/rhnsat/tables/rhnChannel.sql | 2 schema/spacewalk/rhnsat/tables/rhnChecksumType.sql | 44 ++++ schema/spacewalk/rhnsat/tables/rhnChecksumType_data.sql | 37 +++ schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/125-rhnChecksumType.sql | 44 ++++ schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/126-rhnChecksumType_data.sql | 37 +++ schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/191-rhnChannel.sql | 7 21 files changed, 548 insertions(+), 58 deletions(-)
New commits: commit a39bf26b3a479712458f103c7e05bc58c49458e9 Author: Pradeep Kilambi pkilambi@redhat.com Date: Thu Jul 23 14:30:00 2009 -0400
Sha256 support for channel creation:
- Added the ablility for user to specify a yum repository checksum type at the channel creation time.
- Added a new table lookup table called rhnChecksumType
- Added a new column to rhnChannel checksum_type_id
- Channel creation sets the checksum_type_id and stores it for further lookup for repo generation to pick the user specified checksum.
- Edit channel page should reset the checksum_type_id value and trigger the repo generation with new checksum type.
diff --git a/java/code/src/com/redhat/rhn/domain/channel/Channel.hbm.xml b/java/code/src/com/redhat/rhn/domain/channel/Channel.hbm.xml index f4ecff3..c5ac8f3 100644 --- a/java/code/src/com/redhat/rhn/domain/channel/Channel.hbm.xml +++ b/java/code/src/com/redhat/rhn/domain/channel/Channel.hbm.xml @@ -45,6 +45,11 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" class="com.redhat.rhn.domain.channel.ChannelArch" column="channel_arch_id"/>
+ <many-to-one + name="checksum" + class="com.redhat.rhn.domain.common.ChecksumType" + column="checksum_type_id"/> + <set name="distChannelMaps"> <key column="channel_id"/> <one-to-many class="com.redhat.rhn.domain.channel.DistChannelMap"/> diff --git a/java/code/src/com/redhat/rhn/domain/channel/Channel.java b/java/code/src/com/redhat/rhn/domain/channel/Channel.java index ca5071e..9a40950 100644 --- a/java/code/src/com/redhat/rhn/domain/channel/Channel.java +++ b/java/code/src/com/redhat/rhn/domain/channel/Channel.java @@ -20,6 +20,7 @@ import com.redhat.rhn.domain.org.Org; import com.redhat.rhn.domain.rhnpackage.Package; import com.redhat.rhn.domain.server.Server; import com.redhat.rhn.domain.user.User; +import com.redhat.rhn.domain.common.ChecksumType; import com.redhat.rhn.manager.channel.ChannelManager; import com.redhat.rhn.manager.system.IncompatibleArchException; import com.redhat.rhn.manager.system.SystemManager; @@ -50,8 +51,8 @@ public class Channel extends BaseDomainHelper implements Comparable { public static final String PUBLIC = "public"; public static final String PROTECTED = "protected"; public static final String PRIVATE = "private"; - private static final String CHECKSUM_SHA_1 = "SHA1"; - private static final String CHECKSUM_SHA_256 = "SHA-256"; + private static final String CHECKSUM_SHA_1 = "sha1"; + private static final String CHECKSUM_SHA_256 = "sha-256";
private static List<String> releaseToSkipRepodata = new ArrayList<String>(Arrays .asList("2.1AS", "2.1ES", "2.1WS", "3AS", "3ES", "3WS", "3Desktop", "4AS", @@ -63,6 +64,8 @@ public class Channel extends BaseDomainHelper implements Comparable { .asList("5Server", "5Client")); private String baseDir; private ChannelArch channelArch; + private ChecksumType checksum; + private String description; private Date endOfLife; private String GPGKeyUrl; @@ -159,6 +162,21 @@ public class Channel extends BaseDomainHelper implements Comparable { public void setChannelArch(ChannelArch c) { this.channelArch = c; } + + /** + * @return Returns the channelChecksum. + */ + public ChecksumType getChecksum() { + return checksum; + } + + /** + * @param checksumIn The checksum to set. + */ + public void setChecksum(ChecksumType checksumIn) { + this.checksum = checksumIn; + } +
/** * @param compsIn The Comps to set. @@ -798,12 +816,14 @@ public class Channel extends BaseDomainHelper implements Comparable {
/** * get the compatible checksum type to be used for repomd.xml - * based on channel release. If its RHEL-5 we use sha1 - * anything newer will be sha256. + * based on channel release. + * If its a custom channel use the checksum_type_id from db set at creation time + * If its RHEL-5 we use sha1 anything newer will be sha256. * @return checksumType */ public String getChecksumType() { Channel toConsider = this; + while (toConsider.getParentChannel() != null) { toConsider = toConsider.getParentChannel(); } @@ -811,13 +831,16 @@ public class Channel extends BaseDomainHelper implements Comparable { if (channelDist != null) { String release = channelDist.getRelease(); // If channel or parent is RHEL-5 use sha1, else use sha256 - if (toConsider.isCustom() || sha1compatiblechannels.contains(release)) { + if (sha1compatiblechannels.contains(release)) { return CHECKSUM_SHA_1; } - else { - return CHECKSUM_SHA_256; - } } + + // IF its custom use the one set at channel creation time + if (toConsider.isCustom()) { + return toConsider.getChecksum().getLabel(); + } + // default to sha256 return CHECKSUM_SHA_256; } 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 aff50d6..ec8d52c 100644 --- a/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java +++ b/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java @@ -14,6 +14,22 @@ */ package com.redhat.rhn.domain.channel;
+import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.log4j.Logger; +import org.hibernate.Criteria; +import org.hibernate.HibernateException; +import org.hibernate.Session; +import org.hibernate.criterion.CriteriaSpecification; +import org.hibernate.criterion.Projections; +import org.hibernate.criterion.Restrictions; + import com.redhat.rhn.common.db.datasource.CallableMode; import com.redhat.rhn.common.db.datasource.DataResult; import com.redhat.rhn.common.db.datasource.ModeFactory; @@ -21,28 +37,13 @@ import com.redhat.rhn.common.db.datasource.SelectMode; import com.redhat.rhn.common.db.datasource.WriteMode; import com.redhat.rhn.common.hibernate.HibernateFactory; import com.redhat.rhn.common.hibernate.HibernateRuntimeException; +import com.redhat.rhn.domain.common.ChecksumType; import com.redhat.rhn.domain.kickstart.KickstartableTree; import com.redhat.rhn.domain.org.Org; import com.redhat.rhn.domain.rhnpackage.Package; import com.redhat.rhn.domain.user.User; import com.redhat.rhn.manager.channel.ChannelManager;
-import org.apache.log4j.Logger; -import org.hibernate.Criteria; -import org.hibernate.HibernateException; -import org.hibernate.Session; -import org.hibernate.criterion.CriteriaSpecification; -import org.hibernate.criterion.Projections; -import org.hibernate.criterion.Restrictions; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - /** * ChannelFactory * @version $Rev$ @@ -223,7 +224,6 @@ public class ChannelFactory extends HibernateFactory { c.add(Restrictions.in("label", labels)); return c.list(); } -
/** * Returns list of channel architectures @@ -234,7 +234,7 @@ public class ChannelFactory extends HibernateFactory { Criteria criteria = session.createCriteria(ChannelArch.class); return criteria.list(); } - + /** * returns a ChannelArch by label * @param label ChannelArch label @@ -530,7 +530,27 @@ public class ChannelFactory extends HibernateFactory { "KickstartableTree.findTreesForChannel", params); }
- + /** + * Find yum supported checksum types + * @return List of ChecksumTypes instances + */ + public static List<ChecksumType> listYumSupportedChecksums() { + return singleton.listObjectsByNamedQuery( + "ChecksumType.loadAllForYum", Collections.EMPTY_MAP); + } + + /** + * Find checksumtype by label + * @param checksum checksum label + * @return ChecksumType instance for given label + */ + public static ChecksumType findChecksumByLabel(String checksum) { + Map params = new HashMap(); + params.put("label", checksum); + return (ChecksumType) + singleton.lookupObjectByNamedQuery("ChecksumType.findByLabel", params); + } + /** * Get a list of packages ids that are in a channel * and in a list of errata. (The errata do not diff --git a/java/code/src/com/redhat/rhn/domain/channel/test/ChannelFactoryTest.java b/java/code/src/com/redhat/rhn/domain/channel/test/ChannelFactoryTest.java index a9e9f24..fe901d9 100644 --- a/java/code/src/com/redhat/rhn/domain/channel/test/ChannelFactoryTest.java +++ b/java/code/src/com/redhat/rhn/domain/channel/test/ChannelFactoryTest.java @@ -22,6 +22,7 @@ import com.redhat.rhn.domain.channel.ChannelFamily; import com.redhat.rhn.domain.channel.ChannelFamilyFactory; import com.redhat.rhn.domain.channel.ClonedChannel; import com.redhat.rhn.domain.channel.ProductName; +import com.redhat.rhn.domain.common.ChecksumType; import com.redhat.rhn.domain.org.Org; import com.redhat.rhn.domain.rhnpackage.Package; import com.redhat.rhn.domain.rhnpackage.test.PackageTest; @@ -382,7 +383,22 @@ public class ChannelFactoryTest extends RhnBaseTestCase { fileNameChild); assertNotNull(lookedUpChild); assertEquals(cp.getId(), lookedUpChild.getId()); + + } + + public void testfindChecksumByLabel() { + assertNull("Checksum found for null label", + ChannelFactory.findChecksumByLabel(null)); + assertNull("Checksum found for invalid label", + ChannelFactory.findChecksumByLabel("some-invalid_checksum"));
+ ChecksumType ct = ChannelFactory.findChecksumByLabel("sha-256"); + assertNotNull(ct); + assertEquals("sha-256", ct.getLabel());
+ ChecksumType ct2 = ChannelFactory.findChecksumByLabel("sha1"); + assertNotNull(ct2); + assertEquals("sha1", ct2.getLabel()); } + } diff --git a/java/code/src/com/redhat/rhn/domain/common/ChecksumType.hbm.xml b/java/code/src/com/redhat/rhn/domain/common/ChecksumType.hbm.xml new file mode 100644 index 0000000..dea8be7 --- /dev/null +++ b/java/code/src/com/redhat/rhn/domain/common/ChecksumType.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.common.ChecksumType" + table="rhnChecksumType" mutable="false"> + <cache usage="read-only"/> + <id name="id" type="long" column="id"> + <meta attribute="scope-set">protected</meta> + <generator class="assigned" /> + </id> + <property name="label" type="string" column="label" /> + <property name="description" type="string" column="description" /> + <property name="created" type="date" column="created" /> + <property name="modified" type="date" column="modified" /> + </class> + + <query name="ChecksumType.loadAll"> + <![CDATA[from com.redhat.rhn.domain.common.ChecksumType]]> + </query> + <query name="ChecksumType.loadAllForYum"> + <![CDATA[from com.redhat.rhn.domain.common.ChecksumType as t + where t.label = 'sha-256' or t.label = 'sha1']]> + </query> + <query name="ChecksumType.findById"> + <![CDATA[from com.redhat.rhn.domain.common.ChecksumType as t where t.id = :id]]> + </query> + <query name="ChecksumType.findByLabel"> + <![CDATA[from com.redhat.rhn.domain.common.ChecksumType as t where t.label = :label]]> + </query> +</hibernate-mapping> diff --git a/java/code/src/com/redhat/rhn/domain/common/ChecksumType.java b/java/code/src/com/redhat/rhn/domain/common/ChecksumType.java new file mode 100644 index 0000000..3e41435 --- /dev/null +++ b/java/code/src/com/redhat/rhn/domain/common/ChecksumType.java @@ -0,0 +1,105 @@ +/** + * Copyright (c) 2009 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.common; + +import com.redhat.rhn.domain.BaseDomainHelper; + +import org.apache.commons.lang.builder.ToStringBuilder; + +/** + * ArchType + * @version $Rev$ + */ +public class ChecksumType extends BaseDomainHelper { + + private Long id; + private String label; + private String description; + + /** + * @return Returns the id. + */ + public Long getId() { + return id; + } + + /** + * @param i The id to set. + */ + public void setId(Long i) { + this.id = i; + } + + /** + * @return Returns the label. + */ + public String getLabel() { + return label; + } + + /** + * @param l The label to set. + */ + public void setLabel(String l) { + this.label = l; + } + + /** + * @return Returns the description. + */ + public String getDescription() { + return description; + } + + /** + * @param n The name to set. + */ + public void setDescription(String n) { + this.description = n; + } + + /** {@inheritDoc} */ + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + ChecksumType checksumType = (ChecksumType) o; + + if (id != null ? !id.equals(checksumType.id) : checksumType.id != null) { + return false; + } + + return true; + } + + /** {@inheritDoc} */ + public int hashCode() { + return id != null ? id.hashCode() : 0; + } + + /** {@inheritDoc} */ + public String toString() { + ToStringBuilder builder = new ToStringBuilder(this); + + builder.append("id", id); + builder.append("label", label); + + return builder.toString(); + } +} diff --git a/java/code/src/com/redhat/rhn/domain/common/test/ChecksumTypeTest.java b/java/code/src/com/redhat/rhn/domain/common/test/ChecksumTypeTest.java new file mode 100644 index 0000000..a0fd478 --- /dev/null +++ b/java/code/src/com/redhat/rhn/domain/common/test/ChecksumTypeTest.java @@ -0,0 +1,42 @@ +/** + * Copyright (c) 2009 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.common.test; + +import com.redhat.rhn.domain.common.ChecksumType; +import com.redhat.rhn.testing.RhnBaseTestCase; +import com.redhat.rhn.testing.TestUtils; + +/** + * ArchTypeTest + * @version $Rev$ + */ +public class ChecksumTypeTest extends RhnBaseTestCase { + + public void testChecksumType() throws Exception { + + Long testid = new Long(1); + String query = "ChecksumType.findById"; + + ChecksumType at1 = (ChecksumType) TestUtils.lookupFromCacheById(testid, query); + assertNotNull(at1); + assertEquals(at1.getId(), testid); + + ChecksumType at2 = (ChecksumType) TestUtils.lookupFromCacheById(at1.getId(), query); + assertEquals(at1.getLabel(), at2.getLabel()); + + ChecksumType at3 = (ChecksumType) TestUtils.lookupFromCacheById(at1.getId(), query); + } + +} diff --git a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java index 929dfc2..09d500e 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java @@ -14,6 +14,24 @@ */ package com.redhat.rhn.frontend.action.channel.manage;
+import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionErrors; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.action.ActionMessage; +import org.apache.struts.action.ActionMessages; +import org.apache.struts.action.DynaActionForm; + import com.redhat.rhn.common.db.datasource.DataResult; import com.redhat.rhn.common.localization.LocalizationService; import com.redhat.rhn.common.security.PermissionException; @@ -41,24 +59,6 @@ import com.redhat.rhn.manager.channel.UpdateChannelCommand; import com.redhat.rhn.manager.system.SystemManager; import com.redhat.rhn.manager.user.UserManager;
-import org.apache.struts.action.ActionErrors; -import org.apache.struts.action.ActionForm; -import org.apache.struts.action.ActionForward; -import org.apache.struts.action.ActionMapping; -import org.apache.struts.action.ActionMessage; -import org.apache.struts.action.ActionMessages; -import org.apache.struts.action.DynaActionForm; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -
/** * EditChannelAction @@ -158,6 +158,7 @@ public class EditChannelAction extends RhnAction implements Listable { request.setAttribute("channel_name", form.getString("name")); request.setAttribute("channel_arch", form.get("arch_name")); request.setAttribute("channel_arch_label", form.get("arch")); + request.setAttribute("checksum_label", form.get("checksum")); addErrors(request, errors); prepDropdowns(new RequestContext(request)); return getStrutsDelegate().forwardParams( @@ -197,6 +198,7 @@ public class EditChannelAction extends RhnAction implements Listable { request.setAttribute("label", form.get("label")); request.setAttribute("parent", form.get("parent")); request.setAttribute("arch", form.get("arch")); + request.setAttribute("checksum", form.get("checksum")); request.setAttribute("arch_name", form.get("arch_name")); request.setAttribute("summary", form.get("summary")); request.setAttribute("description", form.get("description")); @@ -319,6 +321,7 @@ public class EditChannelAction extends RhnAction implements Listable { // times where python would make this SOOOO much easier. UpdateChannelCommand ucc = new UpdateChannelCommand(); ucc.setArchLabel((String)form.get("arch")); + ucc.setChecksum((String)form.get("checksum")); ucc.setLabel((String)form.get("label")); ucc.setName((String)form.get("name")); ucc.setSummary((String)form.get("summary")); @@ -388,6 +391,7 @@ public class EditChannelAction extends RhnAction implements Listable { // times where python would make this SOOOO much easier. CreateChannelCommand ccc = new CreateChannelCommand(); ccc.setArchLabel((String)form.get("arch")); + ccc.setChecksum((String)form.get("checksum")); ccc.setLabel((String)form.get("label")); ccc.setName((String)form.get("name")); ccc.setSummary((String)form.get("summary")); @@ -546,6 +550,7 @@ public class EditChannelAction extends RhnAction implements Listable { form.set("maintainer_phone", c.getMaintainerPhone()); form.set("maintainer_email", c.getMaintainerEmail()); form.set("support_policy", c.getSupportPolicy()); + form.set("checksum", c.getChecksum().getLabel()); if (c.isGloballySubscribable(ctx.getLoggedInUser().getOrg())) { form.set("per_user_subscriptions", "all"); } @@ -569,6 +574,7 @@ public class EditChannelAction extends RhnAction implements Listable { request.setAttribute("channel_name", c.getName()); request.setAttribute("channel_arch", c.getChannelArch().getName()); request.setAttribute("channel_arch_label", c.getChannelArch().getLabel()); + } else { // default settings @@ -601,6 +607,10 @@ public class EditChannelAction extends RhnAction implements Listable { addOption(channelArches, arch.getName(), arch.getLabel()); } ctx.getRequest().setAttribute("channelArches", channelArches); + // set the list of yum supported checksums + ctx.getRequest().setAttribute("checksums", + ChannelFactory.listYumSupportedChecksums()); + }
/** diff --git a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml index aab7a1f..af98b30 100644 --- a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml +++ b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml @@ -20940,6 +20940,21 @@ given channel.</source> <context context-type="sourcefile">/rhn/channels/manage/Edit.do</context> </context-group> </trans-unit> + <trans-unit id="channel.edit.jsp.checksum"> + <source>Yum Repository Checksum Type</source> + <context-group name="ctx"> + <context context-type="sourcefile">/rhn/channels/manage/Edit.do</context> + </context-group> + </trans-unit> + <trans-unit id="channel.edit.jsp.checksumtip"> + <source><strong> Tip:</strong> + sha1 offers the widest compatibility with clients. sha-256 offers higher security, + but is compatible only with newer clients: Fedora 11 and newer, or Enterprise Linux 6 and newer. + </source> + <context-group name="ctx"> + <context context-type="sourcefile">/rhn/channels/manage/Edit.do</context> + </context-group> + </trans-unit> <trans-unit id="channel.edit.jsp.summary"> <source>Channel Summary</source> <context-group name="ctx"> diff --git a/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java b/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java index 0b94bfe..a078105 100644 --- a/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java +++ b/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java @@ -17,6 +17,7 @@ package com.redhat.rhn.manager.channel; import com.redhat.rhn.domain.channel.Channel; import com.redhat.rhn.domain.channel.ChannelArch; import com.redhat.rhn.domain.channel.ChannelFactory; +import com.redhat.rhn.domain.common.ChecksumType; import com.redhat.rhn.domain.role.RoleFactory; import com.redhat.rhn.domain.user.User; import com.redhat.rhn.frontend.xmlrpc.InvalidChannelLabelException; @@ -62,6 +63,9 @@ public class CreateChannelCommand { protected String gpgKeyUrl; protected String gpgKeyId; protected String gpgKeyFp; + protected String checksum; + + protected String maintainerName; protected String maintainerEmail; protected String maintainerPhone; @@ -77,6 +81,7 @@ public class CreateChannelCommand { name = null; summary = null; archLabel = null; + checksum = null; parentLabel = null; parentId = null; } @@ -103,6 +108,13 @@ public class CreateChannelCommand { }
/** + * @param checksumIn The name to set. + */ + public void setChecksum(String checksumIn) { + this.checksum = checksumIn; + } + + /** * @param parentLabelIn The parentLabel to set. */ public void setParentLabel(String parentLabelIn) { @@ -239,6 +251,9 @@ public class CreateChannelCommand { throw new IllegalArgumentException("Invalid architecture label"); }
+ ChecksumType ct = ChannelFactory.findChecksumByLabel(checksum); + + Channel c = ChannelFactory.createChannel(); c.setLabel(label); c.setName(name); @@ -247,6 +262,7 @@ public class CreateChannelCommand { c.setOrg(user.getOrg()); c.setBaseDir("/dev/null"); c.setChannelArch(ca); + c.setChecksum(ct); c.setGPGKeyId(gpgKeyId); c.setGPGKeyUrl(gpgKeyUrl); c.setGPGKeyFp(gpgKeyFp); diff --git a/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java b/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java index 576fcc9..6447deb 100644 --- a/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java +++ b/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java @@ -17,6 +17,7 @@ package com.redhat.rhn.manager.channel;
import com.redhat.rhn.domain.channel.Channel; import com.redhat.rhn.domain.channel.ChannelFactory; +import com.redhat.rhn.domain.common.ChecksumType; import com.redhat.rhn.frontend.xmlrpc.InvalidChannelLabelException; import com.redhat.rhn.frontend.xmlrpc.InvalidChannelNameException; import com.redhat.rhn.frontend.xmlrpc.InvalidParentChannelException; @@ -63,6 +64,15 @@ public class UpdateChannelCommand extends CreateChannelCommand { if (ChannelFactory.findArchByLabel(archLabel) == null) { throw new IllegalArgumentException("Invalid architecture label"); } + + ChecksumType ct = ChannelFactory.findChecksumByLabel(checksum); + + if (!ct.getLabel().equals(c.getChecksum().getLabel()) && c.getPackageCount() > 0) { + // schedule repo re generation if the checksum type changed + // and the channel has packages + ChannelManager.queueChannelChange(c.getLabel(), + "java::updateChannelCommon", null); + }
c.setName(name); c.setSummary(summary); @@ -72,6 +82,7 @@ public class UpdateChannelCommand extends CreateChannelCommand { c.setGPGKeyId(gpgKeyId); c.setGPGKeyUrl(gpgKeyUrl); c.setGPGKeyFp(gpgKeyFp); + c.setChecksum(ct); c.setAccess(access); c.setMaintainerName(maintainerName); c.setMaintainerEmail(maintainerEmail); diff --git a/java/code/src/com/redhat/rhn/taskomatic/task/repomd/RepomdIndexData.java b/java/code/src/com/redhat/rhn/taskomatic/task/repomd/RepomdIndexData.java index a29ff41..bbcffad 100644 --- a/java/code/src/com/redhat/rhn/taskomatic/task/repomd/RepomdIndexData.java +++ b/java/code/src/com/redhat/rhn/taskomatic/task/repomd/RepomdIndexData.java @@ -27,6 +27,7 @@ public class RepomdIndexData { private String openChecksum; private Date timestamp; private String type; +
/** * @@ -53,12 +54,7 @@ public class RepomdIndexData { * @param typeIn checksum type */ public void setType(String typeIn) { - if (typeIn == "SHA1") { - this.type = "sha"; - } - else if (typeIn == "SHA-256") { - this.type = "sha256"; - } + this.type = typeIn; }
/** 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 ab91812..37ba643 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 @@ -56,6 +56,7 @@ public class RepositoryWriter { private String pathPrefix; private String mountPoint; private String checksumtype; + private String checksumname;
/** * Constructor takes in pathprefix and mountpoint @@ -105,6 +106,9 @@ public class RepositoryWriter {
// Get compatible checksumType this.checksumtype = channel.getChecksumType(); + this.checksumname = channel.getChecksum().getDescription(); + + log.info("Checksum Type Value" + this.checksumtype);
try { primaryFile = new CompressingDigestOutputWriter( @@ -177,18 +181,28 @@ public class RepositoryWriter {
log.info("Starting updateinfo generation for '" + channel.getLabel() + '"'); + log.info("Checksum Type Value for generate updateinfo" + this.checksumtype); RepomdIndexData updateinfoData = generateUpdateinfo(channel, prefix, this.checksumtype);
RepomdIndexData groupsData = loadCompsFile(channel); - + //Set the type so yum can read and perform checksum - primaryData.setType(this.checksumtype); - filelistsData.setType(this.checksumtype); - otherData.setType(this.checksumtype); - updateinfoData.setType(this.checksumtype); - groupsData.setType(this.checksumtype); - + primaryData.setType(this.checksumname); + filelistsData.setType(this.checksumname); + otherData.setType(this.checksumname); + if (updateinfoData != null) { + updateinfoData.setType(this.checksumname); + } + + if (groupsData != null) { + groupsData.setType(this.checksumname); + } + + log.info("Primary xml's type" + primaryData.getType()); + log.info("filelists xml's type" + filelistsData.getType()); + log.info("other xml's type" + otherData.getType()); + FileWriter indexFile;
try { diff --git a/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp b/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp index d7c45e4..57ff58a 100644 --- a/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp +++ b/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp @@ -93,6 +93,19 @@ </tr> <tr> <th nowrap="nowrap"> + <bean:message key="channel.edit.jsp.checksum"/>: + </th> + <td class="small-form"> + <html:select property="checksum"> + <html:options collection="checksums" + property="label" + labelProperty="label" /> + </html:select><br/> + <span class="small-text"><bean:message key="channel.edit.jsp.checksumtip"/></span> + </td> + </tr> + <tr> + <th nowrap="nowrap"> <rhn:required-field key="channel.edit.jsp.summary"/>: </th> <td class="small-form"> diff --git a/java/code/webapp/WEB-INF/struts-config.xml b/java/code/webapp/WEB-INF/struts-config.xml index a7966a9..daa9e20 100644 --- a/java/code/webapp/WEB-INF/struts-config.xml +++ b/java/code/webapp/WEB-INF/struts-config.xml @@ -842,6 +842,7 @@ <form-property name="gpg_key_url" type="java.lang.String" /> <form-property name="gpg_key_id" type="java.lang.String" /> <form-property name="gpg_key_fingerprint" type="java.lang.String" /> + <form-property name="checksum" type="java.lang.String" /> </form-bean>
<form-bean name="channelDeleteForm" diff --git a/schema/spacewalk/rhnsat/tables/rhnChannel.sql b/schema/spacewalk/rhnsat/tables/rhnChannel.sql index 95a54dc..b4e1fab 100644 --- a/schema/spacewalk/rhnsat/tables/rhnChannel.sql +++ b/schema/spacewalk/rhnsat/tables/rhnChannel.sql @@ -49,6 +49,8 @@ rhnChannel gpg_key_id varchar2(14), gpg_key_fp varchar2(50), end_of_life date, + checksum_type_id number constraint rhn_channel_checksum_fk + references rhnChecksumType(id), receiving_updates char(1) default 'Y' constraint rhn_channel_ru_nn not null diff --git a/schema/spacewalk/rhnsat/tables/rhnChecksumType.sql b/schema/spacewalk/rhnsat/tables/rhnChecksumType.sql new file mode 100644 index 0000000..8d88905 --- /dev/null +++ b/schema/spacewalk/rhnsat/tables/rhnChecksumType.sql @@ -0,0 +1,44 @@ +create sequence rhn_checksum_id_seq; + +create table +rhnChecksumType +( + id number + constraint rhn_checksumtype_id_nn not null, + label varchar2(32) + constraint rhn_checksumtype_label_nn not null, + description varchar2(64) + constraint rhn_checksumtype_desc_nn not null, + created date default(sysdate) + constraint rhn_checksumtype_creat_nn not null, + modified date default(sysdate) + constraint rhn_checksumtype_mod_nn not null +) + enable row movement + ; + +create index rhn_checksumtype_label_id_idx + on rhnChecksumType( label, id ) + tablespace [[64k_tbs]] + ; +alter table rhnChecksumType add constraint rhn_checksumtype_id_pk + primary key ( id ); +alter table rhnChecksumType add constraint rhn_checksumtype_label_uq + unique ( label ); + +create or replace trigger +rhn_checksumtype_mod_trig +before insert or update on rhnChecksumType +for each row +begin + :new.modified := sysdate; +end; +/ +show errors + +-- +-- +-- Revision 1.1 2009/06/26 10:39:17 pkilambi +-- add schema to hold checksum types +-- + diff --git a/schema/spacewalk/rhnsat/tables/rhnChecksumType_data.sql b/schema/spacewalk/rhnsat/tables/rhnChecksumType_data.sql new file mode 100644 index 0000000..627d4ee --- /dev/null +++ b/schema/spacewalk/rhnsat/tables/rhnChecksumType_data.sql @@ -0,0 +1,37 @@ +-- +-- Copyright (c) 2008 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. +-- +-- +-- +-- + + +insert into rhnChecksumType (id, label, description) values + (rhn_checksum_id_seq.nextval, 'md5', 'md5sum' ); +insert into rhnChecksumType (id, label, description) values + (rhn_checksum_id_seq.nextval, 'sha1', 'sha' ); +insert into rhnChecksumType (id, label, description) values + (rhn_checksum_id_seq.nextval, 'sha-256', 'sha256' ); +insert into rhnChecksumType (id, label, description) values + (rhn_checksum_id_seq.nextval, 'sha-384', 'sha384' ); +insert into rhnChecksumType (id, label, description) values + (rhn_checksum_id_seq.nextval, 'sha-512', 'sha512' ); + +commit; + +-- +-- +-- Revision 1.1 2009/06/26 11:00:17 pkilambi +-- + diff --git a/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/125-rhnChecksumType.sql b/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/125-rhnChecksumType.sql new file mode 100644 index 0000000..8d88905 --- /dev/null +++ b/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/125-rhnChecksumType.sql @@ -0,0 +1,44 @@ +create sequence rhn_checksum_id_seq; + +create table +rhnChecksumType +( + id number + constraint rhn_checksumtype_id_nn not null, + label varchar2(32) + constraint rhn_checksumtype_label_nn not null, + description varchar2(64) + constraint rhn_checksumtype_desc_nn not null, + created date default(sysdate) + constraint rhn_checksumtype_creat_nn not null, + modified date default(sysdate) + constraint rhn_checksumtype_mod_nn not null +) + enable row movement + ; + +create index rhn_checksumtype_label_id_idx + on rhnChecksumType( label, id ) + tablespace [[64k_tbs]] + ; +alter table rhnChecksumType add constraint rhn_checksumtype_id_pk + primary key ( id ); +alter table rhnChecksumType add constraint rhn_checksumtype_label_uq + unique ( label ); + +create or replace trigger +rhn_checksumtype_mod_trig +before insert or update on rhnChecksumType +for each row +begin + :new.modified := sysdate; +end; +/ +show errors + +-- +-- +-- Revision 1.1 2009/06/26 10:39:17 pkilambi +-- add schema to hold checksum types +-- + diff --git a/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/126-rhnChecksumType_data.sql b/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/126-rhnChecksumType_data.sql new file mode 100644 index 0000000..0977588 --- /dev/null +++ b/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/126-rhnChecksumType_data.sql @@ -0,0 +1,37 @@ +-- +-- Copyright (c) 2008 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. +-- +-- +-- +-- + + +insert into rhnChecksumType (id, label, description) values + (rhn_checksum_id_seq.nextval, 'md5', 'md5sum' ); +insert into rhnChecksumType (id, label, description) values + (rhn_checksum_id_seq.nextval, 'sha1', 'sha1' ); +insert into rhnChecksumType (id, label, description) values + (rhn_checksum_id_seq.nextval, 'sha-256', 'sha256' ); +insert into rhnChecksumType (id, label, description) values + (rhn_checksum_id_seq.nextval, 'sha-384', 'sha384' ); +insert into rhnChecksumType (id, label, description) values + (rhn_checksum_id_seq.nextval, 'sha-512', 'sha512' ); + +commit; + +-- +-- +-- Revision 1.1 2009/06/26 11:00:17 pkilambi +-- + diff --git a/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/191-rhnChannel.sql b/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/191-rhnChannel.sql new file mode 100644 index 0000000..8842689 --- /dev/null +++ b/schema/spacewalk/upgrade/spacewalk-schema-0.5-to-spacewalk-schema-0.6/191-rhnChannel.sql @@ -0,0 +1,7 @@ +-- Add a checksum_type_id column, and fk to rhnChecksumType +ALTER TABLE rhnChannel + ADD checksum_type_id number +CONSTRAINT rhn_channel_checksum_fk + REFERENCES rhnChecksumType(id); + +show errors
spacewalk-commits@lists.fedorahosted.org