archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From och...@apache.org
Subject svn commit: r890916 - in /archiva/branches/MRM-1296/archiva-modules/archiva-web/archiva-webapp/src/main: java/org/apache/maven/archiva/web/action/reports/ViewAuditLogReportAction.java webapp/WEB-INF/jsp/reports/auditLogReport.jsp webapp/css/site.css
Date Tue, 15 Dec 2009 17:50:11 GMT
Author: oching
Date: Tue Dec 15 17:50:10 2009
New Revision: 890916

URL: http://svn.apache.org/viewvc?rev=890916&view=rev
Log:
[MRM-1296] Audit Log Report
o fixed pagination
o prettify report UI

Modified:
    archiva/branches/MRM-1296/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ViewAuditLogReportAction.java
    archiva/branches/MRM-1296/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/auditLogReport.jsp
    archiva/branches/MRM-1296/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/css/site.css

Modified: archiva/branches/MRM-1296/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ViewAuditLogReportAction.java
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-1296/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ViewAuditLogReportAction.java?rev=890916&r1=890915&r2=890916&view=diff
==============================================================================
--- archiva/branches/MRM-1296/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ViewAuditLogReportAction.java
(original)
+++ archiva/branches/MRM-1296/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ViewAuditLogReportAction.java
Tue Dec 15 17:50:10 2009
@@ -24,10 +24,11 @@
 import java.util.Collections;
 import java.util.Date;
 import java.util.List;
-import java.util.regex.Pattern;
 
 import javax.servlet.http.HttpServletRequest;
 
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.time.DateUtils;
 import org.apache.maven.archiva.database.ArchivaAuditLogsDao;
 import org.apache.maven.archiva.database.ArchivaDAO;
 import org.apache.maven.archiva.database.ArchivaDatabaseException;
@@ -82,10 +83,10 @@
 
     private String artifactId;
 
-    private Date startDate;
-
-    private Date endDate;
+    private String startDate;
 
+    private String endDate;
+    
     private int rowCount = 30;
 
     private int page = 1;
@@ -101,6 +102,18 @@
     private static final String ALL_REPOSITORIES = "all";
 
     protected int[] range = new int[2];
+    
+    private String initial = "true";
+    
+    private String headerName;
+    
+    private static final String HEADER_LATEST_EVENTS = "Latest Events";
+    
+    private static final String HEADER_RESULTS = "Results";
+    
+    private String[] datePatterns = new String[] { "MM/dd/yy", "MM/dd/yyyy", "MMMMM/dd/yyyy",
"MMMMM/dd/yy", 
+        "dd MMMMM yyyy", "dd/MM/yy", "dd/MM/yyyy", "yyyy/MM/dd", "yyyy-MM-dd", "yyyy-dd-MM",
"MM-dd-yyyy",
+        "MM-dd-yy" };
 
     public SecureActionBundle getSecureActionBundle()
         throws SecureActionException
@@ -125,6 +138,15 @@
         groupId = "";
         artifactId = "";
         repository = "";
+                
+        if( Boolean.parseBoolean( initial ) )
+        {
+            headerName = HEADER_LATEST_EVENTS;
+        }
+        else
+        {
+            headerName = HEADER_RESULTS;
+        }
 
         SimpleConstraint constraint = new MostRecentArchivaAuditLogsConstraint();
         auditLogs = (List<ArchivaAuditLogs>) dao.query( constraint );
@@ -144,44 +166,72 @@
         {               
             artifact = ( artifactId != null  && !"".equals( artifactId.trim() ) )
? ( "%:" + artifactId + ":%" ) : "";
         }        
-        
-        if ( startDate == null )
-        {
+                
+        Date startDateInDF = null;
+        Date endDateInDF = null;        
+        if ( startDate == null || "".equals( startDate ) )
+        {            
             Calendar cal = Calendar.getInstance();
             cal.set( Calendar.HOUR, 0 );
             cal.set( Calendar.MINUTE, 0 );
             cal.set( Calendar.SECOND, 0 );
 
-            startDate = cal.getTime();
+            startDateInDF = cal.getTime();
+        }
+        else
+        {
+            startDateInDF = DateUtils.parseDate( startDate, datePatterns );
         }
 
-        if ( startDate.equals( endDate ) || endDate == null )
+        if ( endDate == null || "".equals( endDate ) )
         {
-            endDate = Calendar.getInstance().getTime();
+            endDateInDF = Calendar.getInstance().getTime();
+        } 
+        else
+        {
+            endDateInDF = DateUtils.parseDate( endDate, datePatterns );     
+            if( endDate.equals( startDate ) )
+            {
+                Calendar cal = Calendar.getInstance();
+                cal.setTime( endDateInDF );
+                cal.set( Calendar.HOUR, 23 );
+                cal.set( Calendar.MINUTE, 59 );
+                cal.set( Calendar.SECOND, 59 );
+                
+                endDateInDF = cal.getTime();
+            }
         }
 
         range[0] = ( page - 1 ) * rowCount;
         range[1] = ( page * rowCount ) + 1;
-
+        
         ArchivaAuditLogsConstraint constraint = null;
         if ( !repository.equals( ALL_REPOSITORIES ) )
         {
             constraint =
-                new ArchivaAuditLogsConstraint( range, artifact, repository, AuditEvent.UPLOAD_FILE,
startDate, endDate );
+                new ArchivaAuditLogsConstraint( range, artifact, repository, AuditEvent.UPLOAD_FILE,
startDateInDF, endDateInDF );
         }
         else
         {
             constraint =
-                new ArchivaAuditLogsConstraint( range, artifact, null, AuditEvent.UPLOAD_FILE,
startDate, endDate );
+                new ArchivaAuditLogsConstraint( range, artifact, null, AuditEvent.UPLOAD_FILE,
startDateInDF, endDateInDF );
         }
 
         try
         {
-            auditLogs = auditLogsDao.queryAuditLogs( constraint );
+            auditLogs = auditLogsDao.queryAuditLogs( constraint );            
             if( auditLogs.isEmpty() )
             {
                 addActionError( "No audit logs found." );
+                initial = "true";                
+            }
+            else
+            {   
+                initial = "false";
             }
+            
+            headerName = HEADER_RESULTS;         
+            paginate();
         }
         catch ( ObjectNotFoundException e )
         {
@@ -193,31 +243,34 @@
             addActionError( "Error occurred while querying audit logs." );
             return ERROR;
         }
-        
-        // pagination
-        paginate();
-
-        startDate = null;
-        endDate = null;
 
         return SUCCESS;
     }
-
+    
     private void paginate()
     {
         if ( auditLogs.size() <= rowCount )
         {
             isLastPage = true;
         }
+        else
+        {   
+            isLastPage = false;
+            auditLogs.remove( rowCount );
+        }
 
         prev =
             request.getRequestURL() + "?page=" + ( page - 1 ) + "&rowCount=" + rowCount
+ "&groupId=" + groupId +
-                "&artifactId=" + artifactId + "&repositoryId=" + repository + "&startDate="
+ startDate + "&endDate=" +
+                "&artifactId=" + artifactId + "&repository=" + repository + "&startDate="
+ startDate + "&endDate=" +
                 endDate;
+        
         next =
             request.getRequestURL() + "?page=" + ( page + 1 ) + "&rowCount=" + rowCount
+ "&groupId=" + groupId +
-                "&artifactId=" + artifactId + "&repositoryId=" + repository + "&startDate="
+ startDate + "&endDate=" +
+                "&artifactId=" + artifactId + "&repository=" + repository + "&startDate="
+ startDate + "&endDate=" +
                 endDate;
+        
+        prev = StringUtils.replace( prev, " ", "%20" );
+        next = StringUtils.replace( next, " ", "%20" );
     }
 
     private List<String> getObservableRepositories()
@@ -301,22 +354,22 @@
         this.rowCount = rowCount;
     }
 
-    public Date getStartDate()
+    public String getStartDate()
     {
         return startDate;
     }
 
-    public void setStartDate( Date startDate )
+    public void setStartDate( String startDate )
     {
         this.startDate = startDate;
     }
 
-    public Date getEndDate()
+    public String getEndDate()
     {
         return endDate;
     }
 
-    public void setEndDate( Date endDate )
+    public void setEndDate( String endDate )
     {
         this.endDate = endDate;
     }
@@ -331,12 +384,12 @@
         this.page = page;
     }
 
-    public boolean isLastPage()
+    public boolean getIsLastPage()
     {
         return isLastPage;
     }
 
-    public void setLastPage( boolean isLastPage )
+    public void setIsLastPage( boolean isLastPage )
     {
         this.isLastPage = isLastPage;
     }
@@ -360,4 +413,24 @@
     {
         this.next = next;
     }
+    
+    public String getInitial()
+    {
+        return initial;
+    }
+
+    public void setInitial( String initial )
+    {
+        this.initial = initial;
+    }
+
+    public String getHeaderName()
+    {
+        return headerName;
+    }
+
+    public void setHeaderName( String headerName )
+    {
+        this.headerName = headerName;
+    }
 }

Modified: archiva/branches/MRM-1296/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/auditLogReport.jsp
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-1296/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/auditLogReport.jsp?rev=890916&r1=890915&r2=890916&view=diff
==============================================================================
--- archiva/branches/MRM-1296/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/auditLogReport.jsp
(original)
+++ archiva/branches/MRM-1296/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/auditLogReport.jsp
Tue Dec 15 17:50:10 2009
@@ -46,79 +46,106 @@
   
   <s:form action="viewAuditLogReport" namespace="/report" validate="false">
      
-    <p>
-    <s:actionerror/>
-    </p>
-   
+    <s:hidden name="initial"/>
+    
     <div id="auditLogReport"> 	
-	   	<s:select label="Repository" name="repository" list="repositories"/>
-	   	
-	   	<s:textfield label="Group ID" id="groupId" name="groupId"/>
-	   	
-	   	<s:textfield label="Artifact ID" id="artifactId" name="artifactId"/>
-	   	
-		<s:textfield label="Start Date" id="startDate" name="startDate"/>	      
-	    <%--
-	    <script type="text/javascript">
-	      Calendar.setup({
-	        inputField     :    "startDate",     
-	        ifFormat       :    "%Y-%m-%d",             
-	        align          :    "Tl",           
-	        singleClick    :    true
-	      });
-	    </script>
-	    --%>
-		
-		<s:textfield label="End Date" id="endDate" name="endDate"/>
-		<%--
-		<script type="text/javascript">
-	      Calendar.setup({
-	        inputField     :    "endDate",     
-	        ifFormat       :    "%Y-%m-%d",             
-	        align          :    "Tl",           
-	        singleClick    :    true
-	      });
-	    </script>
-		--%>    
-		
-		<s:textfield label="Row Count" name="rowCount" />
-		
-	    <s:submit value="View Audit Log"/>
-	    
-	    <s:set name="page" value="page"/>
-      	<c:if test="${page > 1}"><a href="<s:property value='prev' />">&lt;&lt;</a></c:if>
-		  Page: ${page}
-		<s:set name="isLastPage" value="isLastPage"/>
-		<c:if test="${!isLastPage}"><a href="<s:property value='next' />">&gt;&gt;</a></c:if>
    
-      
+        <table id="auditLogFieds">
+          <tbody>
+            <tr>
+	   	      <td>Repository: </td>
+	   	      <td><s:select name="repository" list="repositories" theme="simple"/></td>
+	   	    <tr>
+	   	    <tr>
+	   	      <td>Group ID: </td>
+	   	      <td><s:textfield id="groupId" name="groupId" theme="simple"/></td>
+	   	    <tr>
+	   	    <tr>
+	   	      <td>Artifact ID: </td>
+	   	      <td><s:textfield id="artifactId" name="artifactId" theme="simple"/></td>
+	   	    <tr>
+	   	    <tr>
+	   	      <td>Start Date: </td>
+	   	      <td><s:textfield id="startDate" name="startDate" theme="simple"/>
      
+			    <%--
+			    <script type="text/javascript">
+			      Calendar.setup({
+			        inputField     :    "startDate",     
+			        ifFormat       :    "%Y-%m-%d",             
+			        align          :    "Tl",           
+			        singleClick    :    true
+			      });
+			    </script>
+			    --%>
+	    	  </td>
+	   	    <tr>
+	   	    <tr>
+	   	      <td>End Date: </td>
+	   	      <td><s:textfield id="endDate" name="endDate" theme="simple"/>
+				<%--
+				<script type="text/javascript">
+			      Calendar.setup({
+			        inputField     :    "endDate",     
+			        ifFormat       :    "%Y-%m-%d",             
+			        align          :    "Tl",           
+			        singleClick    :    true
+			      });
+			    </script>
+				--%>    		
+	    	  </td>
+	   	    <tr>
+	   	    <tr>
+	   	      <td>Row Count: </td>
+	   	      <td><s:textfield name="rowCount" theme="simple"/></td>
+	   	    <tr>
+	   	    <tr>
+	   	      <td/>
+	   	      <td style="text-align: right"><s:submit value="View Audit Log" theme="simple"/></td>
+	   	    </tr>
+	   	  </tbody>
+	   	</table>	
     </div>    
+    
+    <p/>
+    
+    <div class="auditLogReportResults">
+    
+    <h2>${headerName}</h2>
+      <p>
+        <s:actionerror/>
+      </p>
+        
+	    <c:if test="${not empty (auditLogs)}">  
+		  <table class="auditlogs" cellspacing="0">
+	         <tr>
+		        <th>Event</th>
+		        <th>Repository</th>
+		        <th>Artifact</th>
+		        <th>Event Date</th>
+		        <th>Username</th>
+		      </tr>
+		    
+		    <c:forEach items="${auditLogs}" var="auditLog" varStatus="i">	    
+		      <tr>
+		        <td>${auditLog.event}</td>
+		        <td>${auditLog.repositoryId}</td>
+		        <td>${auditLog.artifact}</td>
+		        <td>${auditLog.eventDate}</td>
+		        <td>${auditLog.username}</td>
+		      </tr>		    
+		    </c:forEach>
+		  </table>	
+		  
+		  <s:set name="page" value="page"/>
+	      <c:if test="${page > 1}"><a href="<s:property value='prev' />">&lt;&lt;</a></c:if>
+			  <strong>Page: </strong>${page}
+		  <s:set name="isLastPage" value="isLastPage"/>		  
+		  <c:if test="${!isLastPage}"><a href="<s:property value='next' />">&gt;&gt;</a></c:if>
+		</c:if>  
+	</div>
    
   </s:form>
     
-  <c:if test="${not empty (auditLogs)}">
-	  <table border="1" cellpadding="5" cellspacing="5" width="100%">
-        <thead>
-	      <tr>
-	        <th style="text-align:center">Event</th>
-	        <th style="text-align:center">Repository</th>
-	        <th style="text-align:center">Artifact</th>
-	        <th style="text-align:center">Event Date</th>
-	        <th style="text-align:center">Username</th>
-	      </tr>
-	    </thead>
-	    <c:forEach items="${auditLogs}" var="auditLog" varStatus="i">
-	    <tbody>
-	      <tr>
-	        <td>${auditLog.event}</td>
-	        <td>${auditLog.repositoryId}</td>
-	        <td>${auditLog.artifact}</td>
-	        <td>${auditLog.eventDate}</td>
-	        <td>${auditLog.username}</td>
-	      </tr>
-	    </tbody>
-	    </c:forEach>
-	  </table>	 
-	</c:if>  
+  
 </div>
 
 </body>

Modified: archiva/branches/MRM-1296/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/css/site.css
URL: http://svn.apache.org/viewvc/archiva/branches/MRM-1296/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/css/site.css?rev=890916&r1=890915&r2=890916&view=diff
==============================================================================
--- archiva/branches/MRM-1296/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/css/site.css
(original)
+++ archiva/branches/MRM-1296/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/css/site.css
Tue Dec 15 17:50:10 2009
@@ -435,4 +435,46 @@
 div.versions a.expand {
     font-size: 7pt;
 	color: gray;	
-}
\ No newline at end of file
+}
+
+table.auditlogs {
+	text-align: center;
+	font-family: Verdana, Geneva, Arial, Helvetica, sans-serif ;
+	font-weight: normal;
+	font-size: 11px;
+	color: #fff;
+	width: 100%;
+	background-color: #666;
+	border: 0px;
+	border-collapse: collapse;
+	border-spacing: 0px;
+}
+
+table.auditlogs th {
+	background-color: #666;
+	color: #fff;
+	padding: 4px;
+	text-align: center;
+	border-bottom: 2px #fff solid;
+	font-size: 12px;
+	font-weight: bold;
+}
+
+table.auditlogs td {
+	background-color: #CCC;
+	color: #000;
+	padding: 4px;
+	text-align: center;
+	border: 1px #fff solid;
+}
+
+div.auditLogReportResults {
+	border: 1px dashed #DFDEDE;
+	margin-bottom: 15px;
+	margin-left: 2px;
+	padding: 5px;
+}
+
+
+
+



Mime
View raw message