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 2017/02/20 09:58:01 UTC

svn commit: r1783732 - in /openmeetings/application: branches/3.2.x/openmeetings-install/src/main/java/org/apache/openmeetings/cli/ trunk/openmeetings-install/src/main/java/org/apache/openmeetings/cli/

Author: solomax
Date: Mon Feb 20 09:58:01 2017
New Revision: 1783732

URL: http://svn.apache.org/viewvc?rev=1783732&view=rev
Log:
[OPENMEETINGS-1569] recordings clean-up should work as expected

Modified:
    openmeetings/application/branches/3.2.x/openmeetings-install/src/main/java/org/apache/openmeetings/cli/Admin.java
    openmeetings/application/branches/3.2.x/openmeetings-install/src/main/java/org/apache/openmeetings/cli/CleanupHelper.java
    openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/cli/Admin.java
    openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/cli/CleanupHelper.java

Modified: openmeetings/application/branches/3.2.x/openmeetings-install/src/main/java/org/apache/openmeetings/cli/Admin.java
URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-install/src/main/java/org/apache/openmeetings/cli/Admin.java?rev=1783732&r1=1783731&r2=1783732&view=diff
==============================================================================
--- openmeetings/application/branches/3.2.x/openmeetings-install/src/main/java/org/apache/openmeetings/cli/Admin.java (original)
+++ openmeetings/application/branches/3.2.x/openmeetings-install/src/main/java/org/apache/openmeetings/cli/Admin.java Mon Feb 20 09:58:01 2017
@@ -75,7 +75,7 @@ import org.springframework.web.context.W
 
 public class Admin {
 	private static final Logger log = Red5LoggerFactory.getLogger(Admin.class);
-	
+
 	private boolean verbose = false;
 	private InstallationConfig cfg = null;
 	private Options opts = null;
@@ -86,7 +86,7 @@ public class Admin {
 		cfg = new InstallationConfig();
 		opts = buildOptions();
 	}
-	
+
 	private Options buildOptions() {
 		Options options = new Options();
 		OptionGroup group = new OptionGroup()
@@ -96,7 +96,7 @@ public class Admin {
 			.addOption(new OmOption("i", 3, "i", "install", false, "Fill DB table, and make OM usable"))
 			.addOption(new OmOption("l", 3, "l", "LDAP", false, "Import LDAP users into DB"))
 			.addOption(new OmOption("f", 4, "f", "files", false, "File operations - statictics/cleanup"));
-		group.setRequired(true); 
+		group.setRequired(true);
 		options.addOptionGroup(group);
 		//general
 		options.addOption(new OmOption(null, "v", "verbose", false, "verbose error messages"));
@@ -134,7 +134,7 @@ public class Admin {
 		options.addOption(new OmOption("l", null, "print-only", false, "Print users found instead of importing", true));
 		return options;
 	}
-	
+
 	private enum Command {
 		install
 		, backup
@@ -143,7 +143,7 @@ public class Admin {
 		, ldap
 		, usage
 	}
-	
+
 	private void usage() {
 		OmHelpFormatter formatter = new OmHelpFormatter();
 		formatter.setWidth(100);
@@ -152,11 +152,11 @@ public class Admin {
 				"\t./admin.sh -i -v -file backup_31_07_2012_12_07_51.zip --drop\n" +
 				"\t./admin.sh -i -v -user admin -email someemail@gmail.com -tz \"Asia/Tehran\" -group \"yourgroup\" --db-type mysql --db-host localhost");
 	}
-	
+
 	private void handleError(String msg, Exception e) {
 		handleError(msg, e, false);
 	}
-	
+
 	private void handleError(String msg, Exception e, boolean printUsage) {
 		if (printUsage) {
 			usage();
@@ -168,7 +168,7 @@ public class Admin {
 		}
 		System.exit(1);
 	}
-	
+
 	private WebApplicationContext getApplicationContext() {
 		if (ctx == null) {
 			Long lngId = StringValue.valueOf(cfg.defaultLangId).toLong(1L);
@@ -182,13 +182,13 @@ public class Admin {
 		}
 		return ctx;
 	}
-	
+
 	private void process(String[] args) {
 		String ctxName = System.getProperty("context", "openmeetings");
 		OpenmeetingsVariables.wicketApplicationName = ctxName;
 		File home = new File(System.getenv("RED5_HOME"));
 		OmFileHelper.setOmHome(new File(new File(home, "webapps"), ctxName));
-		
+
 		CommandLineParser parser = new DefaultParser();
 		try {
 			cmdl = parser.parse(opts, args);
@@ -266,18 +266,18 @@ public class Admin {
 					if (cmdl.hasOption("file")) {
 						File backup = checkRestoreFile(file);
 						dropDB(connectionProperties);
-						
+
 						ImportInitvalues importInit = getApplicationContext().getBean(ImportInitvalues.class);
-						importInit.loadSystem(cfg, force); 
+						importInit.loadSystem(cfg, force);
 						restoreOm(backup);
 					} else {
 						checkAdminDetails();
 						dropDB(connectionProperties);
-						
+
 						ImportInitvalues importInit = getApplicationContext().getBean(ImportInitvalues.class);
 						importInit.loadAll(cfg, force);
-					}					
-					
+					}
+
 					InstallationDocumentHandler.createDocument(3);
 				} catch(Exception e) {
 					handleError("Install failed", e);
@@ -296,7 +296,7 @@ public class Admin {
 					boolean includeFiles = !cmdl.hasOption("exclude-files");
 					File backup_dir = new File(OmFileHelper.getUploadBackupDir(), "" + System.currentTimeMillis());
 					backup_dir.mkdirs();
-					
+
 					BackupExport export = getApplicationContext().getBean(BackupExport.class);
 					export.performExport(f, backup_dir, includeFiles, new ProgressHolder());
 					FileUtils.deleteDirectory(backup_dir);
@@ -316,7 +316,7 @@ public class Admin {
 				try {
 					boolean cleanup = cmdl.hasOption("cleanup");
 					if (cleanup) {
-						System.out.println("WARNING: all intermadiate files will be clean up!");
+						System.out.println("WARNING: all intermediate files will be clean up!");
 					}
 					StringBuilder report = new StringBuilder();
 					{ //UPLOAD
@@ -397,11 +397,11 @@ public class Admin {
 				usage();
 				break;
 		}
-		
+
 		System.out.println("... Done");
 		System.exit(0);
 	}
-	
+
 	private void checkAdminDetails() throws Exception {
 		cfg.username = cmdl.getOptionValue("user");
 		cfg.email = cmdl.getOptionValue("email");
@@ -410,7 +410,7 @@ public class Admin {
 			System.out.println("User login was not provided, or too short, should be at least " + USER_LOGIN_MINIMUM_LENGTH + " character long.");
 			System.exit(1);
 		}
-		
+
 		try {
 			if (cfg.email == null || !MailUtil.matches(cfg.email)) {
 				throw new AddressException("Invalid address");
@@ -442,26 +442,26 @@ public class Admin {
 		}
 		if (cfg.ical_timeZone == null) {
 			System.out.println("Please enter timezone, Possible timezones are:");
-			
+
 			for (Map.Entry<String,String> me : tzMap.entrySet()) {
 				System.out.println(String.format("%1$-25s%2$s", "\"" + me.getKey() + "\"", me.getValue()));
 			}
 			System.exit(1);
 		}
 	}
-	
+
 	public void dropDB() throws Exception {
 		File conf = OmFileHelper.getPersistence();
 		ConnectionProperties connectionProperties = ConnectionPropertiesPatcher.getConnectionProperties(conf);
 		immediateDropDB(connectionProperties);
 	}
-	
+
 	private void dropDB(ConnectionProperties props) throws Exception {
 		if(cmdl.hasOption("drop")) {
 			immediateDropDB(props);
 		}
 	}
-	
+
 	private static LogImpl getLogImpl(JDBCConfiguration conf) {
 		return (LogImpl)conf.getLog(JDBCConfiguration.LOG_SCHEMA);
 	}
@@ -477,7 +477,7 @@ public class Admin {
 		}
 		st.run();
 	}
-	
+
 	private void immediateDropDB(ConnectionProperties props) throws Exception {
 		if (ctx != null) {
 			destroyApplication();
@@ -506,10 +506,10 @@ public class Admin {
 			usage();
 			System.exit(1);
 		}
-		
+
 		return backup;
 	}
-	
+
 	private void restoreOm(File backup) {
 		try (InputStream is = new FileInputStream(backup)) {
 			BackupImport importCtrl = getApplicationContext().getBean(BackupImport.class);
@@ -518,7 +518,7 @@ public class Admin {
 			handleError("Restore failed", e);
 		}
 	}
-	
+
 	public static void main(String[] args) {
 		new Admin().process(args);
 	}

Modified: openmeetings/application/branches/3.2.x/openmeetings-install/src/main/java/org/apache/openmeetings/cli/CleanupHelper.java
URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-install/src/main/java/org/apache/openmeetings/cli/CleanupHelper.java?rev=1783732&r1=1783731&r2=1783732&view=diff
==============================================================================
--- openmeetings/application/branches/3.2.x/openmeetings-install/src/main/java/org/apache/openmeetings/cli/CleanupHelper.java (original)
+++ openmeetings/application/branches/3.2.x/openmeetings-install/src/main/java/org/apache/openmeetings/cli/CleanupHelper.java Mon Feb 20 09:58:01 2017
@@ -18,8 +18,7 @@
  */
 package org.apache.openmeetings.cli;
 
-import static org.apache.openmeetings.util.OmFileHelper.EXTENSION_FLV;
-import static org.apache.openmeetings.util.OmFileHelper.recordingFileName;
+import static org.apache.openmeetings.util.OmFileHelper.EXTENSION_MP4;
 
 import java.io.File;
 import java.io.FilenameFilter;
@@ -41,7 +40,7 @@ import org.slf4j.Logger;
 public class CleanupHelper {
 	private static final Logger log = Red5LoggerFactory.getLogger(CleanupHelper.class);
 	private static File hibernateDir = OmFileHelper.getStreamsHibernateDir();
-	
+
 	public static CleanupEntityUnit getProfileUnit(final UserDao udao) {
 		File parent = OmFileHelper.getUploadProfilesDir();
 		List<File> invalid = new ArrayList<>();
@@ -102,29 +101,29 @@ public class CleanupHelper {
 		for (File f : list(hibernateDir, new FilenameFilter() {
 			@Override
 			public boolean accept(File dir, String name) {
-				return name.startsWith(recordingFileName) && name.endsWith(EXTENSION_FLV);
+				return name.endsWith(EXTENSION_MP4);
 			}
 		})) {
 			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() - EXTENSION_FLV.length() - 1));
-			Recording item = recordDao.get(id);
+			String hash = f.getName().substring(0, f.getName().length() - EXTENSION_MP4.length() - 1);
+			Recording item = recordDao.getByHash(hash);
 			if (item == null) {
-				add(invalid, id);
+				add(invalid, hash);
 			} else if (item.isDeleted()) {
-				add(deleted, id);
+				add(deleted, hash);
 			}
 		}
 		for (Recording item : recordDao.get()) {
-			if (!item.isDeleted() && item.getHash() != null && list(item.getId()).length == 0) {
+			if (!item.isDeleted() && item.getHash() != null && list(item.getHash()).length == 0) {
 				missing++;
 			}
 		}
 		return new CleanupEntityUnit(parent, invalid, deleted, missing) {
 			private static final long serialVersionUID = 1L;
-			
+
 			@Override
 			public void cleanup() throws IOException {
 				String hiberPath = hibernateDir.getCanonicalPath();
@@ -142,18 +141,18 @@ public class CleanupHelper {
 		File[] l = ff == null ? f.listFiles() : f.listFiles(ff);
 		return l == null ? new File[0] : l;
 	}
-	
-	private static File[] list(final Long id) {
+
+	private static File[] list(final String hash) {
 		return list(hibernateDir, new FilenameFilter() {
 			@Override
 			public boolean accept(File dir, String name) {
-				return name.startsWith(recordingFileName + id);
+				return name.startsWith(hash);
 			}
 		});
 	}
-	
-	private static void add(List<File> list, final Long id) {
-		for (File f : list(id)) {
+
+	private static void add(List<File> list, final String hash) {
+		for (File f : list(hash)) {
 			list.add(f);
 		}
 	}

Modified: openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/cli/Admin.java
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/cli/Admin.java?rev=1783732&r1=1783731&r2=1783732&view=diff
==============================================================================
--- openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/cli/Admin.java (original)
+++ openmeetings/application/trunk/openmeetings-install/src/main/java/org/apache/openmeetings/cli/Admin.java Mon Feb 20 09:58:01 2017
@@ -75,7 +75,7 @@ import org.springframework.web.context.W
 
 public class Admin {
 	private static final Logger log = Red5LoggerFactory.getLogger(Admin.class);
-	
+
 	private boolean verbose = false;
 	private InstallationConfig cfg = null;
 	private Options opts = null;
@@ -86,7 +86,7 @@ public class Admin {
 		cfg = new InstallationConfig();
 		opts = buildOptions();
 	}
-	
+
 	private Options buildOptions() {
 		Options options = new Options();
 		OptionGroup group = new OptionGroup()
@@ -96,7 +96,7 @@ public class Admin {
 			.addOption(new OmOption("i", 3, "i", "install", false, "Fill DB table, and make OM usable"))
 			.addOption(new OmOption("l", 3, "l", "LDAP", false, "Import LDAP users into DB"))
 			.addOption(new OmOption("f", 4, "f", "files", false, "File operations - statictics/cleanup"));
-		group.setRequired(true); 
+		group.setRequired(true);
 		options.addOptionGroup(group);
 		//general
 		options.addOption(new OmOption(null, "v", "verbose", false, "verbose error messages"));
@@ -134,7 +134,7 @@ public class Admin {
 		options.addOption(new OmOption("l", null, "print-only", false, "Print users found instead of importing", true));
 		return options;
 	}
-	
+
 	private enum Command {
 		install
 		, backup
@@ -143,7 +143,7 @@ public class Admin {
 		, ldap
 		, usage
 	}
-	
+
 	private void usage() {
 		OmHelpFormatter formatter = new OmHelpFormatter();
 		formatter.setWidth(100);
@@ -152,11 +152,11 @@ public class Admin {
 				"\t./admin.sh -i -v -file backup_31_07_2012_12_07_51.zip --drop\n" +
 				"\t./admin.sh -i -v -user admin -email someemail@gmail.com -tz \"Asia/Tehran\" -group \"yourgroup\" --db-type mysql --db-host localhost");
 	}
-	
+
 	private void handleError(String msg, Exception e) {
 		handleError(msg, e, false);
 	}
-	
+
 	private void handleError(String msg, Exception e, boolean printUsage) {
 		if (printUsage) {
 			usage();
@@ -168,7 +168,7 @@ public class Admin {
 		}
 		System.exit(1);
 	}
-	
+
 	private WebApplicationContext getApplicationContext() {
 		if (ctx == null) {
 			Long lngId = StringValue.valueOf(cfg.defaultLangId).toLong(1L);
@@ -182,13 +182,13 @@ public class Admin {
 		}
 		return ctx;
 	}
-	
+
 	private void process(String[] args) {
 		String ctxName = System.getProperty("context", "openmeetings");
 		OpenmeetingsVariables.wicketApplicationName = ctxName;
 		File home = new File(System.getenv("RED5_HOME"));
 		OmFileHelper.setOmHome(new File(new File(home, "webapps"), ctxName));
-		
+
 		CommandLineParser parser = new DefaultParser();
 		try {
 			cmdl = parser.parse(opts, args);
@@ -266,18 +266,18 @@ public class Admin {
 					if (cmdl.hasOption("file")) {
 						File backup = checkRestoreFile(file);
 						dropDB(connectionProperties);
-						
+
 						ImportInitvalues importInit = getApplicationContext().getBean(ImportInitvalues.class);
-						importInit.loadSystem(cfg, force); 
+						importInit.loadSystem(cfg, force);
 						restoreOm(backup);
 					} else {
 						checkAdminDetails();
 						dropDB(connectionProperties);
-						
+
 						ImportInitvalues importInit = getApplicationContext().getBean(ImportInitvalues.class);
 						importInit.loadAll(cfg, force);
-					}					
-					
+					}
+
 					InstallationDocumentHandler.createDocument(3);
 				} catch(Exception e) {
 					handleError("Install failed", e);
@@ -296,7 +296,7 @@ public class Admin {
 					boolean includeFiles = !cmdl.hasOption("exclude-files");
 					File backup_dir = new File(OmFileHelper.getUploadBackupDir(), "" + System.currentTimeMillis());
 					backup_dir.mkdirs();
-					
+
 					BackupExport export = getApplicationContext().getBean(BackupExport.class);
 					export.performExport(f, backup_dir, includeFiles, new ProgressHolder());
 					FileUtils.deleteDirectory(backup_dir);
@@ -316,7 +316,7 @@ public class Admin {
 				try {
 					boolean cleanup = cmdl.hasOption("cleanup");
 					if (cleanup) {
-						System.out.println("WARNING: all intermadiate files will be clean up!");
+						System.out.println("WARNING: all intermediate files will be clean up!");
 					}
 					StringBuilder report = new StringBuilder();
 					{ //UPLOAD
@@ -397,11 +397,11 @@ public class Admin {
 				usage();
 				break;
 		}
-		
+
 		System.out.println("... Done");
 		System.exit(0);
 	}
-	
+
 	private void checkAdminDetails() throws Exception {
 		cfg.username = cmdl.getOptionValue("user");
 		cfg.email = cmdl.getOptionValue("email");
@@ -410,7 +410,7 @@ public class Admin {
 			System.out.println("User login was not provided, or too short, should be at least " + USER_LOGIN_MINIMUM_LENGTH + " character long.");
 			System.exit(1);
 		}
-		
+
 		try {
 			if (cfg.email == null || !MailUtil.matches(cfg.email)) {
 				throw new AddressException("Invalid address");
@@ -442,26 +442,26 @@ public class Admin {
 		}
 		if (cfg.ical_timeZone == null) {
 			System.out.println("Please enter timezone, Possible timezones are:");
-			
+
 			for (Map.Entry<String,String> me : tzMap.entrySet()) {
 				System.out.println(String.format("%1$-25s%2$s", "\"" + me.getKey() + "\"", me.getValue()));
 			}
 			System.exit(1);
 		}
 	}
-	
+
 	public void dropDB() throws Exception {
 		File conf = OmFileHelper.getPersistence();
 		ConnectionProperties connectionProperties = ConnectionPropertiesPatcher.getConnectionProperties(conf);
 		immediateDropDB(connectionProperties);
 	}
-	
+
 	private void dropDB(ConnectionProperties props) throws Exception {
 		if(cmdl.hasOption("drop")) {
 			immediateDropDB(props);
 		}
 	}
-	
+
 	private static LogImpl getLogImpl(JDBCConfiguration conf) {
 		return (LogImpl)conf.getLog(JDBCConfiguration.LOG_SCHEMA);
 	}
@@ -477,7 +477,7 @@ public class Admin {
 		}
 		st.run();
 	}
-	
+
 	private void immediateDropDB(ConnectionProperties props) throws Exception {
 		if (ctx != null) {
 			destroyApplication();
@@ -506,10 +506,10 @@ public class Admin {
 			usage();
 			System.exit(1);
 		}
-		
+
 		return backup;
 	}
-	
+
 	private void restoreOm(File backup) {
 		try (InputStream is = new FileInputStream(backup)) {
 			BackupImport importCtrl = getApplicationContext().getBean(BackupImport.class);
@@ -518,7 +518,7 @@ public class Admin {
 			handleError("Restore failed", e);
 		}
 	}
-	
+
 	public static void main(String[] args) {
 		new Admin().process(args);
 	}

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=1783732&r1=1783731&r2=1783732&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 Mon Feb 20 09:58:01 2017
@@ -18,8 +18,7 @@
  */
 package org.apache.openmeetings.cli;
 
-import static org.apache.openmeetings.util.OmFileHelper.EXTENSION_FLV;
-import static org.apache.openmeetings.util.OmFileHelper.recordingFileName;
+import static org.apache.openmeetings.util.OmFileHelper.EXTENSION_MP4;
 
 import java.io.File;
 import java.io.FilenameFilter;
@@ -41,7 +40,7 @@ import org.slf4j.Logger;
 public class CleanupHelper {
 	private static final Logger log = Red5LoggerFactory.getLogger(CleanupHelper.class);
 	private static File hibernateDir = OmFileHelper.getStreamsHibernateDir();
-	
+
 	public static CleanupEntityUnit getProfileUnit(final UserDao udao) {
 		File parent = OmFileHelper.getUploadProfilesDir();
 		List<File> invalid = new ArrayList<>();
@@ -102,29 +101,29 @@ public class CleanupHelper {
 		for (File f : list(hibernateDir, new FilenameFilter() {
 			@Override
 			public boolean accept(File dir, String name) {
-				return name.startsWith(recordingFileName) && name.endsWith(EXTENSION_FLV);
+				return name.endsWith(EXTENSION_MP4);
 			}
 		})) {
 			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() - EXTENSION_FLV.length() - 1));
-			Recording item = recordDao.get(id);
+			String hash = f.getName().substring(0, f.getName().length() - EXTENSION_MP4.length() - 1);
+			Recording item = recordDao.getByHash(hash);
 			if (item == null) {
-				add(invalid, id);
+				add(invalid, hash);
 			} else if (item.isDeleted()) {
-				add(deleted, id);
+				add(deleted, hash);
 			}
 		}
 		for (Recording item : recordDao.get()) {
-			if (!item.isDeleted() && item.getHash() != null && list(item.getId()).length == 0) {
+			if (!item.isDeleted() && item.getHash() != null && list(item.getHash()).length == 0) {
 				missing++;
 			}
 		}
 		return new CleanupEntityUnit(parent, invalid, deleted, missing) {
 			private static final long serialVersionUID = 1L;
-			
+
 			@Override
 			public void cleanup() throws IOException {
 				String hiberPath = hibernateDir.getCanonicalPath();
@@ -142,18 +141,18 @@ public class CleanupHelper {
 		File[] l = ff == null ? f.listFiles() : f.listFiles(ff);
 		return l == null ? new File[0] : l;
 	}
-	
-	private static File[] list(final Long id) {
+
+	private static File[] list(final String hash) {
 		return list(hibernateDir, new FilenameFilter() {
 			@Override
 			public boolean accept(File dir, String name) {
-				return name.startsWith(recordingFileName + id);
+				return name.startsWith(hash);
 			}
 		});
 	}
-	
-	private static void add(List<File> list, final Long id) {
-		for (File f : list(id)) {
+
+	private static void add(List<File> list, final String hash) {
+		for (File f : list(hash)) {
 			list.add(f);
 		}
 	}