Author: solomax
Date: Fri Mar 30 19:50:48 2012
New Revision: 1307586
URL: http://svn.apache.org/viewvc?rev=1307586&view=rev
Log:
OPENMEETINGS-111 backup partially done
Added:
incubator/openmeetings/trunk/singlewebapp/WebContent/red5/admin.sh
incubator/openmeetings/trunk/singlewebapp/WebContent/red5/jee-container-ssl.xml
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/app/Admin.java
Modified:
incubator/openmeetings/trunk/singlewebapp/build.xml
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/servlet/outputhandler/BackupExport.java
Added: incubator/openmeetings/trunk/singlewebapp/WebContent/red5/admin.sh
URL:
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/WebContent/red5/admin.sh?rev=1307586&view=auto
==============================================================================
--- incubator/openmeetings/trunk/singlewebapp/WebContent/red5/admin.sh (added)
+++ incubator/openmeetings/trunk/singlewebapp/WebContent/red5/admin.sh Fri Mar
30 19:50:48 2012
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+export
CLASSPATH=.:webapps/openmeetings/WEB-INF/classes:lib/*.jar:webapps/openmeetings/WEB-INF/lib/*.jar
+
+java -cp $CLASSPATH org.openmeetings.app.Admin
+
Added:
incubator/openmeetings/trunk/singlewebapp/WebContent/red5/jee-container-ssl.xml
URL:
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/WebContent/red5/jee-container-ssl.xml?rev=1307586&view=auto
==============================================================================
---
incubator/openmeetings/trunk/singlewebapp/WebContent/red5/jee-container-ssl.xml
(added)
+++
incubator/openmeetings/trunk/singlewebapp/WebContent/red5/jee-container-ssl.xml
Fri Mar 30 19:50:48 2012
@@ -0,0 +1,221 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:lang="http://www.springframework.org/schema/lang"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/lang
http://www.springframework.org/schema/lang/spring-lang-3.0.xsd">
+
+ <bean id="tomcat.server" class="org.red5.server.tomcat.TomcatLoader"
init-method="init" destroy-method="shutdown" depends-on="context.loader">
+
+ <property name="webappFolder" value="${red5.root}/webapps" />
+
+ <property name="connector">
+ <bean class="org.apache.catalina.connector.Connector">
+ <!-- Blocking I/O -->
+ <constructor-arg type="java.lang.String"
value="org.apache.coyote.http11.Http11Protocol" />
+ <!-- Non-blocking I/O -->
+ <!--
+ <constructor-arg type="java.lang.String"
value="org.apache.coyote.http11.Http11NioProtocol" />
+ -->
+ <property name="port"><value>${https.port}</value></property>
+ <property
name="redirectPort"><value>${http.port}</value></property>
+ <property name="enableLookups"><value>false</value></property>
+ <property name="useIPVHosts"><value>true</value></property>
+ </bean>
+ </property>
+
+ <property name="address">
+ <bean class="java.net.InetSocketAddress">
+ <constructor-arg index="0" type="java.lang.String"
value="${http.host}" />
+ <constructor-arg index="1" type="int" value="${http.port}" />
+ </bean>
+ </property>
+
+ <property name="connectionProperties">
+ <map>
+ <entry>
+ <key><value>port</value></key>
+ <value>${https.port}</value>
+ </entry>
+ <entry>
+ <key><value>redirectPort</value></key>
+ <value>${http.port}</value>
+ </entry>
+ <entry>
+ <key><value>SSLEnabled</value></key>
+ <value>true</value>
+ </entry>
+ <entry>
+ <key><value>sslProtocol</value></key>
+ <value>TLS</value>
+ </entry>
+ <entry>
+ <key><value>clientAuth</value></key>
+ <value>false</value>
+ </entry>
+ <entry>
+ <key><value>keystoreFile</value></key>
+ <value>conf/keystore</value>
+ </entry>
+ <entry>
+ <key><value>keystorePass</value></key>
+ <value>${rtmps.keystorepass}</value>
+ </entry>
+ <entry>
+ <key><value>keystoreType</value></key>
+ <value>JKS</value>
+ </entry>
+ <entry key="maxKeepAliveRequests"
value="${rtmps.max_keep_alive_requests}"/>
+ <entry key="useExecutor" value="true"/>
+ <entry key="maxThreads"
value="${rtmps.max_threads}"/>
+ <entry key="acceptorThreadCount"
value="${rtmps.acceptor_thread_count}"/>
+ <entry key="processorCache"
value="${rtmps.processor_cache}"/>
+ </map>
+ </property>
+
+
+ <property name="baseHost">
+ <bean class="org.apache.catalina.core.StandardHost">
+ <property name="name" value="${http.host}" />
+ <property name="unpackWARs" value="true" />
+ <property name="autoDeploy" value="true" />
+ <property name="xmlValidation" value="false" />
+ <property name="xmlNamespaceAware" value="false" />
+ </bean>
+ </property>
+
+ <property name="valves">
+ <list>
+ <bean id="valve.access"
class="org.apache.catalina.valves.AccessLogValve">
+ <property name="directory" value="log" />
+ <property name="prefix" value="${http.host}_access." />
+ <property name="suffix" value=".log" />
+ <property name="pattern" value="common" />
+ <property name="resolveHosts" value="false" />
+ <property name="rotatable" value="true" />
+ </bean>
+ </list>
+ </property>
+
+ </bean>
+
+ <!-- RTMPT (dedicated server) -->
+<!--
+ <bean id="rtmpt.server"
class="org.red5.server.tomcat.rtmpt.RTMPTLoader" init-method="init"
lazy-init="true">
+
+ <property name="webappFolder" value="${red5.root}/webapps" />
+
+ <property name="connector">
+ <bean class="org.apache.catalina.connector.Connector">
+ <constructor-arg type="java.lang.String"
value="org.apache.coyote.http11.Http11NioProtocol" />
+ <property
name="port"><value>${rtmpt.port}</value></property>
+ <property
name="enableLookups"><value>false</value></property>
+ </bean>
+ </property>
+
+ <property name="connectionProperties">
+ <map>
+ <entry key="maxKeepAliveRequests"
value="${rtmpt.max_keep_alive_requests}"/>
+ <entry key="useExecutor" value="true"/>
+ <entry key="maxThreads"
value="${rtmpt.max_threads}"/>
+ <entry key="acceptorThreadCount"
value="${rtmpt.acceptor_thread_count}"/>
+ <entry key="processorCache"
value="${rtmpt.processor_cache}"/>
+ </map>
+ </property>
+
+ <property name="host">
+ <bean class="org.apache.catalina.core.StandardHost">
+ <property name="name" value="${rtmpt.host}" />
+ <property name="unpackWARs" value="false" />
+ <property name="autoDeploy" value="false" />
+ <property name="xmlValidation" value="false" />
+ <property name="xmlNamespaceAware"
value="false" />
+ </bean>
+ </property>
+
+ </bean>
+-->
+
+ <!-- RTMPS (dedicated server) -->
+<!--
+ <bean id="rtmps.server"
class="org.red5.server.tomcat.rtmps.RTMPSLoader" init-method="init"
lazy-init="true">
+
+ <property name="webappFolder" value="${red5.root}/webapps" />
+
+ <property name="connector">
+ <bean class="org.apache.catalina.connector.Connector">
+ <constructor-arg type="java.lang.String"
value="org.apache.coyote.http11.Http11NioProtocol" />
+ <property name="port" value="${rtmps.port}" />
+ <property name="redirectPort"
value="${rtmp.port}" />
+ </bean>
+ </property>
+
+ <property name="host">
+ <bean class="org.apache.catalina.core.StandardHost">
+ <property name="name" value="${rtmps.host}" />
+ <property name="unpackWARs" value="false" />
+ <property name="autoDeploy" value="false" />
+ <property name="xmlValidation" value="false" />
+ <property name="xmlNamespaceAware"
value="false" />
+ </bean>
+ </property>
+
+ <property name="connectionProperties">
+ <map>
+ <entry>
+ <key><value>port</value></key>
+ <value>${rtmps.port}</value>
+ </entry>
+ <entry>
+ <key><value>redirectPort</value></key>
+ <value>${rtmp.port}</value>
+ </entry>
+ <entry>
+ <key><value>SSLEnabled</value></key>
+ <value>true</value>
+ </entry>
+ <entry>
+ <key><value>sslProtocol</value></key>
+ <value>TLS</value>
+ </entry>
+ <entry>
+ <key><value>clientAuth</value></key>
+ <value>false</value>
+ </entry>
+ <entry>
+ <key><value>keystoreFile</value></key>
+ <value>conf/keystore</value>
+ </entry>
+ <entry>
+ <key><value>keystorePass</value></key>
+ <value>${rtmps.keystorepass}</value>
+ </entry>
+ <entry>
+ <key><value>keystoreType</value></key>
+ <value>JKS</value>
+ </entry>
+ <entry key="maxKeepAliveRequests"
value="${rtmps.max_keep_alive_requests}"/>
+ <entry key="useExecutor" value="true"/>
+ <entry key="maxThreads"
value="${rtmps.max_threads}"/>
+ <entry key="acceptorThreadCount"
value="${rtmps.acceptor_thread_count}"/>
+ <entry key="processorCache"
value="${rtmps.processor_cache}"/>
+ </map>
+ </property>
+
+ <property name="valves">
+ <list>
+ <bean id="valve.access"
class="org.apache.catalina.valves.AccessLogValve">
+ <property name="directory" value="log" />
+ <property name="prefix"
value="${rtmps.host}_rtmps_access." />
+ <property name="suffix" value=".log" />
+ <property name="pattern" value="common" />
+ <property name="resolveHosts" value="false" />
+ <property name="rotatable" value="true" />
+ </bean>
+ </list>
+ </property>
+
+ </bean>
+-->
+
+</beans>
Modified: incubator/openmeetings/trunk/singlewebapp/build.xml
URL:
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/build.xml?rev=1307586&r1=1307585&r2=1307586&view=diff
==============================================================================
--- incubator/openmeetings/trunk/singlewebapp/build.xml (original)
+++ incubator/openmeetings/trunk/singlewebapp/build.xml Fri Mar 30 19:50:48 2012
@@ -702,8 +702,13 @@
<delete dir="${red5.lib}/webapps/installer"/>
<delete dir="${red5.lib}/webapps/live"/>
<delete dir="${red5.lib}/webapps/vod"/>
- <copy file="${webcontent.src.dir}/red5/jee-container.xml"
todir="${red5.lib}/conf" overwrite="true" force="true"/>
+ <copy todir="${red5.lib}/conf" overwrite="true" force="true">
+ <fileset dir="${webcontent.src.dir}/red5"
includes="jee-container*.xml"/>
+ </copy>
<copy file="${webcontent.src.dir}/red5/index.html"
todir="${red5.lib}/webapps/root" overwrite="true" force="true"/>
+ <copy todir="${red5.lib}" overwrite="true" force="true">
+ <fileset dir="${webcontent.src.dir}/red5"
includes="admin.*"/>
+ </copy>
</target>
<!-- Check for the Top level libraries -->
<target name="-retrieve-mainlibs" unless="mainlib.installed"
description="Retrieves the libraries if needed" depends="-retrieve-red5">
Added:
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/app/Admin.java
URL:
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/app/Admin.java?rev=1307586&view=auto
==============================================================================
---
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/app/Admin.java
(added)
+++
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/app/Admin.java
Fri Mar 30 19:50:48 2012
@@ -0,0 +1,90 @@
+package org.openmeetings.app;
+
+import java.io.File;
+
+import org.openmeetings.servlet.outputhandler.BackupExport;
+import org.red5.logging.Red5LoggerFactory;
+import org.slf4j.Logger;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class Admin {
+ private static final Logger log =
Red5LoggerFactory.getLogger(Admin.class);
+ private boolean verbose = false;
+
+ private enum Command {
+ install
+ , backup
+ , restore
+ }
+
+ private void handleError(String msg, Exception e) {
+ if (verbose) {
+ log.error(msg, e);
+ } else {
+ log.error(msg + e.getMessage());
+ }
+ System.exit(1);
+ }
+
+ private String getFile(String[] args) {
+ String result = null;
+ for (int i = 0; i < args.length; ++i) {
+ String a = args[i];
+ if ("-file".equals(a)) {
+ result = args[i + 1];
+ break;
+ }
+ }
+ return result;
+ }
+
+ private void process(String[] args) {
+ String red5Home = "webapps/openmeetings/";
+ for (String a : args) {
+ if ("-v".equals(a)) {
+ verbose = true;
+ break;
+ }
+ }
+ ClassPathXmlApplicationContext applicationContext = null;
+ try {
+ applicationContext = new
ClassPathXmlApplicationContext("openmeetings-applicationContext.xml");
+ } catch (Exception e) {
+ handleError("Unable to obtain application context", e);
+ }
+
+ Command cmd = null;
+ try {
+ cmd = Command.valueOf(args[0]);
+ } catch (Exception e) {
+ handleError("Failed to get command ", e);
+ }
+ switch(cmd) {
+ case install:
+ break;
+ case backup:
+ try {
+ //FIXME !!!! cleanup
+ //FIXME hardcoded paths
+ BackupExport export =
(BackupExport)applicationContext.getBean("backupExport");
+ String backup_dir = red5Home +
"uploadtemp/" + System.currentTimeMillis() + "/";
+ new File(backup_dir).mkdirs();
+ export.performExport(getFile(args),
backup_dir, true, red5Home);
+ export.deleteDirectory(new
File(backup_dir));
+ } catch (Exception e) {
+ handleError("Backup failed", e);
+ }
+ break;
+ case restore:
+ break;
+ }
+
+ //Exit the shell process
+ log.info("... Done");
+ System.exit(0);
+ }
+
+ public static void main(String[] args) {
+ new Admin().process(args);
+ }
+}
Modified:
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/servlet/outputhandler/BackupExport.java
URL:
http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/servlet/outputhandler/BackupExport.java?rev=1307586&r1=1307585&r2=1307586&view=diff
==============================================================================
---
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/servlet/outputhandler/BackupExport.java
(original)
+++
incubator/openmeetings/trunk/singlewebapp/src/org/openmeetings/servlet/outputhandler/BackupExport.java
Fri Mar 30 19:50:48 2012
@@ -128,385 +128,349 @@ public class BackupExport {
@Autowired
private PollManagement pollManagement;
- /*
- * (non-Javadoc)
- *
- * @see
- *
javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest
- * , javax.servlet.http.HttpServletResponse)
- */
- public void service(HttpServletRequest httpServletRequest,
- HttpServletResponse httpServletResponse, ServletContext
servletCtx)
- throws ServletException, IOException {
+ public void performExport(String filePath, String backup_dir,
+ boolean includeFiles, String omFilesDir) throws
Exception {
+ /*
+ * ##################### Backup Organizations
+ */
+ List<Organisation> orgList = organisationmanagement
+ .getOrganisations(3L);
- try {
- String sid = httpServletRequest.getParameter("sid");
- if (sid == null) {
- sid = "default";
- }
- log.debug("sid: " + sid);
+ if (orgList != null) {
+ Document doc = this.createOrgDocument(orgList);
- Long users_id = sessionManagement.checkSession(sid);
- Long user_level =
userManagement.getUserLevelByID(users_id);
+ String orgListXML = backup_dir + "organizations.xml";
- log.debug("users_id: " + users_id);
- log.debug("user_level: " + user_level);
+ FileOutputStream fos = new FileOutputStream(orgListXML);
- if (authLevelManagement.checkAdminLevel(user_level)) {
- // if (true) {
+ this.serializetoXML(fos, "UTF-8", doc);
+ }
- String includeFileOption = httpServletRequest
-
.getParameter("includeFileOption");
- if (includeFileOption == null) {
- includeFileOption = "yes";
- }
+ /*
+ * ##################### Backup Users
+ */
- String moduleName = httpServletRequest
- .getParameter("moduleName");
- if (moduleName == null) {
- moduleName = "moduleName";
- }
- log.debug("moduleName: " + moduleName);
+ List<Users> uList = usersDao.getAllUsersDeleted();
- if (moduleName.equals("backup")) {
+ if (uList != null) {
+ log.debug("Number of Users to be deleted " +
uList.size());
- /*
- * ##################### Create Base
Folder structure
- */
+ Document doc = this.createDocument(uList);
- String current_dir =
servletCtx.getRealPath("/");
- String working_dir = current_dir +
"upload"
- + File.separatorChar +
"backup"
- + File.separatorChar;
- File working_dirFile = new
File(working_dir);
+ String userListXML = backup_dir + "users.xml";
- if (!working_dirFile.exists()) {
- working_dirFile.mkdir();
- }
+ FileOutputStream fos = new
FileOutputStream(userListXML);
- String dateString = "backup_"
- +
CalendarPatterns.getTimeForStreamId(new Date());
+ this.serializetoXML(fos, "UTF-8", doc);
+ }
- String backup_file = working_dir +
File.separatorChar
- + dateString;
+ /*
+ * ##################### Backup Room
+ */
+ List<Rooms> roomList = roommanagement.getBackupRooms();
- String backup_dir = backup_file +
File.separatorChar;
+ if (roomList != null) {
+ Document doc = this.createRoomsDocument(roomList);
- File backup_dirFile = new
File(backup_dir);
+ String roomListXML = backup_dir + "rooms.xml";
- if (!backup_dirFile.exists()) {
- backup_dirFile.mkdir();
- }
+ FileOutputStream fos = new
FileOutputStream(roomListXML);
- /*
- * ##################### Backup
Organizations
- */
- List<Organisation> orgList =
organisationmanagement
- .getOrganisations(3L);
+ this.serializetoXML(fos, "UTF-8", doc);
+ }
- if (orgList != null) {
- Document doc =
this.createOrgDocument(orgList);
+ /*
+ * ##################### Backup Room Organizations
+ */
+ List<Rooms_Organisation> roomOrgList = roommanagement
+ .getRoomsOrganisations();
- String orgListXML = backup_dir
+ "organizations.xml";
+ if (roomOrgList != null) {
+ Document doc = this.createOrgRoomsDocument(roomOrgList);
- FileOutputStream fos = new
FileOutputStream(orgListXML);
+ String roomListXML = backup_dir +
"rooms_organisation.xml";
- this.serializetoXML(fos,
"UTF-8", doc);
+ FileOutputStream fos = new
FileOutputStream(roomListXML);
- }
+ this.serializetoXML(fos, "UTF-8", doc);
+ }
- /*
- * ##################### Backup Users
- */
+ /*
+ * ##################### Backup Appointements
+ */
+ List<Appointment> aList = appointmentDao.getAppointments();
- List<Users> uList =
usersDao.getAllUsersDeleted();
+ if (aList != null) {
+ Document doc = this.createAppointementDocument(aList);
- if (uList != null) {
+ String aListXML = backup_dir + "appointements.xml";
- log.debug("Number of Users to
be deleted "
- + uList.size());
+ FileOutputStream fos = new FileOutputStream(aListXML);
- Document doc =
this.createDocument(uList);
+ this.serializetoXML(fos, "UTF-8", doc);
- String userListXML = backup_dir
+ "users.xml";
+ }
- FileOutputStream fos = new
FileOutputStream(userListXML);
+ /*
+ * ##################### Backup Meeting Members
+ */
+ List<MeetingMember> membersList =
meetingMemberDao.getMeetingMembers();
- this.serializetoXML(fos,
"UTF-8", doc);
+ if (membersList != null) {
+ Document doc =
this.createMeetingMemberDocument(membersList);
- }
+ String aListXML = backup_dir + "meetingmembers.xml";
- /*
- * ##################### Backup Room
- */
- List<Rooms> roomList =
roommanagement.getBackupRooms();
+ FileOutputStream fos = new FileOutputStream(aListXML);
- if (roomList != null) {
- Document doc =
this.createRoomsDocument(roomList);
+ this.serializetoXML(fos, "UTF-8", doc);
- String roomListXML = backup_dir
+ "rooms.xml";
+ }
- FileOutputStream fos = new
FileOutputStream(roomListXML);
+ /*
+ * ##################### LDAP Configs
+ */
+ List<LdapConfig> ldapConfigList =
ldapConfigDao.getLdapConfigs();
- this.serializetoXML(fos,
"UTF-8", doc);
+ if (ldapConfigList != null) {
+ Document doc =
this.createLdapConfigDocument(ldapConfigList);
- }
+ String aListXML = backup_dir + "ldapconfigs.xml";
- /*
- * ##################### Backup Room
Organizations
- */
- List<Rooms_Organisation> roomOrgList =
roommanagement
-
.getRoomsOrganisations();
+ FileOutputStream fos = new FileOutputStream(aListXML);
- if (roomOrgList != null) {
- Document doc =
this.createOrgRoomsDocument(roomOrgList);
+ this.serializetoXML(fos, "UTF-8", doc);
+ }
- String roomListXML = backup_dir
- +
"rooms_organisation.xml";
+ /*
+ * ##################### Private Messages
+ */
+ List<PrivateMessages> privateMessages = privateMessagesDao
+ .getPrivateMessages();
- FileOutputStream fos = new
FileOutputStream(roomListXML);
+ if (privateMessages != null) {
+ Document doc =
this.createPrivateMessagesDocument(privateMessages);
- this.serializetoXML(fos,
"UTF-8", doc);
+ String aListXML = backup_dir + "privateMessages.xml";
- }
+ FileOutputStream fos = new FileOutputStream(aListXML);
- /*
- * ##################### Backup
Appointements
- */
- List<Appointment> aList =
appointmentDao.getAppointments();
+ this.serializetoXML(fos, "UTF-8", doc);
+ }
- if (aList != null) {
- Document doc =
this.createAppointementDocument(aList);
+ /*
+ * ##################### Private Message Folders
+ */
+ List<PrivateMessageFolder> privateMessageFolders =
privateMessageFolderDao
+ .getPrivateMessageFolders();
- String aListXML = backup_dir +
"appointements.xml";
+ if (privateMessageFolders != null) {
+ Document doc = this
+
.createPrivateMessageFolderDocument(privateMessageFolders);
- FileOutputStream fos = new
FileOutputStream(aListXML);
+ String aListXML = backup_dir +
"privateMessageFolder.xml";
- this.serializetoXML(fos,
"UTF-8", doc);
+ FileOutputStream fos = new FileOutputStream(aListXML);
- }
+ this.serializetoXML(fos, "UTF-8", doc);
+ }
- /*
- * ##################### Backup Meeting
Members
- */
- List<MeetingMember> membersList =
meetingMemberDao
- .getMeetingMembers();
+ /*
+ * ##################### User Contacts
+ */
+ List<UserContacts> userContacts =
userContactsDao.getUserContacts();
- if (membersList != null) {
- Document doc = this
-
.createMeetingMemberDocument(membersList);
+ if (privateMessageFolders != null) {
+ Document doc =
this.createUserContactsDocument(userContacts);
- String aListXML = backup_dir +
"meetingmembers.xml";
+ String aListXML = backup_dir + "userContacts.xml";
- FileOutputStream fos = new
FileOutputStream(aListXML);
+ FileOutputStream fos = new FileOutputStream(aListXML);
- this.serializetoXML(fos,
"UTF-8", doc);
+ this.serializetoXML(fos, "UTF-8", doc);
+ }
- }
+ /*
+ * ##################### File-Explorer
+ */
+ List<FileExplorerItem> fileExplorerList = fileExplorerItemDao
+ .getFileExplorerItems();
- /*
- * ##################### LDAP Configs
- */
- List<LdapConfig> ldapConfigList =
ldapConfigDao
- .getLdapConfigs();
+ if (fileExplorerList != null) {
+ Document doc = this
+
.createFileExplorerItemDocument(fileExplorerList);
- if (ldapConfigList != null) {
- Document doc = this
-
.createLdapConfigDocument(ldapConfigList);
+ String aListXML = backup_dir + "fileExplorerItems.xml";
- String aListXML = backup_dir +
"ldapconfigs.xml";
+ FileOutputStream fos = new FileOutputStream(aListXML);
- FileOutputStream fos = new
FileOutputStream(aListXML);
+ this.serializetoXML(fos, "UTF-8", doc);
+ }
- this.serializetoXML(fos,
"UTF-8", doc);
+ /*
+ * ##################### Recordings
+ */
+ List<FlvRecording> flvRecordings = flvRecordingDao
+ .getAllFlvRecordings();
+
+ for (FlvRecording flvRecording : flvRecordings) {
+
flvRecording.setFlvRecordingMetaData(flvRecordingMetaDataDao
+
.getFlvRecordingMetaDataByRecording(flvRecording
+ .getFlvRecordingId()));
+ }
- }
+ if (privateMessageFolders != null) {
+ Document doc =
this.createFlvRecordingDocument(flvRecordings);
- /*
- * ##################### Private
Messages
- */
- List<PrivateMessages> privateMessages =
privateMessagesDao
- .getPrivateMessages();
+ String aListXML = backup_dir + "flvRecordings.xml";
- if (privateMessages != null) {
- Document doc = this
-
.createPrivateMessagesDocument(privateMessages);
+ FileOutputStream fos = new FileOutputStream(aListXML);
- String aListXML = backup_dir +
"privateMessages.xml";
+ this.serializetoXML(fos, "UTF-8", doc);
+ }
- FileOutputStream fos = new
FileOutputStream(aListXML);
+ /*
+ * ##################### Polls
+ */
+ List<RoomPoll> roomPolls = pollManagement.getPollListBackup();
- this.serializetoXML(fos,
"UTF-8", doc);
- }
+ if (roomPolls != null) {
+ Document doc = this.createRoomPollDocument(roomPolls);
- /*
- * ##################### Private
Message Folders
- */
- List<PrivateMessageFolder>
privateMessageFolders = privateMessageFolderDao
-
.getPrivateMessageFolders();
+ String aListXML = backup_dir + "roompolls.xml";
- if (privateMessageFolders != null) {
- Document doc = this
-
.createPrivateMessageFolderDocument(privateMessageFolders);
+ FileOutputStream fos = new FileOutputStream(aListXML);
- String aListXML = backup_dir
- +
"privateMessageFolder.xml";
+ this.serializetoXML(fos, "UTF-8", doc);
+ }
- FileOutputStream fos = new
FileOutputStream(aListXML);
+ if (includeFiles) {
+ /*
+ * ##################### Backup Room Files
+ */
+ File targetDir = new File(backup_dir +
File.separatorChar
+ + "roomFiles");
- this.serializetoXML(fos,
"UTF-8", doc);
- }
+ if (!targetDir.exists()) {
+ targetDir.mkdir();
+ }
- /*
- * ##################### User Contacts
- */
- List<UserContacts> userContacts =
userContactsDao
- .getUserContacts();
+ File sourceDir = new File(omFilesDir + "upload"
+ + File.separatorChar);
- if (privateMessageFolders != null) {
- Document doc = this
-
.createUserContactsDocument(userContacts);
+ File[] files = sourceDir.listFiles();
+ for (File file : files) {
+ if (file.isDirectory()) {
+ if (!file.getName().equals("backup")
+ &&
!file.getName().equals("import")) {
- String aListXML = backup_dir +
"userContacts.xml";
+ targetDir = new File(backup_dir
+ File.separatorChar
+ + "roomFiles" +
File.separatorChar
+ +
file.getName());
- FileOutputStream fos = new
FileOutputStream(aListXML);
+ log.debug("### " +
file.getName());
- this.serializetoXML(fos,
"UTF-8", doc);
+ copyDirectory(file, targetDir);
}
+ }
+ }
- /*
- * ##################### File-Explorer
- */
- List<FileExplorerItem> fileExplorerList
= fileExplorerItemDao
- .getFileExplorerItems();
+ /*
+ * ##################### Backup Recording Files
+ */
+ File targetDirRec = new File(backup_dir +
File.separatorChar
+ + "recordingFiles");
- if (fileExplorerList != null) {
+ if (!targetDirRec.exists()) {
+ targetDirRec.mkdir();
+ }
- Document doc = this
-
.createFileExplorerItemDocument(fileExplorerList);
+ File sourceDirRec = new File(omFilesDir + "streams"
+ + File.separatorChar + "hibernate" +
File.separatorChar);
- String aListXML = backup_dir +
"fileExplorerItems.xml";
+ copyDirectory(sourceDirRec, targetDirRec);
+ }
+ File backup_dirFile = new File(backup_dir);
- FileOutputStream fos = new
FileOutputStream(aListXML);
+ if (!backup_dirFile.exists()) {
+ backup_dirFile.mkdir();
+ }
- this.serializetoXML(fos,
"UTF-8", doc);
+ List<File> fileList = new ArrayList<File>();
+ log.debug("---Getting references to all files in: "
+ + backup_dirFile.getCanonicalPath());
+ getAllFiles(backup_dirFile, fileList);
+ log.debug("---Creating zip file");
+ writeZipFile(backup_dirFile, fileList, new
FileOutputStream(filePath));
+ log.debug("---Done");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ *
javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest
+ * , javax.servlet.http.HttpServletResponse)
+ */
+ public void service(HttpServletRequest httpServletRequest,
+ HttpServletResponse httpServletResponse, ServletContext
servletCtx)
+ throws ServletException, IOException {
- }
+ try {
+ String sid = httpServletRequest.getParameter("sid");
+ if (sid == null) {
+ sid = "default";
+ }
+ log.debug("sid: " + sid);
- /*
- * ##################### Recordings
- */
- List<FlvRecording> flvRecordings =
flvRecordingDao
- .getAllFlvRecordings();
+ Long users_id = sessionManagement.checkSession(sid);
+ Long user_level =
userManagement.getUserLevelByID(users_id);
- for (FlvRecording flvRecording :
flvRecordings) {
- flvRecording
-
.setFlvRecordingMetaData(flvRecordingMetaDataDao
-
.getFlvRecordingMetaDataByRecording(flvRecording
-
.getFlvRecordingId()));
- }
+ log.debug("users_id: " + users_id);
+ log.debug("user_level: " + user_level);
- if (privateMessageFolders != null) {
- Document doc = this
-
.createFlvRecordingDocument(flvRecordings);
+ if (authLevelManagement.checkAdminLevel(user_level)) {
+ // if (true) {
- String aListXML = backup_dir +
"flvRecordings.xml";
+ String includeFileOption = httpServletRequest
+
.getParameter("includeFileOption");
+ boolean includeFiles = includeFileOption ==
null || "yes".equals(includeFileOption);
- FileOutputStream fos = new
FileOutputStream(aListXML);
+ String moduleName = httpServletRequest
+ .getParameter("moduleName");
+ if (moduleName == null) {
+ moduleName = "moduleName";
+ }
+ log.debug("moduleName: " + moduleName);
- this.serializetoXML(fos,
"UTF-8", doc);
- }
+ if (moduleName.equals("backup")) {
/*
- * ##################### Polls
+ * ##################### Create Base
Folder structure
*/
- List<RoomPoll> roomPolls =
pollManagement
- .getPollListBackup();
- if (roomPolls != null) {
-
- Document doc =
this.createRoomPollDocument(roomPolls);
-
- String aListXML = backup_dir +
"roompolls.xml";
-
- FileOutputStream fos = new
FileOutputStream(aListXML);
-
- this.serializetoXML(fos,
"UTF-8", doc);
+ String current_dir =
servletCtx.getRealPath("/");
+ String working_dir = current_dir +
"upload"
+ + File.separatorChar +
"backup"
+ + File.separatorChar;
+ File working_dirFile = new
File(working_dir);
+ if (!working_dirFile.exists()) {
+ working_dirFile.mkdir();
}
- if (includeFileOption.equals("yes")) {
-
- /*
- * ##################### Backup
Room Files
- */
- File targetDir = new
File(backup_dir
- +
File.separatorChar + "roomFiles");
-
- if (!targetDir.exists()) {
- targetDir.mkdir();
- }
-
- File sourceDir = new
File(current_dir + "upload"
- +
File.separatorChar);
-
- File[] files =
sourceDir.listFiles();
- for (File file : files) {
- if (file.isDirectory())
{
-
- if
(!file.getName().equals("backup")
-
&& !file.getName().equals("import")) {
-
-
targetDir = new File(backup_dir
-
+ File.separatorChar + "roomFiles"
-
+ File.separatorChar
-
+ file.getName());
-
-
log.debug("### " + file.getName());
-
-
copyDirectory(file, targetDir);
-
- }
-
- }
- }
-
- /*
- * ##################### Backup
Recording Files
- */
- File targetDirRec = new
File(backup_dir
- +
File.separatorChar + "recordingFiles");
-
- if (!targetDirRec.exists()) {
- targetDirRec.mkdir();
- }
-
- File sourceDirRec = new
File(current_dir + "streams"
- +
File.separatorChar + "hibernate"
- +
File.separatorChar);
+ String dateString = "backup_"
+ +
CalendarPatterns.getTimeForStreamId(new Date());
- copyDirectory(sourceDirRec,
targetDirRec);
+ String backup_file = working_dir +
File.separatorChar
+ + dateString;
- }
+ String backup_dir = backup_file +
File.separatorChar;
String full_path = backup_file + ".zip";
- // ZipOutputStream zos = new
ZipOutputStream(new
- // FileOutputStream(full_path));
- //
- // zipToDir(backup_dir, zos);
- //
- // zos.close();
-
- List<File> fileList = new
ArrayList<File>();
- log.debug("---Getting references to all
files in: "
- +
backup_dirFile.getCanonicalPath());
- getAllFiles(backup_dirFile, fileList);
- log.debug("---Creating zip file");
- writeZipFile(backup_dirFile, fileList,
- new
FileOutputStream(full_path));
- log.debug("---Done");
-
+ performExport(full_path, backup_dir,
includeFiles, current_dir);
+
RandomAccessFile rf = new
RandomAccessFile(full_path, "r");
String requestedFile = dateString +
".zip";
@@ -541,7 +505,7 @@ public class BackupExport {
backupFile.delete();
}
- this.deleteDirectory(backup_dirFile);
+ deleteDirectory(new File(backup_dir));
}
} else {
@@ -1452,8 +1416,9 @@ public class BackupExport {
room_organisation.addElement("rooms_organisation_id").addCDATA(
formatString("" +
roomOrg.getRooms_organisation_id()));
room_organisation.addElement("organisation_id").addCDATA(
- formatString(""
- +
roomOrg.getOrganisation().getOrganisation_id()));
+ "true".equals(roomOrg.getDeleted()) ? "0" :
+ formatString(""
+ +
roomOrg.getOrganisation().getOrganisation_id()));
if (roomOrg.getRoom() != null) {
room_organisation.addElement("rooms_id").addCDATA(
formatString("" +
roomOrg.getRoom().getRooms_id()));