Commit 21ea2f09 authored by sashah's avatar sashah
Browse files

remove multiple corrupt files

git-svn-id: https://subversion.umiacs.umd.edu/ace/trunk@144 f1b3a171-7291-4a19-a512-95ad0ad9394a
parent 8895dbea
......@@ -58,12 +58,14 @@ public class RemoveItemServlet extends EntityManagerServlet {
public static final String PARAM_REDIRECT = "redirect";
public static final String DEFAULT_REDIRECT = "browse.jsp";
public static final String REMOVAL = "removal";
private static final Logger LOG = Logger.getLogger(RemoveItemServlet.class);
@Override
protected void processRequest( HttpServletRequest request,
HttpServletResponse response, EntityManager em ) throws ServletException, IOException {
MonitoredItem item;
long[] itemIds;
HttpSession session = request.getSession();
DirectoryTree dt =
(DirectoryTree) session.getAttribute(BrowseServlet.SESSION_DIRECTORY_TREE);
......@@ -71,7 +73,8 @@ public class RemoveItemServlet extends EntityManagerServlet {
long itemId = getParameter(request, PARAM_ITEM_ID, 0);
if ( itemId > 0 ) {
item = em.getReference(MonitoredItem.class, itemId);
if ( item != null ) {
removeItem(item, em, dt);
/*if ( item != null ) {
LogEventManager lem =
new LogEventManager(System.currentTimeMillis(), item.getParentCollection());
lem.persistItemEvent(LogEnum.REMOVE_ITEM, item.getPath(), null, em);
......@@ -89,9 +92,19 @@ public class RemoveItemServlet extends EntityManagerServlet {
} else {
new MyDeleteThread(item, dt).start();
}
}*/
}
else{
itemIds = getParameterList(request,REMOVAL, 0);
if(itemIds != null){
for(long l:itemIds){
if(l > 0){
item = em.getReference(MonitoredItem.class, l);
removeItem(item, em, dt);
}
}
}
}
String redirect = request.getParameter(PARAM_REDIRECT);
if ( Strings.isEmpty(redirect) ) {
redirect = DEFAULT_REDIRECT;
......@@ -101,6 +114,28 @@ public class RemoveItemServlet extends EntityManagerServlet {
dispatcher.forward(request, response);
}
private void removeItem(MonitoredItem item, EntityManager em, DirectoryTree dt){
if ( item != null ) {
LogEventManager lem =
new LogEventManager(System.currentTimeMillis(), item.getParentCollection());
lem.persistItemEvent(LogEnum.REMOVE_ITEM, item.getPath(), null, em);
if ( !item.isDirectory() ) {
String parent = item.getParentPath();
Collection c = item.getParentCollection();
EntityTransaction trans = em.getTransaction();
trans.begin();
if ( item.getToken() != null ) {
em.remove(item.getToken());
}
em.remove(item);
trans.commit();
reloadTree(dt, parent, c, em);
} else {
new MyDeleteThread(item, dt).start();
}
}
}
private static void reloadTree( DirectoryTree dt, String parent,
Collection c, EntityManager em ) {
if ( dt == null ) {
......
......@@ -158,6 +158,21 @@ public abstract class EntityManagerServlet extends HttpServlet {
}
}
public long[] getParameterList(HttpServletRequest request, String paramName, long defaultValue){
String[] strValues = request.getParameterValues(paramName);
if(strValues == null)
return null;
long[] longValues = new long[strValues.length];
for(int counter=0; counter<strValues.length; counter++){
String s = strValues[counter];
if(Strings.isValidLong(s))
longValues[counter] = Long.parseLong(s);
else
longValues[counter] = defaultValue;
}
return longValues;
}
public boolean getParameter( HttpServletRequest request, String paramName,
boolean defaultValue ) {
if ( Strings.isValidInt(request.getParameter(paramName)) ) {
......
......@@ -16,7 +16,7 @@
'name' is the resource name used by the web app to refer to this
database and NOT the database name, do not change unless you want bad
things to happen.-->
<Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" maxActive="20" maxIdle="10" maxWait="-1" name="jdbc/aceamdb" password="password" testOnBorrow="true" type="javax.sql.DataSource" url="jdbc:mysql://naraapp12/aceam2" username="aceam" validationQuery="SELECT 1"/>
<Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" maxActive="20" maxIdle="10" maxWait="-1" name="jdbc/aceamdb" password="ace" testOnBorrow="true" type="javax.sql.DataSource" url="jdbc:mysql://localhost/ace2" username="ace" validationQuery="SELECT 1"/>
<!--Mail server to use when mailing reports. You will need to set this if
you want reports to be mailed properly.-->
<Parameter name="mail.server" value="localhost.localdomain"/>
......
......@@ -20,6 +20,7 @@ on Libraries node in Projects view can be used to add the JSTL 1.1 library.
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Collection Errors</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script src="jquery-1.7.1.min.js" type="text/javascript"></script>
<style type="text/css">
#summaryTable {
margin-left: 50px;
......@@ -61,7 +62,6 @@ on Libraries node in Projects view can be used to add the JSTL 1.1 library.
</head>
<body>
<jsp:include page="header.jsp" />
<table id="summaryTable">
<tr>
<td class="lblTd">Active Files</td>
......@@ -90,9 +90,15 @@ on Libraries node in Projects view can be used to add the JSTL 1.1 library.
</tr>
</table>
<span>Select All:&nbsp;</span> <input type="checkbox" id="selectall" />
<form method="GET" action="RemoveItem">
<input type="hidden" name="redirect" value="Report"/>
<input type="hidden" name="collectionid" value="${collection.collection.id}" />
<table id="reportTable">
<thead>
<tr>
<td>Remove</td>
<td>State</td>
<td>Path</td>
<td>Last Seen</td>
......@@ -101,6 +107,9 @@ on Libraries node in Projects view can be used to add the JSTL 1.1 library.
</thead>
<c:forEach var="item" items="${items}">
<tr>
<td>
<input type="checkbox" name="removal" value="${item.id}" />
</td>
<td>
<c:choose>
<c:when test="${item.state eq 'C'}">
......@@ -148,8 +157,17 @@ on Libraries node in Projects view can be used to add the JSTL 1.1 library.
</table>
</td></tr>
</table>
<input type="submit" value="Remove Selected Items" onclick="document.location = 'report.jsp';"/>
</form>
<script type="text/javascript">
$("#selectall").click(function(){
if($("#selectall").attr("checked")=="checked")
$('input[name="removal"]').attr('checked', 'checked');
else
$('input[name="removal"]').removeAttr('checked');
});
</script>
<jsp:include page="footer.jsp" />
</body>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment