summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaria Odea B. Ching <oching@apache.org>2009-12-15 17:50:10 +0000
committerMaria Odea B. Ching <oching@apache.org>2009-12-15 17:50:10 +0000
commit7250b799d092891556f8e1fb42f4d8223ce25d3b (patch)
treec6dcabb95d8ca92238900718e2a56e61e34efebc
parent3078e1af860b8ab78ff042d628505317c428899e (diff)
downloadarchiva-7250b799d092891556f8e1fb42f4d8223ce25d3b.tar.gz
archiva-7250b799d092891556f8e1fb42f4d8223ce25d3b.zip
[MRM-1296] Audit Log Report
o fixed pagination o prettify report UI git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1296@890916 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ViewAuditLogReportAction.java131
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/auditLogReport.jsp163
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/main/webapp/css/site.css44
3 files changed, 240 insertions, 98 deletions
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ViewAuditLogReportAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ViewAuditLogReportAction.java
index 24a8ed197..3b4c11546 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ViewAuditLogReportAction.java
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/reports/ViewAuditLogReportAction.java
@@ -24,10 +24,11 @@ import java.util.Calendar;
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 @@ public class ViewAuditLogReportAction
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 @@ public class ViewAuditLogReportAction
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 @@ public class ViewAuditLogReportAction
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 @@ public class ViewAuditLogReportAction
{
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 @@ public class ViewAuditLogReportAction
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 @@ public class ViewAuditLogReportAction
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 @@ public class ViewAuditLogReportAction
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 @@ public class ViewAuditLogReportAction
{
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;
+ }
}
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/auditLogReport.jsp b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/auditLogReport.jsp
index ece7ca95c..664f8e7fa 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/auditLogReport.jsp
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/reports/auditLogReport.jsp
@@ -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>
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/css/site.css b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/css/site.css
index a68b439a2..996614608 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/css/site.css
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/css/site.css
@@ -435,4 +435,46 @@ div.versions {
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;
+}
+
+
+
+