You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openmeetings.apache.org by so...@apache.org on 2016/04/07 04:01:44 UTC
svn commit: r1738071 - in /openmeetings/application:
branches/3.1.x/openmeetings-install/src/main/java/org/apache/openmeetings/cli/
branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/admin/
trunk/openmeetings-insta...
Author: solomax
Date: Thu Apr 7 02:01:44 2016
New Revision: 1738071
URL: http://svn.apache.org/viewvc?rev=1738071&view=rev
Log:
[OPENMEETINGS-853] clean-up dialog works with no warnings
Modified:
openmeetings/application/branches/3.1.x/openmeetings-install/src/main/java/org/apache/openmeetings/cli/CleanupEntityUnit.java
openmeetings/application/branches/3.1.x/openmeetings-install/src/main/java/org/apache/openmeetings/cli/CleanupHelper.java
openmeetings/application/branches/3.1.x/openmeetings-install/src/main/java/org/apache/openmeetings/cli/CleanupUnit.java
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/admin/AdminCleanupInfoDialog.html
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/admin/AdminCleanupInfoDialog.java
openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/admin/AdminWidgetView.java
openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/cli/CleanupEntityUnit.java
openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/cli/CleanupHelper.java
openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/cli/CleanupUnit.java
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/admin/AdminCleanupInfoDialog.html
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/admin/AdminCleanupInfoDialog.java
openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/admin/AdminWidgetView.java
Modified: openmeetings/application/branches/3.1.x/openmeetings-install/src/main/java/org/apache/openmeetings/cli/CleanupEntityUnit.java
URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-install/src/main/java/org/apache/openmeetings/cli/CleanupEntityUnit.java?rev=1738071&r1=1738070&r2=1738071&view=diff
==============================================================================
--- openmeetings/application/branches/3.1.x/openmeetings-install/src/main/java/org/apache/openmeetings/cli/CleanupEntityUnit.java (original)
+++ openmeetings/application/branches/3.1.x/openmeetings-install/src/main/java/org/apache/openmeetings/cli/CleanupEntityUnit.java Thu Apr 7 02:01:44 2016
@@ -26,17 +26,25 @@ import java.util.List;
import org.apache.commons.transaction.util.FileHelper;
import org.apache.openmeetings.util.OmFileHelper;
-public abstract class CleanupEntityUnit extends CleanupUnit {
+public class CleanupEntityUnit extends CleanupUnit {
private static final long serialVersionUID = 1L;
- protected List<File> invalid = new ArrayList<>();
- protected List<File> deleted = new ArrayList<>();
+ private final List<File> invalid;
+ private final List<File> deleted;
private long sizeInvalid = 0;
private long sizeDeleted = 0;
- protected int missing = 0;
+ protected final int missing;
- public CleanupEntityUnit(File parent) {
+ public CleanupEntityUnit() {
+ invalid = new ArrayList<>();
+ deleted = new ArrayList<>();
+ missing = 0;
+ }
+
+ public CleanupEntityUnit(File parent, List<File> invalid, List<File> deleted, int missing) {
super(parent);
- fill();
+ this.invalid = invalid;
+ this.deleted = deleted;
+ this.missing = missing;
for (File i : invalid) {
sizeInvalid += OmFileHelper.getSize(i);
}
@@ -55,8 +63,6 @@ public abstract class CleanupEntityUnit
}
}
- public abstract void fill();
-
public long getSizeInvalid() {
return sizeInvalid;
}
Modified: openmeetings/application/branches/3.1.x/openmeetings-install/src/main/java/org/apache/openmeetings/cli/CleanupHelper.java
URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-install/src/main/java/org/apache/openmeetings/cli/CleanupHelper.java?rev=1738071&r1=1738070&r2=1738071&view=diff
==============================================================================
--- openmeetings/application/branches/3.1.x/openmeetings-install/src/main/java/org/apache/openmeetings/cli/CleanupHelper.java (original)
+++ openmeetings/application/branches/3.1.x/openmeetings-install/src/main/java/org/apache/openmeetings/cli/CleanupHelper.java Thu Apr 7 02:01:44 2016
@@ -24,6 +24,7 @@ import static org.apache.openmeetings.ut
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.List;
import org.apache.commons.transaction.util.FileHelper;
@@ -39,33 +40,32 @@ import org.slf4j.Logger;
public class CleanupHelper {
private static final Logger log = Red5LoggerFactory.getLogger(CleanupHelper.class);
+ private static File hibernateDir = OmFileHelper.getStreamsHibernateDir();
public static CleanupUnit getTempUnit() {
return new CleanupUnit(OmFileHelper.getUploadTempDir());
}
public static CleanupEntityUnit getProfileUnit(final UserDao udao) {
- return new CleanupEntityUnit(OmFileHelper.getUploadProfilesDir()) {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void fill() {
- for (File profile : getParent().listFiles()) {
- long userId = getUserIdByProfile(profile.getName());
- User u = udao.get(userId);
- if (profile.isFile() || userId < 0 || u == null) {
- invalid.add(profile);
- } else if (u.isDeleted()) {
- deleted.add(profile);
- }
- }
- for (User u : udao.getAllBackupUsers()) {
- if (!u.isDeleted() && u.getPictureuri() != null && !new File(OmFileHelper.getUploadProfilesUserDir(u.getId()), u.getPictureuri()).exists()) {
- missing++;
- }
- }
+ File parent = OmFileHelper.getUploadProfilesDir();
+ List<File> invalid = new ArrayList<>();
+ List<File> deleted = new ArrayList<>();
+ int missing = 0;
+ for (File profile : parent.listFiles()) {
+ long userId = getUserIdByProfile(profile.getName());
+ User u = udao.get(userId);
+ if (profile.isFile() || userId < 0 || u == null) {
+ invalid.add(profile);
+ } else if (u.isDeleted()) {
+ deleted.add(profile);
+ }
+ }
+ for (User u : udao.getAllBackupUsers()) {
+ if (!u.isDeleted() && u.getPictureuri() != null && !new File(OmFileHelper.getUploadProfilesUserDir(u.getId()), u.getPictureuri()).exists()) {
+ missing++;
}
- };
+ }
+ return new CleanupEntityUnit(parent, invalid, deleted, missing);
}
public static CleanupUnit getImportUnit() {
@@ -77,34 +77,58 @@ public class CleanupHelper {
}
public static CleanupEntityUnit getFileUnit(final FileExplorerItemDao fileDao) {
- return new CleanupEntityUnit(OmFileHelper.getUploadFilesDir()) {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void fill() {
- for (File f : getParent().listFiles()) {
- FileExplorerItem item = fileDao.getByHash(f.getName()); // TODO probable extension should be stripped
- if (item == null) {
- invalid.add(f);
- } else if (item.isDeleted()) {
- deleted.add(f);
- }
- }
- //TODO WML_DIR should also be checked
- for (FileExplorerItem item : fileDao.get()) {
- if (!item.isDeleted() && item.getHash() != null && !new File(getParent(), item.getHash()).exists()) {
- missing++;
- }
- }
+ File parent = OmFileHelper.getUploadFilesDir();
+ List<File> invalid = new ArrayList<>();
+ List<File> deleted = new ArrayList<>();
+ int missing = 0;
+ for (File f : parent.listFiles()) {
+ FileExplorerItem item = fileDao.getByHash(f.getName()); // TODO probable extension should be stripped
+ if (item == null) {
+ invalid.add(f);
+ } else if (item.isDeleted()) {
+ deleted.add(f);
+ }
+ }
+ //TODO WML_DIR should also be checked
+ for (FileExplorerItem item : fileDao.get()) {
+ if (!item.isDeleted() && item.getHash() != null && !new File(parent, item.getHash()).exists()) {
+ missing++;
}
- };
+ }
+ return new CleanupEntityUnit(parent, invalid, deleted, missing);
}
public static CleanupEntityUnit getRecUnit(final RecordingDao recordDao) {
- return new CleanupEntityUnit(OmFileHelper.getStreamsDir()) {
+ File parent = OmFileHelper.getStreamsDir();
+ List<File> invalid = new ArrayList<>();
+ List<File> deleted = new ArrayList<>();
+ int missing = 0;
+ for (File f : hibernateDir.listFiles(new FilenameFilter() {
+ @Override
+ public boolean accept(File dir, String name) {
+ return name.startsWith(recordingFileName) && name.endsWith(FLV_EXTENSION);
+ }
+ })) {
+ if (!f.isFile()) {
+ log.warn("Recording found is not a file: " + f);
+ continue;
+ }
+ Long id = Long.valueOf(f.getName().substring(recordingFileName.length(), f.getName().length() - FLV_EXTENSION.length()));
+ Recording item = recordDao.get(id);
+ if (item == null) {
+ add(invalid, id);
+ } else if (item.isDeleted()) {
+ add(deleted, id);
+ }
+ }
+ for (Recording item : recordDao.get()) {
+ if (!item.isDeleted() && item.getHash() != null && list(item.getId()).length == 0) {
+ missing++;
+ }
+ }
+ return new CleanupEntityUnit(parent, invalid, deleted, missing) {
private static final long serialVersionUID = 1L;
- private File hibernateDir;
-
+
@Override
public void cleanup() throws IOException {
String hiberPath = hibernateDir.getCanonicalPath();
@@ -115,50 +139,22 @@ public class CleanupHelper {
}
super.cleanup();
}
-
+ };
+ }
+
+ private static File[] list(final Long id) {
+ return hibernateDir.listFiles(new FilenameFilter() {
@Override
- public void fill() {
- hibernateDir = OmFileHelper.getStreamsHibernateDir();
- for (File f : hibernateDir.listFiles(new FilenameFilter() {
- @Override
- public boolean accept(File dir, String name) {
- return name.startsWith(recordingFileName) && name.endsWith(FLV_EXTENSION);
- }
- })) {
- if (!f.isFile()) {
- log.warn("Recording found is not a file: " + f);
- continue;
- }
- Long id = Long.valueOf(f.getName().substring(recordingFileName.length(), f.getName().length() - FLV_EXTENSION.length()));
- Recording item = recordDao.get(id);
- if (item == null) {
- add(invalid, id);
- } else if (item.isDeleted()) {
- add(deleted, id);
- }
- }
- for (Recording item : recordDao.get()) {
- if (!item.isDeleted() && item.getHash() != null && list(item.getId()).length == 0) {
- missing++;
- }
- }
- }
-
- private File[] list(final Long id) {
- return hibernateDir.listFiles(new FilenameFilter() {
- @Override
- public boolean accept(File dir, String name) {
- return name.startsWith(recordingFileName + id);
- }
- });
- }
-
- private void add(List<File> list, final Long id) {
- for (File f : list(id)) {
- list.add(f);
- }
+ public boolean accept(File dir, String name) {
+ return name.startsWith(recordingFileName + id);
}
- };
+ });
+ }
+
+ private static void add(List<File> list, final Long id) {
+ for (File f : list(id)) {
+ list.add(f);
+ }
}
private static long getUserIdByProfile(String name) {
Modified: openmeetings/application/branches/3.1.x/openmeetings-install/src/main/java/org/apache/openmeetings/cli/CleanupUnit.java
URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-install/src/main/java/org/apache/openmeetings/cli/CleanupUnit.java?rev=1738071&r1=1738070&r2=1738071&view=diff
==============================================================================
--- openmeetings/application/branches/3.1.x/openmeetings-install/src/main/java/org/apache/openmeetings/cli/CleanupUnit.java (original)
+++ openmeetings/application/branches/3.1.x/openmeetings-install/src/main/java/org/apache/openmeetings/cli/CleanupUnit.java Thu Apr 7 02:01:44 2016
@@ -30,6 +30,11 @@ public class CleanupUnit implements Seri
private final File parent;
private final long sizeTotal;
+ public CleanupUnit() {
+ parent = new File(".");
+ sizeTotal = 0;
+ }
+
public CleanupUnit(File parent) {
this.parent = parent;
if (!parent.isDirectory() || !parent.exists()) {
Modified: openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/admin/AdminCleanupInfoDialog.html
URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/admin/AdminCleanupInfoDialog.html?rev=1738071&r1=1738070&r2=1738071&view=diff
==============================================================================
--- openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/admin/AdminCleanupInfoDialog.html (original)
+++ openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/admin/AdminCleanupInfoDialog.html Thu Apr 7 02:01:44 2016
@@ -22,7 +22,7 @@
<wicket:panel>
<div class="ui-widget">
<div class="ui-widget-content ui-corner-all">
- <ul>
+ <ul wicket:id="container">
<li><div wicket:id="temp"></div></li>
<li><span><wicket:message key="dashboard.widget.admin.cleanup.upload"/></span> <span wicket:id="upload-size"></span>
<ul>
Modified: openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/admin/AdminCleanupInfoDialog.java
URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/admin/AdminCleanupInfoDialog.java?rev=1738071&r1=1738070&r2=1738071&view=diff
==============================================================================
--- openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/admin/AdminCleanupInfoDialog.java (original)
+++ openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/admin/AdminCleanupInfoDialog.java Thu Apr 7 02:01:44 2016
@@ -29,10 +29,14 @@ import static org.apache.openmeetings.ut
import static org.apache.openmeetings.util.OmFileHelper.getUploadDir;
import static org.apache.openmeetings.web.app.Application.getBean;
+import org.apache.openmeetings.cli.CleanupEntityUnit;
+import org.apache.openmeetings.cli.CleanupUnit;
import org.apache.openmeetings.db.dao.file.FileExplorerItemDao;
import org.apache.openmeetings.db.dao.record.RecordingDao;
import org.apache.openmeetings.db.dao.user.UserDao;
+import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.core.request.handler.IPartialPageRequestHandler;
+import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.Model;
@@ -41,17 +45,28 @@ import com.googlecode.wicket.jquery.ui.w
public class AdminCleanupInfoDialog extends AbstractDialog<String> {
private static final long serialVersionUID = 1L;
+ private final CleanupUnitPanel temp;
+ private final Label uploadSize;
+ private final CleanupEntityUnitPanel profile;
+ private final CleanupUnitPanel imp;
+ private final CleanupUnitPanel backup;
+ private final CleanupEntityUnitPanel files;
+ private final Label streamsSize;
+ private final CleanupEntityUnitPanel fin;
+ private final WebMarkupContainer container = new WebMarkupContainer("container");
public AdminCleanupInfoDialog(String id) {
super(id, "");
- add(new CleanupUnitPanel("temp", "dashboard.widget.admin.cleanup.temp", getTempUnit()));
- add(new Label("upload-size", getHumanSize(getUploadDir())));
- add(new CleanupEntityUnitPanel("profile", "dashboard.widget.admin.cleanup.profiles", getProfileUnit(getBean(UserDao.class))));
- add(new CleanupUnitPanel("import", "dashboard.widget.admin.cleanup.import", getImportUnit()));
- add(new CleanupUnitPanel("backup", "dashboard.widget.admin.cleanup.backup", getBackupUnit()));
- add(new CleanupEntityUnitPanel("files", "dashboard.widget.admin.cleanup.files", getFileUnit(getBean(FileExplorerItemDao.class))));
- add(new Label("streams-size", getHumanSize(getStreamsDir())));
- add(new CleanupEntityUnitPanel("final", "dashboard.widget.admin.cleanup.final", getRecUnit(getBean(RecordingDao.class))));
+ temp = new CleanupUnitPanel("temp", "dashboard.widget.admin.cleanup.temp", new CleanupUnit());
+ uploadSize = new Label("upload-size", "");
+ profile = new CleanupEntityUnitPanel("profile", "dashboard.widget.admin.cleanup.profiles", new CleanupEntityUnit());
+ imp = new CleanupUnitPanel("import", "dashboard.widget.admin.cleanup.import", new CleanupUnit());
+ backup = new CleanupUnitPanel("backup", "dashboard.widget.admin.cleanup.backup", new CleanupUnit());
+ files = new CleanupEntityUnitPanel("files", "dashboard.widget.admin.cleanup.files", new CleanupEntityUnit());
+ streamsSize = new Label("streams-size", "");
+ fin = new CleanupEntityUnitPanel("final", "dashboard.widget.admin.cleanup.final", new CleanupEntityUnit());
+
+ add(container.add(temp, uploadSize, profile, imp, backup, files, streamsSize, fin).setOutputMarkupId(true));
}
@Override
@@ -63,6 +78,18 @@ public class AdminCleanupInfoDialog exte
@Override
public void onClose(IPartialPageRequestHandler handler, DialogButton button) {
// TODO Auto-generated method stub
-
+ }
+
+ public void show(AjaxRequestTarget target) {
+ temp.setDefaultModelObject(getTempUnit());
+ uploadSize.setDefaultModelObject(getHumanSize(getUploadDir()));
+ profile.setDefaultModelObject(getProfileUnit(getBean(UserDao.class)));
+ imp.setDefaultModelObject(getImportUnit());
+ backup.setDefaultModelObject(getBackupUnit());
+ files.setDefaultModelObject(getFileUnit(getBean(FileExplorerItemDao.class)));
+ streamsSize.setDefaultModelObject(getHumanSize(getStreamsDir()));
+ fin.setDefaultModelObject(getRecUnit(getBean(RecordingDao.class)));
+ target.add(container);
+ open(target);
}
}
Modified: openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/admin/AdminWidgetView.java
URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/admin/AdminWidgetView.java?rev=1738071&r1=1738070&r2=1738071&view=diff
==============================================================================
--- openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/admin/AdminWidgetView.java (original)
+++ openmeetings/application/branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/admin/AdminWidgetView.java Thu Apr 7 02:01:44 2016
@@ -41,7 +41,7 @@ public class AdminWidgetView extends Wid
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
- cleanupDialog.open(target);
+ cleanupDialog.show(target);
}
});
}
Modified: openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/cli/CleanupEntityUnit.java
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/cli/CleanupEntityUnit.java?rev=1738071&r1=1738070&r2=1738071&view=diff
==============================================================================
--- openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/cli/CleanupEntityUnit.java (original)
+++ openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/cli/CleanupEntityUnit.java Thu Apr 7 02:01:44 2016
@@ -26,17 +26,25 @@ import java.util.List;
import org.apache.commons.transaction.util.FileHelper;
import org.apache.openmeetings.util.OmFileHelper;
-public abstract class CleanupEntityUnit extends CleanupUnit {
+public class CleanupEntityUnit extends CleanupUnit {
private static final long serialVersionUID = 1L;
- protected List<File> invalid = new ArrayList<>();
- protected List<File> deleted = new ArrayList<>();
+ private final List<File> invalid;
+ private final List<File> deleted;
private long sizeInvalid = 0;
private long sizeDeleted = 0;
- protected int missing = 0;
+ protected final int missing;
- public CleanupEntityUnit(File parent) {
+ public CleanupEntityUnit() {
+ invalid = new ArrayList<>();
+ deleted = new ArrayList<>();
+ missing = 0;
+ }
+
+ public CleanupEntityUnit(File parent, List<File> invalid, List<File> deleted, int missing) {
super(parent);
- fill();
+ this.invalid = invalid;
+ this.deleted = deleted;
+ this.missing = missing;
for (File i : invalid) {
sizeInvalid += OmFileHelper.getSize(i);
}
@@ -55,8 +63,6 @@ public abstract class CleanupEntityUnit
}
}
- public abstract void fill();
-
public long getSizeInvalid() {
return sizeInvalid;
}
Modified: openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/cli/CleanupHelper.java
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/cli/CleanupHelper.java?rev=1738071&r1=1738070&r2=1738071&view=diff
==============================================================================
--- openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/cli/CleanupHelper.java (original)
+++ openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/cli/CleanupHelper.java Thu Apr 7 02:01:44 2016
@@ -24,6 +24,7 @@ import static org.apache.openmeetings.ut
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.List;
import org.apache.commons.transaction.util.FileHelper;
@@ -39,33 +40,32 @@ import org.slf4j.Logger;
public class CleanupHelper {
private static final Logger log = Red5LoggerFactory.getLogger(CleanupHelper.class);
+ private static File hibernateDir = OmFileHelper.getStreamsHibernateDir();
public static CleanupUnit getTempUnit() {
return new CleanupUnit(OmFileHelper.getUploadTempDir());
}
public static CleanupEntityUnit getProfileUnit(final UserDao udao) {
- return new CleanupEntityUnit(OmFileHelper.getUploadProfilesDir()) {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void fill() {
- for (File profile : getParent().listFiles()) {
- long userId = getUserIdByProfile(profile.getName());
- User u = udao.get(userId);
- if (profile.isFile() || userId < 0 || u == null) {
- invalid.add(profile);
- } else if (u.isDeleted()) {
- deleted.add(profile);
- }
- }
- for (User u : udao.getAllBackupUsers()) {
- if (!u.isDeleted() && u.getPictureuri() != null && !new File(OmFileHelper.getUploadProfilesUserDir(u.getId()), u.getPictureuri()).exists()) {
- missing++;
- }
- }
+ File parent = OmFileHelper.getUploadProfilesDir();
+ List<File> invalid = new ArrayList<>();
+ List<File> deleted = new ArrayList<>();
+ int missing = 0;
+ for (File profile : parent.listFiles()) {
+ long userId = getUserIdByProfile(profile.getName());
+ User u = udao.get(userId);
+ if (profile.isFile() || userId < 0 || u == null) {
+ invalid.add(profile);
+ } else if (u.isDeleted()) {
+ deleted.add(profile);
+ }
+ }
+ for (User u : udao.getAllBackupUsers()) {
+ if (!u.isDeleted() && u.getPictureuri() != null && !new File(OmFileHelper.getUploadProfilesUserDir(u.getId()), u.getPictureuri()).exists()) {
+ missing++;
}
- };
+ }
+ return new CleanupEntityUnit(parent, invalid, deleted, missing);
}
public static CleanupUnit getImportUnit() {
@@ -77,34 +77,58 @@ public class CleanupHelper {
}
public static CleanupEntityUnit getFileUnit(final FileExplorerItemDao fileDao) {
- return new CleanupEntityUnit(OmFileHelper.getUploadFilesDir()) {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void fill() {
- for (File f : getParent().listFiles()) {
- FileExplorerItem item = fileDao.getByHash(f.getName()); // TODO probable extension should be stripped
- if (item == null) {
- invalid.add(f);
- } else if (item.isDeleted()) {
- deleted.add(f);
- }
- }
- //TODO WML_DIR should also be checked
- for (FileExplorerItem item : fileDao.get()) {
- if (!item.isDeleted() && item.getHash() != null && !new File(getParent(), item.getHash()).exists()) {
- missing++;
- }
- }
+ File parent = OmFileHelper.getUploadFilesDir();
+ List<File> invalid = new ArrayList<>();
+ List<File> deleted = new ArrayList<>();
+ int missing = 0;
+ for (File f : parent.listFiles()) {
+ FileExplorerItem item = fileDao.getByHash(f.getName()); // TODO probable extension should be stripped
+ if (item == null) {
+ invalid.add(f);
+ } else if (item.isDeleted()) {
+ deleted.add(f);
+ }
+ }
+ //TODO WML_DIR should also be checked
+ for (FileExplorerItem item : fileDao.get()) {
+ if (!item.isDeleted() && item.getHash() != null && !new File(parent, item.getHash()).exists()) {
+ missing++;
}
- };
+ }
+ return new CleanupEntityUnit(parent, invalid, deleted, missing);
}
public static CleanupEntityUnit getRecUnit(final RecordingDao recordDao) {
- return new CleanupEntityUnit(OmFileHelper.getStreamsDir()) {
+ File parent = OmFileHelper.getStreamsDir();
+ List<File> invalid = new ArrayList<>();
+ List<File> deleted = new ArrayList<>();
+ int missing = 0;
+ for (File f : hibernateDir.listFiles(new FilenameFilter() {
+ @Override
+ public boolean accept(File dir, String name) {
+ return name.startsWith(recordingFileName) && name.endsWith(FLV_EXTENSION);
+ }
+ })) {
+ if (!f.isFile()) {
+ log.warn("Recording found is not a file: " + f);
+ continue;
+ }
+ Long id = Long.valueOf(f.getName().substring(recordingFileName.length(), f.getName().length() - FLV_EXTENSION.length()));
+ Recording item = recordDao.get(id);
+ if (item == null) {
+ add(invalid, id);
+ } else if (item.isDeleted()) {
+ add(deleted, id);
+ }
+ }
+ for (Recording item : recordDao.get()) {
+ if (!item.isDeleted() && item.getHash() != null && list(item.getId()).length == 0) {
+ missing++;
+ }
+ }
+ return new CleanupEntityUnit(parent, invalid, deleted, missing) {
private static final long serialVersionUID = 1L;
- private File hibernateDir;
-
+
@Override
public void cleanup() throws IOException {
String hiberPath = hibernateDir.getCanonicalPath();
@@ -115,50 +139,22 @@ public class CleanupHelper {
}
super.cleanup();
}
-
+ };
+ }
+
+ private static File[] list(final Long id) {
+ return hibernateDir.listFiles(new FilenameFilter() {
@Override
- public void fill() {
- hibernateDir = OmFileHelper.getStreamsHibernateDir();
- for (File f : hibernateDir.listFiles(new FilenameFilter() {
- @Override
- public boolean accept(File dir, String name) {
- return name.startsWith(recordingFileName) && name.endsWith(FLV_EXTENSION);
- }
- })) {
- if (!f.isFile()) {
- log.warn("Recording found is not a file: " + f);
- continue;
- }
- Long id = Long.valueOf(f.getName().substring(recordingFileName.length(), f.getName().length() - FLV_EXTENSION.length()));
- Recording item = recordDao.get(id);
- if (item == null) {
- add(invalid, id);
- } else if (item.isDeleted()) {
- add(deleted, id);
- }
- }
- for (Recording item : recordDao.get()) {
- if (!item.isDeleted() && item.getHash() != null && list(item.getId()).length == 0) {
- missing++;
- }
- }
- }
-
- private File[] list(final Long id) {
- return hibernateDir.listFiles(new FilenameFilter() {
- @Override
- public boolean accept(File dir, String name) {
- return name.startsWith(recordingFileName + id);
- }
- });
- }
-
- private void add(List<File> list, final Long id) {
- for (File f : list(id)) {
- list.add(f);
- }
+ public boolean accept(File dir, String name) {
+ return name.startsWith(recordingFileName + id);
}
- };
+ });
+ }
+
+ private static void add(List<File> list, final Long id) {
+ for (File f : list(id)) {
+ list.add(f);
+ }
}
private static long getUserIdByProfile(String name) {
Modified: openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/cli/CleanupUnit.java
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/cli/CleanupUnit.java?rev=1738071&r1=1738070&r2=1738071&view=diff
==============================================================================
--- openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/cli/CleanupUnit.java (original)
+++ openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/cli/CleanupUnit.java Thu Apr 7 02:01:44 2016
@@ -30,6 +30,11 @@ public class CleanupUnit implements Seri
private final File parent;
private final long sizeTotal;
+ public CleanupUnit() {
+ parent = new File(".");
+ sizeTotal = 0;
+ }
+
public CleanupUnit(File parent) {
this.parent = parent;
if (!parent.isDirectory() || !parent.exists()) {
Modified: openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/admin/AdminCleanupInfoDialog.html
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/admin/AdminCleanupInfoDialog.html?rev=1738071&r1=1738070&r2=1738071&view=diff
==============================================================================
--- openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/admin/AdminCleanupInfoDialog.html (original)
+++ openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/admin/AdminCleanupInfoDialog.html Thu Apr 7 02:01:44 2016
@@ -22,7 +22,7 @@
<wicket:panel>
<div class="ui-widget">
<div class="ui-widget-content ui-corner-all">
- <ul>
+ <ul wicket:id="container">
<li><div wicket:id="temp"></div></li>
<li><span><wicket:message key="dashboard.widget.admin.cleanup.upload"/></span> <span wicket:id="upload-size"></span>
<ul>
Modified: openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/admin/AdminCleanupInfoDialog.java
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/admin/AdminCleanupInfoDialog.java?rev=1738071&r1=1738070&r2=1738071&view=diff
==============================================================================
--- openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/admin/AdminCleanupInfoDialog.java (original)
+++ openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/admin/AdminCleanupInfoDialog.java Thu Apr 7 02:01:44 2016
@@ -29,10 +29,14 @@ import static org.apache.openmeetings.ut
import static org.apache.openmeetings.util.OmFileHelper.getUploadDir;
import static org.apache.openmeetings.web.app.Application.getBean;
+import org.apache.openmeetings.cli.CleanupEntityUnit;
+import org.apache.openmeetings.cli.CleanupUnit;
import org.apache.openmeetings.db.dao.file.FileExplorerItemDao;
import org.apache.openmeetings.db.dao.record.RecordingDao;
import org.apache.openmeetings.db.dao.user.UserDao;
+import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.core.request.handler.IPartialPageRequestHandler;
+import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.Model;
@@ -41,17 +45,28 @@ import com.googlecode.wicket.jquery.ui.w
public class AdminCleanupInfoDialog extends AbstractDialog<String> {
private static final long serialVersionUID = 1L;
+ private final CleanupUnitPanel temp;
+ private final Label uploadSize;
+ private final CleanupEntityUnitPanel profile;
+ private final CleanupUnitPanel imp;
+ private final CleanupUnitPanel backup;
+ private final CleanupEntityUnitPanel files;
+ private final Label streamsSize;
+ private final CleanupEntityUnitPanel fin;
+ private final WebMarkupContainer container = new WebMarkupContainer("container");
public AdminCleanupInfoDialog(String id) {
super(id, "");
- add(new CleanupUnitPanel("temp", "dashboard.widget.admin.cleanup.temp", getTempUnit()));
- add(new Label("upload-size", getHumanSize(getUploadDir())));
- add(new CleanupEntityUnitPanel("profile", "dashboard.widget.admin.cleanup.profiles", getProfileUnit(getBean(UserDao.class))));
- add(new CleanupUnitPanel("import", "dashboard.widget.admin.cleanup.import", getImportUnit()));
- add(new CleanupUnitPanel("backup", "dashboard.widget.admin.cleanup.backup", getBackupUnit()));
- add(new CleanupEntityUnitPanel("files", "dashboard.widget.admin.cleanup.files", getFileUnit(getBean(FileExplorerItemDao.class))));
- add(new Label("streams-size", getHumanSize(getStreamsDir())));
- add(new CleanupEntityUnitPanel("final", "dashboard.widget.admin.cleanup.final", getRecUnit(getBean(RecordingDao.class))));
+ temp = new CleanupUnitPanel("temp", "dashboard.widget.admin.cleanup.temp", new CleanupUnit());
+ uploadSize = new Label("upload-size", "");
+ profile = new CleanupEntityUnitPanel("profile", "dashboard.widget.admin.cleanup.profiles", new CleanupEntityUnit());
+ imp = new CleanupUnitPanel("import", "dashboard.widget.admin.cleanup.import", new CleanupUnit());
+ backup = new CleanupUnitPanel("backup", "dashboard.widget.admin.cleanup.backup", new CleanupUnit());
+ files = new CleanupEntityUnitPanel("files", "dashboard.widget.admin.cleanup.files", new CleanupEntityUnit());
+ streamsSize = new Label("streams-size", "");
+ fin = new CleanupEntityUnitPanel("final", "dashboard.widget.admin.cleanup.final", new CleanupEntityUnit());
+
+ add(container.add(temp, uploadSize, profile, imp, backup, files, streamsSize, fin).setOutputMarkupId(true));
}
@Override
@@ -63,6 +78,18 @@ public class AdminCleanupInfoDialog exte
@Override
public void onClose(IPartialPageRequestHandler handler, DialogButton button) {
// TODO Auto-generated method stub
-
+ }
+
+ public void show(AjaxRequestTarget target) {
+ temp.setDefaultModelObject(getTempUnit());
+ uploadSize.setDefaultModelObject(getHumanSize(getUploadDir()));
+ profile.setDefaultModelObject(getProfileUnit(getBean(UserDao.class)));
+ imp.setDefaultModelObject(getImportUnit());
+ backup.setDefaultModelObject(getBackupUnit());
+ files.setDefaultModelObject(getFileUnit(getBean(FileExplorerItemDao.class)));
+ streamsSize.setDefaultModelObject(getHumanSize(getStreamsDir()));
+ fin.setDefaultModelObject(getRecUnit(getBean(RecordingDao.class)));
+ target.add(container);
+ open(target);
}
}
Modified: openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/admin/AdminWidgetView.java
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/admin/AdminWidgetView.java?rev=1738071&r1=1738070&r2=1738071&view=diff
==============================================================================
--- openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/admin/AdminWidgetView.java (original)
+++ openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/dashboard/admin/AdminWidgetView.java Thu Apr 7 02:01:44 2016
@@ -41,7 +41,7 @@ public class AdminWidgetView extends Wid
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
- cleanupDialog.open(target);
+ cleanupDialog.show(target);
}
});
}