On 20 April 2010 15:47, Tomas Lestach <[email protected]> wrote:
>
>
>
>
> --
> Tomas Lestach
> RHN Satellite Engineering, Red Hat
>
> ----- "James Hogarth" <[email protected]> wrote:
>
>> Hi all,
>>
>> This is my first time trying to follow through the code and
>> contribute
>> to the codebase.
>>
>> >From my perspective the ability via the XML-RPC API to get the last
>> repo modified date (and possibly whether a build would be in
>> progress)
>> would be extremely useful to us.
>
> Hello James,
>
> I think this is wonderful idea! It might be helpful for more people.
>
>>
>> The idea being that after an RPM is built via a build system and
>> pushed via rhnpush there is not (as far as I know) a way via the API
>> to check when the repodata actually gets updated.
>>
>> As a result I have had a couple of times when a deploy of the new RPM
>> for our application is meant to be carried out but the repodata
>> hasn't
>> quite been built yet resulting in wasted time and another RPM
>> deployment later.
>>
>> I'm thinking adding this to
>> java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/ChannelSoftwareHandler.java
>> within the ChannelSoftwareHandler class *could* provide at least part
>> of that info...
>>
>>  /**
>>     * Returns the last build date on the repodata for a channel
>>     * @param sessionKey WebSession containing User information.
>>     * @param id - id of channel wanted
>>     * @throws NoSuchChannelException thrown if no channel is found.
>>     * @return the build date on the repodata of the channel requested
>>     */
>>
>>    public String getChannelLastBuildById(String sessionKey, Integer
>> id)
>>         throws NoSuchChannelException {
>>          User user = getLoggedInUser(sessionKey);
>>          return
>> ChannelManager.getRepoLastBuild(lookupChannelById(user,id));
>>    }
>>
>>
>
> I've already applied your patch with one single change ...
> (because getRepoLastBuild() may return null -> no repo will be generated for 
> empty channels)
>
> http://git.fedorahosted.org/git/?p=spacewalk.git;a=commitdiff;h=6519f98fe579244ead774895b50f46c5a0d1f334
>
> Thank you!
>
>> I'm a sysadmin by trade and only dabble in code at this point....
>>
>> Does it at least look like I'm on the right track for a proper patch
>> to be submitted?
>
> Yes, the patch looks very good.
> Usually patches are sent as output of `git format-patch`. Otherwise no 
> objections. :-)
>
>
> Best Regards,
> Tomas
>
>> Incidentally whilst I'm looking at this code anyway.... I've noticed
>> that ChannelDetail shows a 12 hour date for last repo build and last
>> modified a 24 hour date.... any ideas?
>>
>> James
>>
>> _______________________________________________
>> Spacewalk-devel mailing list
>> [email protected]
>> https://www.redhat.com/mailman/listinfo/spacewalk-devel
>
> _______________________________________________
> Spacewalk-devel mailing list
> [email protected]
> https://www.redhat.com/mailman/listinfo/spacewalk-devel
>

I'm more used to subversion than git... having troubles with getting
any output from git format-patch on ubuntu lucid ...

Attached is a `git diff` output with your revision and the changes to
documentation too...

There is a test included but I'm not sure how useful it would be...

Wahoo! My first code inclusion! ;)

Thanks for the feedback Tomas... hopefully over time I'll be able to
contribute more as Spacewalk gets put to further use here....

Kind regards,

James
diff --git a/documentation/javadoc/com/redhat/rhn/frontend/xmlrpc/channel/software/ChannelSoftwareHandler.html b/documentation/javadoc/com/redhat/rhn/frontend/xmlrpc/channel/software/ChannelSoftwareHandler.html
index a46a0ef..3d0650b 100644
--- a/documentation/javadoc/com/redhat/rhn/frontend/xmlrpc/channel/software/ChannelSoftwareHandler.html
+++ b/documentation/javadoc/com/redhat/rhn/frontend/xmlrpc/channel/software/ChannelSoftwareHandler.html
@@ -204,6 +204,17 @@ ChannelSoftwareHandler
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the details of the given channel as a map with the following
  keys:</TD>
 </TR>
+
+<TR BGCOLOR="white" CLASS="TableRowColor">
+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
+<CODE>&nbsp;String</CODE></FONT></TD>
+<TD><CODE><B><A HREF="../../../../../../../com/redhat/rhn/frontend/xmlrpc/channel/software/ChannelSoftwareHandler.html#getChannelLastBuildById(java.lang.String, java.lang.Integer)">getChannelLastBuildById</A></B>(java.lang.String&nbsp;sessionKey,
+           java.lang.Integer&nbsp;channelId)</CODE>
+
+<BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns the last build date of the repomd.xml file for the given Channel ID as a localised string.</TD>
+</TR>
+
 <TR BGCOLOR="white" CLASS="TableRowColor">
 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 <CODE>&nbsp;int</CODE></FONT></TD>
@@ -708,6 +719,25 @@ public <A HREF="../../../../../../../com/redhat/rhn/domain/channel/Channel.html"
 </DL>
 <HR>
 
+<A NAME="getChannelLastBuildById(java.lang.String, java.lang.Integer)"><!-- --></A><H3>
+getChannelLastBuildById</H3>
+<PRE>
+public String <B>getChannelLastBuildById</B>(java.lang.String&nbsp;sessionKey,
+                          java.lang.Integer&nbsp;id)
+                   throws <A HREF="../../../../../../../com/redhat/rhn/frontend/xmlrpc/NoSuchChannelException.html" title="class in com.redhat.rhn.frontend.xmlrpc">NoSuchChannelException</A></PRE>
+<DL>
+<DD>Returns the last build date of the repomd.xml file for the given Channel ID as a localised string.
+<P>
+<DD><DL>
+<DT><B>Parameters:</B><DD><CODE>sessionKey</CODE> - WebSession containing User information.<DD><CODE>id</CODE> - - id of channel wanted
+<DT><B>Returns:</B><DD>the last build date of the repomd.xml file for the given Channel ID as a localised string.
+<DT><B>Throws:</B>
+<DD><CODE><A HREF="../../../../../../../com/redhat/rhn/frontend/xmlrpc/NoSuchChannelException.html" title="class in com.redhat.rhn.frontend.xmlrpc">NoSuchChannelException</A></CODE> - thrown if no channel is found.</DL>
+</DD>
+</DL>
+<HR>
+
+
 <A NAME="availableEntitlements(java.lang.String, java.lang.String)"><!-- --></A><H3>
 availableEntitlements</H3>
 <PRE>
diff --git a/documentation/javadoc/com/redhat/rhn/frontend/xmlrpc/channel/software/test/ChannelSoftwareHandlerTest.html b/documentation/javadoc/com/redhat/rhn/frontend/xmlrpc/channel/software/test/ChannelSoftwareHandlerTest.html
index 94883eb..bf26be7 100644
--- a/documentation/javadoc/com/redhat/rhn/frontend/xmlrpc/channel/software/test/ChannelSoftwareHandlerTest.html
+++ b/documentation/javadoc/com/redhat/rhn/frontend/xmlrpc/channel/software/test/ChannelSoftwareHandlerTest.html
@@ -252,6 +252,14 @@ ChannelSoftwareHandlerTest
 <TR BGCOLOR="white" CLASS="TableRowColor">
 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
 <CODE>&nbsp;void</CODE></FONT></TD>
+<TD><CODE><B><A HREF="../../../../../../../../com/redhat/rhn/frontend/xmlrpc/channel/software/test/ChannelSoftwareHandlerTest.html#testGetChannelLastBuildById()">testGetChannelLastBuildById</A></B>()</CODE>
+
+<BR>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>
+</TR>
+<TR BGCOLOR="white" CLASS="TableRowColor">
+<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
+<CODE>&nbsp;void</CODE></FONT></TD>
 <TD><CODE><B><A HREF="../../../../../../../../com/redhat/rhn/frontend/xmlrpc/channel/software/test/ChannelSoftwareHandlerTest.html#testInvalidChannelNameAndLabel()">testInvalidChannelNameAndLabel</A></B>()</CODE>
 
 <BR>
@@ -628,6 +636,21 @@ public void <B>testGetDetails</B>()
 </DL>
 <HR>
 
+<A NAME="testGetChannelLastBuildById()"><!-- --></A><H3>
+testGetDetails</H3>
+<PRE>
+public void <B>testGetChannelLastBuildById</B>()
+                    throws java.lang.Exception</PRE>
+<DL>
+<DD><DL>
+
+<DT><B>Throws:</B>
+<DD><CODE>java.lang.Exception</CODE></DL>
+</DD>
+</DL>
+<HR>
+
+
 <A NAME="testCreate()"><!-- --></A><H3>
 testCreate</H3>
 <PRE>
diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/ChannelSoftwareHandler.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/ChannelSoftwareHandler.java
index 6dc7317..785c06c 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/ChannelSoftwareHandler.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/ChannelSoftwareHandler.java
@@ -488,7 +488,25 @@ public class ChannelSoftwareHandler extends BaseHandler {
         User user = getLoggedInUser(sessionKey);
         return lookupChannelById(user, id);        
     }
-    
+
+   /**
+    * Returns the last build date on the repodata for a channel
+    * @param sessionKey WebSession containing User information.
+    * @param id - id of channel wanted
+    * @throws NoSuchChannelException thrown if no channel is found.
+    * @return the build date on the repodata of the channel requested
+    */    
+   public String getChannelLastBuildById(String sessionKey, Integer id)
+	throws NoSuchChannelException {
+         User user = getLoggedInUser(sessionKey);
+	String repoLastBuild =
+                ChannelManager.getRepoLastBuild(lookupChannelById(user, id));
+        if (repoLastBuild == null) {
+            return "";
+        }
+        return repoLastBuild;
+    }
+   }
     
     /**
      * Returns the number of available subscriptions for the given channel
diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/test/ChannelSoftwareHandlerTest.java b/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/test/ChannelSoftwareHandlerTest.java
index 13eca8e..69923c3 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/test/ChannelSoftwareHandlerTest.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/channel/software/test/ChannelSoftwareHandlerTest.java
@@ -466,6 +466,16 @@ public class ChannelSoftwareHandlerTest extends BaseHandlerTestCase {
         result = csh.getDetails(adminKey, c.getId().intValue());
         channelDetailsEquality(c, result);
     }
+   
+   public void testGetChannelLastBuildById() throws Exception {
+	ChannelSoftwareHandler csh = new ChannelSoftwareHandler();
+        addRole(admin, RoleFactory.CHANNEL_ADMIN);
+        Channel c = ChannelFactoryTest.createTestChannel(admin);
+        assertNotNull(c);
+        String lastRepoBuild = csh.getChannelLastBuildById(adminKey, c.getId());
+	assertEquals(lastRepoBuild, "");
+    }
+
 
     private void channelDetailsEquality(Channel original, Channel result) {
         assertNotNull(result);
_______________________________________________
Spacewalk-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Reply via email to