Initial | 3 backend/satellite_tools/reposync.py | 30 - java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml | 11 java/code/src/com/redhat/rhn/domain/channel/Channel.hbm.xml | 20 - java/code/src/com/redhat/rhn/domain/channel/Channel.java | 112 +++--- java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java | 58 +++ java/code/src/com/redhat/rhn/domain/channel/ContentSource.hbm.xml | 49 ++- java/code/src/com/redhat/rhn/domain/channel/ContentSource.java | 59 +-- java/code/src/com/redhat/rhn/domain/channel/test/ChannelTest.java | 9 java/code/src/com/redhat/rhn/domain/task/Task.java | 2 java/code/src/com/redhat/rhn/frontend/action/channel/manage/EditChannelAction.java | 60 +-- java/code/src/com/redhat/rhn/frontend/action/channel/manage/RepositoriesAction.java | 115 +++++++ java/code/src/com/redhat/rhn/frontend/action/channel/manage/SyncRepositoriesAction.java | 96 +++++ java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDeleteAction.java | 68 ++++ java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java | 161 ++++++++++ java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoListSetupAction.java | 60 +++ java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/validation/repoForm.xsd | 18 + java/code/src/com/redhat/rhn/frontend/action/common/DownloadFile.java | 60 +-- java/code/src/com/redhat/rhn/frontend/dto/ContentSourceDto.java | 73 ++++ java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml | 16 java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml | 96 +++++ java/code/src/com/redhat/rhn/frontend/strings/nav/StringResource_en_US.xml | 16 java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ChannelSerializer.java | 20 - java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java | 8 java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java | 48 +- java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java | 5 java/code/src/com/redhat/rhn/manager/channel/RepoLister.java | 78 ++++ java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java | 8 java/code/src/com/redhat/rhn/manager/channel/repo/BaseRepoCommand.java | 129 ++++++++ java/code/src/com/redhat/rhn/manager/channel/repo/CreateRepoCommand.java | 36 ++ java/code/src/com/redhat/rhn/manager/channel/repo/EditRepoCommand.java | 36 ++ java/code/src/com/redhat/rhn/manager/download/DownloadManager.java | 18 - java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java | 47 +- java/code/webapp/WEB-INF/nav/manage_channel.xml | 9 java/code/webapp/WEB-INF/nav/sitenav-authenticated.xml | 6 java/code/webapp/WEB-INF/pages/channel/manage/channelrepos.jsp | 55 +++ java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp | 49 --- java/code/webapp/WEB-INF/pages/channel/manage/repo/deleteconfirm.jsp | 52 +++ java/code/webapp/WEB-INF/pages/channel/manage/repo/repodetails.jsp | 81 +++++ java/code/webapp/WEB-INF/pages/channel/manage/repo/repos.jsp | 53 +++ java/code/webapp/WEB-INF/pages/channel/manage/syncrepos.jsp | 53 +++ java/code/webapp/WEB-INF/pages/kickstart/cobbler/snippets.jsp | 20 - java/code/webapp/WEB-INF/struts-config.xml | 74 ++++ schema/spacewalk/common/tables/rhnChannelContentSource.sql | 50 +-- schema/spacewalk/common/tables/rhnContentSource.sql | 53 +++ schema/spacewalk/common/tables/rhnTaskQueue.sql | 8 schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/001-repo-sync.sql | 67 ++++ web/html/nav/manage_channel.xml | 3 48 files changed, 1881 insertions(+), 377 deletions(-)
New commits: commit 85aff8aab1e9bb6ab3ceebf5d4f606c33d36b354 Author: Shannon Hughes shughes@redhat.com Date: Tue Jun 29 14:54:55 2010 -0400
fix bug Validation i18n key
diff --git a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java index e3bd9a5..65fae34 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java @@ -65,7 +65,6 @@ public class RepoDetailsAction extends RhnAction {
if (ctx.isSubmitted()) {
- ValidatorResult result = RhnValidationHelper.validate(this.getClass(), makeValidationMap(form), null, VALIDATION_XSD); diff --git a/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml b/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml index 27f9c82..de8d6c2 100644 --- a/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml +++ b/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml @@ -292,6 +292,9 @@ http://www.oasis-open.org/committees/xliff/documents/xliff-core-1.1.xsd" <context context-type="sourcefile">Navigation Menu</context> </context-group> </trans-unit> + <trans-unit id="url"> + <source>url</source> + </trans-unit> <trans-unit id="alphabet"> <source>A B C D E F G H I J K L M N O P Q R S T U V W X Y Z</source> <context-group name="ctx">
commit e72e6dc96bb96a85020ca9ab668a2298ebb88fd1 Author: Shannon Hughes shughes@redhat.com Date: Tue Jun 29 13:17:45 2010 -0400
bug fixing for reposync
diff --git a/backend/satellite_tools/reposync.py b/backend/satellite_tools/reposync.py index 19bda74..2194c8d 100644 --- a/backend/satellite_tools/reposync.py +++ b/backend/satellite_tools/reposync.py @@ -37,7 +37,6 @@ class RepoSync: channel_label = None channel = None fail = False - repo_label = None quiet = False
def main(self): @@ -95,7 +94,6 @@ class RepoSync: self.type = options.type self.channel_label = options.channel_label self.fail = options.fail - #self.repo_label = self.short_hash(self.url) self.quiet = options.quiet self.channel = self.load_channel()
@@ -104,8 +102,7 @@ class RepoSync: sys.exit(1)
for url in self.urls: - self.repo_label = self.short_hash(url) - plugin = self.load_plugin()(url, self.channel_label + "-" + self.repo_label) + plugin = self.load_plugin()(url, self.channel_label) self.import_packages(plugin, url) self.print_msg("Sync complete")
diff --git a/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java b/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java index 63d62b8..58cc8ae 100644 --- a/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java +++ b/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java @@ -109,6 +109,6 @@ public class RepoSyncTask implements Job { cmd.add("--quiet"); return cmd; } - +
}
commit bf3c0427459e9923ad71d9404e1b4f08c5141199 Author: Shannon Hughes shughes@redhat.com Date: Fri Jun 25 14:18:40 2010 -0400
modified reposync script to handle 1:many channel content source objects
diff --git a/backend/satellite_tools/reposync.py b/backend/satellite_tools/reposync.py index 0ec6517..19bda74 100644 --- a/backend/satellite_tools/reposync.py +++ b/backend/satellite_tools/reposync.py @@ -33,9 +33,8 @@ class RepoSync:
parser = None type = None - url = None + urls = None channel_label = None - plugin = None channel = None fail = False repo_label = None @@ -61,20 +60,23 @@ class RepoSync: quit = False if not options.url: if options.channel_label: + # TODO:need to look at user security across orgs h = rhnSQL.prepare("""select s.source_url - from rhnChannelContentSource s, + from rhnContentSource s, + rhnChannelContentSource cs, rhnChannel c - where c.id = s.channel_id + where s.id = cs.source_id + and cs.channel_id = c.id and c.label = :label""") h.execute(label=options.channel_label) source_urls = h.fetchall_dict() or [] if source_urls: - self.url = source_urls[0]['source_url'] + self.urls = [row['source_url'] for row in source_urls] else: quit = True self.error_msg("Channel has no URL associated") else: - self.url = options.url + self.urls = [options.url] if not options.channel_label: quit = True self.error_msg("--channel must be specified") @@ -93,7 +95,7 @@ class RepoSync: self.type = options.type self.channel_label = options.channel_label self.fail = options.fail - self.repo_label = self.short_hash(self.url) + #self.repo_label = self.short_hash(self.url) self.quiet = options.quiet self.channel = self.load_channel()
@@ -101,8 +103,10 @@ class RepoSync: print "Channel does not exist or is not custom" sys.exit(1)
- self.plugin = self.load_plugin()(self.url, self.channel_label + "-" + self.repo_label) - self.import_packages(self.plugin.list_packages()) + for url in self.urls: + self.repo_label = self.short_hash(url) + plugin = self.load_plugin()(url, self.channel_label + "-" + self.repo_label) + self.import_packages(plugin, url) self.print_msg("Sync complete")
def process_args(self): @@ -122,10 +126,11 @@ class RepoSync: submod = getattr(mod, name) return getattr(submod, "ContentSource")
- def import_packages(self, packages): + def import_packages(self, plug, url): + packages = plug.list_packages() to_link = [] to_download = [] - self.print_msg("Repo " + self.url + " has " + str(len(packages)) + " packages.") + self.print_msg("Repo " + url + " has " + str(len(packages)) + " packages.") for pack in packages: if self.channel_label not in \ rhnPackage.get_channels_for_package([pack.name, \ @@ -137,7 +142,7 @@ class RepoSync:
if len(to_download) == 0: self.print_msg("No new packages to download.") - is_non_local_repo = (self.url.find("file://") < 0) + is_non_local_repo = (url.find("file://") < 0) for (index, pack) in enumerate(to_download): """download each package""" # try/except/finally doesn't work in python 2.4 (RHEL5), so here's a hack @@ -145,7 +150,7 @@ class RepoSync: try: self.print_msg(str(index+1) + "/" + str(len(to_download)) + " : "+ \ pack.getNVREA()) - path = self.plugin.get_package(pack) + path = plug.get_package(pack) self.upload_package(pack, path) self.associate_package(pack) except KeyboardInterrupt:
commit d31d6317bdb792b449e3f1528b0629ba39d5039a Author: Shannon Hughes shughes@redhat.com Date: Thu Jun 24 15:45:24 2010 -0400
junit modification for repo sync
diff --git a/java/code/src/com/redhat/rhn/domain/channel/test/ChannelTest.java b/java/code/src/com/redhat/rhn/domain/channel/test/ChannelTest.java index b71ee6f..d4b2397 100644 --- a/java/code/src/com/redhat/rhn/domain/channel/test/ChannelTest.java +++ b/java/code/src/com/redhat/rhn/domain/channel/test/ChannelTest.java @@ -182,12 +182,13 @@ public class ChannelTest extends BaseTestCaseWithUser { ContentSource cs = new ContentSource(); cs.setLabel("repo_label-" + c.getLabel()); cs.setSourceUrl("fake url"); - cs.getChannels().add(c); cs.setType(ChannelFactory.CONTENT_SOURCE_TYPE_YUM); - //c.getSources().add(cs); + cs.setOrg(user.getOrg()); + cs = (ContentSource) TestUtils.saveAndReload(cs); + c.getSources().add(cs); c = (Channel) TestUtils.saveAndReload(c); assertNotEmpty(c.getSources()); } - +
}
commit 0d44795e07dcb8b1afdc1e40d82c3a84df49291e Author: Shannon Hughes shughes@redhat.com Date: Wed Jun 23 17:04:21 2010 -0400
checkstyle fix, extra java import
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 517a62c..4d14542 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,13 +14,30 @@ */ 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; 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.channel.ContentSource; import com.redhat.rhn.domain.org.Org; import com.redhat.rhn.domain.role.RoleFactory; import com.redhat.rhn.domain.server.Server; @@ -43,24 +60,6 @@ import com.redhat.rhn.manager.download.DownloadManager; 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
commit a70320de3d85312979fd0227fad2c4780b16122e Author: Shannon Hughes shughes@redhat.com Date: Wed Jun 23 16:59:24 2010 -0400
hook to call create repo sync task in taskomatic
diff --git a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/SyncRepositoriesAction.java b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/SyncRepositoriesAction.java index cc2f6be..bb0b6b6 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/SyncRepositoriesAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/SyncRepositoriesAction.java @@ -17,7 +17,6 @@ package com.redhat.rhn.frontend.action.channel.manage; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -29,12 +28,14 @@ import org.apache.struts.action.ActionMapping; import com.redhat.rhn.domain.channel.Channel; import com.redhat.rhn.domain.channel.ChannelFactory; import com.redhat.rhn.domain.channel.ContentSource; +import com.redhat.rhn.domain.task.TaskFactory; import com.redhat.rhn.domain.user.User; import com.redhat.rhn.frontend.struts.RequestContext; import com.redhat.rhn.frontend.struts.RhnAction; import com.redhat.rhn.frontend.struts.StrutsDelegate; -import com.redhat.rhn.frontend.taglibs.list.helper.ListSessionSetHelper; +import com.redhat.rhn.frontend.taglibs.list.helper.ListHelper; import com.redhat.rhn.frontend.taglibs.list.helper.Listable; +import com.redhat.rhn.taskomatic.task.RepoSyncTask;
/** * @@ -61,21 +62,19 @@ public class SyncRepositoriesAction extends RhnAction implements Listable {
Map params = new HashMap(); params.put(RequestContext.CID, chan.getId().toString()); - ListSessionSetHelper helper = new ListSessionSetHelper(this, request, params); + + ListHelper helper = new ListHelper(this, request, params);
helper.execute();
- if (helper.isDispatched()) { - Set <String> set = helper.getSet(); - for (String id : set) { - Long sgid = Long.valueOf(id); - ContentSource tmp = ChannelFactory.lookupContentSource(sgid); - System.out.println("SYNCING:" + tmp.getSourceUrl()); - } + if (context.isSubmitted()) { + + TaskFactory.createTask(user.getOrg(), + RepoSyncTask.DISPLAY_NAME, chan.getId());
StrutsDelegate strutsDelegate = getStrutsDelegate(); - strutsDelegate.saveMessage("channel.edit.repo.updated", - new String[] {chan.getName()}, request); + createSuccessMessage(request, "message.syncscheduled", + chan.getName());
return strutsDelegate.forwardParams (mapping.findForward("success"), params); diff --git a/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml b/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml index 44c0a3a..27f9c82 100644 --- a/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml +++ b/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml @@ -8427,7 +8427,7 @@ Follow this url to see the full list of inactive systems: <source>Channel <strong>{0}</strong> updated.</source> </trans-unit> <trans-unit id="message.syncscheduled"> - <source>Repository Sync Scheduled.</source> + <source>Repository sync scheduled for {0}.</source> </trans-unit> <trans-unit id="message.channelsubscribers"> <source>Per-User subscription restrictions may be applied in the Subscribers tab</source> 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 32f338f..247509b 100644 --- a/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java +++ b/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java @@ -17,12 +17,10 @@ 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.task.TaskFactory; 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; -import com.redhat.rhn.taskomatic.task.RepoSyncTask;
/** * UpdateChannelCommand - command to create a new channel. diff --git a/java/code/webapp/WEB-INF/pages/channel/manage/syncrepos.jsp b/java/code/webapp/WEB-INF/pages/channel/manage/syncrepos.jsp index 31afed4..6d2554c 100644 --- a/java/code/webapp/WEB-INF/pages/channel/manage/syncrepos.jsp +++ b/java/code/webapp/WEB-INF/pages/channel/manage/syncrepos.jsp @@ -21,21 +21,19 @@ <input type="hidden" name="cid" value="${cid}" />
<rl:list - decorator="SelectableDecorator" emptykey="repos.jsp.norepos" alphabarcolumn="label" >
<rl:decorator name="PageSizeDecorator"/>
- <rl:selectablecolumn value="${current.id}" - styleclass="first-column"/>
<rl:column sortable="true" bound="false" headerkey="repos.jsp.channel.header" sortattr="label" defaultsort="asc" + styleclass="first-column last-column" >
<a href="/rhn/channels/manage/repos/RepoEdit.do?id=${current.id}">${current.label}</a>
commit b04e0997c0f9a832971db021f5f804724fdccf57 Author: Shannon Hughes shughes@redhat.com Date: Tue Jun 22 15:51:17 2010 -0400
remove call to repo task from the channel edit/update cmds
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 181a09a..517a62c 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 @@ -169,11 +169,6 @@ public class EditChannelAction extends RhnAction implements Listable { params); }
- if (errors.isEmpty() && form.get("sync_repo") != null) { - createSuccessMessage(request, "message.syncscheduled", - form.getString("name")); - } - return getStrutsDelegate().forwardParams( mapping.findForward("success"), params); } 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 c56ae00..32f338f 100644 --- a/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java +++ b/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java @@ -89,11 +89,6 @@ public class UpdateChannelCommand extends CreateChannelCommand { c.setMaintainerEmail(maintainerEmail); c.setMaintainerPhone(maintainerPhone); c.setSupportPolicy(supportPolicy); - - if (syncRepo && !c.getSources().isEmpty()) { - TaskFactory.createTask(user.getOrg(), RepoSyncTask.DISPLAY_NAME, - c.getSources().iterator().next().getId()); - }
// need to save before calling stored proc below ChannelFactory.save(c); diff --git a/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java b/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java index 1cb2072..63d62b8 100644 --- a/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java +++ b/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java @@ -70,7 +70,7 @@ public class RepoSyncTask implements Job { continue; } Channel c = ChannelFactory.lookupById(task.getData()); - if (log.isInfoEnabled()) { + if (log.isInfoEnabled() && c != null) { log.info("Syncing repos for channel: " + c.getName()); } if (c == null) {
commit 83508f5cb0cbaac3f6711a3dccdbe41de6f5ba8f Author: Shannon Hughes shughes@redhat.com Date: Tue Jun 22 13:40:09 2010 -0400
add last log repo sync to edit channel
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 465f48e..181a09a 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 @@ -343,7 +343,6 @@ public class EditChannelAction extends RhnAction implements Listable { ucc.setMaintainerPhone((String)form.get("maintainer_phone")); ucc.setSupportPolicy((String)form.get("support_policy")); ucc.setAccess((String)form.get("org_sharing")); - ucc.setYumUrl((String) form.getString("yum_repo")); ucc.setRepoLabel((String) form.getString("repo_label")); if (form.get("sync_repo") != null) { ucc.setSyncRepo((Boolean)form.get("sync_repo")); @@ -419,8 +418,6 @@ public class EditChannelAction extends RhnAction implements Listable { ccc.setMaintainerPhone((String)form.get("maintainer_phone")); ccc.setSupportPolicy((String)form.get("support_policy")); ccc.setAccess((String)form.get("org_sharing")); - ccc.setYumUrl((String) form.getString("yum_repo")); - ccc.setRepoLabel((String) form.getString("repo_label")); if (form.get("sync_repo") != null) { ccc.setSyncRepo((Boolean)form.get("sync_repo")); } @@ -594,14 +591,9 @@ public class EditChannelAction extends RhnAction implements Listable { }
if (c.getSources().isEmpty()) { - form.set("yum_repo", ""); - form.set("repo_label", ""); request.setAttribute("last_sync", ""); } else { - ContentSource cs = c.getSources().iterator().next(); - form.set("yum_repo", cs.getSourceUrl()); - form.set("repo_label", cs.getLabel()); String lastSync = LocalizationService.getInstance().getMessage( "channel.edit.repo.neversynced"); if (c.getLastSynced() != null) { @@ -611,7 +603,7 @@ public class EditChannelAction extends RhnAction implements Listable { request.setAttribute("last_sync", lastSync); if (ChannelManager.getLatestSyncLogFile(c) != null) { request.setAttribute("log_url", - DownloadManager.getChannelSyncLogDownloadPath(cs, + DownloadManager.getChannelSyncLogDownloadPath(c, ctx.getLoggedInUser())); }
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml b/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml index db8b97a..44c0a3a 100644 --- a/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml +++ b/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml @@ -8454,7 +8454,7 @@ Follow this url to see the full list of inactive systems: <source>Configuration Channels Updated</source> </trans-unit> <trans-unit id="channel.edit.repo.neversynced"> - <source>This repo has never been synced.</source> + <source>This channel has never been synced to external repositories.</source> </trans-unit> <trans-unit id="channel.edit.repo.updated"> <source>{0} repository information was successfully updated</source> diff --git a/java/code/src/com/redhat/rhn/manager/download/DownloadManager.java b/java/code/src/com/redhat/rhn/manager/download/DownloadManager.java index 94ed940..ded2e04 100644 --- a/java/code/src/com/redhat/rhn/manager/download/DownloadManager.java +++ b/java/code/src/com/redhat/rhn/manager/download/DownloadManager.java @@ -14,10 +14,15 @@ */ package com.redhat.rhn.manager.download;
+import java.io.File; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + import com.redhat.rhn.common.conf.Config; import com.redhat.rhn.common.conf.ConfigDefaults; import com.redhat.rhn.common.security.SessionSwap; -import com.redhat.rhn.domain.channel.ContentSource; +import com.redhat.rhn.domain.channel.Channel; import com.redhat.rhn.domain.rhnpackage.Package; import com.redhat.rhn.domain.rhnpackage.PackageSource; import com.redhat.rhn.domain.rhnpackage.Patch; @@ -26,11 +31,6 @@ import com.redhat.rhn.domain.user.User; import com.redhat.rhn.frontend.dto.ISOImage; import com.redhat.rhn.manager.BaseManager;
-import java.io.File; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - /** * Provides methods for downloading packages and files and getting urls * DownloadManager @@ -101,13 +101,13 @@ public class DownloadManager extends BaseManager { /** * Get a download path that is used to download a repo log file. * - * @param src the content source + * @param c the Channel * @param user the user * @return the path/url */ - public static String getChannelSyncLogDownloadPath(ContentSource src, + public static String getChannelSyncLogDownloadPath(Channel c, User user) { - return getNonExpiringDownloadPath(src.getId(), src.getLabel(), user, + return getNonExpiringDownloadPath(c.getId(), c.getLabel(), user, DownloadManager.DOWNLOAD_TYPE_REPO_LOG); }
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 b2090fe..cbc34b2 100644 --- a/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp +++ b/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp @@ -120,8 +120,25 @@ <html:textarea property="description" cols="40" rows="6" styleId="description"/> </td> </tr> + <c:if test='${not empty param.cid}'> + <tr> + <th> + <bean:message key="channel.edit.jsp.lastsynced"/>: + </th> + <td> + <c:if test='${not empty log_url}'> + <a href='${log_url}'><c:out value='${last_sync}'/></a> + </c:if> + <c:if test='${empty log_url}'> + <c:out value='${last_sync}'/> + </c:if> + </td> + </tr> + </c:if> </table>
+ + <h2><bean:message key="channel.edit.jsp.contactsupportinfo"/></h2> <table class="details"> <tr>
commit d4542548ed2c5af07ed920e4d557289cdac9fb0a Author: Shannon Hughes shughes@redhat.com Date: Tue Jun 22 13:12:14 2010 -0400
remove old repo fields from channel edit page, clean up i18n strings
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/nav/StringResource_en_US.xml b/java/code/src/com/redhat/rhn/frontend/strings/nav/StringResource_en_US.xml index 305a1d6..dbff12b 100644 --- a/java/code/src/com/redhat/rhn/frontend/strings/nav/StringResource_en_US.xml +++ b/java/code/src/com/redhat/rhn/frontend/strings/nav/StringResource_en_US.xml @@ -733,13 +733,6 @@ http://www.oasis-open.org/committees/xliff/documents/xliff-core-1.1.xsd" <context-group name="ctx"> <context context-type="sourcefile">Navigation Menu</context> </context-group> - </trans-unit> - - <trans-unit id="Sync"> -<source>Sync</source> - <context-group name="ctx"> - <context context-type="sourcefile">Navigation Menu</context> - </context-group> </trans-unit>
<trans-unit id="Add / Remove"> 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 d7aef0f..b2090fe 100644 --- a/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp +++ b/java/code/webapp/WEB-INF/pages/channel/manage/edit.jsp @@ -122,50 +122,6 @@ </tr> </table>
- - <h2><bean:message key="channel.edit.jsp.yumrepo"/></h2> - <table class="details"> - <tr> - <th> - <label for="yum_repo"><bean:message key="channel.edit.jsp.repourl"/>:</label> - </th> - <td> - <html:text property="yum_repo" maxlength="512" size="64" styleId="yum_repo"/> - </td> - </tr> - <tr> - <th> - <label for="repolabel"><bean:message key="channel.edit.jsp.repolabel"/>:</label> - </th> - <td> - <html:text property="repo_label" maxlength="64" size="20" styleId="repolabel" /> - </td> - </tr> - <c:if test='${not empty param.cid}'> - <tr> - <th> - <bean:message key="channel.edit.jsp.lastsynced"/>: - </th> - <td> - <c:if test='${not empty log_url}'> - <a href='${log_url}'><c:out value='${last_sync}'/></a> - </c:if> - <c:if test='${empty log_url}'> - <c:out value='${last_sync}'/> - </c:if> - </td> - </tr> - </c:if> - <tr> - <th> - <label for="sync_repo"><bean:message key="channel.edit.jsp.sync"/>:</label> - </th> - <td> - <html:checkbox property="sync_repo" styleId="sync_repo"/> - </td> - </tr> - </table> - <h2><bean:message key="channel.edit.jsp.contactsupportinfo"/></h2> <table class="details"> <tr>
commit b4ca7d407690026ce759aa599e437a8e1d2df6f2 Author: Shannon Hughes shughes@redhat.com Date: Mon Jun 21 16:52:56 2010 -0400
making links between repo objects and taskomatic
diff --git a/java/code/src/com/redhat/rhn/domain/task/Task.hbm.xml b/java/code/src/com/redhat/rhn/domain/task/Task.hbm.xml index 08d3b56..70b8f1a 100644 --- a/java/code/src/com/redhat/rhn/domain/task/Task.hbm.xml +++ b/java/code/src/com/redhat/rhn/domain/task/Task.hbm.xml @@ -11,7 +11,6 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" column="org_id" /> <key-property name="name" type="string" column="task_name" length="64"/> <key-property name="data" column="task_data" type="long"/> - <key-property name="data2" column="task_data_two" type="long"/> <key-property name="earliest" column="earliest" type="timestamp"/> </composite-id>
diff --git a/java/code/src/com/redhat/rhn/domain/task/Task.java b/java/code/src/com/redhat/rhn/domain/task/Task.java index 3d8a877..dbeb1ec 100644 --- a/java/code/src/com/redhat/rhn/domain/task/Task.java +++ b/java/code/src/com/redhat/rhn/domain/task/Task.java @@ -30,7 +30,6 @@ public class Task implements Serializable {
private String name; private Long data; - private Long data2; private int priority; private Date earliest; private Org org; @@ -49,22 +48,6 @@ public class Task implements Serializable { public void setData(Long dataIn) { this.data = dataIn; } - - /** - * - * @return the data - */ - public Long getData2() { - return data2; - } - - /** - * - * @param dataIn data to set - */ - public void setData2(Long dataIn) { - this.data2 = dataIn; - }
/** * @return Returns the earliest. 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 08e231d..465f48e 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 @@ -609,7 +609,7 @@ public class EditChannelAction extends RhnAction implements Listable { c.getLastSynced()); } request.setAttribute("last_sync", lastSync); - if (ChannelManager.getLatestSyncLogFile(cs, c) != null) { + if (ChannelManager.getLatestSyncLogFile(c) != null) { request.setAttribute("log_url", DownloadManager.getChannelSyncLogDownloadPath(cs, ctx.getLoggedInUser())); diff --git a/java/code/src/com/redhat/rhn/frontend/action/common/DownloadFile.java b/java/code/src/com/redhat/rhn/frontend/action/common/DownloadFile.java index be00ea7..a4d9f87 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/common/DownloadFile.java +++ b/java/code/src/com/redhat/rhn/frontend/action/common/DownloadFile.java @@ -14,6 +14,32 @@ */ package com.redhat.rhn.frontend.action.common;
+import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Date; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.TimeZone; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.actions.DownloadAction; + import com.redhat.rhn.common.conf.Config; import com.redhat.rhn.common.conf.ConfigDefaults; import com.redhat.rhn.common.security.SessionSwap; @@ -22,7 +48,6 @@ import com.redhat.rhn.common.util.MD5Sum; import com.redhat.rhn.common.util.download.ByteArrayStreamInfo; import com.redhat.rhn.domain.channel.Channel; import com.redhat.rhn.domain.channel.ChannelFactory; -import com.redhat.rhn.domain.channel.ContentSource; import com.redhat.rhn.domain.kickstart.KickstartFactory; import com.redhat.rhn.domain.kickstart.KickstartSession; import com.redhat.rhn.domain.kickstart.KickstartSessionState; @@ -42,32 +67,6 @@ import com.redhat.rhn.manager.download.DownloadManager; import com.redhat.rhn.manager.download.UnknownDownloadTypeException; import com.redhat.rhn.manager.kickstart.KickstartManager;
-import org.apache.commons.lang.StringUtils; -import org.apache.log4j.Logger; -import org.apache.struts.action.ActionForm; -import org.apache.struts.action.ActionForward; -import org.apache.struts.action.ActionMapping; -import org.apache.struts.actions.DownloadAction; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.text.SimpleDateFormat; -import java.util.Arrays; -import java.util.Calendar; -import java.util.Date; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.TimeZone; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - /** * ChannelPackagesAction * @version $Rev$ @@ -371,13 +370,11 @@ public class DownloadFile extends DownloadAction { response.addHeader("Content-Length", patch.getPackageSize() + ""); return getStreamForText(patch.getReadme().getBytes(1L, (int) patch.getReadme().length())); - } + } else if (type.equals(DownloadManager.DOWNLOAD_TYPE_REPO_LOG)) { - Channel c = ChannelFactory.lookupById((Long)params.get(CHANNEL)); - ContentSource cs = - ChannelFactory.lookupContentSource(fileId, user.getOrg()); + Channel c = ChannelFactory.lookupById((Long)params.get(fileId)); ChannelManager.verifyChannelAdmin(user, fileId); - File file = new File(ChannelManager.getLatestSyncLogFile(cs, c)); + File file = new File(ChannelManager.getLatestSyncLogFile(c));
StringBuilder output = new StringBuilder(); BufferedReader input = new BufferedReader(new FileReader(file)); 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 7fcf617..8e66d2a 100644 --- a/java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java +++ b/java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java @@ -14,6 +14,26 @@ */ package com.redhat.rhn.manager.channel;
+import java.io.File; +import java.sql.Timestamp; +import java.sql.Types; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.commons.lang.BooleanUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; + import com.redhat.rhn.common.conf.Config; import com.redhat.rhn.common.conf.ConfigDefaults; import com.redhat.rhn.common.db.datasource.CallableMode; @@ -35,7 +55,6 @@ import com.redhat.rhn.domain.channel.ChannelFamily; import com.redhat.rhn.domain.channel.ChannelFamilyFactory; import com.redhat.rhn.domain.channel.ChannelVersion; import com.redhat.rhn.domain.channel.ClonedChannel; -import com.redhat.rhn.domain.channel.ContentSource; import com.redhat.rhn.domain.channel.DistChannelMap; import com.redhat.rhn.domain.channel.InvalidChannelRoleException; import com.redhat.rhn.domain.channel.ProductName; @@ -73,26 +92,6 @@ import com.redhat.rhn.manager.system.SystemManager; import com.redhat.rhn.manager.user.UserManager; import com.redhat.rhn.taskomatic.task.TaskConstants;
-import org.apache.commons.lang.BooleanUtils; -import org.apache.commons.lang.StringUtils; -import org.apache.log4j.Logger; - -import java.io.File; -import java.sql.Timestamp; -import java.sql.Types; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; - /** * ChannelManager * @version $Rev$ @@ -2819,20 +2818,18 @@ public class ChannelManager extends BaseManager {
/** * get the latest log file for spacewalk-repo-sync - * @param cs the channel content source you want the latest log file for * @param c channel * @return the string of the filename (fully qualified) */ - public static String getLatestSyncLogFile(ContentSource cs, Channel c) { + public static String getLatestSyncLogFile(Channel c) {
String logPath = Config.get().getString(ConfigDefaults.SPACEWALK_REPOSYNC_LOG_PATH, "/var/log/rhn/reposync/"); - String repoLabel = cs.getLabel();
File dir = new File(logPath); List<String> possibleList = new ArrayList<String>(); for (String file : dir.list()) { - if (file.contains(c.getLabel() + '-' + repoLabel)) { + if (file.contains(c.getLabel())) { possibleList.add(file); } } diff --git a/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java b/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java index 82ba218..1cb2072 100644 --- a/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java +++ b/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java @@ -14,23 +14,22 @@ */ package com.redhat.rhn.taskomatic.task;
-import com.redhat.rhn.common.conf.Config; -import com.redhat.rhn.common.conf.ConfigDefaults; -import com.redhat.rhn.domain.channel.Channel; -import com.redhat.rhn.domain.channel.ChannelFactory; -import com.redhat.rhn.domain.channel.ContentSource; -import com.redhat.rhn.domain.task.Task; -import com.redhat.rhn.domain.task.TaskFactory; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Date; +import java.util.List;
import org.apache.log4j.Logger; import org.quartz.Job; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException;
-import java.io.IOException; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; +import com.redhat.rhn.common.conf.Config; +import com.redhat.rhn.common.conf.ConfigDefaults; +import com.redhat.rhn.domain.channel.Channel; +import com.redhat.rhn.domain.channel.ChannelFactory; +import com.redhat.rhn.domain.task.Task; +import com.redhat.rhn.domain.task.TaskFactory;
/** @@ -70,14 +69,12 @@ public class RepoSyncTask implements Job { TaskFactory.removeTask(task); continue; } - ContentSource src = ChannelFactory.lookupContentSource(task.getData()); - Channel c = ChannelFactory.lookupById(task.getData2()); + Channel c = ChannelFactory.lookupById(task.getData()); if (log.isInfoEnabled()) { - log.info("Syncing repo " + src.getSourceUrl() + " to channel " + - c.getLabel()); + log.info("Syncing repos for channel: " + c.getName()); } - if (src == null) { - log.error("Content Source could not be found: " + task.getData()); + if (c == null) { + log.error("Channel could not be found: " + task.getData()); TaskFactory.removeTask(task); continue; } @@ -85,7 +82,7 @@ public class RepoSyncTask implements Job {
try { Process p = Runtime.getRuntime().exec( - getSyncCommand(src, c).toArray(new String[0])); + getSyncCommand(c).toArray(new String[0])); c.setLastSynced(new Date()); int chr = p.getInputStream().read(); while (chr != -1) { @@ -101,18 +98,14 @@ public class RepoSyncTask implements Job { } }
- private static List<String> getSyncCommand(ContentSource src, Channel c) { + private static List<String> getSyncCommand(Channel c) { List<String> cmd = new ArrayList<String>(); cmd.add(Config.get().getString(ConfigDefaults.SPACEWALK_REPOSYNC_PATH, "/usr/bin/spacewalk-repo-sync")); cmd.add("--channel"); cmd.add(c.getLabel()); - cmd.add("--url"); - cmd.add(src.getSourceUrl()); cmd.add("--type"); - cmd.add(src.getType().getLabel()); - cmd.add("--label"); - cmd.add(src.getLabel()); + cmd.add(ChannelFactory.CONTENT_SOURCE_TYPE_YUM.getLabel()); cmd.add("--quiet"); return cmd; } diff --git a/schema/spacewalk/common/tables/rhnTaskQueue.sql b/schema/spacewalk/common/tables/rhnTaskQueue.sql index 6ee756d..240c8c3 100644 --- a/schema/spacewalk/common/tables/rhnTaskQueue.sql +++ b/schema/spacewalk/common/tables/rhnTaskQueue.sql @@ -22,7 +22,6 @@ CREATE TABLE rhnTaskQueue ON DELETE CASCADE, task_name VARCHAR2(64) NOT NULL, task_data NUMBER, - task_data_two NUMBER, priority NUMBER DEFAULT (0), earliest DATE diff --git a/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/001-repo-sync.sql b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/001-repo-sync.sql index 8a3304d..9c7a8ca 100644 --- a/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/001-repo-sync.sql +++ b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/001-repo-sync.sql @@ -1,10 +1,6 @@
ALTER table rhnChannelContentSource rename to rhnContentSource;
-ALTER table rhnTaskQueue -add task_data_two NUMBER; - - -- create new table for mapping channels and repos CREATE TABLE rhnChannelContentSource (
commit 8a2cfc754b7d23b06d2a8563d40aba8495efa85d Author: Shannon Hughes shughes@redhat.com Date: Thu Jun 17 15:14:03 2010 -0400
lots of checkstyle fixes
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 51dc6af..64957a0 100644 --- a/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java +++ b/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java @@ -161,9 +161,9 @@ public class ChannelFactory extends HibernateFactory {
/** * lookup content source by id and org - * @param id - * @param orgIn - * @return + * @param id id of content source + * @param orgIn org to check + * @return content source */ public static ContentSource lookupContentSource(Long id, Org orgIn) { Map params = new HashMap(); diff --git a/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java b/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java index c830212..0567dd1 100644 --- a/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java +++ b/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java @@ -110,8 +110,8 @@ public class ContentSource extends BaseDomainHelper { }
/** - * - * @param set of channels this repo is pushed to + * + * @param channelsIn of channels this repo is pushed to */ public void setChannels(Set<Channel> channelsIn) { this.channels = channelsIn; 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 e503aea..08e231d 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 @@ -609,7 +609,7 @@ public class EditChannelAction extends RhnAction implements Listable { c.getLastSynced()); } request.setAttribute("last_sync", lastSync); - if (ChannelManager.getLatestSyncLogFile(cs,c) != null) { + if (ChannelManager.getLatestSyncLogFile(cs, c) != null) { request.setAttribute("log_url", DownloadManager.getChannelSyncLogDownloadPath(cs, ctx.getLoggedInUser())); 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 509fc7d..7500c63 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 @@ -37,64 +37,77 @@ import com.redhat.rhn.frontend.struts.StrutsDelegate; import com.redhat.rhn.frontend.taglibs.list.helper.ListSessionSetHelper; import com.redhat.rhn.frontend.taglibs.list.helper.Listable;
- +/** + * + * RepositoriesAction + * @version $Rev$ + */ public class RepositoriesAction extends RhnAction implements Listable { - - - public ActionForward execute(ActionMapping mapping, - ActionForm formIn, - HttpServletRequest request, - HttpServletResponse response) { - - RequestContext context = new RequestContext(request); - User user = context.getLoggedInUser(); - - long cid = context.getRequiredParam("cid"); - Channel chan = ChannelFactory.lookupByIdAndUser(cid, user); - request.setAttribute("channel_name", chan.getName()); - - Map params = new HashMap(); - params.put(RequestContext.CID, chan.getId().toString()); - - ListSessionSetHelper helper = new ListSessionSetHelper(this, request,params); - - if (!context.isSubmitted()) { - List<ContentSource> result = getResult(context); - Set<String> preSelect = new HashSet<String>(); - for (int i = 0; i < result.size(); i++) { - ContentSource src = result.get(i); - if(src.getChannels().contains(chan)) { - preSelect.add(src.getId().toString()); - } + + /** + * + * {@inheritDoc} + */ + public ActionForward execute(ActionMapping mapping, + ActionForm formIn, + HttpServletRequest request, + HttpServletResponse response) { + + RequestContext context = new RequestContext(request); + User user = context.getLoggedInUser(); + + long cid = context.getRequiredParam("cid"); + Channel chan = ChannelFactory.lookupByIdAndUser(cid, user); + request.setAttribute("channel_name", chan.getName()); + + Map params = new HashMap(); + params.put(RequestContext.CID, chan.getId().toString()); + + ListSessionSetHelper helper = + new ListSessionSetHelper(this, request, params); + + if (!context.isSubmitted()) { + List<ContentSource> result = getResult(context); + Set<String> preSelect = new HashSet<String>(); + for (int i = 0; i < result.size(); i++) { + ContentSource src = result.get(i); + if (src.getChannels().contains(chan)) { + preSelect.add(src.getId().toString()); } - helper.preSelect(preSelect); } + helper.preSelect(preSelect); + }
- helper.ignoreEmptySelection(); - helper.execute(); - - if(helper.isDispatched()) { - Set<ContentSource> foo = chan.getSources(); - foo.clear(); - Set <String> set = helper.getSet(); - for (String id : set) { - Long sgid = Long.valueOf(id); - ContentSource tmp = ChannelFactory.lookupContentSource(sgid); - foo.add(tmp); - } - - ChannelFactory.save(chan); + helper.ignoreEmptySelection(); + helper.execute(); + + if (helper.isDispatched()) { + Set<ContentSource> foo = chan.getSources(); + foo.clear(); + Set <String> set = helper.getSet(); + for (String id : set) { + Long sgid = Long.valueOf(id); + ContentSource tmp = ChannelFactory.lookupContentSource(sgid); + foo.add(tmp); + }
- StrutsDelegate strutsDelegate = getStrutsDelegate(); - strutsDelegate.saveMessage("channel.edit.repo.updated", new String[] {chan.getName()}, request ); + ChannelFactory.save(chan);
- return strutsDelegate.forwardParams - (mapping.findForward("success"), params); - } + StrutsDelegate strutsDelegate = getStrutsDelegate(); + strutsDelegate.saveMessage("channel.edit.repo.updated", + new String[] {chan.getName()}, request);
- return mapping.findForward("default"); + return strutsDelegate.forwardParams + (mapping.findForward("success"), params); }
+ return mapping.findForward("default"); + } + + /** + * + * {@inheritDoc} + */ public List<ContentSource> getResult(RequestContext context) { User user = context.getLoggedInUser(); return ChannelFactory.lookupContentSources(user.getOrg()); diff --git a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/SyncRepositoriesAction.java b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/SyncRepositoriesAction.java index 66bb6dc..cc2f6be 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/SyncRepositoriesAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/SyncRepositoriesAction.java @@ -36,47 +36,58 @@ import com.redhat.rhn.frontend.struts.StrutsDelegate; import com.redhat.rhn.frontend.taglibs.list.helper.ListSessionSetHelper; import com.redhat.rhn.frontend.taglibs.list.helper.Listable;
- +/** + * + * SyncRepositoriesAction + * @version $Rev$ + */ public class SyncRepositoriesAction extends RhnAction implements Listable { - - - public ActionForward execute(ActionMapping mapping, - ActionForm formIn, - HttpServletRequest request, - HttpServletResponse response) { - - RequestContext context = new RequestContext(request); - User user = context.getLoggedInUser(); - - long cid = context.getRequiredParam("cid"); - Channel chan = ChannelFactory.lookupByIdAndUser(cid, user); - request.setAttribute("channel_name", chan.getName()); - - Map params = new HashMap(); - params.put(RequestContext.CID, chan.getId().toString()); - - ListSessionSetHelper helper = new ListSessionSetHelper(this, request,params); - - helper.execute(); - - if(helper.isDispatched()) { - Set <String> set = helper.getSet(); - for (String id : set) { - Long sgid = Long.valueOf(id); - ContentSource tmp = ChannelFactory.lookupContentSource(sgid); - System.out.println("SYNCING:" + tmp.getSourceUrl()); - } - - StrutsDelegate strutsDelegate = getStrutsDelegate(); - strutsDelegate.saveMessage("channel.edit.repo.updated", new String[] {chan.getName()}, request ); - - return strutsDelegate.forwardParams - (mapping.findForward("success"), params); + + /** + * + * {@inheritDoc} + */ + public ActionForward execute(ActionMapping mapping, + ActionForm formIn, + HttpServletRequest request, + HttpServletResponse response) { + + RequestContext context = new RequestContext(request); + User user = context.getLoggedInUser(); + + long cid = context.getRequiredParam("cid"); + Channel chan = ChannelFactory.lookupByIdAndUser(cid, user); + request.setAttribute("channel_name", chan.getName()); + + Map params = new HashMap(); + params.put(RequestContext.CID, chan.getId().toString()); + ListSessionSetHelper helper = new ListSessionSetHelper(this, request, params); + + helper.execute(); + + if (helper.isDispatched()) { + Set <String> set = helper.getSet(); + for (String id : set) { + Long sgid = Long.valueOf(id); + ContentSource tmp = ChannelFactory.lookupContentSource(sgid); + System.out.println("SYNCING:" + tmp.getSourceUrl()); }
- return mapping.findForward("default"); + StrutsDelegate strutsDelegate = getStrutsDelegate(); + strutsDelegate.saveMessage("channel.edit.repo.updated", + new String[] {chan.getName()}, request); + + return strutsDelegate.forwardParams + (mapping.findForward("success"), params); }
+ return mapping.findForward("default"); + } + + /** + * + * {@inheritDoc} + */ public List<ContentSource> getResult(RequestContext context) { User user = context.getLoggedInUser(); long cid = context.getRequiredParam("cid"); diff --git a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDeleteAction.java b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDeleteAction.java index 31a1da0..ae3ff58 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDeleteAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDeleteAction.java @@ -45,9 +45,9 @@ public class RepoDeleteAction extends RhnAction { context.getParamAsLong("id"));
ContentSource src = cmd.getNewRepo(); - - request.setAttribute(RepoDetailsAction.LABEL, src.getLabel() ); - request.setAttribute(RepoDetailsAction.URL, src.getSourceUrl() ); + + request.setAttribute(RepoDetailsAction.LABEL, src.getLabel()); + request.setAttribute(RepoDetailsAction.URL, src.getSourceUrl()); request.setAttribute("id", src.getId());
if (context.isSubmitted()) { diff --git a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java index d2b3623..e3bd9a5 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java @@ -96,15 +96,15 @@ public class RepoDetailsAction extends RhnAction { } } } - else if(!isCreateMode(request)) { + else if (!isCreateMode(request)) { setup(request, form); }
return mapping.findForward(RhnHelper.DEFAULT_FORWARD); }
- private Map<String,String> makeValidationMap(DynaActionForm form) { - Map<String,String> map = new HashMap<String,String>(); + private Map<String, String> makeValidationMap(DynaActionForm form) { + Map<String, String> map = new HashMap<String, String>(); map.put(LABEL, form.getString(LABEL)); map.put(URL, form.getString(URL)); return map; @@ -133,7 +133,7 @@ public class RepoDetailsAction extends RhnAction { /** * Method to bind the repo to a request * @param request the servlet request - * @param snip the snippet to bind + * @param repo content source */ public static void bindRepo(HttpServletRequest request, ContentSource repo) { request.setAttribute(REPO, repo); @@ -145,11 +145,12 @@ public class RepoDetailsAction extends RhnAction { String label = form.getString(LABEL); Org org = context.getLoggedInUser().getOrg(); BaseRepoCommand repoCmd = null; - if(isCreateMode(request)) { + if (isCreateMode(request)) { repoCmd = new CreateRepoCommand(org); } else { - repoCmd = new EditRepoCommand(context.getLoggedInUser(), context.getParamAsLong(SOURCEID)); + repoCmd = new EditRepoCommand(context.getLoggedInUser(), + context.getParamAsLong(SOURCEID)); }
repoCmd.setLabel(label); diff --git a/java/code/src/com/redhat/rhn/frontend/action/common/DownloadFile.java b/java/code/src/com/redhat/rhn/frontend/action/common/DownloadFile.java index 13998b5..be00ea7 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/common/DownloadFile.java +++ b/java/code/src/com/redhat/rhn/frontend/action/common/DownloadFile.java @@ -374,7 +374,8 @@ public class DownloadFile extends DownloadAction { } else if (type.equals(DownloadManager.DOWNLOAD_TYPE_REPO_LOG)) { Channel c = ChannelFactory.lookupById((Long)params.get(CHANNEL)); - ContentSource cs = ChannelFactory.lookupContentSource(fileId, user.getOrg()); + ContentSource cs = + ChannelFactory.lookupContentSource(fileId, user.getOrg()); ChannelManager.verifyChannelAdmin(user, fileId); File file = new File(ChannelManager.getLatestSyncLogFile(cs, c));
diff --git a/java/code/src/com/redhat/rhn/frontend/dto/ContentSourceDto.java b/java/code/src/com/redhat/rhn/frontend/dto/ContentSourceDto.java index e17ccd5..b9f651c 100644 --- a/java/code/src/com/redhat/rhn/frontend/dto/ContentSourceDto.java +++ b/java/code/src/com/redhat/rhn/frontend/dto/ContentSourceDto.java @@ -62,7 +62,7 @@ public class ContentSourceDto extends BaseDto { }
/** - * @param idIn The id to set. + * @param cIn The channel id to set. */ public void setChannels(Long cIn) { this.channels = cIn; diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java index 8449e9f..378f16e 100644 --- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java +++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/system/SystemHandler.java @@ -529,11 +529,11 @@ public class SystemHandler extends BaseHandler { Channel baseChannel = server.getBaseChannel(); List returnList = new ArrayList();
- List<EssentialChannelDto> list = ChannelManager. - listBaseChannelsForSystem(loggedInUser, server); + List<EssentialChannelDto> list = + ChannelManager.listBaseChannelsForSystem(loggedInUser, server); for (EssentialChannelDto ch : list) { - Boolean currentBase = (baseChannel != null) && - baseChannel.getId().equals(ch.getId()); + Boolean currentBase = (baseChannel != null) && + baseChannel.getId().equals(ch.getId()); returnList.add(createChannelMap(ch, currentBase)); }
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 42c2eff..7fcf617 100644 --- a/java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java +++ b/java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java @@ -2820,6 +2820,7 @@ public class ChannelManager extends BaseManager { /** * get the latest log file for spacewalk-repo-sync * @param cs the channel content source you want the latest log file for + * @param c channel * @return the string of the filename (fully qualified) */ public static String getLatestSyncLogFile(ContentSource cs, Channel c) { diff --git a/java/code/src/com/redhat/rhn/manager/channel/RepoLister.java b/java/code/src/com/redhat/rhn/manager/channel/RepoLister.java index e28ca4e..c92a3ef 100644 --- a/java/code/src/com/redhat/rhn/manager/channel/RepoLister.java +++ b/java/code/src/com/redhat/rhn/manager/channel/RepoLister.java @@ -48,7 +48,12 @@ public class RepoLister extends BaseManager { public static RepoLister getInstance() { return INSTANCE; } - + + /** + * + * @param orgIn org to check + * @return list of contet source dto's + */ public DataResult<ContentSourceDto> sourcesInOrg(Org orgIn) {
SelectMode m = ModeFactory.getMode("Channel_queries", "contentsrc_for_org"); @@ -60,7 +65,11 @@ public class RepoLister extends BaseManager { return returnDataResult; }
- + /** + * + * @param user that is logged in + * @return list of content source dto's for users org + */ public List<ContentSourceDto> list(User user) { List <ContentSourceDto> repos = new LinkedList<ContentSourceDto>(); repos.addAll(sourcesInOrg(user.getOrg())); 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 ed7e0dd..823604f 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 @@ -50,11 +50,11 @@ public class BaseRepoCommand { }
/** - * - * @param org to set for repo + * + * @param orgIn to set for repo */ - public void setOrg(Org org) { - this.org = org; + public void setOrg(Org orgIn) { + this.org = orgIn; }
/** @@ -69,8 +69,8 @@ public class BaseRepoCommand { * * @param labelIn to set for repo */ - public void setLabel(String LabelIn) { - this.label = LabelIn; + public void setLabel(String labelIn) { + this.label = labelIn; }
/** @@ -94,9 +94,9 @@ public class BaseRepoCommand { * @return ValidatorError[] array if there are errors */ public ValidatorError[] store() { - ValidatorError[] errors = validate(); - if (errors != null && errors.length > 0) { - return errors; + ValidatorError[] errorst = validate(); + if (errorst != null && errorst.length > 0) { + return errorst; } else { // Create repo diff --git a/java/code/src/com/redhat/rhn/manager/channel/repo/CreateRepoCommand.java b/java/code/src/com/redhat/rhn/manager/channel/repo/CreateRepoCommand.java index e769d32..8e4a0f5 100644 --- a/java/code/src/com/redhat/rhn/manager/channel/repo/CreateRepoCommand.java +++ b/java/code/src/com/redhat/rhn/manager/channel/repo/CreateRepoCommand.java @@ -23,7 +23,11 @@ import com.redhat.rhn.domain.org.Org; */ public class CreateRepoCommand extends BaseRepoCommand {
- public CreateRepoCommand(Org orgIn) { + /** + * + * @param orgIn org for repo + */ + public CreateRepoCommand(Org orgIn) { super(); this.repo = ChannelFactory.createRepo(); this.repo.setOrg(orgIn); diff --git a/java/code/src/com/redhat/rhn/manager/channel/repo/EditRepoCommand.java b/java/code/src/com/redhat/rhn/manager/channel/repo/EditRepoCommand.java index fa65f94..ad0ee68 100644 --- a/java/code/src/com/redhat/rhn/manager/channel/repo/EditRepoCommand.java +++ b/java/code/src/com/redhat/rhn/manager/channel/repo/EditRepoCommand.java @@ -23,6 +23,11 @@ import com.redhat.rhn.domain.user.User; */ public class EditRepoCommand extends BaseRepoCommand {
+ /** + * + * @param currentUser logged in user + * @param repoId id of content source object + */ public EditRepoCommand(User currentUser, Long repoId) { super(); this.repo = ChannelFactory.lookupContentSource(repoId, currentUser.getOrg()); diff --git a/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java b/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java index f5e621c..82ba218 100644 --- a/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java +++ b/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java @@ -85,7 +85,7 @@ public class RepoSyncTask implements Job {
try { Process p = Runtime.getRuntime().exec( - getSyncCommand(src,c).toArray(new String[0])); + getSyncCommand(src, c).toArray(new String[0])); c.setLastSynced(new Date()); int chr = p.getInputStream().read(); while (chr != -1) {
commit d0be6bb507832909e8137e2a2f5c22a73c1c066f Author: Shannon Hughes shughes@redhat.com Date: Tue Jun 8 16:23:06 2010 -0400
add channel count access for repo objects
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 971307e..8cc6e48 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 @@ -1035,7 +1035,10 @@ SELECT CP.package_id, CP.name_id, CP.evr_id, CP.package_arch_id
<mode name="contentsrc_for_org" class="com.redhat.rhn.frontend.dto.ContentSourceDto"> <query params="org_id"> - SELECT CS.id, CS.label + SELECT CS.id, CS.label, + (SELECT count(ccs.channel_id) + FROM rhnChannelContentSource ccs + WHERE ccs.source_id = CS.id) as channels FROM rhnContentSource CS WHERE CS.org_id = :org_id </query> diff --git a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/SyncRepositoriesAction.java b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/SyncRepositoriesAction.java index ffce1c3..66bb6dc 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/SyncRepositoriesAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/SyncRepositoriesAction.java @@ -15,7 +15,6 @@ package com.redhat.rhn.frontend.action.channel.manage;
import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -58,7 +57,6 @@ public class SyncRepositoriesAction extends RhnAction implements Listable {
ListSessionSetHelper helper = new ListSessionSetHelper(this, request,params);
- //helper.ignoreEmptySelection(); helper.execute();
if(helper.isDispatched()) { diff --git a/java/code/src/com/redhat/rhn/frontend/dto/ContentSourceDto.java b/java/code/src/com/redhat/rhn/frontend/dto/ContentSourceDto.java index 7653c8c..e17ccd5 100644 --- a/java/code/src/com/redhat/rhn/frontend/dto/ContentSourceDto.java +++ b/java/code/src/com/redhat/rhn/frontend/dto/ContentSourceDto.java @@ -22,6 +22,7 @@ package com.redhat.rhn.frontend.dto; public class ContentSourceDto extends BaseDto {
private Long id; + private Long channels; private String label;
/** @@ -53,5 +54,20 @@ public class ContentSourceDto extends BaseDto { this.label = labelIn; }
+ /** + * {@inheritDoc} + */ + public Long getChannels() { + return channels; + } + + /** + * @param idIn The id to set. + */ + public void setChannels(Long cIn) { + this.channels = cIn; + } + +
} 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 ef22915..ac4bf2b 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 @@ -6769,6 +6769,13 @@ value for this entitlement, excluding the default organization's consumption.</s </context-group> </trans-unit>
+ <trans-unit id="repo.jsp.channels"> +<source>Channels</source> + <context-group name="ctx"> + <context context-type="sourcefile">/rhn/channels/manage/repos/RepoList</context> + </context-group> + </trans-unit> + <trans-unit id="download.jsp.package"> <source>Package</source> <context-group name="ctx"> diff --git a/java/code/webapp/WEB-INF/pages/channel/manage/repo/repos.jsp b/java/code/webapp/WEB-INF/pages/channel/manage/repo/repos.jsp index e387d3e..9b4a9c2 100644 --- a/java/code/webapp/WEB-INF/pages/channel/manage/repo/repos.jsp +++ b/java/code/webapp/WEB-INF/pages/channel/manage/repo/repos.jsp @@ -39,6 +39,13 @@ filterattr="label"> <c:out value="<a href="/rhn/channels/manage/repos/RepoEdit.do?id=${current.id}">${current.label}</a>" escapeXml="false" /> </rl:column> + <rl:column bound="false" + sortable="false" + headerkey="repo.jsp.channels" + attr="channels" + styleclass="last-column"> + <c:out value="${current.channels}" /> + </rl:column> </rl:list> </rl:listset>
commit ca93372c4a6ca36638273c83226ffa1e680e1c60 Author: Shannon Hughes shughes@redhat.com Date: Tue Jun 8 15:16:03 2010 -0400
general repo cleanup, bugfixing
diff --git a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/SyncRepositoriesAction.java b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/SyncRepositoriesAction.java index 2437846..ffce1c3 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/SyncRepositoriesAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/SyncRepositoriesAction.java @@ -58,33 +58,17 @@ public class SyncRepositoriesAction extends RhnAction implements Listable {
ListSessionSetHelper helper = new ListSessionSetHelper(this, request,params);
- if (!context.isSubmitted()) { - List<ContentSource> result = getResult(context); - Set<String> preSelect = new HashSet<String>(); - for (int i = 0; i < result.size(); i++) { - ContentSource src = result.get(i); - if(src.getChannels().contains(chan)) { - preSelect.add(src.getId().toString()); - } - } - helper.preSelect(preSelect); - } - - helper.ignoreEmptySelection(); + //helper.ignoreEmptySelection(); helper.execute();
if(helper.isDispatched()) { - Set<ContentSource> foo = chan.getSources(); - foo.clear(); Set <String> set = helper.getSet(); for (String id : set) { Long sgid = Long.valueOf(id); ContentSource tmp = ChannelFactory.lookupContentSource(sgid); - foo.add(tmp); + System.out.println("SYNCING:" + tmp.getSourceUrl()); }
- ChannelFactory.save(chan); - StrutsDelegate strutsDelegate = getStrutsDelegate(); strutsDelegate.saveMessage("channel.edit.repo.updated", new String[] {chan.getName()}, request );
diff --git a/java/code/webapp/WEB-INF/pages/channel/manage/syncrepos.jsp b/java/code/webapp/WEB-INF/pages/channel/manage/syncrepos.jsp index 7bc65f2..31afed4 100644 --- a/java/code/webapp/WEB-INF/pages/channel/manage/syncrepos.jsp +++ b/java/code/webapp/WEB-INF/pages/channel/manage/syncrepos.jsp @@ -45,7 +45,7 @@ <div align="right"> <hr /> <input type="submit" name="dispatch" - value="<bean:message key="repos.jsp.update.channel"/>" /> + value="<bean:message key="Sync"/>" /> </div> rhn:submitted/
diff --git a/java/code/webapp/WEB-INF/struts-config.xml b/java/code/webapp/WEB-INF/struts-config.xml index df8e13b..94c3c5a 100644 --- a/java/code/webapp/WEB-INF/struts-config.xml +++ b/java/code/webapp/WEB-INF/struts-config.xml @@ -6509,7 +6509,7 @@ type="com.redhat.rhn.frontend.action.channel.manage.SyncRepositoriesAction" className="com.redhat.rhn.frontend.struts.RhnActionMapping"> <forward name="default" path="/WEB-INF/pages/channel/manage/syncrepos.jsp" /> - <forward name="success" path="/channels/manage/SyncRepositories.do" redirect="true" /> + <forward name="success" path="/channels/manage/Edit.do" redirect="true" /> </action>
<action path="/channels/manage/Manage"
commit 109e249c30afa0556ce74428224514db4ffca2a0 Author: Shannon Hughes shughes@redhat.com Date: Tue Jun 8 13:36:38 2010 -0400
new page: list of repos to sync (session sets)
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 3239ca3..51dc6af 100644 --- a/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java +++ b/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java @@ -145,6 +145,21 @@ public class ChannelFactory extends HibernateFactory { }
/** + * Lookup a content source by org/channel + * @param org the org to lookup + * @param c the channel + * @return the ContentSource(s) + */ + public static List<ContentSource> lookupContentSources(Org org, Channel c) { + Map params = new HashMap(); + params.put("org", org); + params.put("channel", c); + return singleton.listObjectsByNamedQuery( + "ContentSource.findByOrgandChannel", params); + } + + + /** * lookup content source by id and org * @param id * @param orgIn 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 dbf537c..8944184 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 @@ -47,6 +47,15 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" <query name="ContentSource.findByOrg"> <![CDATA[from com.redhat.rhn.domain.channel.ContentSource as c where c.org = :org]]> </query> + <query name="ContentSource.findByOrgandChannel"> + <![CDATA[SELECT cs from com.redhat.rhn.domain.channel.ContentSource as cs, + com.redhat.rhn.domain.channel.Channel as c + where cs.org = :org + and c = :channel + and cs in elements(c.sources) + ]]> + </query> +
diff --git a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/SyncRepositoriesAction.java b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/SyncRepositoriesAction.java new file mode 100644 index 0000000..2437846 --- /dev/null +++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/SyncRepositoriesAction.java @@ -0,0 +1,104 @@ +/** + * Copyright (c) 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.action.channel.manage; + +import java.util.HashMap; +import java.util.HashSet; +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.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; + +import com.redhat.rhn.domain.channel.Channel; +import com.redhat.rhn.domain.channel.ChannelFactory; +import com.redhat.rhn.domain.channel.ContentSource; +import com.redhat.rhn.domain.user.User; +import com.redhat.rhn.frontend.struts.RequestContext; +import com.redhat.rhn.frontend.struts.RhnAction; +import com.redhat.rhn.frontend.struts.StrutsDelegate; +import com.redhat.rhn.frontend.taglibs.list.helper.ListSessionSetHelper; +import com.redhat.rhn.frontend.taglibs.list.helper.Listable; + + +public class SyncRepositoriesAction extends RhnAction implements Listable { + + + public ActionForward execute(ActionMapping mapping, + ActionForm formIn, + HttpServletRequest request, + HttpServletResponse response) { + + RequestContext context = new RequestContext(request); + User user = context.getLoggedInUser(); + + long cid = context.getRequiredParam("cid"); + Channel chan = ChannelFactory.lookupByIdAndUser(cid, user); + request.setAttribute("channel_name", chan.getName()); + + Map params = new HashMap(); + params.put(RequestContext.CID, chan.getId().toString()); + + ListSessionSetHelper helper = new ListSessionSetHelper(this, request,params); + + if (!context.isSubmitted()) { + List<ContentSource> result = getResult(context); + Set<String> preSelect = new HashSet<String>(); + for (int i = 0; i < result.size(); i++) { + ContentSource src = result.get(i); + if(src.getChannels().contains(chan)) { + preSelect.add(src.getId().toString()); + } + } + helper.preSelect(preSelect); + } + + helper.ignoreEmptySelection(); + helper.execute(); + + if(helper.isDispatched()) { + Set<ContentSource> foo = chan.getSources(); + foo.clear(); + Set <String> set = helper.getSet(); + for (String id : set) { + Long sgid = Long.valueOf(id); + ContentSource tmp = ChannelFactory.lookupContentSource(sgid); + foo.add(tmp); + } + + ChannelFactory.save(chan); + + StrutsDelegate strutsDelegate = getStrutsDelegate(); + strutsDelegate.saveMessage("channel.edit.repo.updated", new String[] {chan.getName()}, request ); + + return strutsDelegate.forwardParams + (mapping.findForward("success"), params); + } + + return mapping.findForward("default"); + } + + public List<ContentSource> getResult(RequestContext context) { + User user = context.getLoggedInUser(); + long cid = context.getRequiredParam("cid"); + Channel chan = ChannelFactory.lookupByIdAndUser(cid, user); + return ChannelFactory.lookupContentSources(user.getOrg(), chan); + } +} diff --git a/java/code/webapp/WEB-INF/pages/channel/manage/syncrepos.jsp b/java/code/webapp/WEB-INF/pages/channel/manage/syncrepos.jsp new file mode 100644 index 0000000..7bc65f2 --- /dev/null +++ b/java/code/webapp/WEB-INF/pages/channel/manage/syncrepos.jsp @@ -0,0 +1,55 @@ +<%@ taglib uri="http://rhn.redhat.com/rhn" prefix="rhn" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %> +<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %> +<%@ taglib uri="http://rhn.redhat.com/tags/list" prefix="rl" %> + +html:xhtml/ +<html> +<head> + <meta name="page-decorator" content="none" /> +</head> +<body> + +<%@ include file="/WEB-INF/pages/common/fragments/channel/manage/manage_channel_header.jspf" %> +<BR> + +<h2><img src="/img/rhn-icon-packages.gif"> <bean:message key="repos.jsp.channel.repos"/></h2> + +<rl:listset name="packageSet"> + +<input type="hidden" name="cid" value="${cid}" /> + + <rl:list + decorator="SelectableDecorator" + emptykey="repos.jsp.norepos" + alphabarcolumn="label" + > + + <rl:decorator name="PageSizeDecorator"/> + + <rl:selectablecolumn value="${current.id}" + styleclass="first-column"/> + + <rl:column sortable="true" + bound="false" + headerkey="repos.jsp.channel.header" + sortattr="label" + defaultsort="asc" + > + + <a href="/rhn/channels/manage/repos/RepoEdit.do?id=${current.id}">${current.label}</a> + </rl:column> + + </rl:list> + <div align="right"> + <hr /> + <input type="submit" name="dispatch" + value="<bean:message key="repos.jsp.update.channel"/>" /> + </div> + rhn:submitted/ + +</rl:listset> + +</body> +</html> \ No newline at end of file
commit d28997e8a3ff7ed61c50787a4a1250dc425b314c Author: Shannon Hughes shughes@redhat.com Date: Tue Jun 8 12:33:51 2010 -0400
struts support for repo sync action
diff --git a/java/code/webapp/WEB-INF/struts-config.xml b/java/code/webapp/WEB-INF/struts-config.xml index 095d485..df8e13b 100644 --- a/java/code/webapp/WEB-INF/struts-config.xml +++ b/java/code/webapp/WEB-INF/struts-config.xml @@ -6502,7 +6502,15 @@ className="com.redhat.rhn.frontend.struts.RhnActionMapping"> <forward name="default" path="/WEB-INF/pages/channel/manage/channelrepos.jsp" /> <forward name="success" path="/channels/manage/Repositories.do" redirect="true" /> - </action> + </action> + + <action path="/channels/manage/Sync" + scope="request" + type="com.redhat.rhn.frontend.action.channel.manage.SyncRepositoriesAction" + className="com.redhat.rhn.frontend.struts.RhnActionMapping"> + <forward name="default" path="/WEB-INF/pages/channel/manage/syncrepos.jsp" /> + <forward name="success" path="/channels/manage/SyncRepositories.do" redirect="true" /> + </action>
<action path="/channels/manage/Manage" scope="request"
commit 7a93c22f68400fc4cf6f5cb889160e9af05dc59b Author: Shannon Hughes shughes@redhat.com Date: Tue Jun 8 10:21:16 2010 -0400
adding new sync nav, moving add/remove to new tab
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/nav/StringResource_en_US.xml b/java/code/src/com/redhat/rhn/frontend/strings/nav/StringResource_en_US.xml index bca43a9..305a1d6 100644 --- a/java/code/src/com/redhat/rhn/frontend/strings/nav/StringResource_en_US.xml +++ b/java/code/src/com/redhat/rhn/frontend/strings/nav/StringResource_en_US.xml @@ -735,6 +735,20 @@ http://www.oasis-open.org/committees/xliff/documents/xliff-core-1.1.xsd" </context-group> </trans-unit>
+ <trans-unit id="Sync"> +<source>Sync</source> + <context-group name="ctx"> + <context context-type="sourcefile">Navigation Menu</context> + </context-group> + </trans-unit> + + <trans-unit id="Add / Remove"> +<source>Add / Remove</source> + <context-group name="ctx"> + <context context-type="sourcefile">Navigation Menu</context> + </context-group> + </trans-unit> + <trans-unit id="List / Leave"> <source>List / Leave</source> <context-group name="ctx"> diff --git a/java/code/webapp/WEB-INF/nav/manage_channel.xml b/java/code/webapp/WEB-INF/nav/manage_channel.xml index ea66733..9cd3640 100644 --- a/java/code/webapp/WEB-INF/nav/manage_channel.xml +++ b/java/code/webapp/WEB-INF/nav/manage_channel.xml @@ -50,6 +50,12 @@ </rhn-tab> <rhn-tab name="Repositories" acl="channel_exists()"> <rhn-tab-url>/rhn/channels/manage/Repositories.do</rhn-tab-url> + <rhn-tab name="Add / Remove"> + <rhn-tab-url>/rhn/channels/manage/Repositories.do</rhn-tab-url> + </rhn-tab> + <rhn-tab name="Sync"> + <rhn-tab-url>/rhn/channels/manage/Sync.do</rhn-tab-url> + </rhn-tab> </rhn-tab> <rhn-tab name="Patches" acl="channel_exists();channel_packaging_type(sysv-solaris)" on-click="Sniglets::Lists->navi_empty_set" node-id="remove_channel_packages"> <rhn-tab-url>/network/software/channels/manage/patches/index.pxt</rhn-tab-url>
commit c84ad74c83a270567c0f48e078c8883327745c58 Author: Shannon Hughes shughes@redhat.com Date: Mon Jun 7 16:47:23 2010 -0400
remove debug messages, add extra i18n update string
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 00248a7..509fc7d 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 @@ -60,12 +60,10 @@ public class RepositoriesAction extends RhnAction implements Listable {
if (!context.isSubmitted()) { List<ContentSource> result = getResult(context); - System.out.println("result set is " + result.size()); Set<String> preSelect = new HashSet<String>(); for (int i = 0; i < result.size(); i++) { ContentSource src = result.get(i); if(src.getChannels().contains(chan)) { - System.out.println("adding repo to preselect, " + src.getLabel() ); preSelect.add(src.getId().toString()); } } @@ -79,7 +77,6 @@ public class RepositoriesAction extends RhnAction implements Listable { Set<ContentSource> foo = chan.getSources(); foo.clear(); Set <String> set = helper.getSet(); - System.out.println("SET is " + set.size()); for (String id : set) { Long sgid = Long.valueOf(id); ContentSource tmp = ChannelFactory.lookupContentSource(sgid); @@ -88,9 +85,9 @@ public class RepositoriesAction extends RhnAction implements Listable {
ChannelFactory.save(chan);
- - StrutsDelegate strutsDelegate = getStrutsDelegate(); + strutsDelegate.saveMessage("channel.edit.repo.updated", new String[] {chan.getName()}, request ); + return strutsDelegate.forwardParams (mapping.findForward("success"), params); } diff --git a/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml b/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml index f75f70c..db8b97a 100644 --- a/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml +++ b/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml @@ -8456,6 +8456,9 @@ Follow this url to see the full list of inactive systems: <trans-unit id="channel.edit.repo.neversynced"> <source>This repo has never been synced.</source> </trans-unit> + <trans-unit id="channel.edit.repo.updated"> + <source>{0} repository information was successfully updated</source> + </trans-unit> <trans-unit id="ssm.provision.scheduled"> <source>Successfully scheduled {0} system(s) for provisioning.</source> </trans-unit>
commit 0e03b27b7a2d2e0e34fb6c87c73199e8ef1a5b3e Author: Shannon Hughes shughes@redhat.com Date: Wed Jun 2 19:22:05 2010 -0400
db mapping logic for channel repos
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 877a060..00248a7 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 @@ -33,6 +33,7 @@ import com.redhat.rhn.domain.channel.ContentSource; import com.redhat.rhn.domain.user.User; import com.redhat.rhn.frontend.struts.RequestContext; import com.redhat.rhn.frontend.struts.RhnAction; +import com.redhat.rhn.frontend.struts.StrutsDelegate; import com.redhat.rhn.frontend.taglibs.list.helper.ListSessionSetHelper; import com.redhat.rhn.frontend.taglibs.list.helper.Listable;
@@ -53,25 +54,45 @@ public class RepositoriesAction extends RhnAction implements Listable { request.setAttribute("channel_name", chan.getName());
Map params = new HashMap(); - params.put(RequestContext.CID, context.getRequiredParamAsString(RequestContext.CID)); + params.put(RequestContext.CID, chan.getId().toString());
- ListSessionSetHelper helper = new ListSessionSetHelper(this, request, params); + ListSessionSetHelper helper = new ListSessionSetHelper(this, request,params);
if (!context.isSubmitted()) { List<ContentSource> result = getResult(context); + System.out.println("result set is " + result.size()); Set<String> preSelect = new HashSet<String>(); for (int i = 0; i < result.size(); i++) { ContentSource src = result.get(i); if(src.getChannels().contains(chan)) { + System.out.println("adding repo to preselect, " + src.getLabel() ); preSelect.add(src.getId().toString()); } } helper.preSelect(preSelect); }
+ helper.ignoreEmptySelection(); helper.execute(); + if(helper.isDispatched()) { - return mapping.findForward("success"); + Set<ContentSource> foo = chan.getSources(); + foo.clear(); + Set <String> set = helper.getSet(); + System.out.println("SET is " + set.size()); + for (String id : set) { + Long sgid = Long.valueOf(id); + ContentSource tmp = ChannelFactory.lookupContentSource(sgid); + foo.add(tmp); + } + + ChannelFactory.save(chan); + + + + StrutsDelegate strutsDelegate = getStrutsDelegate(); + return strutsDelegate.forwardParams + (mapping.findForward("success"), params); }
return mapping.findForward("default"); diff --git a/java/code/webapp/WEB-INF/pages/channel/manage/channelrepos.jsp b/java/code/webapp/WEB-INF/pages/channel/manage/channelrepos.jsp index 1016cda..7bc65f2 100644 --- a/java/code/webapp/WEB-INF/pages/channel/manage/channelrepos.jsp +++ b/java/code/webapp/WEB-INF/pages/channel/manage/channelrepos.jsp @@ -16,9 +16,7 @@
<h2><img src="/img/rhn-icon-packages.gif"> <bean:message key="repos.jsp.channel.repos"/></h2>
- - -<rl:listset name="packageSet" legend="system-group"> +<rl:listset name="packageSet">
<input type="hidden" name="cid" value="${cid}" />
@@ -43,17 +41,14 @@ <a href="/rhn/channels/manage/repos/RepoEdit.do?id=${current.id}">${current.label}</a> </rl:column>
- - </rl:list> <div align="right"> <hr /> - <input type="submit" name="confirm" + <input type="submit" name="dispatch" value="<bean:message key="repos.jsp.update.channel"/>" /> </div> rhn:submitted/
- </rl:listset>
</body>
commit c2b28e4bcc3396acf452dcc84ee871dc0f6e5da5 Author: Shannon Hughes shughes@redhat.com Date: Wed Jun 2 16:05:59 2010 -0400
preselect set channel repo logic
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 bde5ec2..877a060 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 @@ -27,6 +27,7 @@ import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping;
+import com.redhat.rhn.domain.channel.Channel; import com.redhat.rhn.domain.channel.ChannelFactory; import com.redhat.rhn.domain.channel.ContentSource; import com.redhat.rhn.domain.user.User; @@ -45,17 +46,25 @@ public class RepositoriesAction extends RhnAction implements Listable { HttpServletResponse response) {
RequestContext context = new RequestContext(request); + User user = context.getLoggedInUser(); + + long cid = context.getRequiredParam("cid"); + Channel chan = ChannelFactory.lookupByIdAndUser(cid, user); + request.setAttribute("channel_name", chan.getName());
Map params = new HashMap(); params.put(RequestContext.CID, context.getRequiredParamAsString(RequestContext.CID));
- ListSessionSetHelper helper = new ListSessionSetHelper(this, request); + ListSessionSetHelper helper = new ListSessionSetHelper(this, request, params);
if (!context.isSubmitted()) { List<ContentSource> result = getResult(context); Set<String> preSelect = new HashSet<String>(); for (int i = 0; i < result.size(); i++) { - preSelect.add(result.get(i).getId().toString()); + ContentSource src = result.get(i); + if(src.getChannels().contains(chan)) { + preSelect.add(src.getId().toString()); + } } helper.preSelect(preSelect); } 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 20b47b8..ef22915 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 @@ -9450,6 +9450,15 @@ Please note that some manual configuration of these scripts may still be require <trans-unit id="repos.jsp.delete.info.header"> <source>Repository Information</source> </trans-unit> + <trans-unit id="repos.jsp.update.channel"> + <source>Update Repositories</source> + </trans-unit> + <trans-unit id="repos.jsp.channel.header"> + <source>Repository</source> + </trans-unit> + <trans-unit id="repos.jsp.channel.repos"> + <source>Channel Repositories</source> + </trans-unit>
<!-- TNC --> <trans-unit id="tnc.jsp.tnc"> diff --git a/java/code/webapp/WEB-INF/pages/channel/manage/channelrepos.jsp b/java/code/webapp/WEB-INF/pages/channel/manage/channelrepos.jsp index f2c562f..1016cda 100644 --- a/java/code/webapp/WEB-INF/pages/channel/manage/channelrepos.jsp +++ b/java/code/webapp/WEB-INF/pages/channel/manage/channelrepos.jsp @@ -14,7 +14,7 @@ <%@ include file="/WEB-INF/pages/common/fragments/channel/manage/manage_channel_header.jspf" %> <BR>
-<h2><img src="/img/rhn-icon-packages.gif"> <bean:message key="channel.jsp.package.list"/></h2> +<h2><img src="/img/rhn-icon-packages.gif"> <bean:message key="repos.jsp.channel.repos"/></h2>
@@ -24,7 +24,7 @@
<rl:list decorator="SelectableDecorator" - emptykey="package.jsp.emptylist" + emptykey="repos.jsp.norepos" alphabarcolumn="label" >
@@ -35,12 +35,12 @@
<rl:column sortable="true" bound="false" - headerkey="download.jsp.package" + headerkey="repos.jsp.channel.header" sortattr="label" defaultsort="asc" >
- <a href="/rhn/software/packages/Details.do?pid=${current.id}">${current.label}</a> + <a href="/rhn/channels/manage/repos/RepoEdit.do?id=${current.id}">${current.label}</a> </rl:column>
@@ -49,7 +49,7 @@ <div align="right"> <hr /> <input type="submit" name="confirm" - value="<bean:message key="channel.jsp.package.removebutton"/>" /> + value="<bean:message key="repos.jsp.update.channel"/>" /> </div> rhn:submitted/
commit 203d3be79a95fe7a0746fd01dcaf07604dbb879e Author: Shannon Hughes shughes@redhat.com Date: Wed Jun 2 15:28:08 2010 -0400
initial jsp support for channel to repo mapping
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 c6a680b..bde5ec2 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 @@ -14,8 +14,10 @@ */ package com.redhat.rhn.frontend.action.channel.manage;
+import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Set;
import javax.servlet.http.HttpServletRequest; @@ -42,9 +44,13 @@ public class RepositoriesAction extends RhnAction implements Listable { HttpServletRequest request, HttpServletResponse response) {
+ RequestContext context = new RequestContext(request); + + Map params = new HashMap(); + params.put(RequestContext.CID, context.getRequiredParamAsString(RequestContext.CID)); + ListSessionSetHelper helper = new ListSessionSetHelper(this, request);
- RequestContext context = new RequestContext(request); if (!context.isSubmitted()) { List<ContentSource> result = getResult(context); Set<String> preSelect = new HashSet<String>(); @@ -56,7 +62,6 @@ public class RepositoriesAction extends RhnAction implements Listable {
helper.execute(); if(helper.isDispatched()) { - //handle the dispatch action (like removing groups etc) return mapping.findForward("success"); }
diff --git a/java/code/webapp/WEB-INF/pages/channel/manage/channelrepos.jsp b/java/code/webapp/WEB-INF/pages/channel/manage/channelrepos.jsp new file mode 100644 index 0000000..f2c562f --- /dev/null +++ b/java/code/webapp/WEB-INF/pages/channel/manage/channelrepos.jsp @@ -0,0 +1,60 @@ +<%@ taglib uri="http://rhn.redhat.com/rhn" prefix="rhn" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %> +<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %> +<%@ taglib uri="http://rhn.redhat.com/tags/list" prefix="rl" %> + +html:xhtml/ +<html> +<head> + <meta name="page-decorator" content="none" /> +</head> +<body> + +<%@ include file="/WEB-INF/pages/common/fragments/channel/manage/manage_channel_header.jspf" %> +<BR> + +<h2><img src="/img/rhn-icon-packages.gif"> <bean:message key="channel.jsp.package.list"/></h2> + + + +<rl:listset name="packageSet" legend="system-group"> + +<input type="hidden" name="cid" value="${cid}" /> + + <rl:list + decorator="SelectableDecorator" + emptykey="package.jsp.emptylist" + alphabarcolumn="label" + > + + <rl:decorator name="PageSizeDecorator"/> + + <rl:selectablecolumn value="${current.id}" + styleclass="first-column"/> + + <rl:column sortable="true" + bound="false" + headerkey="download.jsp.package" + sortattr="label" + defaultsort="asc" + > + + <a href="/rhn/software/packages/Details.do?pid=${current.id}">${current.label}</a> + </rl:column> + + + + </rl:list> + <div align="right"> + <hr /> + <input type="submit" name="confirm" + value="<bean:message key="channel.jsp.package.removebutton"/>" /> + </div> + rhn:submitted/ + + +</rl:listset> + +</body> +</html> \ No newline at end of file diff --git a/java/code/webapp/WEB-INF/struts-config.xml b/java/code/webapp/WEB-INF/struts-config.xml index b7b2978..095d485 100644 --- a/java/code/webapp/WEB-INF/struts-config.xml +++ b/java/code/webapp/WEB-INF/struts-config.xml @@ -6500,7 +6500,7 @@ scope="request" type="com.redhat.rhn.frontend.action.channel.manage.RepositoriesAction" className="com.redhat.rhn.frontend.struts.RhnActionMapping"> - <forward name="default" path="/WEB-INF/pages/channel/manage/repositories.jsp" /> + <forward name="default" path="/WEB-INF/pages/channel/manage/channelrepos.jsp" /> <forward name="success" path="/channels/manage/Repositories.do" redirect="true" /> </action>
commit a461c4c57fac106378fc5ea16f2f7fd3b971fc1b Author: Shannon Hughes shughes@redhat.com Date: Wed Jun 2 15:08:52 2010 -0400
change from rhnset to sessionset for repo maps
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 85e4487..c6a680b 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 @@ -14,7 +14,9 @@ */ package com.redhat.rhn.frontend.action.channel.manage;
+import java.util.HashSet; import java.util.List; +import java.util.Set;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -24,12 +26,12 @@ import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping;
import com.redhat.rhn.domain.channel.ChannelFactory; +import com.redhat.rhn.domain.channel.ContentSource; import com.redhat.rhn.domain.user.User; import com.redhat.rhn.frontend.struts.RequestContext; import com.redhat.rhn.frontend.struts.RhnAction; -import com.redhat.rhn.frontend.taglibs.list.helper.ListRhnSetHelper; +import com.redhat.rhn.frontend.taglibs.list.helper.ListSessionSetHelper; import com.redhat.rhn.frontend.taglibs.list.helper.Listable; -import com.redhat.rhn.manager.rhnset.RhnSetDecl;
public class RepositoriesAction extends RhnAction implements Listable { @@ -40,8 +42,18 @@ public class RepositoriesAction extends RhnAction implements Listable { HttpServletRequest request, HttpServletResponse response) {
- ListRhnSetHelper helper = - new ListRhnSetHelper(this, request,RhnSetDecl.REPOSITORY_CHANNEL_MAPS); + ListSessionSetHelper helper = new ListSessionSetHelper(this, request); + + RequestContext context = new RequestContext(request); + if (!context.isSubmitted()) { + List<ContentSource> result = getResult(context); + Set<String> preSelect = new HashSet<String>(); + for (int i = 0; i < result.size(); i++) { + preSelect.add(result.get(i).getId().toString()); + } + helper.preSelect(preSelect); + } + helper.execute(); if(helper.isDispatched()) { //handle the dispatch action (like removing groups etc) @@ -51,7 +63,7 @@ public class RepositoriesAction extends RhnAction implements Listable { return mapping.findForward("default"); }
- public List getResult(RequestContext context) { + public List<ContentSource> getResult(RequestContext context) { User user = context.getLoggedInUser(); return ChannelFactory.lookupContentSources(user.getOrg()); } diff --git a/java/code/src/com/redhat/rhn/manager/rhnset/RhnSetDecl.java b/java/code/src/com/redhat/rhn/manager/rhnset/RhnSetDecl.java index a5f791a..35ce110 100644 --- a/java/code/src/com/redhat/rhn/manager/rhnset/RhnSetDecl.java +++ b/java/code/src/com/redhat/rhn/manager/rhnset/RhnSetDecl.java @@ -276,9 +276,6 @@ public class RhnSetDecl { public static final RhnSetDecl REMOVE_SYSTEMS_LIST = make( "remove_systems_list", SetCleanup.NOOP);
- public static final RhnSetDecl REPOSITORY_CHANNEL_MAPS = make( - "repository_channel_maps", SetCleanup.NOOP); - public static final RhnSetDecl CHANNEL_SUBSCRIPTION_PERMS = make( "channel_subscription_perms", SetCleanup.NOOP);
commit eef1d5071b3b501ab024deb23a5223bae087b397 Author: Shannon Hughes shughes@redhat.com Date: Wed Jun 2 14:47:01 2010 -0400
intial strut action for channel repository mapping
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 9026fa0..3239ca3 100644 --- a/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java +++ b/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java @@ -133,6 +133,18 @@ public class ChannelFactory extends HibernateFactory { }
/** + * Lookup a content source by org + * @param org the org to lookup + * @return the ContentSource(s) + */ + public static List<ContentSource> lookupContentSources(Org org) { + Map params = new HashMap(); + params.put("org", org); + return singleton.listObjectsByNamedQuery( + "ContentSource.findByOrg", params); + } + + /** * lookup content source by id and org * @param id * @param orgIn 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 532aeba..dbf537c 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,6 +44,10 @@ 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.findByOrg"> + <![CDATA[from com.redhat.rhn.domain.channel.ContentSource as c where c.org = :org]]> + </query> +
</hibernate-mapping> 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 new file mode 100644 index 0000000..85e4487 --- /dev/null +++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/RepositoriesAction.java @@ -0,0 +1,58 @@ +/** + * Copyright (c) 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.action.channel.manage; + +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; + +import com.redhat.rhn.domain.channel.ChannelFactory; +import com.redhat.rhn.domain.user.User; +import com.redhat.rhn.frontend.struts.RequestContext; +import com.redhat.rhn.frontend.struts.RhnAction; +import com.redhat.rhn.frontend.taglibs.list.helper.ListRhnSetHelper; +import com.redhat.rhn.frontend.taglibs.list.helper.Listable; +import com.redhat.rhn.manager.rhnset.RhnSetDecl; + + +public class RepositoriesAction extends RhnAction implements Listable { + + + public ActionForward execute(ActionMapping mapping, + ActionForm formIn, + HttpServletRequest request, + HttpServletResponse response) { + + ListRhnSetHelper helper = + new ListRhnSetHelper(this, request,RhnSetDecl.REPOSITORY_CHANNEL_MAPS); + helper.execute(); + if(helper.isDispatched()) { + //handle the dispatch action (like removing groups etc) + return mapping.findForward("success"); + } + + return mapping.findForward("default"); + } + + public List getResult(RequestContext context) { + User user = context.getLoggedInUser(); + return ChannelFactory.lookupContentSources(user.getOrg()); + } +} diff --git a/java/code/src/com/redhat/rhn/manager/rhnset/RhnSetDecl.java b/java/code/src/com/redhat/rhn/manager/rhnset/RhnSetDecl.java index 35ce110..a5f791a 100644 --- a/java/code/src/com/redhat/rhn/manager/rhnset/RhnSetDecl.java +++ b/java/code/src/com/redhat/rhn/manager/rhnset/RhnSetDecl.java @@ -276,6 +276,9 @@ public class RhnSetDecl { public static final RhnSetDecl REMOVE_SYSTEMS_LIST = make( "remove_systems_list", SetCleanup.NOOP);
+ public static final RhnSetDecl REPOSITORY_CHANNEL_MAPS = make( + "repository_channel_maps", SetCleanup.NOOP); + public static final RhnSetDecl CHANNEL_SUBSCRIPTION_PERMS = make( "channel_subscription_perms", SetCleanup.NOOP);
commit 9c49e0ab6723dcd7eba3c5283b215cfbe1706ff8 Author: Shannon Hughes shughes@redhat.com Date: Wed Jun 2 13:40:02 2010 -0400
strut support for channel repository mapping
diff --git a/java/code/webapp/WEB-INF/struts-config.xml b/java/code/webapp/WEB-INF/struts-config.xml index 4d8d93b..b7b2978 100644 --- a/java/code/webapp/WEB-INF/struts-config.xml +++ b/java/code/webapp/WEB-INF/struts-config.xml @@ -6496,6 +6496,14 @@ <forward name="default" path="/WEB-INF/pages/channel/manage/listremovepackages.jsp" /> </action>
+ <action path="/channels/manage/Repositories" + scope="request" + type="com.redhat.rhn.frontend.action.channel.manage.RepositoriesAction" + className="com.redhat.rhn.frontend.struts.RhnActionMapping"> + <forward name="default" path="/WEB-INF/pages/channel/manage/repositories.jsp" /> + <forward name="success" path="/channels/manage/Repositories.do" redirect="true" /> + </action> + <action path="/channels/manage/Manage" scope="request" type="com.redhat.rhn.frontend.action.channel.manage.ManageChannelsAction"
commit 2584781b89dca8dfcd2745c17090256eae1a65cb Author: Shannon Hughes shughes@redhat.com Date: Wed Jun 2 13:32:07 2010 -0400
channel nav support for repository mapping
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/nav/StringResource_en_US.xml b/java/code/src/com/redhat/rhn/frontend/strings/nav/StringResource_en_US.xml index fb95487..bca43a9 100644 --- a/java/code/src/com/redhat/rhn/frontend/strings/nav/StringResource_en_US.xml +++ b/java/code/src/com/redhat/rhn/frontend/strings/nav/StringResource_en_US.xml @@ -1019,6 +1019,13 @@ http://www.oasis-open.org/committees/xliff/documents/xliff-core-1.1.xsd" </context-group> </trans-unit>
+ <trans-unit id="Repositories"> + <source>Repositories</source> + <context-group name="ctx"> + <context context-type="sourcefile">/rhn/channels/manage/Edit.do</context> + </context-group> + </trans-unit> + <trans-unit id="Managers"> <source>Managers</source> <context-group name="ctx"> diff --git a/java/code/webapp/WEB-INF/nav/manage_channel.xml b/java/code/webapp/WEB-INF/nav/manage_channel.xml index acdb4cd..ea66733 100644 --- a/java/code/webapp/WEB-INF/nav/manage_channel.xml +++ b/java/code/webapp/WEB-INF/nav/manage_channel.xml @@ -48,6 +48,9 @@ <rhn-tab-directory>/network/software/channels/manage/packages/compare</rhn-tab-directory> </rhn-tab> </rhn-tab> + <rhn-tab name="Repositories" acl="channel_exists()"> + <rhn-tab-url>/rhn/channels/manage/Repositories.do</rhn-tab-url> + </rhn-tab> <rhn-tab name="Patches" acl="channel_exists();channel_packaging_type(sysv-solaris)" on-click="Sniglets::Lists->navi_empty_set" node-id="remove_channel_packages"> <rhn-tab-url>/network/software/channels/manage/patches/index.pxt</rhn-tab-url> <rhn-tab name="List / Remove" node-id="remove_channel_packages"> diff --git a/web/html/nav/manage_channel.xml b/web/html/nav/manage_channel.xml index cb764a4..14807bc 100644 --- a/web/html/nav/manage_channel.xml +++ b/web/html/nav/manage_channel.xml @@ -45,6 +45,9 @@ <rhn-tab-directory>/network/software/channels/manage/packages/compare</rhn-tab-directory> </rhn-tab> </rhn-tab> + <rhn-tab name="Repositories" acl="channel_exists()"> + <rhn-tab-url>/rhn/channels/manage/Repositories.do</rhn-tab-url> + </rhn-tab> <rhn-tab name="Patches" acl="channel_exists();channel_packaging_type(sysv-solaris)" on-click="Sniglets::Lists->navi_empty_set" node-id="remove_channel_packages"> <rhn-tab-url>/network/software/channels/manage/patches/index.pxt</rhn-tab-url> <rhn-tab name="List / Remove" on-click="Sniglets::Lists->navi_empty_set" node-id="remove_channel_packages">
commit e94a2c9ee2219cd840d9898582bffc6927904493 Author: Shannon Hughes shughes@redhat.com Date: Thu May 27 15:42:47 2010 -0400
modify verbage for repo list summary
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 ec20df0..20b47b8 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 @@ -9376,7 +9376,7 @@ Please note that some manual configuration of these scripts may still be require
<!-- Repo Sync --> <trans-unit id="repos.jsp.summary"> - <source>Summary for repos here</source> + <source>Use repositories to sync additional packages to your channels. Repositories may be linked to your channels.</source> </trans-unit> <trans-unit id="repos.jsp.note.default"> <source>note here</source> @@ -9405,6 +9405,9 @@ Please note that some manual configuration of these scripts may still be require <trans-unit id="repos.jsp.toolbar"> <source>Create New Repository</source> </trans-unit> + <trans-unit id="repos.jsp.header"> + <source>Repositories</source> + </trans-unit> <trans-unit id="repos.jsp.header2"> <source>Create Repository</source> </trans-unit> diff --git a/java/code/webapp/WEB-INF/pages/channel/manage/repo/repos.jsp b/java/code/webapp/WEB-INF/pages/channel/manage/repo/repos.jsp index 46dba89..e387d3e 100644 --- a/java/code/webapp/WEB-INF/pages/channel/manage/repo/repos.jsp +++ b/java/code/webapp/WEB-INF/pages/channel/manage/repo/repos.jsp @@ -10,7 +10,7 @@ creationUrl="RepoCreate.do" creationType="repos" imgAlt="info.alt.img"> - <bean:message key="repos.jsp.toolbar"/> + <bean:message key="repos.jsp.header"/> </rhn:toolbar> <div class="page-summary"> <p><bean:message key="repos.jsp.summary"/></p>
commit 7d9ea6458f6b4246227904ef1ae0afc2098da6a7 Author: Shannon Hughes shughes@redhat.com Date: Thu May 27 14:45:15 2010 -0400
logic to delete content sources from db
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 44372bd..9026fa0 100644 --- a/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java +++ b/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java @@ -212,6 +212,14 @@ public class ChannelFactory extends HibernateFactory { }
/** + * Remove a Content Source from the DB + * @param src to be removed from database + */ + public static void remove(ContentSource src) { + singleton.removeObject(src); + } + + /** * Returns the base channel for the given server id. * @param sid Server id whose base channel we want. * @return Base Channel for the given server id. diff --git a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDeleteAction.java b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDeleteAction.java index 1ac7804..31a1da0 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDeleteAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDeleteAction.java @@ -22,6 +22,7 @@ import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping;
import com.redhat.rhn.common.validator.ValidatorException; +import com.redhat.rhn.domain.channel.ChannelFactory; import com.redhat.rhn.domain.channel.ContentSource; import com.redhat.rhn.frontend.struts.RequestContext; import com.redhat.rhn.frontend.struts.RhnAction; @@ -51,7 +52,7 @@ public class RepoDeleteAction extends RhnAction {
if (context.isSubmitted()) { try { - //delete here + ChannelFactory.remove(src); createSuccessMessage(request, "repos.delete.success", cmd.getLabel()); return mapping.findForward("success"); diff --git a/java/code/webapp/WEB-INF/pages/channel/manage/repo/deleteconfirm.jsp b/java/code/webapp/WEB-INF/pages/channel/manage/repo/deleteconfirm.jsp index 7de61ad..58fe0a5 100644 --- a/java/code/webapp/WEB-INF/pages/channel/manage/repo/deleteconfirm.jsp +++ b/java/code/webapp/WEB-INF/pages/channel/manage/repo/deleteconfirm.jsp @@ -14,7 +14,7 @@ <p><bean:message key="repos.jsp.delete.summary"/></p> <p><rhn:warning key= "repos.jsp.delete.warning"/></p> <div> - <form method="post" action="/rhn/channels/cobbler/manage/repos/RepoDelete.do"> + <form method="post" action="/rhn/channels/manage/repos/RepoDelete.do"> <h2><bean:message key="repos.jsp.delete.info.header"/></h2> <table class="details"> <tr>
commit f439527ea026b33c14b280796664fe964757da13 Author: Shannon Hughes shughes@redhat.com Date: Thu May 27 14:29:35 2010 -0400
minor syntax issue with i18n repo delete strings
diff --git a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDeleteAction.java b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDeleteAction.java index fb47115..1ac7804 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDeleteAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDeleteAction.java @@ -42,6 +42,7 @@ public class RepoDeleteAction extends RhnAction { RequestContext context = new RequestContext(request); EditRepoCommand cmd = new EditRepoCommand(context.getLoggedInUser(), context.getParamAsLong("id")); + ContentSource src = cmd.getNewRepo();
request.setAttribute(RepoDetailsAction.LABEL, src.getLabel() ); 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 a065574..ec20df0 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 @@ -9442,7 +9442,7 @@ Please note that some manual configuration of these scripts may still be require <source>Are you sure you want to delete this repository permanently?</source> </trans-unit> <trans-unit id="repos.jsp.delete.warning"> - <source>Warning: Deleting this repository will remove any channel mappings this repository is associated with</source> + <source>Deleting this repository will remove any channel mappings this repository is associated with</source> </trans-unit> <trans-unit id="repos.jsp.delete.info.header"> <source>Repository Information</source>
commit 46c06c83675cf814483b696b48680a5cdddc0a28 Author: Shannon Hughes shughes@redhat.com Date: Thu May 27 14:19:20 2010 -0400
initial files to support Repo delete
diff --git a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDeleteAction.java b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDeleteAction.java new file mode 100644 index 0000000..fb47115 --- /dev/null +++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDeleteAction.java @@ -0,0 +1,66 @@ +/** + * 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.action.channel.manage.repo; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; + +import com.redhat.rhn.common.validator.ValidatorException; +import com.redhat.rhn.domain.channel.ContentSource; +import com.redhat.rhn.frontend.struts.RequestContext; +import com.redhat.rhn.frontend.struts.RhnAction; +import com.redhat.rhn.frontend.struts.RhnHelper; +import com.redhat.rhn.frontend.struts.RhnValidationHelper; +import com.redhat.rhn.manager.channel.repo.EditRepoCommand; + +/** + * RepoDeleteAction + * @version $Rev: 1 $ + */ +public class RepoDeleteAction extends RhnAction { + /** {@inheritDoc} */ + public ActionForward execute(ActionMapping mapping, + ActionForm formIn, + HttpServletRequest request, + HttpServletResponse response) { + RequestContext context = new RequestContext(request); + EditRepoCommand cmd = new EditRepoCommand(context.getLoggedInUser(), + context.getParamAsLong("id")); + ContentSource src = cmd.getNewRepo(); + + request.setAttribute(RepoDetailsAction.LABEL, src.getLabel() ); + request.setAttribute(RepoDetailsAction.URL, src.getSourceUrl() ); + request.setAttribute("id", src.getId()); + + if (context.isSubmitted()) { + try { + //delete here + createSuccessMessage(request, + "repos.delete.success", cmd.getLabel()); + return mapping.findForward("success"); + } + catch (ValidatorException ve) { + getStrutsDelegate().saveMessages(request, ve.getResult()); + RhnValidationHelper.setFailedValidation(request); + } + } + + return mapping.findForward(RhnHelper.DEFAULT_FORWARD); + } +} 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 ba724a4..a065574 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 @@ -9420,15 +9420,33 @@ Please note that some manual configuration of these scripts may still be require <trans-unit id="repos.jsp.update.submit"> <source>Update Repository</source> </trans-unit> + <trans-unit id="repos.jsp.delete.submit"> + <source>Delete Repository</source> + </trans-unit> <trans-unit id="repos.jsp.create.success"> <source>Repository created successfully</source> </trans-unit> <trans-unit id="repos.jsp.update.success"> <source>Repository updated successfully</source> </trans-unit> + <trans-unit id="repos.delete.success"> + <source>Repository deleted successfully</source> + </trans-unit> <trans-unit id="repos.jsp.details.header2"> <source>Repository Details</source> </trans-unit> + <trans-unit id="repos.jsp.delete.header2"> + <source>Confirm Repository Delete</source> + </trans-unit> + <trans-unit id="repos.jsp.delete.summary"> + <source>Are you sure you want to delete this repository permanently?</source> + </trans-unit> + <trans-unit id="repos.jsp.delete.warning"> + <source>Warning: Deleting this repository will remove any channel mappings this repository is associated with</source> + </trans-unit> + <trans-unit id="repos.jsp.delete.info.header"> + <source>Repository Information</source> + </trans-unit>
<!-- TNC --> <trans-unit id="tnc.jsp.tnc"> diff --git a/java/code/webapp/WEB-INF/pages/channel/manage/repo/deleteconfirm.jsp b/java/code/webapp/WEB-INF/pages/channel/manage/repo/deleteconfirm.jsp new file mode 100644 index 0000000..7de61ad --- /dev/null +++ b/java/code/webapp/WEB-INF/pages/channel/manage/repo/deleteconfirm.jsp @@ -0,0 +1,52 @@ +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="http://rhn.redhat.com/rhn" prefix="rhn" %> +<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %> +<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %> + +html:xhtml/ +<html> +<body> +<rhn:toolbar base="h1" img="/img/rhn-icon-info.gif" imgAlt="info.alt.img"> + <c:out value="${requestScope.label}"/> +</rhn:toolbar> + +<h2><bean:message key="repos.jsp.delete.header2"/></h2> +<p><bean:message key="repos.jsp.delete.summary"/></p> +<p><rhn:warning key= "repos.jsp.delete.warning"/></p> +<div> + <form method="post" action="/rhn/channels/cobbler/manage/repos/RepoDelete.do"> +<h2><bean:message key="repos.jsp.delete.info.header"/></h2> + <table class="details"> + <tr> + <th> + <bean:message key="repos.jsp.create.label"/> + </th> + <td> + <c:out value="${label}"/></pre> + </td> + </tr> + <tr> + <th> + <bean:message key="repos.jsp.create.url"/> + </th> + <td> + <c:out value="${url}"/></pre> + </td> + </tr> + + </table> + <hr /> + <table align="right"> + <tr> + <td></td> + rhn:submitted/ + <input type="hidden" name="id" value="${requestScope.id}"/> + <td align="right"><input type=submit name="dispatch" + value="${rhn:localize('repos.jsp.delete.submit')}"/></td> + </tr> + </table> + </form> +</div> + +</body> +</html> diff --git a/java/code/webapp/WEB-INF/struts-config.xml b/java/code/webapp/WEB-INF/struts-config.xml index c18168b..4d8d93b 100644 --- a/java/code/webapp/WEB-INF/struts-config.xml +++ b/java/code/webapp/WEB-INF/struts-config.xml @@ -6654,6 +6654,16 @@ path="/channels/manage/repos/RepoEdit.do" redirect = "true"/> </action>
+ <action path="/channels/manage/repos/RepoDelete" + scope="request" + type="com.redhat.rhn.frontend.action.channel.manage.repo.RepoDeleteAction" + className="com.redhat.rhn.frontend.struts.RhnActionMapping"> + <forward name="default" + path="/WEB-INF/pages/channel/manage/repo/deleteconfirm.jsp"/> + <forward name="success" + path="/channels/manage/repos/RepoList.do" redirect = "true"/> + </action> + <!-- end repo -->
<action path="/common/DownloadFile"
commit e6f715f0d73ec5415b89f3e68ccfbbd46b98fa0a Author: Shannon Hughes shughes@redhat.com Date: Wed May 26 16:38:59 2010 -0400
bug fixes for EditRepo, strut path fixes
diff --git a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java index 4366217..d2b3623 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java @@ -33,6 +33,7 @@ import com.redhat.rhn.frontend.struts.RequestContext; import com.redhat.rhn.frontend.struts.RhnAction; import com.redhat.rhn.frontend.struts.RhnHelper; import com.redhat.rhn.frontend.struts.RhnValidationHelper; +import com.redhat.rhn.manager.channel.repo.BaseRepoCommand; import com.redhat.rhn.manager.channel.repo.CreateRepoCommand; import com.redhat.rhn.manager.channel.repo.EditRepoCommand;
@@ -47,7 +48,7 @@ public class RepoDetailsAction extends RhnAction { public static final String REPO = "repo"; public static final String URL = "url"; public static final String LABEL = "label"; - public static final String OLD_LABEL = "oldLabel"; + public static final String SOURCEID = "sourceid";
private static final String VALIDATION_XSD = "/com/redhat/rhn/frontend/action/channel/" + @@ -87,7 +88,7 @@ public class RepoDetailsAction extends RhnAction { request.removeAttribute(CREATE_MODE); setupRepo(request, form, repo); return getStrutsDelegate().forwardParam(mapping.findForward("success"), - LABEL, repo.getLabel()); + "id", repo.getId().toString()); } catch (ValidatorException ve) { getStrutsDelegate().saveMessages(request, ve.getResult()); @@ -99,8 +100,6 @@ public class RepoDetailsAction extends RhnAction { setup(request, form); }
- // setup(request, form); - return mapping.findForward(RhnHelper.DEFAULT_FORWARD); }
@@ -126,8 +125,8 @@ public class RepoDetailsAction extends RhnAction { ContentSource repo) {
form.set(LABEL, repo.getLabel()); - form.set(OLD_LABEL, repo.getLabel()); form.set(URL, repo.getSourceUrl()); + form.set(SOURCEID, repo.getId()); bindRepo(request, repo); }
@@ -142,13 +141,17 @@ public class RepoDetailsAction extends RhnAction {
private ContentSource submit(HttpServletRequest request, DynaActionForm form) { RequestContext context = new RequestContext(request); - - String label = isCreateMode(request) ? - form.getString(LABEL) : form.getString(OLD_LABEL); String url = form.getString(URL); + String label = form.getString(LABEL); Org org = context.getLoggedInUser().getOrg(); + BaseRepoCommand repoCmd = null; + if(isCreateMode(request)) { + repoCmd = new CreateRepoCommand(org); + } + else { + repoCmd = new EditRepoCommand(context.getLoggedInUser(), context.getParamAsLong(SOURCEID)); + }
- CreateRepoCommand repoCmd = new CreateRepoCommand(org); repoCmd.setLabel(label); repoCmd.setUrl(url); repoCmd.store(); 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 e1f4fa3..ba724a4 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 @@ -9423,6 +9423,9 @@ Please note that some manual configuration of these scripts may still be require <trans-unit id="repos.jsp.create.success"> <source>Repository created successfully</source> </trans-unit> + <trans-unit id="repos.jsp.update.success"> + <source>Repository updated successfully</source> + </trans-unit> <trans-unit id="repos.jsp.details.header2"> <source>Repository Details</source> </trans-unit> diff --git a/java/code/webapp/WEB-INF/pages/channel/manage/repo/repodetails.jsp b/java/code/webapp/WEB-INF/pages/channel/manage/repo/repodetails.jsp index 518b903..9f31783 100644 --- a/java/code/webapp/WEB-INF/pages/channel/manage/repo/repodetails.jsp +++ b/java/code/webapp/WEB-INF/pages/channel/manage/repo/repodetails.jsp @@ -43,7 +43,7 @@ <html:text property="label"/>
<c:if test = "${empty requestScope.create_mode}"> - <html:hidden property="oldLabel"/> + <html:hidden property="sourceid"/> </c:if> </td> </tr> diff --git a/java/code/webapp/WEB-INF/struts-config.xml b/java/code/webapp/WEB-INF/struts-config.xml index 6b61400..c18168b 100644 --- a/java/code/webapp/WEB-INF/struts-config.xml +++ b/java/code/webapp/WEB-INF/struts-config.xml @@ -821,7 +821,7 @@ <form-bean name="contentSourceForm" type="com.redhat.rhn.frontend.struts.ScrubbingDynaActionForm"> <form-property name="url" type="java.lang.String"/> - <form-property name="oldLabel" type="java.lang.String" /> + <form-property name="sourceid" type="java.lang.Long" /> <form-property name="label" type="java.lang.String"/> </form-bean>
@@ -6651,7 +6651,7 @@ <forward name="default" path="/WEB-INF/pages/channel/manage/repo/repodetails.jsp"/> <forward name="success" - path="/channels/manage/repo/RepoEdit.do" redirect = "true"/> + path="/channels/manage/repos/RepoEdit.do" redirect = "true"/> </action>
<!-- end repo -->
commit db481c03285b6deac4eaf49a26fb23c9f9be569f Author: Shannon Hughes shughes@redhat.com Date: Wed May 26 15:14:01 2010 -0400
RepoEdit page cleanup, jsp fixes
diff --git a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java index cecd40d..4366217 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java @@ -129,7 +129,6 @@ public class RepoDetailsAction extends RhnAction { form.set(OLD_LABEL, repo.getLabel()); form.set(URL, repo.getSourceUrl()); bindRepo(request, repo); - request.setAttribute(ORG, repo.getOrg()); }
/** 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 1a998c5..e1f4fa3 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 @@ -9396,6 +9396,12 @@ Please note that some manual configuration of these scripts may still be require <context context-type="sourcefile">/rhn/channel/manage/repo/RepoList.do</context> </context-group> </trans-unit> + <trans-unit id="toolbar.delete.repos"> + <source>delete repository</source> + <context-group name="ctx"> + <context context-type="sourcefile">/rhn/channel/manage/repo/RepoDetails.do</context> + </context-group> + </trans-unit> <trans-unit id="repos.jsp.toolbar"> <source>Create New Repository</source> </trans-unit> @@ -9412,12 +9418,14 @@ Please note that some manual configuration of these scripts may still be require <source>Create Repository</source> </trans-unit> <trans-unit id="repos.jsp.update.submit"> - <source>Create Repository</source> + <source>Update Repository</source> </trans-unit> <trans-unit id="repos.jsp.create.success"> <source>Repository created successfully</source> </trans-unit> - + <trans-unit id="repos.jsp.details.header2"> + <source>Repository Details</source> + </trans-unit>
<!-- TNC --> <trans-unit id="tnc.jsp.tnc"> diff --git a/java/code/webapp/WEB-INF/pages/channel/manage/repo/repodetails.jsp b/java/code/webapp/WEB-INF/pages/channel/manage/repo/repodetails.jsp index 1f81305..518b903 100644 --- a/java/code/webapp/WEB-INF/pages/channel/manage/repo/repodetails.jsp +++ b/java/code/webapp/WEB-INF/pages/channel/manage/repo/repodetails.jsp @@ -7,22 +7,21 @@ <body> <c:choose> <c:when test = "${not empty requestScope.create_mode}"> -<rhn:toolbar base="h1" img="/img/rhn-icon-info.gif" imgAlt="info.alt.img"> - <bean:message key="repos.jsp.toolbar"/> -</rhn:toolbar> -<h2><bean:message key="repos.jsp.header2"/></h2> + <rhn:toolbar base="h1" img="/img/rhn-icon-info.gif" imgAlt="info.alt.img"> + <bean:message key="repos.jsp.toolbar"/> + </rhn:toolbar> + <h2><bean:message key="repos.jsp.header2"/></h2> </c:when> <c:otherwise> -<rhn:toolbar base="h1" img="/img/rhn-icon-info.gif" imgAlt="info.alt.img" - deletionUrl="RepoDelete.do?label=${contentSourceForm.map.label}" - deletionType="snippets"> - <c:out value="${requestScope.snippet.displayName}"/> -</rhn:toolbar> -<h2><bean:message key="snippetdetails.jsp.header2"/></h2> + <rhn:toolbar base="h1" img="/img/rhn-icon-info.gif" imgAlt="info.alt.img" + deletionUrl="RepoDelete.do?id=${requestScope.repo.id}" + deletionType="repos"> + <c:out value="${requestScope.repo.label}"/> + </rhn:toolbar> + <h2><bean:message key="repos.jsp.details.header2"/></h2> </c:otherwise> </c:choose>
- <c:choose> <c:when test="${empty requestScope.create_mode}"> <c:set var="url" value ="/channels/manage/repos/RepoEdit"/> @@ -32,7 +31,6 @@ </c:otherwise> </c:choose>
- <div> <html:form action="${url}"> rhn:submitted/
commit 0ed520a1fe1de6db04a6ea69eb38104032264727 Author: Shannon Hughes shughes@redhat.com Date: Wed May 26 14:38:00 2010 -0400
fix hibernate content obj named queries for Edit Repo
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 51b5169..44372bd 100644 --- a/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java +++ b/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java @@ -141,7 +141,7 @@ public class ChannelFactory extends HibernateFactory { public static ContentSource lookupContentSource(Long id, Org orgIn) { Map params = new HashMap(); params.put("id", id); - params.put("org", orgIn.getId()); + params.put("org", orgIn); return (ContentSource) singleton.lookupObjectByNamedQuery( "ContentSource.findByIdandOrg", 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 7df6ca8..532aeba 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 @@ -39,7 +39,7 @@ 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_id = :org]]> + <![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]]> diff --git a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java index a0d74c6..cecd40d 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java @@ -20,7 +20,6 @@ import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;
-import org.apache.log4j.Logger; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; @@ -29,13 +28,13 @@ import org.apache.struts.action.DynaActionForm; import com.redhat.rhn.common.validator.ValidatorException; import com.redhat.rhn.common.validator.ValidatorResult; import com.redhat.rhn.domain.channel.ContentSource; -import com.redhat.rhn.domain.kickstart.cobbler.CobblerSnippet; import com.redhat.rhn.domain.org.Org; import com.redhat.rhn.frontend.struts.RequestContext; import com.redhat.rhn.frontend.struts.RhnAction; import com.redhat.rhn.frontend.struts.RhnHelper; import com.redhat.rhn.frontend.struts.RhnValidationHelper; import com.redhat.rhn.manager.channel.repo.CreateRepoCommand; +import com.redhat.rhn.manager.channel.repo.EditRepoCommand;
/** @@ -97,7 +96,7 @@ public class RepoDetailsAction extends RhnAction { } } else if(!isCreateMode(request)) { - + setup(request, form); }
// setup(request, form); @@ -115,24 +114,14 @@ public class RepoDetailsAction extends RhnAction { private boolean isCreateMode(HttpServletRequest request) { return Boolean.TRUE.equals(request.getAttribute(CREATE_MODE)); } - /* + private void setup(HttpServletRequest request, DynaActionForm form) { RequestContext context = new RequestContext(request); - if (isCreateMode(request)) { - request.setAttribute(PREFIX, CobblerSnippet.getPrefixFor( - context.getLoggedInUser().getOrg())); - } - else { - String param = NAME; - if (!isCreateMode(request) && RhnValidationHelper. - getFailedValidation(request)) { - param = OLD_NAME; - } - CobblerSnippet snip = loadEditableSnippet(request, param); - setupSnippet(request, form, snip); - } + EditRepoCommand cmd = new EditRepoCommand(context.getLoggedInUser(), + context.getParamAsLong("id")); + setupRepo(request, form, cmd.getNewRepo()); } - */ + private void setupRepo(HttpServletRequest request, DynaActionForm form, ContentSource repo) {
commit b59ee070df08bc04bc64e8c4fffcf4eb61da5cf2 Author: Shannon Hughes shughes@redhat.com Date: Wed May 26 11:37:18 2010 -0400
starting checking content objects off id and org for security; also fix query for taskomatic
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 5ce5953..51b5169 100644 --- a/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java +++ b/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java @@ -125,13 +125,27 @@ public class ChannelFactory extends HibernateFactory { * @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 content source by id and org + * @param id + * @param orgIn + * @return + */ public static ContentSource lookupContentSource(Long id, Org orgIn) { Map params = new HashMap(); params.put("id", id); params.put("org", orgIn.getId()); return (ContentSource) singleton.lookupObjectByNamedQuery( - "ContentSource.findById", params); + "ContentSource.findByIdandOrg", 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 cf316a7..7df6ca8 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,5 +41,9 @@ 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_id = :org]]> </query> + <query name="ContentSource.findById"> + <![CDATA[from com.redhat.rhn.domain.channel.ContentSource as c where c.id = :id]]> + </query> +
</hibernate-mapping> diff --git a/java/code/src/com/redhat/rhn/frontend/action/common/DownloadFile.java b/java/code/src/com/redhat/rhn/frontend/action/common/DownloadFile.java index f42fc23..13998b5 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/common/DownloadFile.java +++ b/java/code/src/com/redhat/rhn/frontend/action/common/DownloadFile.java @@ -374,7 +374,7 @@ public class DownloadFile extends DownloadAction { } else if (type.equals(DownloadManager.DOWNLOAD_TYPE_REPO_LOG)) { Channel c = ChannelFactory.lookupById((Long)params.get(CHANNEL)); - ContentSource cs = ChannelFactory.lookupContentSource(fileId); + ContentSource cs = ChannelFactory.lookupContentSource(fileId, user.getOrg()); ChannelManager.verifyChannelAdmin(user, fileId); File file = new File(ChannelManager.getLatestSyncLogFile(cs, c));
commit d0c06b164bced75376aaf839ad7a6192b4f1e56d Author: Shannon Hughes shughes@redhat.com Date: Wed May 26 11:22:53 2010 -0400
commit before master merge
diff --git a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java index 8bccfab..a0d74c6 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java @@ -29,6 +29,7 @@ import org.apache.struts.action.DynaActionForm; import com.redhat.rhn.common.validator.ValidatorException; import com.redhat.rhn.common.validator.ValidatorResult; import com.redhat.rhn.domain.channel.ContentSource; +import com.redhat.rhn.domain.kickstart.cobbler.CobblerSnippet; import com.redhat.rhn.domain.org.Org; import com.redhat.rhn.frontend.struts.RequestContext; import com.redhat.rhn.frontend.struts.RhnAction; @@ -95,6 +96,11 @@ public class RepoDetailsAction extends RhnAction { } } } + else if(!isCreateMode(request)) { + + } + + // setup(request, form);
return mapping.findForward(RhnHelper.DEFAULT_FORWARD); } @@ -109,8 +115,24 @@ public class RepoDetailsAction extends RhnAction { private boolean isCreateMode(HttpServletRequest request) { return Boolean.TRUE.equals(request.getAttribute(CREATE_MODE)); } - - + /* + private void setup(HttpServletRequest request, DynaActionForm form) { + RequestContext context = new RequestContext(request); + if (isCreateMode(request)) { + request.setAttribute(PREFIX, CobblerSnippet.getPrefixFor( + context.getLoggedInUser().getOrg())); + } + else { + String param = NAME; + if (!isCreateMode(request) && RhnValidationHelper. + getFailedValidation(request)) { + param = OLD_NAME; + } + CobblerSnippet snip = loadEditableSnippet(request, param); + setupSnippet(request, form, snip); + } + } + */ private void setupRepo(HttpServletRequest request, DynaActionForm form, ContentSource repo) {
commit 74f0bbf6093ba70f53dac44cdc9f10d2af77ce01 Author: Shannon Hughes shughes@redhat.com Date: Tue May 25 17:04:29 2010 -0400
adding repo edit commands
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 915d0e7..5ce5953 100644 --- a/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java +++ b/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java @@ -125,9 +125,10 @@ public class ChannelFactory extends HibernateFactory { * @param id the id to lookup * @return the ContentSource */ - public static ContentSource lookupContentSource(Long id) { + public static ContentSource lookupContentSource(Long id, Org orgIn) { Map params = new HashMap(); params.put("id", id); + params.put("org", orgIn.getId()); return (ContentSource) singleton.lookupObjectByNamedQuery( "ContentSource.findById", 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 b8e56b6..cf316a7 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 @@ -38,8 +38,8 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" </class>
- <query name="ContentSource.findById"> - <![CDATA[from com.redhat.rhn.domain.channel.ContentSource as c where c.id = :id]]> + <query name="ContentSource.findByIdandOrg"> + <![CDATA[from com.redhat.rhn.domain.channel.ContentSource as c where c.id = :id and c.org_id = :org]]> </query>
</hibernate-mapping> diff --git a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java index cbf48cb..8bccfab 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java @@ -42,8 +42,6 @@ import com.redhat.rhn.manager.channel.repo.CreateRepoCommand; * @version $Rev$ */ public class RepoDetailsAction extends RhnAction { - private static final Logger LOG = - Logger.getLogger(RepoDetailsAction.class); public static final String ORG = "org"; public static final String CREATE_MODE = "create_mode"; public static final String REPO = "repo"; diff --git a/java/code/src/com/redhat/rhn/manager/channel/repo/EditRepoCommand.java b/java/code/src/com/redhat/rhn/manager/channel/repo/EditRepoCommand.java new file mode 100644 index 0000000..fa65f94 --- /dev/null +++ b/java/code/src/com/redhat/rhn/manager/channel/repo/EditRepoCommand.java @@ -0,0 +1,31 @@ +/** + * 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.manager.channel.repo; + +import com.redhat.rhn.domain.channel.ChannelFactory; +import com.redhat.rhn.domain.user.User; + +/** + * CreateRepoCommand - Command to create a repo + * @version $Rev: 119601 $ + */ +public class EditRepoCommand extends BaseRepoCommand { + + public EditRepoCommand(User currentUser, Long repoId) { + super(); + this.repo = ChannelFactory.lookupContentSource(repoId, currentUser.getOrg()); + } + +}
commit 0c70cbe31713a986990acdeedbaf9746baa785dd Author: Shannon Hughes shughes@redhat.com Date: Tue May 25 16:43:07 2010 -0400
refactoring repo commands to use base class
diff --git a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java index 1cac277..cbf48cb 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java @@ -140,7 +140,9 @@ public class RepoDetailsAction extends RhnAction { String url = form.getString(URL); Org org = context.getLoggedInUser().getOrg();
- CreateRepoCommand repoCmd = new CreateRepoCommand(label, url, org); + CreateRepoCommand repoCmd = new CreateRepoCommand(org); + repoCmd.setLabel(label); + repoCmd.setUrl(url); repoCmd.store();
return repoCmd.getNewRepo(); 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 new file mode 100644 index 0000000..ed7e0dd --- /dev/null +++ b/java/code/src/com/redhat/rhn/manager/channel/repo/BaseRepoCommand.java @@ -0,0 +1,129 @@ +/** + * 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.manager.channel.repo; + +import java.util.ArrayList; +import java.util.List; + +import com.redhat.rhn.common.validator.ValidatorError; +import com.redhat.rhn.domain.channel.ChannelFactory; +import com.redhat.rhn.domain.channel.ContentSource; +import com.redhat.rhn.domain.org.Org; + +/** + * CreateRepoCommand - Command to create a repo + * @version $Rev: 119601 $ + */ +public class BaseRepoCommand { + + protected ContentSource repo; + + private String label; + private String url; + private Org org; + private List<ValidatorError> errors; + + /** + * Constructor + */ + BaseRepoCommand() { + } + + /** + * + * @return Org of repo + */ + public Org getOrg() { + return org; + } + + /** + * + * @param org to set for repo + */ + public void setOrg(Org org) { + this.org = org; + } + + /** + * + * @return label for repo + */ + public String getLabel() { + return label; + } + + /** + * + * @param labelIn to set for repo + */ + public void setLabel(String LabelIn) { + this.label = LabelIn; + } + + /** + * + * @return url for repo + */ + public String getUrl() { + return url; + } + + /** + * + * @param urlIn to set for repo + */ + public void setUrl(String urlIn) { + this.url = urlIn; + } + + /** + * Check for errors and store Org to db. + * @return ValidatorError[] array if there are errors + */ + public ValidatorError[] store() { + ValidatorError[] errors = validate(); + if (errors != null && errors.length > 0) { + return errors; + } + else { + // Create repo + repo.setLabel(this.label); + repo.setSourceUrl(this.url); + repo.setType(ChannelFactory.CONTENT_SOURCE_TYPE_YUM); + ChannelFactory.save(repo); + } + return null; + } + + /** + * Get the newly created org. + * @return Org that was stored to DB + */ + public ContentSource getNewRepo() { + return this.repo; + } + + /** + * Validates the repo object. + * @return an Object array of ValidatorErrors. + */ + public ValidatorError[] validate() { + errors = new ArrayList(); //clear validation errors + return (ValidatorError[]) errors.toArray(new ValidatorError[0]); + } + + +} diff --git a/java/code/src/com/redhat/rhn/manager/channel/repo/CreateRepoCommand.java b/java/code/src/com/redhat/rhn/manager/channel/repo/CreateRepoCommand.java index 6107bdb..e769d32 100644 --- a/java/code/src/com/redhat/rhn/manager/channel/repo/CreateRepoCommand.java +++ b/java/code/src/com/redhat/rhn/manager/channel/repo/CreateRepoCommand.java @@ -14,125 +14,19 @@ */ package com.redhat.rhn.manager.channel.repo;
-import java.util.ArrayList; -import java.util.List; - -import com.redhat.rhn.common.validator.ValidatorError; import com.redhat.rhn.domain.channel.ChannelFactory; -import com.redhat.rhn.domain.channel.ContentSource; import com.redhat.rhn.domain.org.Org;
/** * CreateRepoCommand - Command to create a repo * @version $Rev: 119601 $ */ -public class CreateRepoCommand { - - private String label; - private String url; - private Org org; - private ContentSource newRepo; - private List<ValidatorError> errors; - - /** - * Constructor to create an org - * @param nameIn to set on the org - * @param loginIn to use for 1st user in org - * @param passwordIn to set for first user - * @param emailIn to set for first user - */ - public CreateRepoCommand(String labelIn, String urlIn, Org orgIn) { - this.label = labelIn; - this.url = urlIn; - this.org = orgIn; - } - - /** - * - * @return Org of repo - */ - public Org getOrg() { - return org; - } - - /** - * - * @param org to set for repo - */ - public void setOrg(Org org) { - this.org = org; - } - - /** - * - * @return label for repo - */ - public String getLabel() { - return label; - } - - /** - * - * @param labelIn to set for repo - */ - public void setLabel(String LabelIn) { - this.label = LabelIn; - } - - /** - * - * @return url for repo - */ - public String getUrl() { - return url; - } - - /** - * - * @param urlIn to set for repo - */ - public void setUrl(String urlIn) { - this.url = urlIn; - } - - /** - * Check for errors and store Org to db. - * @return ValidatorError[] array if there are errors - */ - public ValidatorError[] store() { - ValidatorError[] errors = validate(); - if (errors != null && errors.length > 0) { - return errors; - } - else { - // Create repo - ContentSource repo = ChannelFactory.createRepo(); - repo.setLabel(this.label); - repo.setSourceUrl(this.url); - repo.setOrg(this.org); - repo.setType(ChannelFactory.CONTENT_SOURCE_TYPE_YUM); - ChannelFactory.save(repo); - this.newRepo = repo; - } - return null; - } - - /** - * Get the newly created org. - * @return Org that was stored to DB - */ - public ContentSource getNewRepo() { - return this.newRepo; - } - - /** - * Validates the repo object. - * @return an Object array of ValidatorErrors. - */ - public ValidatorError[] validate() { - errors = new ArrayList(); //clear validation errors - return (ValidatorError[]) errors.toArray(new ValidatorError[0]); - } +public class CreateRepoCommand extends BaseRepoCommand {
+ public CreateRepoCommand(Org orgIn) { + super(); + this.repo = ChannelFactory.createRepo(); + this.repo.setOrg(orgIn); + }
}
commit ab45f3f4bb167d4e33efa1f7c471da44ed03b153 Author: Shannon Hughes shughes@redhat.com Date: Tue May 25 12:39:53 2010 -0400
more repo content obj clean up
diff --git a/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java b/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java index c3ad546..c830212 100644 --- a/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java +++ b/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java @@ -14,7 +14,6 @@ */ package com.redhat.rhn.domain.channel;
-import java.util.Date; import java.util.HashSet; import java.util.Set;
diff --git a/java/code/src/com/redhat/rhn/manager/channel/repo/CreateRepoCommand.java b/java/code/src/com/redhat/rhn/manager/channel/repo/CreateRepoCommand.java index 8109cd0..6107bdb 100644 --- a/java/code/src/com/redhat/rhn/manager/channel/repo/CreateRepoCommand.java +++ b/java/code/src/com/redhat/rhn/manager/channel/repo/CreateRepoCommand.java @@ -17,8 +17,6 @@ package com.redhat.rhn.manager.channel.repo; import java.util.ArrayList; import java.util.List;
-import org.apache.log4j.Logger; - import com.redhat.rhn.common.validator.ValidatorError; import com.redhat.rhn.domain.channel.ChannelFactory; import com.redhat.rhn.domain.channel.ContentSource; @@ -36,8 +34,6 @@ public class CreateRepoCommand { private ContentSource newRepo; private List<ValidatorError> errors;
- private static Logger log = Logger.getLogger(CreateRepoCommand.class); - /** * Constructor to create an org * @param nameIn to set on the org
commit 2dd4fe3c777081d2ff3f06d9e136e0b3b4ee9182 Author: Shannon Hughes shughes@redhat.com Date: Tue May 25 12:14:22 2010 -0400
fix link for repo edit
diff --git a/java/code/webapp/WEB-INF/pages/channel/manage/repo/repos.jsp b/java/code/webapp/WEB-INF/pages/channel/manage/repo/repos.jsp index 751033a..46dba89 100644 --- a/java/code/webapp/WEB-INF/pages/channel/manage/repo/repos.jsp +++ b/java/code/webapp/WEB-INF/pages/channel/manage/repo/repos.jsp @@ -37,7 +37,7 @@ styleclass="first-column" sortattr= "label" filterattr="label"> - <c:out value="<a href="/rhn/channel/manage/RepoEdit.do?label=${current.label}">${current.label}</a>" escapeXml="false" /> + <c:out value="<a href="/rhn/channels/manage/repos/RepoEdit.do?id=${current.id}">${current.label}</a>" escapeXml="false" /> </rl:column> </rl:list> </rl:listset>
commit 6c0b63e264e21b62834f4a54fd6e92391ee67d33 Author: Shannon Hughes shughes@redhat.com Date: Tue May 25 11:58:40 2010 -0400
quick fix to remove sync query from content source obj
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 4203b74..971307e 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 @@ -1035,7 +1035,7 @@ SELECT CP.package_id, CP.name_id, CP.evr_id, CP.package_arch_id
<mode name="contentsrc_for_org" class="com.redhat.rhn.frontend.dto.ContentSourceDto"> <query params="org_id"> - SELECT CS.id, CS.label, CS.last_synced + SELECT CS.id, CS.label FROM rhnContentSource CS WHERE CS.org_id = :org_id </query>
commit 3ec2187899d31e940a71e1d818407a3f9953a3ae Author: Shannon Hughes shughes@redhat.com Date: Mon May 24 18:45:50 2010 -0400
update channel to handle sync date; remove from content source
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 024bdee..973cce0 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 @@ -28,7 +28,7 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" <property name="maintainerEmail" type="string" column="maint_email"/> <property name="maintainerPhone" type="string" column="maint_phone"/> <property name="supportPolicy" type="string" column="support_policy"/> - + <property name="lastSynced" type="timestamp" column="last_synced"/> <property name="created" column="created" type="timestamp" insert="false" update="false"/> <property name="modified" column="modified" type="timestamp" 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 d46cd1b..4fc77e9 100644 --- a/java/code/src/com/redhat/rhn/domain/channel/Channel.java +++ b/java/code/src/com/redhat/rhn/domain/channel/Channel.java @@ -70,6 +70,7 @@ public class Channel extends BaseDomainHelper implements Comparable { private Long id; private String label; private Date lastModified; + private Date lastSynced; private String name; private String access = PRIVATE; private Org org; @@ -302,6 +303,20 @@ public class Channel extends BaseDomainHelper implements Comparable { }
/** + * @return Returns the lastSynced. + */ + public Date getLastSynced() { + return lastSynced; + } + + /** + * @param lastSyncedIn The lastSynced to set. + */ + public void setLastSynced(Date lastSyncedIn) { + this.lastSynced = lastSyncedIn; + } + + /** * @return Returns the name. */ public String getName() { 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 3ef4620..b8e56b6 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 @@ -14,7 +14,6 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" </id>
<property name="sourceUrl" type="string" column="source_url"/> - <property name="lastSynced" type="timestamp" column="last_synced"/> <property name="created" type="timestamp" column="created" insert="false" update="false" /> <property name="modified" type="timestamp" column="modified" insert="false" update="false" /> <property name="label" type="string" column="label"/> diff --git a/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java b/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java index 45fca49..c3ad546 100644 --- a/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java +++ b/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java @@ -31,7 +31,6 @@ public class ContentSource extends BaseDomainHelper { private Org org; private ContentSourceType type; private String sourceUrl; - private Date lastSynced; private String label; private Set<Channel> channels = new HashSet<Channel>(); /** @@ -112,21 +111,6 @@ public class ContentSource extends BaseDomainHelper { }
/** - * @return Returns the lastSynced. - */ - public Date getLastSynced() { - return lastSynced; - } - - - /** - * @param lastSyncedIn The lastSynced to set. - */ - public void setLastSynced(Date lastSyncedIn) { - this.lastSynced = lastSyncedIn; - } - - /** * * @param set of channels this repo is pushed to */ 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 4c928e4..e503aea 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 @@ -604,9 +604,9 @@ public class EditChannelAction extends RhnAction implements Listable { form.set("repo_label", cs.getLabel()); String lastSync = LocalizationService.getInstance().getMessage( "channel.edit.repo.neversynced"); - if (cs.getLastSynced() != null) { + if (c.getLastSynced() != null) { lastSync = LocalizationService.getInstance().formatDate( - cs.getLastSynced()); + c.getLastSynced()); } request.setAttribute("last_sync", lastSync); if (ChannelManager.getLatestSyncLogFile(cs,c) != null) { diff --git a/java/code/src/com/redhat/rhn/frontend/dto/ContentSourceDto.java b/java/code/src/com/redhat/rhn/frontend/dto/ContentSourceDto.java index fb52f73..7653c8c 100644 --- a/java/code/src/com/redhat/rhn/frontend/dto/ContentSourceDto.java +++ b/java/code/src/com/redhat/rhn/frontend/dto/ContentSourceDto.java @@ -14,8 +14,6 @@ */ package com.redhat.rhn.frontend.dto;
-import java.util.Date; -
/** * ContentSourceDto @@ -25,23 +23,6 @@ public class ContentSourceDto extends BaseDto {
private Long id; private String label; - private Date lastSynced; - - /** - * - * @return laste date repo was synced - */ - public Date getLastSynced() { - return lastSynced; - } - - /** - * - * @param lastSyncedIn date to set of last sync - */ - public void setLastSynced(Date lastSyncedIn) { - this.lastSynced = lastSyncedIn; - }
/** * {@inheritDoc} diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ChannelSerializer.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ChannelSerializer.java index 36bab29..71ae913 100644 --- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ChannelSerializer.java +++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ChannelSerializer.java @@ -104,8 +104,8 @@ public class ChannelSerializer implements XmlRpcCustomSerializer { ContentSource cs = c.getSources().iterator().next(); helper.add("yumrepo_source_url", cs.getSourceUrl()); helper.add("yumrepo_label", cs.getLabel()); - if (cs.getLastSynced() != null) { - helper.add("yumrepo_last_sync", cs.getLastSynced()); + if (c.getLastSynced() != null) { + helper.add("yumrepo_last_sync", c.getLastSynced()); } else { helper.add("yumrepo_last_sync", ""); diff --git a/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java b/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java index ce11bff..f5e621c 100644 --- a/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java +++ b/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java @@ -86,7 +86,7 @@ public class RepoSyncTask implements Job { try { Process p = Runtime.getRuntime().exec( getSyncCommand(src,c).toArray(new String[0])); - src.setLastSynced(new Date()); + c.setLastSynced(new Date()); int chr = p.getInputStream().read(); while (chr != -1) { chr = p.getInputStream().read(); diff --git a/java/code/webapp/WEB-INF/pages/channel/manage/repo/repos.jsp b/java/code/webapp/WEB-INF/pages/channel/manage/repo/repos.jsp index 46d5c4e..751033a 100644 --- a/java/code/webapp/WEB-INF/pages/channel/manage/repo/repos.jsp +++ b/java/code/webapp/WEB-INF/pages/channel/manage/repo/repos.jsp @@ -39,9 +39,6 @@ filterattr="label"> <c:out value="<a href="/rhn/channel/manage/RepoEdit.do?label=${current.label}">${current.label}</a>" escapeXml="false" /> </rl:column> - <rl:column headerkey="repos.jsp.lastsync" styleclass="last-column"> - <c:out value="${current.lastSynced}"/> - </rl:column> </rl:list> </rl:listset>
commit f1caf31403e5c47495644778bc2a597744bb0f2e Author: Shannon Hughes shughes@redhat.com Date: Mon May 24 17:51:14 2010 -0400
migrate sync date from repo content source to the channel table
diff --git a/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/001-repo-sync.sql b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/001-repo-sync.sql index 496e446..8a3304d 100644 --- a/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/001-repo-sync.sql +++ b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/001-repo-sync.sql @@ -33,22 +33,33 @@ ALTER TABLE rhnContentSource ADD org_id number CONSTRAINT rhn_cs_org_fk REFERENCES WEB_CUSTOMER(id); +-- add sync column to rhnChannel +ALTER TABLE rhnChannel + ADD last_synced date;
DECLARE -- grab any rows that need the channel to be migrated to new channel content mapping tbl CURSOR content is - select cs.id, cs.channel_id, c.org_id + select cs.id, cs.channel_id, cs.last_synced, c.org_id from rhnContentSource cs, rhnChannel c where 1=1 AND c.id = cs.channel_id BEGIN FOR content_rec IN content LOOP + -- add mapping INSERT INTO rhnChannelContentSource (source_id, channel_id) VALUES (content_rec.id, content_rec.channel_id); + + -- save org id UPDATE rhnConentSource set org_id = content_rec.org_id WHERE 1=1 AND channel_id = content_rec.channel_id; + + -- migrate sync date to channel + UPDATE rhnChannel set last_synced = content_rec.last_synced + WHERE id = content_rec.channel_id; + END LOOP; commit; END; @@ -56,3 +67,4 @@ END;
-- we don't need the channel_id column anymore since mapping table will handle it ALTER TABLE rhnContentSource DROP (channel_id); +ALTER TABLE rhnContentSource DROP (last_synced);
commit cf58bd62ac51cac8fd070dd2d6956dd7269f2d23 Author: Shannon Hughes shughes@redhat.com Date: Mon May 24 17:41:39 2010 -0400
fix incorrect reference to sync column of content source
diff --git a/java/code/webapp/WEB-INF/pages/channel/manage/repo/repos.jsp b/java/code/webapp/WEB-INF/pages/channel/manage/repo/repos.jsp index 53451c6..46d5c4e 100644 --- a/java/code/webapp/WEB-INF/pages/channel/manage/repo/repos.jsp +++ b/java/code/webapp/WEB-INF/pages/channel/manage/repo/repos.jsp @@ -40,7 +40,7 @@ <c:out value="<a href="/rhn/channel/manage/RepoEdit.do?label=${current.label}">${current.label}</a>" escapeXml="false" /> </rl:column> <rl:column headerkey="repos.jsp.lastsync" styleclass="last-column"> - <c:out value="${current.sync}"/> + <c:out value="${current.lastSynced}"/> </rl:column> </rl:list> </rl:listset>
commit 71473f16a8f80fe2fc2dc7330827ba442749c283 Author: Shannon Hughes shughes@redhat.com Date: Mon May 24 17:19:10 2010 -0400
adding org id mapping to content source objects
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 d39416e..3ef4620 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 @@ -19,7 +19,10 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" <property name="modified" type="timestamp" column="modified" insert="false" update="false" /> <property name="label" type="string" column="label"/>
- + <many-to-one name="org" + column="org_id" + class="com.redhat.rhn.domain.org.OrgImpl" + not-null="true" /> <many-to-one name="type" class="com.redhat.rhn.domain.channel.ContentSourceType"
commit a8e2bffc3fb4fc8b7d7cbbc96f376c00c73cb788 Author: Shannon Hughes shughes@redhat.com Date: Mon May 24 17:02:12 2010 -0400
ise fixes for repo create
diff --git a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java index b87a5e9..1cac277 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java @@ -49,7 +49,7 @@ public class RepoDetailsAction extends RhnAction { public static final String REPO = "repo"; public static final String URL = "url"; public static final String LABEL = "label"; - public static final String OLD_LABEL = "old_label"; + public static final String OLD_LABEL = "oldLabel";
private static final String VALIDATION_XSD = "/com/redhat/rhn/frontend/action/channel/" + @@ -79,11 +79,11 @@ public class RepoDetailsAction extends RhnAction { ContentSource repo = submit(request, form); if (isCreateMode(request)) { createSuccessMessage(request, - "repo.create.success", repo.getLabel()); + "repos.jsp.create.success", repo.getLabel()); } else { createSuccessMessage(request, - "repo.update.success", repo.getLabel()); + "repos.jsp.update.success", repo.getLabel()); }
request.removeAttribute(CREATE_MODE); 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 0da3885..1a998c5 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 @@ -9375,9 +9375,6 @@ Please note that some manual configuration of these scripts may still be require </group>
<!-- Repo Sync --> - <trans-unit id="repos.jsp.toolbar"> - <source>Repository</source> - </trans-unit> <trans-unit id="repos.jsp.summary"> <source>Summary for repos here</source> </trans-unit> @@ -9405,9 +9402,6 @@ Please note that some manual configuration of these scripts may still be require <trans-unit id="repos.jsp.header2"> <source>Create Repository</source> </trans-unit> - <trans-unit id="repos.jsp.header2"> - <source>Create Repository</source> - </trans-unit> <trans-unit id="repos.jsp.create.label"> <source>Repository Label</source> </trans-unit> @@ -9420,6 +9414,9 @@ Please note that some manual configuration of these scripts may still be require <trans-unit id="repos.jsp.update.submit"> <source>Create Repository</source> </trans-unit> + <trans-unit id="repos.jsp.create.success"> + <source>Repository created successfully</source> + </trans-unit>
<!-- TNC --> diff --git a/java/code/src/com/redhat/rhn/manager/channel/repo/CreateRepoCommand.java b/java/code/src/com/redhat/rhn/manager/channel/repo/CreateRepoCommand.java index a4d9b5e..8109cd0 100644 --- a/java/code/src/com/redhat/rhn/manager/channel/repo/CreateRepoCommand.java +++ b/java/code/src/com/redhat/rhn/manager/channel/repo/CreateRepoCommand.java @@ -114,6 +114,7 @@ public class CreateRepoCommand { repo.setLabel(this.label); repo.setSourceUrl(this.url); repo.setOrg(this.org); + repo.setType(ChannelFactory.CONTENT_SOURCE_TYPE_YUM); ChannelFactory.save(repo); this.newRepo = repo; } diff --git a/java/code/webapp/WEB-INF/struts-config.xml b/java/code/webapp/WEB-INF/struts-config.xml index f32f476..6b61400 100644 --- a/java/code/webapp/WEB-INF/struts-config.xml +++ b/java/code/webapp/WEB-INF/struts-config.xml @@ -821,6 +821,7 @@ <form-bean name="contentSourceForm" type="com.redhat.rhn.frontend.struts.ScrubbingDynaActionForm"> <form-property name="url" type="java.lang.String"/> + <form-property name="oldLabel" type="java.lang.String" /> <form-property name="label" type="java.lang.String"/> </form-bean>
@@ -6634,11 +6635,10 @@ parameter="create_mode" type="com.redhat.rhn.frontend.action.channel.manage.repo.RepoDetailsAction" className="com.redhat.rhn.frontend.struts.RhnActionMapping"> - <set-property property="acls" value="org_entitlement(rhn_provisioning); user_role(config_admin)"/> <forward name="default" path="/WEB-INF/pages/channel/manage/repo/repodetails.jsp"/> <forward name="success" - path="/channels/manage/repo/RepoEdit.do" redirect = "true" + path="/channels/manage/repos/RepoEdit.do" redirect = "true" /> </action>
@@ -6648,7 +6648,6 @@ parameter="edit_mode" type="com.redhat.rhn.frontend.action.channel.manage.repo.RepoDetailsAction" className="com.redhat.rhn.frontend.struts.RhnActionMapping"> - <set-property property="acls" value="org_entitlement(rhn_provisioning); user_role(config_admin)"/> <forward name="default" path="/WEB-INF/pages/channel/manage/repo/repodetails.jsp"/> <forward name="success"
commit 3d7ed2e31bcbf3209cd1f5089764e655be4baea8 Author: Shannon Hughes shughes@redhat.com Date: Mon May 24 16:09:50 2010 -0400
adding url field to repo details form/jsp
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 26f99a9..0da3885 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 @@ -9414,6 +9414,12 @@ Please note that some manual configuration of these scripts may still be require <trans-unit id="repos.jsp.create.url"> <source>Repository URL</source> </trans-unit> + <trans-unit id="repos.jsp.create.submit"> + <source>Create Repository</source> + </trans-unit> + <trans-unit id="repos.jsp.update.submit"> + <source>Create Repository</source> + </trans-unit>
<!-- TNC --> diff --git a/java/code/webapp/WEB-INF/pages/channel/manage/repo/repodetails.jsp b/java/code/webapp/WEB-INF/pages/channel/manage/repo/repodetails.jsp index 1f8b685..1f81305 100644 --- a/java/code/webapp/WEB-INF/pages/channel/manage/repo/repodetails.jsp +++ b/java/code/webapp/WEB-INF/pages/channel/manage/repo/repodetails.jsp @@ -49,6 +49,15 @@ </c:if> </td> </tr> + <tr> + <th> + <rhn:required-field key = "repos.jsp.create.url"/> + </th> + <td> + <html:text property="url"/> + </td> + </tr> + </table>
<hr /> @@ -58,10 +67,10 @@ <td></td> <c:choose> <c:when test = "${empty requestScope.create_mode}"> - <td align="right">html:submit<bean:message key="snippetupdate.jsp.submit"/></html:submit></td> + <td align="right">html:submit<bean:message key="repos.jsp.update.submit"/></html:submit></td> </c:when> <c:otherwise> - <td align="right">html:submit<bean:message key="snippetcreate.jsp.submit"/></html:submit></td> + <td align="right">html:submit<bean:message key="repos.jsp.create.submit"/></html:submit></td> </c:otherwise> </c:choose> </tr>
commit d9e77292cd65a04d9254e86a0a864a11445830d6 Author: Shannon Hughes shughes@redhat.com Date: Mon May 24 10:20:22 2010 -0400
pushing changes to prepare for master merge
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 1936881..26f99a9 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 @@ -9399,6 +9399,22 @@ Please note that some manual configuration of these scripts may still be require <context context-type="sourcefile">/rhn/channel/manage/repo/RepoList.do</context> </context-group> </trans-unit> + <trans-unit id="repos.jsp.toolbar"> + <source>Create New Repository</source> + </trans-unit> + <trans-unit id="repos.jsp.header2"> + <source>Create Repository</source> + </trans-unit> + <trans-unit id="repos.jsp.header2"> + <source>Create Repository</source> + </trans-unit> + <trans-unit id="repos.jsp.create.label"> + <source>Repository Label</source> + </trans-unit> + <trans-unit id="repos.jsp.create.url"> + <source>Repository URL</source> + </trans-unit> +
<!-- TNC --> <trans-unit id="tnc.jsp.tnc"> diff --git a/java/code/webapp/WEB-INF/pages/channel/manage/repo/repodetails.jsp b/java/code/webapp/WEB-INF/pages/channel/manage/repo/repodetails.jsp index 5adc68d..1f8b685 100644 --- a/java/code/webapp/WEB-INF/pages/channel/manage/repo/repodetails.jsp +++ b/java/code/webapp/WEB-INF/pages/channel/manage/repo/repodetails.jsp @@ -3,22 +3,18 @@ <%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %> <%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
-<head> -<%@ include file="/WEB-INF/pages/common/fragments/editarea.jspf" %> -</head> - <html:html xhtml="true"> <body> <c:choose> <c:when test = "${not empty requestScope.create_mode}"> <rhn:toolbar base="h1" img="/img/rhn-icon-info.gif" imgAlt="info.alt.img"> - <bean:message key="snippetcreate.jsp.toolbar"/> + <bean:message key="repos.jsp.toolbar"/> </rhn:toolbar> -<h2><bean:message key="snippetcreate.jsp.header2"/></h2> +<h2><bean:message key="repos.jsp.header2"/></h2> </c:when> <c:otherwise> <rhn:toolbar base="h1" img="/img/rhn-icon-info.gif" imgAlt="info.alt.img" - deletionUrl="CobblerSnippetDelete.do?name=${cobblerSnippetsForm.map.name}" + deletionUrl="RepoDelete.do?label=${contentSourceForm.map.label}" deletionType="snippets"> <c:out value="${requestScope.snippet.displayName}"/> </rhn:toolbar> @@ -29,10 +25,10 @@
<c:choose> <c:when test="${empty requestScope.create_mode}"> - <c:set var="url" value ="/kickstart/cobbler/CobblerSnippetEdit"/> + <c:set var="url" value ="/channels/manage/repos/RepoEdit"/> </c:when> <c:otherwise> - <c:set var="url" value ="/kickstart/cobbler/CobblerSnippetCreate"/> + <c:set var="url" value ="/channels/manage/repos/RepoCreate"/> </c:otherwise> </c:choose>
@@ -43,58 +39,15 @@ <table class="details"> <tr> <th> - <rhn:required-field key = "cobbler.snippet.name"/> + <rhn:required-field key = "repos.jsp.create.label"/> </th> <td> - <html:text property="name"/> - <rhn:tooltip key="snippetcreate.jsp.tip1"/> + <html:text property="label"/> + <c:if test = "${empty requestScope.create_mode}"> - <rhn:warning key="snippetcreate.jsp.warning.tip"/> - <html:hidden property="oldName"/> + <html:hidden property="oldLabel"/> </c:if> </td> - </tr> - <c:if test = "${empty requestScope.create_mode}"> - <tr> - <th> - <bean:message key="cobbler.snippet.path"/>: - </th> - <td> - <c:out value="${requestScope.snippet.displayPath}"/><br/> - <rhn:tooltip key="cobbler.snippet.path.tip"/> - </td> - </tr> - <tr> - <th> - <bean:message key="cobbler.snippet.macro"/>: - </th> - <td> - <p><c:out value="${requestScope.snippet.fragment}"/></p> - <rhn:tooltip key="cobbler.snippet.copy-paste-snippet-tip"/> - </td> - </tr> - </c:if> - <tr> - <th> - <bean:message key="cobbler.snippet.type"/>: - </th> - <td> - <bean:message key="Custom"/><br/> - rhn:tooltip<bean:message key="cobbler.snippet.custom.tip" - arg0="${requestScope.org}"/></rhn:tooltip> - </td> - </tr> - </table> - <h2><bean:message key="snippetcreate.jsp.contents.header"/></h2> - - <table class="details"> - <tr> - <th> - <rhn:required-field key="snippetcreate.jsp.contents"/> - </th> - <td> - <html:textarea property="contents" rows="24" cols="80" styleId="contents"/> - </td> </tr> </table>
commit 57442b465047cb6b0b8cd23c4905502cbff7ddce Author: Shannon Hughes shughes@redhat.com Date: Wed May 19 15:13:29 2010 -0400
fixed incorrect url syntax for repocreate
diff --git a/java/code/webapp/WEB-INF/struts-config.xml b/java/code/webapp/WEB-INF/struts-config.xml index 146d05d..f32f476 100644 --- a/java/code/webapp/WEB-INF/struts-config.xml +++ b/java/code/webapp/WEB-INF/struts-config.xml @@ -6636,7 +6636,7 @@ className="com.redhat.rhn.frontend.struts.RhnActionMapping"> <set-property property="acls" value="org_entitlement(rhn_provisioning); user_role(config_admin)"/> <forward name="default" - path="/WEB-INF/pages/channel/repo/repodetails.jsp"/> + path="/WEB-INF/pages/channel/manage/repo/repodetails.jsp"/> <forward name="success" path="/channels/manage/repo/RepoEdit.do" redirect = "true" /> @@ -6650,7 +6650,7 @@ className="com.redhat.rhn.frontend.struts.RhnActionMapping"> <set-property property="acls" value="org_entitlement(rhn_provisioning); user_role(config_admin)"/> <forward name="default" - path="/WEB-INF/pages/channel/repo/repodetails.jsp"/> + path="/WEB-INF/pages/channel/manage/repo/repodetails.jsp"/> <forward name="success" path="/channels/manage/repo/RepoEdit.do" redirect = "true"/> </action>
commit 5c8c606fce23ff5d2dfbbdbc77f649a4309e9967 Author: Shannon Hughes shughes@redhat.com Date: Wed May 19 14:36:09 2010 -0400
adding repo domain creation logic to manager/action layer
diff --git a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java index fe903b3..b87a5e9 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java @@ -29,10 +29,12 @@ import org.apache.struts.action.DynaActionForm; import com.redhat.rhn.common.validator.ValidatorException; import com.redhat.rhn.common.validator.ValidatorResult; import com.redhat.rhn.domain.channel.ContentSource; +import com.redhat.rhn.domain.org.Org; import com.redhat.rhn.frontend.struts.RequestContext; import com.redhat.rhn.frontend.struts.RhnAction; import com.redhat.rhn.frontend.struts.RhnHelper; import com.redhat.rhn.frontend.struts.RhnValidationHelper; +import com.redhat.rhn.manager.channel.repo.CreateRepoCommand;
/** @@ -133,21 +135,14 @@ public class RepoDetailsAction extends RhnAction { private ContentSource submit(HttpServletRequest request, DynaActionForm form) { RequestContext context = new RequestContext(request);
- String label = isCreateMode(request) ? form.getString(LABEL) : form.getString(OLD_LABEL); + String url = form.getString(URL); + Org org = context.getLoggedInUser().getOrg();
- /* - CobblerSnippet snip = CobblerSnippet.createOrUpdate( - isCreateMode(request), - name, - form.getString(CONTENTS), - context.getLoggedInUser().getOrg()); - if (!isCreateMode(request) && - !form.getString(NAME).equals(form.getString(OLD_NAME))) { - snip.rename(form.getString(NAME)); - } - */ - return null; + CreateRepoCommand repoCmd = new CreateRepoCommand(label, url, org); + repoCmd.store(); + + return repoCmd.getNewRepo(); } } diff --git a/java/code/src/com/redhat/rhn/manager/channel/repo/CreateRepoCommand.java b/java/code/src/com/redhat/rhn/manager/channel/repo/CreateRepoCommand.java index a54e4ed..a4d9b5e 100644 --- a/java/code/src/com/redhat/rhn/manager/channel/repo/CreateRepoCommand.java +++ b/java/code/src/com/redhat/rhn/manager/channel/repo/CreateRepoCommand.java @@ -22,6 +22,7 @@ import org.apache.log4j.Logger; import com.redhat.rhn.common.validator.ValidatorError; import com.redhat.rhn.domain.channel.ChannelFactory; import com.redhat.rhn.domain.channel.ContentSource; +import com.redhat.rhn.domain.org.Org;
/** * CreateRepoCommand - Command to create a repo @@ -31,6 +32,7 @@ public class CreateRepoCommand {
private String label; private String url; + private Org org; private ContentSource newRepo; private List<ValidatorError> errors;
@@ -43,9 +45,26 @@ public class CreateRepoCommand { * @param passwordIn to set for first user * @param emailIn to set for first user */ - public CreateRepoCommand(String labelIn, String urlIn) { + public CreateRepoCommand(String labelIn, String urlIn, Org orgIn) { this.label = labelIn; this.url = urlIn; + this.org = orgIn; + } + + /** + * + * @return Org of repo + */ + public Org getOrg() { + return org; + } + + /** + * + * @param org to set for repo + */ + public void setOrg(Org org) { + this.org = org; }
/** @@ -94,6 +113,7 @@ public class CreateRepoCommand { ContentSource repo = ChannelFactory.createRepo(); repo.setLabel(this.label); repo.setSourceUrl(this.url); + repo.setOrg(this.org); ChannelFactory.save(repo); this.newRepo = repo; }
commit 636f7ed021bbfe8222b69aaef494f84ab1c40915 Author: Shannon Hughes shughes@redhat.com Date: Wed May 19 11:21:55 2010 -0400
pushing minor changes before master merge
diff --git a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java index eca62d5..fe903b3 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java @@ -29,8 +29,6 @@ import org.apache.struts.action.DynaActionForm; import com.redhat.rhn.common.validator.ValidatorException; import com.redhat.rhn.common.validator.ValidatorResult; import com.redhat.rhn.domain.channel.ContentSource; -import com.redhat.rhn.domain.kickstart.cobbler.CobblerSnippet; -import com.redhat.rhn.frontend.action.common.BadParameterException; import com.redhat.rhn.frontend.struts.RequestContext; import com.redhat.rhn.frontend.struts.RhnAction; import com.redhat.rhn.frontend.struts.RhnHelper; @@ -113,43 +111,6 @@ public class RepoDetailsAction extends RhnAction { }
- /** - * Helper method to get a cobbler snippet.. This code is in this - * action because we need it to throw a "BadParameterException" - * if the set up complains... Also it gets info from the request object - * so this is the right place... - * @param request the request - * @param lookupParam the parameter to which the snippet name is bound.. - * @return the cobbler snippet parameter "name" - */ - private static CobblerSnippet loadEditableSnippet(HttpServletRequest request, - String lookupParam) { - RequestContext context = new RequestContext(request); - try { - String name = context.getParam(lookupParam, true); - return CobblerSnippet.loadEditable(name, - context.getLoggedInUser().getOrg()); - } - catch (ValidatorException ve) { - LOG.error(ve); - throw new BadParameterException( - "The parameter " + LABEL + " is required."); - } - } - - - /** - * Helper method to get a cobbler snippet.. This code is in this - * action because we need it to throw a "BadParameterException" - * if the set up complains... Also it gets info from the request object - * so this is the right place... - * @param request the request - * @return the cobbler snippet parameter "name" - */ - static CobblerSnippet loadEditableRepo(HttpServletRequest request) { - return loadEditableSnippet(request, LABEL); - } - private void setupRepo(HttpServletRequest request, DynaActionForm form, ContentSource repo) {
@@ -161,7 +122,7 @@ public class RepoDetailsAction extends RhnAction { }
/** - * Method to bind the cobbler snippet to a request + * Method to bind the repo to a request * @param request the servlet request * @param snip the snippet to bind */ @@ -171,6 +132,8 @@ public class RepoDetailsAction extends RhnAction {
private ContentSource submit(HttpServletRequest request, DynaActionForm form) { RequestContext context = new RequestContext(request); + + String label = isCreateMode(request) ? form.getString(LABEL) : form.getString(OLD_LABEL);
commit ec1bb7cdf90231465a11ac73a9ed43a3047d1a12 Author: Shannon Hughes shughes@redhat.com Date: Tue May 18 15:52:10 2010 -0400
repo struts action fnd jsp or creating repo objects.
diff --git a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java new file mode 100644 index 0000000..eca62d5 --- /dev/null +++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoDetailsAction.java @@ -0,0 +1,190 @@ +/** + * 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.action.channel.manage.repo; + +import java.util.HashMap; +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.log4j.Logger; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.action.DynaActionForm; + +import com.redhat.rhn.common.validator.ValidatorException; +import com.redhat.rhn.common.validator.ValidatorResult; +import com.redhat.rhn.domain.channel.ContentSource; +import com.redhat.rhn.domain.kickstart.cobbler.CobblerSnippet; +import com.redhat.rhn.frontend.action.common.BadParameterException; +import com.redhat.rhn.frontend.struts.RequestContext; +import com.redhat.rhn.frontend.struts.RhnAction; +import com.redhat.rhn.frontend.struts.RhnHelper; +import com.redhat.rhn.frontend.struts.RhnValidationHelper; + + +/** + * CobblerSnippetDetailsAction + * @version $Rev$ + */ +public class RepoDetailsAction extends RhnAction { + private static final Logger LOG = + Logger.getLogger(RepoDetailsAction.class); + public static final String ORG = "org"; + public static final String CREATE_MODE = "create_mode"; + public static final String REPO = "repo"; + public static final String URL = "url"; + public static final String LABEL = "label"; + public static final String OLD_LABEL = "old_label"; + + private static final String VALIDATION_XSD = + "/com/redhat/rhn/frontend/action/channel/" + + "manage/repo/validation/repoForm.xsd"; + /** {@inheritDoc} */ + public ActionForward execute(ActionMapping mapping, + ActionForm formIn, + HttpServletRequest request, + HttpServletResponse response) { + DynaActionForm form = (DynaActionForm) formIn; + RequestContext ctx = new RequestContext(request); + + request.setAttribute(mapping.getParameter(), Boolean.TRUE); + + if (ctx.isSubmitted()) { + + + ValidatorResult result = RhnValidationHelper.validate(this.getClass(), + makeValidationMap(form), null, + VALIDATION_XSD); + if (!result.isEmpty()) { + getStrutsDelegate().saveMessages(request, result); + RhnValidationHelper.setFailedValidation(request); + } + else { + try { + ContentSource repo = submit(request, form); + if (isCreateMode(request)) { + createSuccessMessage(request, + "repo.create.success", repo.getLabel()); + } + else { + createSuccessMessage(request, + "repo.update.success", repo.getLabel()); + } + + request.removeAttribute(CREATE_MODE); + setupRepo(request, form, repo); + return getStrutsDelegate().forwardParam(mapping.findForward("success"), + LABEL, repo.getLabel()); + } + catch (ValidatorException ve) { + getStrutsDelegate().saveMessages(request, ve.getResult()); + RhnValidationHelper.setFailedValidation(request); + } + } + } + + return mapping.findForward(RhnHelper.DEFAULT_FORWARD); + } + + private Map<String,String> makeValidationMap(DynaActionForm form) { + Map<String,String> map = new HashMap<String,String>(); + map.put(LABEL, form.getString(LABEL)); + map.put(URL, form.getString(URL)); + return map; + } + + private boolean isCreateMode(HttpServletRequest request) { + return Boolean.TRUE.equals(request.getAttribute(CREATE_MODE)); + } + + + /** + * Helper method to get a cobbler snippet.. This code is in this + * action because we need it to throw a "BadParameterException" + * if the set up complains... Also it gets info from the request object + * so this is the right place... + * @param request the request + * @param lookupParam the parameter to which the snippet name is bound.. + * @return the cobbler snippet parameter "name" + */ + private static CobblerSnippet loadEditableSnippet(HttpServletRequest request, + String lookupParam) { + RequestContext context = new RequestContext(request); + try { + String name = context.getParam(lookupParam, true); + return CobblerSnippet.loadEditable(name, + context.getLoggedInUser().getOrg()); + } + catch (ValidatorException ve) { + LOG.error(ve); + throw new BadParameterException( + "The parameter " + LABEL + " is required."); + } + } + + + /** + * Helper method to get a cobbler snippet.. This code is in this + * action because we need it to throw a "BadParameterException" + * if the set up complains... Also it gets info from the request object + * so this is the right place... + * @param request the request + * @return the cobbler snippet parameter "name" + */ + static CobblerSnippet loadEditableRepo(HttpServletRequest request) { + return loadEditableSnippet(request, LABEL); + } + + private void setupRepo(HttpServletRequest request, DynaActionForm form, + ContentSource repo) { + + form.set(LABEL, repo.getLabel()); + form.set(OLD_LABEL, repo.getLabel()); + form.set(URL, repo.getSourceUrl()); + bindRepo(request, repo); + request.setAttribute(ORG, repo.getOrg()); + } + + /** + * Method to bind the cobbler snippet to a request + * @param request the servlet request + * @param snip the snippet to bind + */ + public static void bindRepo(HttpServletRequest request, ContentSource repo) { + request.setAttribute(REPO, repo); + } + + private ContentSource submit(HttpServletRequest request, DynaActionForm form) { + RequestContext context = new RequestContext(request); + String label = isCreateMode(request) ? + form.getString(LABEL) : form.getString(OLD_LABEL); + + /* + CobblerSnippet snip = CobblerSnippet.createOrUpdate( + isCreateMode(request), + name, + form.getString(CONTENTS), + context.getLoggedInUser().getOrg()); + if (!isCreateMode(request) && + !form.getString(NAME).equals(form.getString(OLD_NAME))) { + snip.rename(form.getString(NAME)); + } + */ + return null; + } +} diff --git a/java/code/webapp/WEB-INF/pages/channel/manage/repo/repodetails.jsp b/java/code/webapp/WEB-INF/pages/channel/manage/repo/repodetails.jsp new file mode 100644 index 0000000..5adc68d --- /dev/null +++ b/java/code/webapp/WEB-INF/pages/channel/manage/repo/repodetails.jsp @@ -0,0 +1,121 @@ +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="http://rhn.redhat.com/rhn" prefix="rhn" %> +<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %> +<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %> + +<head> +<%@ include file="/WEB-INF/pages/common/fragments/editarea.jspf" %> +</head> + +<html:html xhtml="true"> +<body> +<c:choose> + <c:when test = "${not empty requestScope.create_mode}"> +<rhn:toolbar base="h1" img="/img/rhn-icon-info.gif" imgAlt="info.alt.img"> + <bean:message key="snippetcreate.jsp.toolbar"/> +</rhn:toolbar> +<h2><bean:message key="snippetcreate.jsp.header2"/></h2> + </c:when> + <c:otherwise> +<rhn:toolbar base="h1" img="/img/rhn-icon-info.gif" imgAlt="info.alt.img" + deletionUrl="CobblerSnippetDelete.do?name=${cobblerSnippetsForm.map.name}" + deletionType="snippets"> + <c:out value="${requestScope.snippet.displayName}"/> +</rhn:toolbar> +<h2><bean:message key="snippetdetails.jsp.header2"/></h2> + </c:otherwise> +</c:choose> + + +<c:choose> + <c:when test="${empty requestScope.create_mode}"> + <c:set var="url" value ="/kickstart/cobbler/CobblerSnippetEdit"/> + </c:when> + <c:otherwise> + <c:set var="url" value ="/kickstart/cobbler/CobblerSnippetCreate"/> + </c:otherwise> +</c:choose> + + +<div> + <html:form action="${url}"> + rhn:submitted/ + <table class="details"> + <tr> + <th> + <rhn:required-field key = "cobbler.snippet.name"/> + </th> + <td> + <html:text property="name"/> + <rhn:tooltip key="snippetcreate.jsp.tip1"/> + <c:if test = "${empty requestScope.create_mode}"> + <rhn:warning key="snippetcreate.jsp.warning.tip"/> + <html:hidden property="oldName"/> + </c:if> + </td> + </tr> + <c:if test = "${empty requestScope.create_mode}"> + <tr> + <th> + <bean:message key="cobbler.snippet.path"/>: + </th> + <td> + <c:out value="${requestScope.snippet.displayPath}"/><br/> + <rhn:tooltip key="cobbler.snippet.path.tip"/> + </td> + </tr> + <tr> + <th> + <bean:message key="cobbler.snippet.macro"/>: + </th> + <td> + <p><c:out value="${requestScope.snippet.fragment}"/></p> + <rhn:tooltip key="cobbler.snippet.copy-paste-snippet-tip"/> + </td> + </tr> + </c:if> + <tr> + <th> + <bean:message key="cobbler.snippet.type"/>: + </th> + <td> + <bean:message key="Custom"/><br/> + rhn:tooltip<bean:message key="cobbler.snippet.custom.tip" + arg0="${requestScope.org}"/></rhn:tooltip> + </td> + </tr> + </table> + <h2><bean:message key="snippetcreate.jsp.contents.header"/></h2> + + <table class="details"> + <tr> + <th> + <rhn:required-field key="snippetcreate.jsp.contents"/> + </th> + <td> + <html:textarea property="contents" rows="24" cols="80" styleId="contents"/> + </td> + </tr> + </table> + + <hr /> + + <table align="right"> + <tr> + <td></td> + <c:choose> + <c:when test = "${empty requestScope.create_mode}"> + <td align="right">html:submit<bean:message key="snippetupdate.jsp.submit"/></html:submit></td> + </c:when> + <c:otherwise> + <td align="right">html:submit<bean:message key="snippetcreate.jsp.submit"/></html:submit></td> + </c:otherwise> + </c:choose> + </tr> + </table> + + </html:form> +</div> + +</body> +</html:html>
commit d1d911c86ef4dadfb55f69f7f0c15f3c05cf98ca Author: Shannon Hughes shughes@redhat.com Date: Tue May 18 15:35:11 2010 -0400
support classes for adding a Repo object
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 5fbc56b..915d0e7 100644 --- a/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java +++ b/java/code/src/com/redhat/rhn/domain/channel/ChannelFactory.java @@ -459,6 +459,14 @@ public class ChannelFactory extends HibernateFactory { }
/** + * Creates an empty Repo + * @return empty Repo + */ + public static ContentSource createRepo() { + return new ContentSource(); + } + + /** * Utility to call {@link #refreshNewestPackageCache(Long, String)} given a channel. * * @param c channel to be refreshed diff --git a/java/code/src/com/redhat/rhn/manager/channel/repo/CreateRepoCommand.java b/java/code/src/com/redhat/rhn/manager/channel/repo/CreateRepoCommand.java new file mode 100644 index 0000000..a54e4ed --- /dev/null +++ b/java/code/src/com/redhat/rhn/manager/channel/repo/CreateRepoCommand.java @@ -0,0 +1,121 @@ +/** + * 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.manager.channel.repo; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.log4j.Logger; + +import com.redhat.rhn.common.validator.ValidatorError; +import com.redhat.rhn.domain.channel.ChannelFactory; +import com.redhat.rhn.domain.channel.ContentSource; + +/** + * CreateRepoCommand - Command to create a repo + * @version $Rev: 119601 $ + */ +public class CreateRepoCommand { + + private String label; + private String url; + private ContentSource newRepo; + private List<ValidatorError> errors; + + private static Logger log = Logger.getLogger(CreateRepoCommand.class); + + /** + * Constructor to create an org + * @param nameIn to set on the org + * @param loginIn to use for 1st user in org + * @param passwordIn to set for first user + * @param emailIn to set for first user + */ + public CreateRepoCommand(String labelIn, String urlIn) { + this.label = labelIn; + this.url = urlIn; + } + + /** + * + * @return label for repo + */ + public String getLabel() { + return label; + } + + /** + * + * @param labelIn to set for repo + */ + public void setLabel(String LabelIn) { + this.label = LabelIn; + } + + /** + * + * @return url for repo + */ + public String getUrl() { + return url; + } + + /** + * + * @param urlIn to set for repo + */ + public void setUrl(String urlIn) { + this.url = urlIn; + } + + /** + * Check for errors and store Org to db. + * @return ValidatorError[] array if there are errors + */ + public ValidatorError[] store() { + ValidatorError[] errors = validate(); + if (errors != null && errors.length > 0) { + return errors; + } + else { + // Create repo + ContentSource repo = ChannelFactory.createRepo(); + repo.setLabel(this.label); + repo.setSourceUrl(this.url); + ChannelFactory.save(repo); + this.newRepo = repo; + } + return null; + } + + /** + * Get the newly created org. + * @return Org that was stored to DB + */ + public ContentSource getNewRepo() { + return this.newRepo; + } + + /** + * Validates the repo object. + * @return an Object array of ValidatorErrors. + */ + public ValidatorError[] validate() { + errors = new ArrayList(); //clear validation errors + return (ValidatorError[]) errors.toArray(new ValidatorError[0]); + } + + +}
commit de059d412b4b24d0b8f26314821e1f0d37ce608d Author: Shannon Hughes shughes@redhat.com Date: Tue May 18 10:45:26 2010 -0400
repo validation xsd schema
diff --git a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/validation/repoForm.xsd b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/validation/repoForm.xsd new file mode 100644 index 0000000..46a630b --- /dev/null +++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/validation/repoForm.xsd @@ -0,0 +1,18 @@ +<?xml version="1.0"?> + +<schema targetNamespace="http://rhn.redhat.com" + xmlns="http://www.w3.org/1999/XMLSchema" + xmlns:rhn="http://rhn.redhat.com%22%3E + + <attribute name="label"> + <simpleType baseType="string"> + <minLength value="1" /> + </simpleType> + </attribute> + <attribute name="url"> + <simpleType baseType="string"> + <minLength value="1" /> + </simpleType> + </attribute> + +</schema> \ No newline at end of file
commit 1cea961d8793ea20376138bae305dcc759527139 Author: Shannon Hughes shughes@redhat.com Date: Tue May 18 10:36:47 2010 -0400
adding nav entries for repo create and edit
diff --git a/java/code/webapp/WEB-INF/nav/sitenav-authenticated.xml b/java/code/webapp/WEB-INF/nav/sitenav-authenticated.xml index 975f6b4..8b9c090 100644 --- a/java/code/webapp/WEB-INF/nav/sitenav-authenticated.xml +++ b/java/code/webapp/WEB-INF/nav/sitenav-authenticated.xml @@ -162,6 +162,8 @@ <rhn-tab name="Manage Repositories" acl="user_role(channel_admin)" node-id="manage_repos"> <rhn-tab-directory>/rhn/channels/manage/repos</rhn-tab-directory> <rhn-tab-url>/rhn/channels/manage/repos/RepoList.do</rhn-tab-url> + <rhn-tab-url>/rhn/channels/manage/repos/RepoEdit.do</rhn-tab-url> + <rhn-tab-url>/rhn/channels/manage/repos/RepoCreate.do</rhn-tab-url> </rhn-tab> </rhn-tab> </rhn-tab>
commit a512542fd1b4c9bbe2d4d4fba7e0a7c5a0404b42 Author: Shannon Hughes shughes@redhat.com Date: Tue May 18 10:33:35 2010 -0400
struts entries for repo create and edit pages
diff --git a/java/code/webapp/WEB-INF/struts-config.xml b/java/code/webapp/WEB-INF/struts-config.xml index 3068197..146d05d 100644 --- a/java/code/webapp/WEB-INF/struts-config.xml +++ b/java/code/webapp/WEB-INF/struts-config.xml @@ -6627,6 +6627,34 @@ path="/WEB-INF/pages/channel/manage/repo/repos.jsp"/> </action>
+ <action path="/channels/manage/repos/RepoCreate" + scope="request" + validate="false" + name="contentSourceForm" + parameter="create_mode" + type="com.redhat.rhn.frontend.action.channel.manage.repo.RepoDetailsAction" + className="com.redhat.rhn.frontend.struts.RhnActionMapping"> + <set-property property="acls" value="org_entitlement(rhn_provisioning); user_role(config_admin)"/> + <forward name="default" + path="/WEB-INF/pages/channel/repo/repodetails.jsp"/> + <forward name="success" + path="/channels/manage/repo/RepoEdit.do" redirect = "true" + /> + </action> + + <action path="/channels/manage/repos/RepoEdit" + scope="request" + name="contentSourceForm" + parameter="edit_mode" + type="com.redhat.rhn.frontend.action.channel.manage.repo.RepoDetailsAction" + className="com.redhat.rhn.frontend.struts.RhnActionMapping"> + <set-property property="acls" value="org_entitlement(rhn_provisioning); user_role(config_admin)"/> + <forward name="default" + path="/WEB-INF/pages/channel/repo/repodetails.jsp"/> + <forward name="success" + path="/channels/manage/repo/RepoEdit.do" redirect = "true"/> + </action> + <!-- end repo -->
<action path="/common/DownloadFile"
commit 6c0608a233dd091e600501ffbe84efd656642a28 Author: Shannon Hughes shughes@redhat.com Date: Mon May 17 16:12:12 2010 -0400
adding dynaform for content source creation
diff --git a/java/code/webapp/WEB-INF/struts-config.xml b/java/code/webapp/WEB-INF/struts-config.xml index fbe792d..3068197 100644 --- a/java/code/webapp/WEB-INF/struts-config.xml +++ b/java/code/webapp/WEB-INF/struts-config.xml @@ -817,6 +817,12 @@ <form-property name="bootimage" type="java.lang.String"/> <form-property name="channelid" type="java.lang.Long"/> </form-bean> + + <form-bean name="contentSourceForm" + type="com.redhat.rhn.frontend.struts.ScrubbingDynaActionForm"> + <form-property name="url" type="java.lang.String"/> + <form-property name="label" type="java.lang.String"/> + </form-bean>
<form-bean name="cobblerSnippetsForm" type="com.redhat.rhn.frontend.struts.ContentsForm">
commit 7c28492d1dc0d405368adb66e29b170402c9560c Author: Shannon Hughes shughes@redhat.com Date: Thu May 13 16:34:58 2010 -0400
fixing toolbar syntax for repo
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 fd250b6..1936881 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 @@ -9393,6 +9393,12 @@ Please note that some manual configuration of these scripts may still be require <trans-unit id="repos.jsp.lastsync"> <source>Last Synced</source> </trans-unit> + <trans-unit id="toolbar.create.repos"> + <source>create new repository</source> + <context-group name="ctx"> + <context context-type="sourcefile">/rhn/channel/manage/repo/RepoList.do</context> + </context-group> + </trans-unit>
<!-- TNC --> <trans-unit id="tnc.jsp.tnc">
commit 024f4042f04114678abeff0aa77f57230715ade1 Author: Shannon Hughes shughes@redhat.com Date: Thu May 13 15:56:00 2010 -0400
minor tweaks to struts url path and hibernate fix
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 3ff823a..d39416e 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 @@ -35,13 +35,9 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
</class>
- + <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_id = :orgId]]> </query>
</hibernate-mapping> diff --git a/java/code/webapp/WEB-INF/struts-config.xml b/java/code/webapp/WEB-INF/struts-config.xml index bc5c673..fbe792d 100644 --- a/java/code/webapp/WEB-INF/struts-config.xml +++ b/java/code/webapp/WEB-INF/struts-config.xml @@ -6614,11 +6614,11 @@ <action path="/channels/manage/repos/RepoList" scope="request" parameter="all" - input="/WEB-INF/pages/channels/manage/repo/repos.jsp" + input="/WEB-INF/pages/channel/manage/repo/repos.jsp" type="com.redhat.rhn.frontend.action.channel.manage.repo.RepoListSetupAction" className="com.redhat.rhn.frontend.struts.RhnActionMapping"> <forward name="default" - path="/WEB-INF/pages/channels/manage/repo/repos.jsp"/> + path="/WEB-INF/pages/channel/manage/repo/repos.jsp"/> </action>
<!-- end repo -->
commit 88a43866eac115bf444cb056454c2f4dc052c58b Author: Shannon Hughes shughes@redhat.com Date: Thu May 13 13:54:12 2010 -0400
adding repolist page to struts
diff --git a/java/code/webapp/WEB-INF/struts-config.xml b/java/code/webapp/WEB-INF/struts-config.xml index 774bee6..bc5c673 100644 --- a/java/code/webapp/WEB-INF/struts-config.xml +++ b/java/code/webapp/WEB-INF/struts-config.xml @@ -6607,6 +6607,21 @@ <forward name="default" path="/WEB-INF/pages/rhnpackage/packagedetail.jsp" /> <forward name="package" path="/software/packages/Details.do" redirect="true"/> </action> + + +<!-- Repo Sync --> + + <action path="/channels/manage/repos/RepoList" + scope="request" + parameter="all" + input="/WEB-INF/pages/channels/manage/repo/repos.jsp" + type="com.redhat.rhn.frontend.action.channel.manage.repo.RepoListSetupAction" + className="com.redhat.rhn.frontend.struts.RhnActionMapping"> + <forward name="default" + path="/WEB-INF/pages/channels/manage/repo/repos.jsp"/> + </action> + +<!-- end repo -->
<action path="/common/DownloadFile" scope="request"
commit d5219c1e6810361efbc805c6f2a1f6519b3fbc63 Author: Shannon Hughes shughes@redhat.com Date: Thu May 13 11:43:48 2010 -0400
datasource queries for repolist listtag page
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 6d5c259..4203b74 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 @@ -1033,6 +1033,14 @@ SELECT CP.package_id, CP.name_id, CP.evr_id, CP.package_arch_id </query> </mode>
+<mode name="contentsrc_for_org" class="com.redhat.rhn.frontend.dto.ContentSourceDto"> + <query params="org_id"> + SELECT CS.id, CS.label, CS.last_synced + FROM rhnContentSource CS + WHERE CS.org_id = :org_id + </query> +</mode> + <mode name="latest_package_equal_in_tree"> <query params="cid, name"> SELECT CP.package_id, CP.name_id, CP.evr_id, CP.package_arch_id diff --git a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoListSetupAction.java b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoListSetupAction.java index a45ef9f..eb33123 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoListSetupAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoListSetupAction.java @@ -25,8 +25,8 @@ import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping;
import com.redhat.rhn.common.util.DynamicComparator; -import com.redhat.rhn.domain.channel.ContentSource; import com.redhat.rhn.domain.user.User; +import com.redhat.rhn.frontend.dto.ContentSourceDto; import com.redhat.rhn.frontend.struts.RequestContext; import com.redhat.rhn.frontend.struts.RhnAction; import com.redhat.rhn.manager.channel.RepoLister; @@ -48,7 +48,7 @@ public class RepoListSetupAction extends RhnAction { request.setAttribute(mapping.getParameter(), Boolean.TRUE); RequestContext context = new RequestContext(request); User user = context.getLoggedInUser(); - List<ContentSource> result; + List<ContentSourceDto> result;
result = RepoLister.getInstance().list(user); Collections.sort(result, LABEL_COMPARATOR); diff --git a/java/code/src/com/redhat/rhn/manager/channel/RepoLister.java b/java/code/src/com/redhat/rhn/manager/channel/RepoLister.java index df561f4..e28ca4e 100644 --- a/java/code/src/com/redhat/rhn/manager/channel/RepoLister.java +++ b/java/code/src/com/redhat/rhn/manager/channel/RepoLister.java @@ -14,13 +14,17 @@ */ package com.redhat.rhn.manager.channel;
+import java.util.HashMap; import java.util.LinkedList; import java.util.List; +import java.util.Map;
import com.redhat.rhn.common.db.datasource.DataResult; -import com.redhat.rhn.domain.channel.ContentSource; +import com.redhat.rhn.common.db.datasource.ModeFactory; +import com.redhat.rhn.common.db.datasource.SelectMode; import com.redhat.rhn.domain.org.Org; import com.redhat.rhn.domain.user.User; +import com.redhat.rhn.frontend.dto.ContentSourceDto; import com.redhat.rhn.manager.BaseManager;
/** @@ -45,17 +49,20 @@ public class RepoLister extends BaseManager { return INSTANCE; }
- public DataResult<ContentSource> sourcesInOrg(Org orgIn) { - - //need to determine if we want to use Hibernate or DataSource query here - DataResult<ContentSource> returnDataResult = null; + public DataResult<ContentSourceDto> sourcesInOrg(Org orgIn) {
+ SelectMode m = ModeFactory.getMode("Channel_queries", "contentsrc_for_org"); + Map params = new HashMap(); + params.put("org_id", orgIn.getId()); + Map elabParams = new HashMap(); + DataResult<ContentSourceDto> returnDataResult = makeDataResult(params, + elabParams, null, m); return returnDataResult; }
- public List<ContentSource> list(User user) { - List <ContentSource> repos = new LinkedList<ContentSource>(); + public List<ContentSourceDto> list(User user) { + List <ContentSourceDto> repos = new LinkedList<ContentSourceDto>(); repos.addAll(sourcesInOrg(user.getOrg())); return repos; }
commit e6d71dd1d9e0a7fad2c7a22b80173f19ab4f119b Author: Shannon Hughes shughes@redhat.com Date: Thu May 13 11:25:35 2010 -0400
adding ContentSource DTO object for repo listtags
diff --git a/java/code/src/com/redhat/rhn/frontend/dto/ContentSourceDto.java b/java/code/src/com/redhat/rhn/frontend/dto/ContentSourceDto.java new file mode 100644 index 0000000..fb52f73 --- /dev/null +++ b/java/code/src/com/redhat/rhn/frontend/dto/ContentSourceDto.java @@ -0,0 +1,76 @@ +/** + * 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.dto; + +import java.util.Date; + + +/** + * ContentSourceDto + * @version $Rev$ + */ +public class ContentSourceDto extends BaseDto { + + private Long id; + private String label; + private Date lastSynced; + + /** + * + * @return laste date repo was synced + */ + public Date getLastSynced() { + return lastSynced; + } + + /** + * + * @param lastSyncedIn date to set of last sync + */ + public void setLastSynced(Date lastSyncedIn) { + this.lastSynced = lastSyncedIn; + } + + /** + * {@inheritDoc} + */ + public Long getId() { + return id; + } + + /** + * @param idIn The id to set. + */ + public void setId(Long idIn) { + this.id = idIn; + } + + /** + * @return the label + */ + public String getLabel() { + return label; + } + + + /** + * @param labelIn The label to set. + */ + public void setLabel(String labelIn) { + this.label = labelIn; + } + + +}
commit dda58f1748a62ceb9c81ef2f09218112a727eaf4 Author: Shannon Hughes shughes@redhat.com Date: Wed May 12 23:42:33 2010 -0400
setting up ContentSource queries
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 29f8a77..3ff823a 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 @@ -40,4 +40,8 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" <![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_id = :orgId]]> + </query> + </hibernate-mapping> diff --git a/java/code/src/com/redhat/rhn/manager/channel/RepoLister.java b/java/code/src/com/redhat/rhn/manager/channel/RepoLister.java index debc9e1..df561f4 100644 --- a/java/code/src/com/redhat/rhn/manager/channel/RepoLister.java +++ b/java/code/src/com/redhat/rhn/manager/channel/RepoLister.java @@ -17,7 +17,9 @@ package com.redhat.rhn.manager.channel; import java.util.LinkedList; import java.util.List;
+import com.redhat.rhn.common.db.datasource.DataResult; import com.redhat.rhn.domain.channel.ContentSource; +import com.redhat.rhn.domain.org.Org; import com.redhat.rhn.domain.user.User; import com.redhat.rhn.manager.BaseManager;
@@ -43,9 +45,18 @@ public class RepoLister extends BaseManager { return INSTANCE; }
+ public DataResult<ContentSource> sourcesInOrg(Org orgIn) { + + //need to determine if we want to use Hibernate or DataSource query here + DataResult<ContentSource> returnDataResult = null; + + return returnDataResult; + } +
public List<ContentSource> list(User user) { List <ContentSource> repos = new LinkedList<ContentSource>(); + repos.addAll(sourcesInOrg(user.getOrg())); return repos; } }
commit 4dae897a1505534a62c5435101ff1cb4ca1749fe Author: Shannon Hughes shughes@redhat.com Date: Wed May 12 23:17:11 2010 -0400
fixing compile errors on RepoLister
diff --git a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoListSetupAction.java b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoListSetupAction.java index 2fe67c6..a45ef9f 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoListSetupAction.java +++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoListSetupAction.java @@ -14,25 +14,22 @@ */ package com.redhat.rhn.frontend.action.channel.manage.repo;
+import java.util.Collections; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; + import com.redhat.rhn.common.util.DynamicComparator; import com.redhat.rhn.domain.channel.ContentSource; -import com.redhat.rhn.domain.kickstart.cobbler.CobblerSnippet; import com.redhat.rhn.domain.user.User; -import com.redhat.rhn.frontend.action.common.BadParameterException; import com.redhat.rhn.frontend.struts.RequestContext; import com.redhat.rhn.frontend.struts.RhnAction; import com.redhat.rhn.manager.channel.RepoLister; -import com.redhat.rhn.manager.kickstart.cobbler.CobblerSnippetLister; - -import org.apache.struts.action.ActionForm; -import org.apache.struts.action.ActionForward; -import org.apache.struts.action.ActionMapping; - -import java.util.Collections; -import java.util.List; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse;
/** * RepoListSetupAction : class to list repos @@ -53,7 +50,7 @@ public class RepoListSetupAction extends RhnAction { User user = context.getLoggedInUser(); List<ContentSource> result;
- result = RepoLister.getInstance().list(user) + result = RepoLister.getInstance().list(user); Collections.sort(result, LABEL_COMPARATOR); request.setAttribute("pageList", result); request.setAttribute("parentUrl", request.getRequestURI()); diff --git a/java/code/src/com/redhat/rhn/manager/channel/RepoLister.java b/java/code/src/com/redhat/rhn/manager/channel/RepoLister.java index 76bb4c1..debc9e1 100644 --- a/java/code/src/com/redhat/rhn/manager/channel/RepoLister.java +++ b/java/code/src/com/redhat/rhn/manager/channel/RepoLister.java @@ -14,29 +14,19 @@ */ package com.redhat.rhn.manager.channel;
-import com.redhat.rhn.common.security.PermissionException; -import com.redhat.rhn.domain.kickstart.cobbler.CobblerSnippet; -import com.redhat.rhn.domain.role.RoleFactory; -import com.redhat.rhn.domain.user.User; -import com.redhat.rhn.manager.BaseManager; - -import org.apache.log4j.Logger; - -import java.io.File; -import java.util.Arrays; import java.util.LinkedList; import java.util.List;
+import com.redhat.rhn.domain.channel.ContentSource; +import com.redhat.rhn.domain.user.User; +import com.redhat.rhn.manager.BaseManager; + /** * CobblerSnippetLister * @version $Rev$ */ public class RepoLister extends BaseManager {
- /** - * Logger for this class - */ - private static final Logger LOG = Logger.getLogger(RepoLister.class); private static final RepoLister INSTANCE = new RepoLister(); /** * Default constructor @@ -53,104 +43,9 @@ public class RepoLister extends BaseManager { return INSTANCE; }
- private void loadDefaultSnippets(File path, - List<CobblerSnippet> snippetFiles) { - if (path.exists() && !path.isHidden()) { - final String spacewalkSnippetsDir = CobblerSnippet. - getSpacewalkSnippetsDir().getAbsolutePath(); - if (!path.getAbsolutePath().startsWith(spacewalkSnippetsDir)) { - if (path.isDirectory()) { - String[] children = path.list(); - Arrays.sort(children); - for (int i = 0; i < children.length; i++) { - loadDefaultSnippets(new File(path, children[i]), snippetFiles); - } - } - else { - snippetFiles.add(CobblerSnippet.loadReadOnly(path)); - } - } - } - } - - private void loadSnippetsInSpacewalkDir(List<CobblerSnippet> snippetFiles) { - for (File path : CobblerSnippet.getSpacewalkSnippetsDir().listFiles()) { - if (path.isFile() && !path.isHidden()) { - snippetFiles.add(CobblerSnippet.loadReadOnly(path)); - } - } - - } - - /** - * Returns a list of snippets accessible to this user - * @param user the user has to be atleast a - * config admin to be able to access snippets. - * @param common true if we want the common snippets - * i.e ones in /var/lib/cobbler/snippets minus spacewalk - * false if want the editable snippets - * i.e ones in /var/lib/cobbler/snippets/spacewalk - * @return the snippets accessible to the user. - */ - private List<CobblerSnippet> listSnippets(User user, boolean common) { - if (!user.hasRole(RoleFactory.CONFIG_ADMIN)) { - throw new PermissionException(RoleFactory.CONFIG_ADMIN); - }
- if (common) { - List<CobblerSnippet> snippetFiles = new LinkedList<CobblerSnippet>(); - loadDefaultSnippets(CobblerSnippet.getCobblerSnippetsDir(), - snippetFiles); - loadSnippetsInSpacewalkDir(snippetFiles); - return snippetFiles; - } - - List<CobblerSnippet> snippetFiles = new LinkedList<CobblerSnippet>(); - File spacewalkDir = new File(CobblerSnippet.getPrefixFor(user.getOrg())); - - if (spacewalkDir.exists() && spacewalkDir.isDirectory()) { - for (File file : spacewalkDir.listFiles()) { - if (!file.isHidden() && file.isFile()) { - snippetFiles.add(CobblerSnippet.loadEditable(file.getName(), - user.getOrg())); - } - } - } - return snippetFiles; - } - - /** - * Returns a list of default snippets accessible to this user - * i.e ones in /var/lib/cobbler/snippets minus spacewalk - * @param user the user has to be atleast a - * config admin to be able to access snippets. - * @return the snippets accessible to the user. - */ - public List<CobblerSnippet> listDefault(User user) { - return listSnippets(user, true); - } - - - /** - * Returns a list of custom snippets accessible to this user - * i.e ones in /var/lib/cobbler/snippets/spacewalk - * @param user the user has to be atleast a - * config admin to be able to access snippets. - * @return the snippets accessible to the user. - */ - public List<CobblerSnippet> listCustom(User user) { - return listSnippets(user, false); - } - - /** - * Returns a list of snippets accessible to this user - * @param user the user has to be atleast a - * config admin to be able to access snippets. - * @return the snippets accessible to the user. - */ - public List<CobblerSnippet> list(User user) { - List <CobblerSnippet> snip = new LinkedList<CobblerSnippet>(listDefault(user)); - snip.addAll(listCustom(user)); - return snip; + public List<ContentSource> list(User user) { + List <ContentSource> repos = new LinkedList<ContentSource>(); + return repos; } }
commit 497fc6c6fa2d568d5dc6d7db807a918abd9755bc Author: Shannon Hughes shughes@redhat.com Date: Wed May 12 22:37:16 2010 -0400
initial classes for Repolisting
diff --git a/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java b/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java index 6276dbb..45fca49 100644 --- a/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java +++ b/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java @@ -19,6 +19,7 @@ import java.util.HashSet; import java.util.Set;
import com.redhat.rhn.domain.BaseDomainHelper; +import com.redhat.rhn.domain.org.Org;
/** * ContentSourceType @@ -27,6 +28,7 @@ import com.redhat.rhn.domain.BaseDomainHelper; public class ContentSource extends BaseDomainHelper {
private Long id; + private Org org; private ContentSourceType type; private String sourceUrl; private Date lastSynced; @@ -48,6 +50,22 @@ public class ContentSource extends BaseDomainHelper { }
/** + * + * @return Org this content source belongs to + */ + public Org getOrg() { + return org; + } + + /** + * + * @param orgIn Org to set + */ + public void setOrg(Org orgIn) { + org = orgIn; + } + + /** * @return Returns the id. */ public Long getId() { diff --git a/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoListSetupAction.java b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoListSetupAction.java new file mode 100644 index 0000000..2fe67c6 --- /dev/null +++ b/java/code/src/com/redhat/rhn/frontend/action/channel/manage/repo/RepoListSetupAction.java @@ -0,0 +1,63 @@ +/** + * 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.action.channel.manage.repo; + +import com.redhat.rhn.common.util.DynamicComparator; +import com.redhat.rhn.domain.channel.ContentSource; +import com.redhat.rhn.domain.kickstart.cobbler.CobblerSnippet; +import com.redhat.rhn.domain.user.User; +import com.redhat.rhn.frontend.action.common.BadParameterException; +import com.redhat.rhn.frontend.struts.RequestContext; +import com.redhat.rhn.frontend.struts.RhnAction; +import com.redhat.rhn.manager.channel.RepoLister; +import com.redhat.rhn.manager.kickstart.cobbler.CobblerSnippetLister; + +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; + +import java.util.Collections; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * RepoListSetupAction : class to list repos + * @version $Rev: 1 $ + */ +public class RepoListSetupAction extends RhnAction { + + private static final DynamicComparator LABEL_COMPARATOR = + new DynamicComparator("label", true); + /** + * ${@inheritDoc} + */ + public ActionForward execute(ActionMapping mapping, ActionForm form, + HttpServletRequest request, HttpServletResponse response) throws Exception { + + request.setAttribute(mapping.getParameter(), Boolean.TRUE); + RequestContext context = new RequestContext(request); + User user = context.getLoggedInUser(); + List<ContentSource> result; + + result = RepoLister.getInstance().list(user) + Collections.sort(result, LABEL_COMPARATOR); + request.setAttribute("pageList", result); + request.setAttribute("parentUrl", request.getRequestURI()); + return mapping.findForward("default"); + } + +} diff --git a/java/code/src/com/redhat/rhn/manager/channel/RepoLister.java b/java/code/src/com/redhat/rhn/manager/channel/RepoLister.java new file mode 100644 index 0000000..76bb4c1 --- /dev/null +++ b/java/code/src/com/redhat/rhn/manager/channel/RepoLister.java @@ -0,0 +1,156 @@ +/** + * 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.manager.channel; + +import com.redhat.rhn.common.security.PermissionException; +import com.redhat.rhn.domain.kickstart.cobbler.CobblerSnippet; +import com.redhat.rhn.domain.role.RoleFactory; +import com.redhat.rhn.domain.user.User; +import com.redhat.rhn.manager.BaseManager; + +import org.apache.log4j.Logger; + +import java.io.File; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; + +/** + * CobblerSnippetLister + * @version $Rev$ + */ +public class RepoLister extends BaseManager { + + /** + * Logger for this class + */ + private static final Logger LOG = Logger.getLogger(RepoLister.class); + private static final RepoLister INSTANCE = new RepoLister(); + /** + * Default constructor + */ + public RepoLister() { + + } + + /** + * Get the instance of the RepoLister + * @return CobblerSnippetLister instance + */ + public static RepoLister getInstance() { + return INSTANCE; + } + + private void loadDefaultSnippets(File path, + List<CobblerSnippet> snippetFiles) { + if (path.exists() && !path.isHidden()) { + final String spacewalkSnippetsDir = CobblerSnippet. + getSpacewalkSnippetsDir().getAbsolutePath(); + if (!path.getAbsolutePath().startsWith(spacewalkSnippetsDir)) { + if (path.isDirectory()) { + String[] children = path.list(); + Arrays.sort(children); + for (int i = 0; i < children.length; i++) { + loadDefaultSnippets(new File(path, children[i]), snippetFiles); + } + } + else { + snippetFiles.add(CobblerSnippet.loadReadOnly(path)); + } + } + } + } + + private void loadSnippetsInSpacewalkDir(List<CobblerSnippet> snippetFiles) { + for (File path : CobblerSnippet.getSpacewalkSnippetsDir().listFiles()) { + if (path.isFile() && !path.isHidden()) { + snippetFiles.add(CobblerSnippet.loadReadOnly(path)); + } + } + + } + + /** + * Returns a list of snippets accessible to this user + * @param user the user has to be atleast a + * config admin to be able to access snippets. + * @param common true if we want the common snippets + * i.e ones in /var/lib/cobbler/snippets minus spacewalk + * false if want the editable snippets + * i.e ones in /var/lib/cobbler/snippets/spacewalk + * @return the snippets accessible to the user. + */ + private List<CobblerSnippet> listSnippets(User user, boolean common) { + if (!user.hasRole(RoleFactory.CONFIG_ADMIN)) { + throw new PermissionException(RoleFactory.CONFIG_ADMIN); + } + + if (common) { + List<CobblerSnippet> snippetFiles = new LinkedList<CobblerSnippet>(); + loadDefaultSnippets(CobblerSnippet.getCobblerSnippetsDir(), + snippetFiles); + loadSnippetsInSpacewalkDir(snippetFiles); + return snippetFiles; + } + + List<CobblerSnippet> snippetFiles = new LinkedList<CobblerSnippet>(); + File spacewalkDir = new File(CobblerSnippet.getPrefixFor(user.getOrg())); + + if (spacewalkDir.exists() && spacewalkDir.isDirectory()) { + for (File file : spacewalkDir.listFiles()) { + if (!file.isHidden() && file.isFile()) { + snippetFiles.add(CobblerSnippet.loadEditable(file.getName(), + user.getOrg())); + } + } + } + return snippetFiles; + } + + /** + * Returns a list of default snippets accessible to this user + * i.e ones in /var/lib/cobbler/snippets minus spacewalk + * @param user the user has to be atleast a + * config admin to be able to access snippets. + * @return the snippets accessible to the user. + */ + public List<CobblerSnippet> listDefault(User user) { + return listSnippets(user, true); + } + + + /** + * Returns a list of custom snippets accessible to this user + * i.e ones in /var/lib/cobbler/snippets/spacewalk + * @param user the user has to be atleast a + * config admin to be able to access snippets. + * @return the snippets accessible to the user. + */ + public List<CobblerSnippet> listCustom(User user) { + return listSnippets(user, false); + } + + /** + * Returns a list of snippets accessible to this user + * @param user the user has to be atleast a + * config admin to be able to access snippets. + * @return the snippets accessible to the user. + */ + public List<CobblerSnippet> list(User user) { + List <CobblerSnippet> snip = new LinkedList<CobblerSnippet>(listDefault(user)); + snip.addAll(listCustom(user)); + return snip; + } +}
commit 04d45e9c2831b1e687ca64cf65d62003a40ae53c Author: Shannon Hughes shughes@redhat.com Date: Wed May 12 15:51:03 2010 -0400
adding repo list jsp page
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 499fca3..fd250b6 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 @@ -9354,14 +9354,12 @@ Please note that some manual configuration of these scripts may still be require <trans-unit id="cobbler.jsp.header2"> <source>Run Cobbler Sync</source> </trans-unit> - <trans-unit id="cobbler.jsp.sync"> <source>Run Cobbler Sync</source> </trans-unit> <trans-unit id="cobbler.jsp.synced"> <source>Cobbler Sync action was successfully executed. Look at /var/log/cobbler/*.log for more information</source> </trans-unit> - <trans-unit id="cobbler.jsp.summary1"> <source>Setup your @@PRODUCT_NAME@@ Cobbler settings below.</source> </trans-unit> @@ -9374,10 +9372,27 @@ Please note that some manual configuration of these scripts may still be require <trans-unit id="update"> <source>Update</source> </trans-unit> - </group>
- +<!-- Repo Sync --> + <trans-unit id="repos.jsp.toolbar"> + <source>Repository</source> + </trans-unit> + <trans-unit id="repos.jsp.summary"> + <source>Summary for repos here</source> + </trans-unit> + <trans-unit id="repos.jsp.note.default"> + <source>note here</source> + </trans-unit> + <trans-unit id="repos.jsp.norepos"> + <source>No repos in the db</source> + </trans-unit> + <trans-unit id="repos.jsp.label"> + <source>Label</source> + </trans-unit> + <trans-unit id="repos.jsp.lastsync"> + <source>Last Synced</source> + </trans-unit>
<!-- TNC --> <trans-unit id="tnc.jsp.tnc"> diff --git a/java/code/webapp/WEB-INF/pages/channel/manage/repo/repos.jsp b/java/code/webapp/WEB-INF/pages/channel/manage/repo/repos.jsp index 424a13b..53451c6 100644 --- a/java/code/webapp/WEB-INF/pages/channel/manage/repo/repos.jsp +++ b/java/code/webapp/WEB-INF/pages/channel/manage/repo/repos.jsp @@ -7,17 +7,15 @@ <html> <body> <rhn:toolbar base="h1" img="/img/rhn-icon-info.gif" - creationUrl="CobblerSnippetCreate.do" - creationType="snippets" + creationUrl="RepoCreate.do" + creationType="repos" imgAlt="info.alt.img"> - <bean:message key="snippets.jsp.toolbar"/> + <bean:message key="repos.jsp.toolbar"/> </rhn:toolbar> -<rhn:dialogmenu mindepth="0" maxdepth="1" definition="/WEB-INF/nav/snippet_tabs.xml" - renderer="com.redhat.rhn.frontend.nav.DialognavRenderer" /> <div class="page-summary"> -<p><bean:message key="snippets.jsp.summary"/></p> +<p><bean:message key="repos.jsp.summary"/></p> <c:if test="${not empty requestScope.default}"> - <rhn:note key = "snippets.jsp.note.default"/> + <rhn:note key = "repos.jsp.note.default"/> </c:if> </div>
@@ -27,35 +25,25 @@ width="100%" name="keysList" styleclass="list" - emptykey="cobbler.snippet.jsp.nosnippets" - alphabarcolumn="name"> + emptykey="repos.jsp.norepos" + alphabarcolumn="label">
<rl:decorator name="PageSizeDecorator"/>
<!-- Description name column --> <rl:column bound="false" sortable="true" - headerkey="cobbler.snippet.name" + headerkey="repos.jsp.label" styleclass="first-column" - sortattr= "name" - filterattr="name"> - <c:choose> - <c:when test = "${current.editable}"> - <c:out value="<a href="/rhn/kickstart/cobbler/CobblerSnippetEdit.do?name=${current.name}">${current.name}</a>" escapeXml="false" /> - </c:when> - <c:otherwise> - <c:out value="<a href="/rhn/kickstart/cobbler/CobblerSnippetView.do?path=${current.displayPath}">${current.name}</a>" escapeXml="false" /> - </c:otherwise> - - </c:choose> + sortattr= "label" + filterattr="label"> + <c:out value="<a href="/rhn/channel/manage/RepoEdit.do?label=${current.label}">${current.label}</a>" escapeXml="false" /> </rl:column> - <rl:column headerkey="cobbler.snippet.macro" styleclass="last-column"> - <c:out value="${current.fragment}"/> + <rl:column headerkey="repos.jsp.lastsync" styleclass="last-column"> + <c:out value="${current.sync}"/> </rl:column> </rl:list> </rl:listset>
- <rhn:tooltip key="cobbler.snippet.copy-paste-snippet-tip"/> - </body> </html>
commit 07c72aa3f3c207f21651717a08820be623a97cc9 Author: Shannon Hughes shughes@redhat.com Date: Wed May 12 10:24:01 2010 -0400
Revert "fixing accidental branch creation, removing cobbler stubs"
This reverts commit ba2c85ace5e35e7388e59673e0bb7f899a1fc8bb.
diff --git a/java/code/webapp/WEB-INF/pages/kickstart/cobbler/snippets.jsp b/java/code/webapp/WEB-INF/pages/kickstart/cobbler/snippets.jsp index 85eee43..32f442b 100644 --- a/java/code/webapp/WEB-INF/pages/kickstart/cobbler/snippets.jsp +++ b/java/code/webapp/WEB-INF/pages/kickstart/cobbler/snippets.jsp @@ -7,15 +7,17 @@ <html> <body> <rhn:toolbar base="h1" img="/img/rhn-icon-info.gif" - creationUrl="RepoCreate.do" - creationType="repos" + creationUrl="CobblerSnippetCreate.do" + creationType="snippets" imgAlt="info.alt.img"> - <bean:message key="repos.jsp.toolbar"/> + <bean:message key="snippets.jsp.toolbar"/> </rhn:toolbar> +<rhn:dialogmenu mindepth="0" maxdepth="1" definition="/WEB-INF/nav/snippet_tabs.xml" + renderer="com.redhat.rhn.frontend.nav.DialognavRenderer" /> <div class="page-summary"> -<p><bean:message key="repos.jsp.summary"/></p> +<p><bean:message key="snippets.jsp.summary"/></p> <c:if test="${not empty requestScope.default}"> - <rhn:note key = "repos.jsp.note.default"/> + <rhn:note key = "snippets.jsp.note.default"/> </c:if> </div>
@@ -25,7 +27,7 @@ width="100%" name="keysList" styleclass="list" - emptykey="cobbler.repo.jsp.norepos" + emptykey="cobbler.snippet.jsp.nosnippets" alphabarcolumn="name">
<rl:decorator name="PageSizeDecorator"/> @@ -33,20 +35,28 @@ <!-- Description name column --> <rl:column bound="false" sortable="true" - headerkey="channel.repo.label" + headerkey="cobbler.snippet.name" styleclass="first-column" - sortattr= "label" - filterattr="label"> + sortattr= "name" + filterattr="name"> <c:choose> - <c:out value="<a href="/rhn/channels/manage/repos/RepoEdit.do?id=${current.id}">${current.label}</a>" escapeXml="false" /> + <c:when test = "${current.editable}"> + <c:out value="<a href="/rhn/kickstart/cobbler/CobblerSnippetEdit.do?name=${current.name}">${current.name}</a>" escapeXml="false" /> + </c:when> + <c:otherwise> + <c:out value="<a href="/rhn/kickstart/cobbler/CobblerSnippetView.do?path=${current.displayPath}">${current.name}</a>" escapeXml="false" /> + </c:otherwise> + </c:choose> </rl:column> - <rl:column headerkey="channel.repo.lastsync" styleclass="last-column"> - <c:out value="${current.sync}"/> + <rl:column headerkey="cobbler.snippet.macro" styleclass="last-column"> + <c:out value="${current.fragment}"/> </rl:column> </rl:list> </rl:listset> - + + <rhn:tooltip key="cobbler.snippet.copy-paste-snippet-tip"/> + </body> </html>
commit b65bcd48d1a4e7f6f259375a85eddbcf0e1aca0a Author: Shannon Hughes shughes@redhat.com Date: Tue May 11 17:06:38 2010 -0400
fixing accidental branch creation, removing cobbler stubs
diff --git a/java/code/webapp/WEB-INF/pages/kickstart/cobbler/snippets.jsp b/java/code/webapp/WEB-INF/pages/kickstart/cobbler/snippets.jsp index 1a73888..85eee43 100644 --- a/java/code/webapp/WEB-INF/pages/kickstart/cobbler/snippets.jsp +++ b/java/code/webapp/WEB-INF/pages/kickstart/cobbler/snippets.jsp @@ -7,17 +7,15 @@ <html> <body> <rhn:toolbar base="h1" img="/img/rhn-icon-info.gif" - creationUrl="CobblerSnippetCreate.do" - creationType="snippets" + creationUrl="RepoCreate.do" + creationType="repos" imgAlt="info.alt.img"> - <bean:message key="snippets.jsp.toolbar"/> + <bean:message key="repos.jsp.toolbar"/> </rhn:toolbar> -<rhn:dialogmenu mindepth="0" maxdepth="1" definition="/WEB-INF/nav/snippet_tabs.xml" - renderer="com.redhat.rhn.frontend.nav.DialognavRenderer" /> <div class="page-summary"> -<p><bean:message key="snippets.jsp.summary"/></p> +<p><bean:message key="repos.jsp.summary"/></p> <c:if test="${not empty requestScope.default}"> - <rhn:note key = "snippets.jsp.note.default"/> + <rhn:note key = "repos.jsp.note.default"/> </c:if> </div>
@@ -27,7 +25,7 @@ width="100%" name="keysList" styleclass="list" - emptykey="cobbler.snippet.jsp.nosnippets" + emptykey="cobbler.repo.jsp.norepos" alphabarcolumn="name">
<rl:decorator name="PageSizeDecorator"/> @@ -35,27 +33,19 @@ <!-- Description name column --> <rl:column bound="false" sortable="true" - headerkey="cobbler.snippet.name" + headerkey="channel.repo.label" styleclass="first-column" - sortattr= "name" - filterattr="name"> + sortattr= "label" + filterattr="label"> <c:choose> - <c:when test = "${current.editable}"> - <c:out value="<a href="/rhn/kickstart/cobbler/CobblerSnippetEdit.do?name=${current.name}">${current.name}</a>" escapeXml="false" /> - </c:when> - <c:otherwise> - <c:out value="<a href="/rhn/kickstart/cobbler/CobblerSnippetView.do?path=${current.displayPath}">${current.name}</a>" escapeXml="false" /> - </c:otherwise> - + <c:out value="<a href="/rhn/channels/manage/repos/RepoEdit.do?id=${current.id}">${current.label}</a>" escapeXml="false" /> </c:choose> </rl:column> - <rl:column headerkey="cobbler.snippet.macro" styleclass="last-column"> - <c:out value="${current.fragment}"/> + <rl:column headerkey="channel.repo.lastsync" styleclass="last-column"> + <c:out value="${current.sync}"/> </rl:column> </rl:list> </rl:listset> - - <rhn:tooltip key="cobbler.snippet.copy-paste-snippet-tip"/>
</body> </html>
commit 3454cff868a90049ba3ae82943f6ecb04773cbe6 Author: Shannon Hughes shughes@redhat.com Date: Tue May 11 16:59:05 2010 -0400
new jsp for the repo list
diff --git a/java/code/webapp/WEB-INF/pages/channel/manage/repo/repos.jsp b/java/code/webapp/WEB-INF/pages/channel/manage/repo/repos.jsp new file mode 100644 index 0000000..424a13b --- /dev/null +++ b/java/code/webapp/WEB-INF/pages/channel/manage/repo/repos.jsp @@ -0,0 +1,61 @@ +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> +<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %> +<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %> +<%@ taglib uri="http://rhn.redhat.com/tags/list" prefix="rl" %> +<%@ taglib uri="http://rhn.redhat.com/rhn" prefix="rhn" %> + +<html> +<body> +<rhn:toolbar base="h1" img="/img/rhn-icon-info.gif" + creationUrl="CobblerSnippetCreate.do" + creationType="snippets" + imgAlt="info.alt.img"> + <bean:message key="snippets.jsp.toolbar"/> +</rhn:toolbar> +<rhn:dialogmenu mindepth="0" maxdepth="1" definition="/WEB-INF/nav/snippet_tabs.xml" + renderer="com.redhat.rhn.frontend.nav.DialognavRenderer" /> +<div class="page-summary"> +<p><bean:message key="snippets.jsp.summary"/></p> +<c:if test="${not empty requestScope.default}"> + <rhn:note key = "snippets.jsp.note.default"/> +</c:if> +</div> + + + <rl:listset name="keySet"> + <rl:list dataset="pageList" + width="100%" + name="keysList" + styleclass="list" + emptykey="cobbler.snippet.jsp.nosnippets" + alphabarcolumn="name"> + + <rl:decorator name="PageSizeDecorator"/> + + <!-- Description name column --> + <rl:column bound="false" + sortable="true" + headerkey="cobbler.snippet.name" + styleclass="first-column" + sortattr= "name" + filterattr="name"> + <c:choose> + <c:when test = "${current.editable}"> + <c:out value="<a href="/rhn/kickstart/cobbler/CobblerSnippetEdit.do?name=${current.name}">${current.name}</a>" escapeXml="false" /> + </c:when> + <c:otherwise> + <c:out value="<a href="/rhn/kickstart/cobbler/CobblerSnippetView.do?path=${current.displayPath}">${current.name}</a>" escapeXml="false" /> + </c:otherwise> + + </c:choose> + </rl:column> + <rl:column headerkey="cobbler.snippet.macro" styleclass="last-column"> + <c:out value="${current.fragment}"/> + </rl:column> + </rl:list> + </rl:listset> + + <rhn:tooltip key="cobbler.snippet.copy-paste-snippet-tip"/> + +</body> +</html>
commit 0c3c038cf6f2cbec6c938da78a60fbaede6af73e Author: Shannon Hughes shughes@redhat.com Date: Tue May 11 14:13:35 2010 -0400
adding nav menu for external repo management
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml b/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml index d8a94a6..f75f70c 100644 --- a/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml +++ b/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml @@ -647,6 +647,12 @@ http://www.oasis-open.org/committees/xliff/documents/xliff-core-1.1.xsd" <context context-type="sourcefile">Navigation Menu</context> </context-group> </trans-unit> + <trans-unit id="Manage Repositories"> +<source>Manage Repositories</source> + <context-group name="ctx"> + <context context-type="sourcefile">Navigation Menu</context> + </context-group> + </trans-unit> <trans-unit id="Monitoring"> <source>Monitoring</source> <context-group name="ctx"> diff --git a/java/code/webapp/WEB-INF/nav/sitenav-authenticated.xml b/java/code/webapp/WEB-INF/nav/sitenav-authenticated.xml index e514848..975f6b4 100644 --- a/java/code/webapp/WEB-INF/nav/sitenav-authenticated.xml +++ b/java/code/webapp/WEB-INF/nav/sitenav-authenticated.xml @@ -159,6 +159,10 @@ <rhn-tab-directory>/rhn/software/manage/packages</rhn-tab-directory> <rhn-tab-url>/rhn/software/manage/packages/PackageList.do</rhn-tab-url> </rhn-tab> + <rhn-tab name="Manage Repositories" acl="user_role(channel_admin)" node-id="manage_repos"> + <rhn-tab-directory>/rhn/channels/manage/repos</rhn-tab-directory> + <rhn-tab-url>/rhn/channels/manage/repos/RepoList.do</rhn-tab-url> + </rhn-tab> </rhn-tab> </rhn-tab> <rhn-tab name="Audit" url="/rhn/audit/Overview.do">
commit 0e9f4498e5b9ce86deaf835e5441633dd3cc061a Author: Shannon Hughes shughes@redhat.com Date: Tue May 11 11:42:55 2010 -0400
modified repo schema to handle org_id for content source objects. migrate script updated too.
diff --git a/schema/spacewalk/common/tables/rhnContentSource.sql b/schema/spacewalk/common/tables/rhnContentSource.sql index c4914fd..03882ab 100644 --- a/schema/spacewalk/common/tables/rhnContentSource.sql +++ b/schema/spacewalk/common/tables/rhnContentSource.sql @@ -21,6 +21,9 @@ rhnContentSource ( id number NOT NULL constraint rhn_ccs_id_pk primary key, + org_id number + constraint rhn_cs_org_fk + references web_customer (id), type_id number NOT NULL constraint rhn_ccs_type_fk references rhnContentSourceType(id), diff --git a/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/001-repo-sync.sql b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/001-repo-sync.sql index 0244dfa..496e446 100644 --- a/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/001-repo-sync.sql +++ b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/001-repo-sync.sql @@ -29,17 +29,26 @@ ALTER TABLE rhnChannelContentSource ADD CONSTRAINT rhn_ccs_uq UNIQUE (source_id, channel_id) USING INDEX TABLESPACE [[4m_tbs]];
+ALTER TABLE rhnContentSource + ADD org_id number + CONSTRAINT rhn_cs_org_fk + REFERENCES WEB_CUSTOMER(id); + DECLARE -- grab any rows that need the channel to be migrated to new channel content mapping tbl CURSOR content is - select id, channel_id - from rhnContentSource + select cs.id, cs.channel_id, c.org_id + from rhnContentSource cs, rhnChannel c where 1=1 + AND c.id = cs.channel_id BEGIN FOR content_rec IN content LOOP INSERT INTO rhnChannelContentSource (source_id, channel_id) VALUES (content_rec.id, content_rec.channel_id); + UPDATE rhnConentSource set org_id = content_rec.org_id + WHERE 1=1 + AND channel_id = content_rec.channel_id; END LOOP; commit; END;
commit 8bf4a23f7a15bc3c839682eabdece7201a56fecf Author: Shannon Hughes shughes@redhat.com Date: Fri May 7 16:33:07 2010 -0400
minor changes to tests
diff --git a/java/code/src/com/redhat/rhn/domain/channel/test/ChannelTest.java b/java/code/src/com/redhat/rhn/domain/channel/test/ChannelTest.java index b67eb0e..b71ee6f 100644 --- a/java/code/src/com/redhat/rhn/domain/channel/test/ChannelTest.java +++ b/java/code/src/com/redhat/rhn/domain/channel/test/ChannelTest.java @@ -184,7 +184,7 @@ public class ChannelTest extends BaseTestCaseWithUser { cs.setSourceUrl("fake url"); cs.getChannels().add(c); cs.setType(ChannelFactory.CONTENT_SOURCE_TYPE_YUM); - c.getSources().add(cs); + //c.getSources().add(cs); c = (Channel) TestUtils.saveAndReload(c); assertNotEmpty(c.getSources()); }
commit 93341dbcf1fd41e98c924d1156867ba2ca2ceda9 Author: Shannon Hughes shughes@redhat.com Date: Fri May 7 14:37:45 2010 -0400
more compiliation fixes to support many2many
diff --git a/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java b/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java index cb48616..6276dbb 100644 --- a/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java +++ b/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java @@ -27,7 +27,6 @@ import com.redhat.rhn.domain.BaseDomainHelper; public class ContentSource extends BaseDomainHelper {
private Long id; - private Channel channel; private ContentSourceType type; private String sourceUrl; private Date lastSynced; @@ -63,23 +62,6 @@ public class ContentSource extends BaseDomainHelper { }
- - /** - * @return Returns the chan. - */ - public Channel getChannel() { - return channel; - } - - - /** - * @param chanIn The chan to set. - */ - public void setChannel(Channel chanIn) { - this.channel = chanIn; - } - - /** * @return Returns the type. */ diff --git a/java/code/src/com/redhat/rhn/domain/channel/test/ChannelTest.java b/java/code/src/com/redhat/rhn/domain/channel/test/ChannelTest.java index 5a132de..b67eb0e 100644 --- a/java/code/src/com/redhat/rhn/domain/channel/test/ChannelTest.java +++ b/java/code/src/com/redhat/rhn/domain/channel/test/ChannelTest.java @@ -182,7 +182,7 @@ public class ChannelTest extends BaseTestCaseWithUser { ContentSource cs = new ContentSource(); cs.setLabel("repo_label-" + c.getLabel()); cs.setSourceUrl("fake url"); - cs.setChannel(c); + cs.getChannels().add(c); cs.setType(ChannelFactory.CONTENT_SOURCE_TYPE_YUM); c.getSources().add(cs); c = (Channel) TestUtils.saveAndReload(c); diff --git a/java/code/src/com/redhat/rhn/domain/task/Task.hbm.xml b/java/code/src/com/redhat/rhn/domain/task/Task.hbm.xml index 70b8f1a..08d3b56 100644 --- a/java/code/src/com/redhat/rhn/domain/task/Task.hbm.xml +++ b/java/code/src/com/redhat/rhn/domain/task/Task.hbm.xml @@ -11,6 +11,7 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" column="org_id" /> <key-property name="name" type="string" column="task_name" length="64"/> <key-property name="data" column="task_data" type="long"/> + <key-property name="data2" column="task_data_two" type="long"/> <key-property name="earliest" column="earliest" type="timestamp"/> </composite-id>
diff --git a/java/code/src/com/redhat/rhn/domain/task/Task.java b/java/code/src/com/redhat/rhn/domain/task/Task.java index 604c90c..3d8a877 100644 --- a/java/code/src/com/redhat/rhn/domain/task/Task.java +++ b/java/code/src/com/redhat/rhn/domain/task/Task.java @@ -30,6 +30,7 @@ public class Task implements Serializable {
private String name; private Long data; + private Long data2; private int priority; private Date earliest; private Org org; @@ -50,6 +51,22 @@ public class Task implements Serializable { }
/** + * + * @return the data + */ + public Long getData2() { + return data2; + } + + /** + * + * @param dataIn data to set + */ + public void setData2(Long dataIn) { + this.data2 = dataIn; + } + + /** * @return Returns the earliest. */ public Date getEarliest() { 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 b9994a7..4c928e4 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 @@ -609,7 +609,7 @@ public class EditChannelAction extends RhnAction implements Listable { cs.getLastSynced()); } request.setAttribute("last_sync", lastSync); - if (ChannelManager.getLatestSyncLogFile(cs) != null) { + if (ChannelManager.getLatestSyncLogFile(cs,c) != null) { request.setAttribute("log_url", DownloadManager.getChannelSyncLogDownloadPath(cs, ctx.getLoggedInUser())); diff --git a/java/code/src/com/redhat/rhn/frontend/action/common/DownloadFile.java b/java/code/src/com/redhat/rhn/frontend/action/common/DownloadFile.java index 96e137b..f42fc23 100644 --- a/java/code/src/com/redhat/rhn/frontend/action/common/DownloadFile.java +++ b/java/code/src/com/redhat/rhn/frontend/action/common/DownloadFile.java @@ -89,6 +89,7 @@ public class DownloadFile extends DownloadAction { private static final String PATH = "path"; private static final String SESSION = "session"; private static final String URL = "url"; + private static final String CHANNEL = "cid";
/** {@inheritDoc} */ public ActionForward execute(ActionMapping mapping, @@ -372,9 +373,10 @@ public class DownloadFile extends DownloadAction { (int) patch.getReadme().length())); } else if (type.equals(DownloadManager.DOWNLOAD_TYPE_REPO_LOG)) { + Channel c = ChannelFactory.lookupById((Long)params.get(CHANNEL)); ContentSource cs = ChannelFactory.lookupContentSource(fileId); ChannelManager.verifyChannelAdmin(user, fileId); - File file = new File(ChannelManager.getLatestSyncLogFile(cs)); + File file = new File(ChannelManager.getLatestSyncLogFile(cs, c));
StringBuilder output = new StringBuilder(); BufferedReader input = new BufferedReader(new FileReader(file)); diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ChannelSerializer.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ChannelSerializer.java index dd6c1a7..36bab29 100644 --- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ChannelSerializer.java +++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ChannelSerializer.java @@ -14,19 +14,19 @@ */ package com.redhat.rhn.frontend.xmlrpc.serializer;
-import com.redhat.rhn.domain.channel.Channel; -import com.redhat.rhn.domain.channel.ContentSource; -import com.redhat.rhn.frontend.xmlrpc.serializer.util.SerializerHelper; - -import org.apache.commons.lang.StringUtils; - import java.io.IOException; import java.io.Writer;
+import org.apache.commons.lang.StringUtils; + import redstone.xmlrpc.XmlRpcCustomSerializer; import redstone.xmlrpc.XmlRpcException; import redstone.xmlrpc.XmlRpcSerializer;
+import com.redhat.rhn.domain.channel.Channel; +import com.redhat.rhn.domain.channel.ContentSource; +import com.redhat.rhn.frontend.xmlrpc.serializer.util.SerializerHelper; + /** * * ChannelSerializer 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 1e30559..42c2eff 100644 --- a/java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java +++ b/java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java @@ -2822,7 +2822,7 @@ public class ChannelManager extends BaseManager { * @param cs the channel content source you want the latest log file for * @return the string of the filename (fully qualified) */ - public static String getLatestSyncLogFile(ContentSource cs) { + public static String getLatestSyncLogFile(ContentSource cs, Channel c) {
String logPath = Config.get().getString(ConfigDefaults.SPACEWALK_REPOSYNC_LOG_PATH, "/var/log/rhn/reposync/"); @@ -2831,7 +2831,7 @@ public class ChannelManager extends BaseManager { File dir = new File(logPath); List<String> possibleList = new ArrayList<String>(); for (String file : dir.list()) { - if (file.contains(cs.getChannel().getLabel() + '-' + repoLabel)) { + if (file.contains(c.getLabel() + '-' + repoLabel)) { possibleList.add(file); } } diff --git a/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java b/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java index 0836dcf..ce11bff 100644 --- a/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java +++ b/java/code/src/com/redhat/rhn/taskomatic/task/RepoSyncTask.java @@ -16,6 +16,7 @@ package com.redhat.rhn.taskomatic.task;
import com.redhat.rhn.common.conf.Config; import com.redhat.rhn.common.conf.ConfigDefaults; +import com.redhat.rhn.domain.channel.Channel; import com.redhat.rhn.domain.channel.ChannelFactory; import com.redhat.rhn.domain.channel.ContentSource; import com.redhat.rhn.domain.task.Task; @@ -70,9 +71,10 @@ public class RepoSyncTask implements Job { continue; } ContentSource src = ChannelFactory.lookupContentSource(task.getData()); + Channel c = ChannelFactory.lookupById(task.getData2()); if (log.isInfoEnabled()) { log.info("Syncing repo " + src.getSourceUrl() + " to channel " + - src.getChannel().getLabel()); + c.getLabel()); } if (src == null) { log.error("Content Source could not be found: " + task.getData()); @@ -83,7 +85,7 @@ public class RepoSyncTask implements Job {
try { Process p = Runtime.getRuntime().exec( - getSyncCommand(src).toArray(new String[0])); + getSyncCommand(src,c).toArray(new String[0])); src.setLastSynced(new Date()); int chr = p.getInputStream().read(); while (chr != -1) { @@ -99,12 +101,12 @@ public class RepoSyncTask implements Job { } }
- private static List<String> getSyncCommand(ContentSource src) { + private static List<String> getSyncCommand(ContentSource src, Channel c) { List<String> cmd = new ArrayList<String>(); cmd.add(Config.get().getString(ConfigDefaults.SPACEWALK_REPOSYNC_PATH, "/usr/bin/spacewalk-repo-sync")); cmd.add("--channel"); - cmd.add(src.getChannel().getLabel()); + cmd.add(c.getLabel()); cmd.add("--url"); cmd.add(src.getSourceUrl()); cmd.add("--type");
commit 07ce6f17e1ccfbc973c2fbd198daf54fa9bb1d39 Author: Shannon Hughes shughes@redhat.com Date: Thu May 6 15:50:58 2010 -0400
fixing breakage after adding many2many objects for yum repo sync
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 e694f52..d46cd1b 100644 --- a/java/code/src/com/redhat/rhn/domain/channel/Channel.java +++ b/java/code/src/com/redhat/rhn/domain/channel/Channel.java @@ -856,6 +856,7 @@ public class Channel extends BaseDomainHelper implements Comparable { ChannelFactory.save(this); }
+ /** * get the compatible checksum type to be used for repomd.xml * based on channel release. diff --git a/java/code/src/com/redhat/rhn/domain/channel/test/ChannelTest.java b/java/code/src/com/redhat/rhn/domain/channel/test/ChannelTest.java index 9323e09..5a132de 100644 --- a/java/code/src/com/redhat/rhn/domain/channel/test/ChannelTest.java +++ b/java/code/src/com/redhat/rhn/domain/channel/test/ChannelTest.java @@ -184,9 +184,9 @@ public class ChannelTest extends BaseTestCaseWithUser { cs.setSourceUrl("fake url"); cs.setChannel(c); cs.setType(ChannelFactory.CONTENT_SOURCE_TYPE_YUM); - c.getContentSources().add(cs); + c.getSources().add(cs); c = (Channel) TestUtils.saveAndReload(c); - assertNotEmpty(c.getContentSources()); + assertNotEmpty(c.getSources()); }
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 2f64eb3..b9994a7 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 @@ -593,13 +593,13 @@ public class EditChannelAction extends RhnAction implements Listable { .getMessage("generic.jsp.none")); }
- if (c.getContentSources().isEmpty()) { + if (c.getSources().isEmpty()) { form.set("yum_repo", ""); form.set("repo_label", ""); request.setAttribute("last_sync", ""); } else { - ContentSource cs = c.getContentSources().iterator().next(); + ContentSource cs = c.getSources().iterator().next(); form.set("yum_repo", cs.getSourceUrl()); form.set("repo_label", cs.getLabel()); String lastSync = LocalizationService.getInstance().getMessage( diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ChannelSerializer.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ChannelSerializer.java index ed116be..dd6c1a7 100644 --- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ChannelSerializer.java +++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/serializer/ChannelSerializer.java @@ -95,13 +95,13 @@ public class ChannelSerializer implements XmlRpcCustomSerializer { helper.add("gpg_key_fp", StringUtils.defaultString(c.getGPGKeyFp()));
- if (c.getContentSources().isEmpty()) { + if (c.getSources().isEmpty()) { helper.add("yumrepo_source_url", ""); helper.add("yumrepo_label", ""); helper.add("yumrepo_last_sync", ""); } else { - ContentSource cs = c.getContentSources().iterator().next(); + ContentSource cs = c.getSources().iterator().next(); helper.add("yumrepo_source_url", cs.getSourceUrl()); helper.add("yumrepo_label", cs.getLabel()); if (cs.getLastSynced() != null) { 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 5e33363..80a46a4 100644 --- a/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java +++ b/java/code/src/com/redhat/rhn/manager/channel/CreateChannelCommand.java @@ -280,7 +280,6 @@ public class CreateChannelCommand { c.setMaintainerEmail(maintainerEmail); c.setMaintainerPhone(maintainerPhone); c.setSupportPolicy(supportPolicy); - c.setYumContentSource(yumUrl, repoLabel);
// handles either parent id or label setParentChannel(c, user, parentLabel, parentId); @@ -293,9 +292,9 @@ public class CreateChannelCommand { ChannelManager.queueChannelChange(c.getLabel(), "createchannel", "createchannel"); ChannelFactory.refreshNewestPackageCache(c, WEB_CHANNEL_CREATED);
- if (syncRepo && !c.getContentSources().isEmpty()) { + if (syncRepo && !c.getSources().isEmpty()) { TaskFactory.createTask(user.getOrg(), RepoSyncTask.DISPLAY_NAME, - c.getContentSources().iterator().next().getId()); + c.getSources().iterator().next().getId()); }
return c; 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 4534105..c56ae00 100644 --- a/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java +++ b/java/code/src/com/redhat/rhn/manager/channel/UpdateChannelCommand.java @@ -89,11 +89,10 @@ public class UpdateChannelCommand extends CreateChannelCommand { c.setMaintainerEmail(maintainerEmail); c.setMaintainerPhone(maintainerPhone); c.setSupportPolicy(supportPolicy); - c.setYumContentSource(yumUrl, repoLabel);
- if (syncRepo && !c.getContentSources().isEmpty()) { + if (syncRepo && !c.getSources().isEmpty()) { TaskFactory.createTask(user.getOrg(), RepoSyncTask.DISPLAY_NAME, - c.getContentSources().iterator().next().getId()); + c.getSources().iterator().next().getId()); }
// need to save before calling stored proc below
commit 23a9b2b76456c1a35dd28b117c06be5456ca3a4b Author: Shannon Hughes shughes@redhat.com Date: Thu May 6 15:22:55 2010 -0400
adding extra column to the rhnTaskQueue to allow tracking of many2many objects IDs
diff --git a/schema/spacewalk/common/tables/rhnTaskQueue.sql b/schema/spacewalk/common/tables/rhnTaskQueue.sql index 696bab2..6ee756d 100644 --- a/schema/spacewalk/common/tables/rhnTaskQueue.sql +++ b/schema/spacewalk/common/tables/rhnTaskQueue.sql @@ -20,11 +20,12 @@ CREATE TABLE rhnTaskQueue CONSTRAINT rhn_task_queue_org_id_fk REFERENCES web_customer (id) ON DELETE CASCADE, - task_name VARCHAR2(64) NOT NULL, - task_data NUMBER, - priority NUMBER + task_name VARCHAR2(64) NOT NULL, + task_data NUMBER, + task_data_two NUMBER, + priority NUMBER DEFAULT (0), - earliest DATE + earliest DATE DEFAULT (sysdate) NOT NULL ) ENABLE ROW MOVEMENT diff --git a/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/001-repo-sync.sql b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/001-repo-sync.sql index 740ff62..0244dfa 100644 --- a/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/001-repo-sync.sql +++ b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/001-repo-sync.sql @@ -1,6 +1,10 @@
ALTER table rhnChannelContentSource rename to rhnContentSource;
+ALTER table rhnTaskQueue +add task_data_two NUMBER; + + -- create new table for mapping channels and repos CREATE TABLE rhnChannelContentSource (
commit 8bd0d66e73ca1ba351c90d2aceda35f7daef214a Author: Shannon Hughes shughes@redhat.com Date: Wed May 5 16:43:29 2010 -0400
upgrade script for migrating channels from repo table to the new mapping table, rhnChannelContentSource
diff --git a/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/001-repo-sync.sql b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/001-repo-sync.sql index db959a5..740ff62 100644 --- a/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/001-repo-sync.sql +++ b/schema/spacewalk/upgrade/spacewalk-schema-1.0-to-spacewalk-schema-1.1/001-repo-sync.sql @@ -1 +1,45 @@ --- placeholder for repo sync migration + +ALTER table rhnChannelContentSource rename to rhnContentSource; + +-- create new table for mapping channels and repos +CREATE TABLE rhnChannelContentSource +( + source_id NUMBER NOT NULL + CONSTRAINT rhn_ccs_src_id_fk + REFERENCES rhnContentSource (id) + ON DELETE CASCADE, + channel_id NUMBER NOT NULL + CONSTRAINT rhn_ccs_cid_fk + REFERENCES rhnChannel (id) + ON DELETE CASCADE, + created DATE + DEFAULT (sysdate) NOT NULL, + modified DATE + DEFAULT (sysdate) NOT NULL +) +ENABLE ROW MOVEMENT +; + +-- add the contraints +ALTER TABLE rhnChannelContentSource + ADD CONSTRAINT rhn_ccs_uq UNIQUE (source_id, channel_id) + USING INDEX TABLESPACE [[4m_tbs]]; + +DECLARE + -- grab any rows that need the channel to be migrated to new channel content mapping tbl + CURSOR content is + select id, channel_id + from rhnContentSource + where 1=1 +BEGIN + FOR content_rec IN content + LOOP + INSERT INTO rhnChannelContentSource (source_id, channel_id) + VALUES (content_rec.id, content_rec.channel_id); + END LOOP; + commit; +END; +/ + +-- we don't need the channel_id column anymore since mapping table will handle it +ALTER TABLE rhnContentSource DROP (channel_id);
commit ed867d0c8d3f876f2fef425e245ce7686b09d45c Author: Shannon Hughes shughes@redhat.com Date: Wed May 5 16:16:34 2010 -0400
minor updates to Channel object to add repos
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 223d60e..e694f52 100644 --- a/java/code/src/com/redhat/rhn/domain/channel/Channel.java +++ b/java/code/src/com/redhat/rhn/domain/channel/Channel.java @@ -847,16 +847,18 @@ public class Channel extends BaseDomainHelper implements Comparable { return ChannelFactory.containsDistributions(this); }
- + /** + * + * @param sourceIn source repo to add + */ public void addYumContentSource(ContentSource sourceIn) { - + this.getSources().add(sourceIn); ChannelFactory.save(this); } -
/** * get the compatible checksum type to be used for repomd.xml - * based on channel release. + * 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
commit 6a5084d590a23441a4df45ecb8ce8488e36d5553 Author: Shannon Hughes shughes@redhat.com Date: Wed May 5 15:59:48 2010 -0400
initial hibernate changes to support many2many relationships of channel to repos
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 a73cef7..024bdee 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 @@ -70,15 +70,7 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
<one-to-one name="comps" property-ref="channel" class="com.redhat.rhn.domain.channel.Comps" cascade="all" lazy="proxy"/> - - <set name="contentSources" lazy="true" table="rhnChannelContentSource" - cascade="all-delete-orphan" inverse="true"> - <key column="channel_id"/> - <one-to-many - class="com.redhat.rhn.domain.channel.ContentSource" /> - </set> - - + <set name="trustedOrgs" lazy="true" table="rhnChannelTrust" cascade="save-update"> <key column="channel_id"/> @@ -104,6 +96,14 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" column="package_id"/> </set>
+ <set name="sources" lazy="true" table="rhnChannelContentSource" + cascade="save-update"> + <key column="channel_id"/> + <many-to-many + class="com.redhat.rhn.domain.channel.ContentSource" + column="source_id"/> + </set> + <many-to-one name="product" column="channel_product_id" class="com.redhat.rhn.domain.channel.ChannelProduct"/> 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 7eca2ef..223d60e 100644 --- a/java/code/src/com/redhat/rhn/domain/channel/Channel.java +++ b/java/code/src/com/redhat/rhn/domain/channel/Channel.java @@ -14,31 +14,30 @@ */ package com.redhat.rhn.domain.channel;
+import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.commons.lang.builder.ToStringBuilder; +import org.apache.log4j.Logger; + import com.redhat.rhn.domain.BaseDomainHelper; +import com.redhat.rhn.domain.common.ChecksumType; import com.redhat.rhn.domain.errata.Errata; 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;
-import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.log4j.Logger; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - /** * Channel * @version $Rev$ @@ -81,6 +80,7 @@ public class Channel extends BaseDomainHelper implements Comparable { private String summary; private Set erratas = new HashSet(); private Set packages = new HashSet(); + private Set<ContentSource> sources = new HashSet<ContentSource>(); private Set channelFamilies = new HashSet(); private Set distChannelMaps = new HashSet(); private Set trustedOrgs = new HashSet(); @@ -88,8 +88,6 @@ public class Channel extends BaseDomainHelper implements Comparable { private String maintainerEmail; private String maintainerPhone; private String supportPolicy; - private Set<ContentSource> contentSources = new HashSet(); -
/** * @param orgIn what org you want to know if it is globally subscribable in @@ -418,6 +416,23 @@ public class Channel extends BaseDomainHelper implements Comparable { }
/** + * + * @param sourcesIn The set of yum repo sources + */ + public void setSources(Set<ContentSource> sourcesIn) { + this.sources = sourcesIn; + } + + /** + * + * @return set of yum repos for this channel + */ + public Set<ContentSource> getSources() { + return sources; + } + + + /** * Adds a single package to the channel * @param packageIn The package to add * @deprecated @@ -831,49 +846,10 @@ public class Channel extends BaseDomainHelper implements Comparable { public boolean containsDistributions() { return ChannelFactory.containsDistributions(this); } - - /** - * @return Returns the contentSources. - */ - public Set<ContentSource> getContentSources() { - return contentSources; - }
- - /** - * @param contentSourcesIn The contentSources to set. - */ - public void setContentSources(Set<ContentSource> contentSourcesIn) { - this.contentSources = contentSourcesIn; - } - - /** - * Set the yum content source, if one is already set, it will be replaced - * if null or '' is passed in, all content sources will be removed. - * @param url the url of the yum repo - * @param labelIn the label of the content source - */ - public void setYumContentSource(String url, String labelIn) { - if (StringUtils.isEmpty(url)) { - if (!this.getContentSources().isEmpty()) { - this.getContentSources().clear(); - } - } - else { - if (this.getContentSources().isEmpty()) { - ContentSource cs = new ContentSource(); - cs.setChannel(this); - cs.setSourceUrl(url); - cs.setLabel(labelIn); - cs.setType(ChannelFactory.CONTENT_SOURCE_TYPE_YUM); - this.getContentSources().add(cs); - } - else { - ContentSource cs = this.getContentSources().iterator().next(); - cs.setSourceUrl(url); - cs.setLabel(labelIn); - } - } + + public void addYumContentSource(ContentSource sourceIn) { + ChannelFactory.save(this); }
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 d6598e3..29f8a77 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 @@ -24,9 +24,17 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" name="type" class="com.redhat.rhn.domain.channel.ContentSourceType" column="type_id"/> - + + <set name="channels" lazy="true" table="rhnChannelContentSource" + cascade="save-update"> + <key column="source_id"/> + <many-to-many + class="com.redhat.rhn.domain.channel.Channel" + column="channel_id"/> + </set> + </class> - +
<query name="ContentSource.findById"> <![CDATA[from com.redhat.rhn.domain.channel.ContentSource as c where c.id = :id]]> diff --git a/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java b/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java index 6624c05..cb48616 100644 --- a/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java +++ b/java/code/src/com/redhat/rhn/domain/channel/ContentSource.java @@ -14,9 +14,11 @@ */ package com.redhat.rhn.domain.channel;
-import com.redhat.rhn.domain.BaseDomainHelper; - import java.util.Date; +import java.util.HashSet; +import java.util.Set; + +import com.redhat.rhn.domain.BaseDomainHelper;
/** * ContentSourceType @@ -30,9 +32,7 @@ public class ContentSource extends BaseDomainHelper { private String sourceUrl; private Date lastSynced; private String label; - - - + private Set<Channel> channels = new HashSet<Channel>(); /** * @return Returns the label. */ @@ -126,6 +126,20 @@ public class ContentSource extends BaseDomainHelper { this.lastSynced = lastSyncedIn; }
- + /** + * + * @param set of channels this repo is pushed to + */ + public void setChannels(Set<Channel> channelsIn) { + this.channels = channelsIn; + } + + /** + * + * @return set of channels that this repo will be pushed to + */ + public Set<Channel> getChannels() { + return channels; + }
}
commit 2f42179c004f24d65cf7b37f528b387631c9f963 Author: Shannon Hughes shughes@redhat.com Date: Wed May 5 15:22:39 2010 -0400
hibernate changes for existing content source objects
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 fd8edd2..d6598e3 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 @@ -4,7 +4,7 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd%22%3E <hibernate-mapping> <class name="com.redhat.rhn.domain.channel.ContentSource" - table="rhnChannelContentSource" > + table="rhnContentSource" >
<id name="id" type="long" column="id"> <meta attribute="scope-set">protected</meta> @@ -24,12 +24,6 @@ PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" name="type" class="com.redhat.rhn.domain.channel.ContentSourceType" column="type_id"/> - - <many-to-one - name="channel" - class="com.redhat.rhn.domain.channel.Channel" - column="channel_id" /> -
</class>
commit 9cd3597540fae13a943606e35dc9ec1afd296808 Author: Shannon Hughes shughes@redhat.com Date: Wed May 5 14:42:27 2010 -0400
initial table for mapping channel ids to content sources (yum repos)
diff --git a/schema/spacewalk/common/tables/rhnChannelContentSource.sql b/schema/spacewalk/common/tables/rhnChannelContentSource.sql new file mode 100644 index 0000000..30d8e37 --- /dev/null +++ b/schema/spacewalk/common/tables/rhnChannelContentSource.sql @@ -0,0 +1,38 @@ +-- +-- Copyright (c) 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. +-- +-- +-- +-- +CREATE TABLE rhnChannelContentSource +( + source_id NUMBER NOT NULL + CONSTRAINT rhn_ccs_src_id_fk + REFERENCES rhnContentSource (id) + ON DELETE CASCADE, + channel_id NUMBER NOT NULL + CONSTRAINT rhn_ccs_cid_fk + REFERENCES rhnChannel (id) + ON DELETE CASCADE, + created DATE + DEFAULT (sysdate) NOT NULL, + modified DATE + DEFAULT (sysdate) NOT NULL +) +ENABLE ROW MOVEMENT +; + +ALTER TABLE rhnChannelContentSource + ADD CONSTRAINT rhn_ccs_uq UNIQUE (source_id, channel_id) + USING INDEX TABLESPACE [[4m_tbs]];
commit a38e77959a76a20754c7c8b9da19d9085025fc7a Author: Shannon Hughes shughes@redhat.com Date: Wed May 5 14:20:07 2010 -0400
renaming to contentsource since we are moving channel out to a new mapping table named rhnChannelContentSource
diff --git a/schema/spacewalk/common/tables/rhnChannelContentSource.sql b/schema/spacewalk/common/tables/rhnChannelContentSource.sql deleted file mode 100644 index 09a585e..0000000 --- a/schema/spacewalk/common/tables/rhnChannelContentSource.sql +++ /dev/null @@ -1,53 +0,0 @@ --- --- 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. --- --- --- --- - -create table -rhnChannelContentSource -( - id number NOT NULL - constraint rhn_ccs_id_pk primary key, - channel_id number NOT NULL - constraint rhn_ccs_c_fk - references rhnChannel(id) on delete cascade, - type_id number NOT NULL - constraint rhn_ccs_type_fk - references rhnContentSourceType(id), - source_url varchar2(512) NOT NULL, - label varchar2(64) NOT NULL, - last_synced date, - created date default(sysdate) NOT NULL, - modified date default(sysdate) NOT NULL -) - enable row movement - ; - - -create sequence rhn_chan_content_src_id_seq start with 500; - - -create unique index rhn_ccs_uq - on rhnChannelContentSource(channel_id, type_id, source_url) - tablespace [[64k_tbs]] - ; - -/ - --- --- Revision 1.0 2009/06/26 21:54 jlsherrill --- Initial file. --- diff --git a/schema/spacewalk/common/tables/rhnContentSource.sql b/schema/spacewalk/common/tables/rhnContentSource.sql new file mode 100644 index 0000000..c4914fd --- /dev/null +++ b/schema/spacewalk/common/tables/rhnContentSource.sql @@ -0,0 +1,50 @@ +-- +-- 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. +-- +-- +-- +-- + +create table +rhnContentSource +( + id number NOT NULL + constraint rhn_ccs_id_pk primary key, + type_id number NOT NULL + constraint rhn_ccs_type_fk + references rhnContentSourceType(id), + source_url varchar2(512) NOT NULL, + label varchar2(64) NOT NULL, + last_synced date, + created date default(sysdate) NOT NULL, + modified date default(sysdate) NOT NULL +) + enable row movement + ; + + +create sequence rhn_chan_content_src_id_seq start with 500; + + +create unique index rhn_ccs_uq + on rhnContentSource(channel_id, type_id, source_url) + tablespace [[64k_tbs]] + ; + +/ + +-- +-- Revision 1.0 2009/06/26 21:54 jlsherrill +-- Initial file. +--
spacewalk-commits@lists.fedorahosted.org