http://git-wip-us.apache.org/repos/asf/openmeetings/blob/1cb3518f/openmeetings-server/src/site/xdoc/red5sip-integration_2.0.xml ---------------------------------------------------------------------- diff --git a/openmeetings-server/src/site/xdoc/red5sip-integration_2.0.xml b/openmeetings-server/src/site/xdoc/red5sip-integration_2.0.xml index 1e1d606..e3b0660 100644 --- a/openmeetings-server/src/site/xdoc/red5sip-integration_2.0.xml +++ b/openmeetings-server/src/site/xdoc/red5sip-integration_2.0.xml @@ -1,179 +1,179 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - --> -<document xmlns="http://maven.apache.org/XDOC/2.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd"> - <properties> - <title>SIP-Transport Integration</title> - <author email="[email protected]">Apache OpenMeetings Team</author> - </properties> - - <body> - - <section name="SIP-Transport Integration"> - <p> - You need minimum version 2.0 of Apache OpenMeetings to apply this guide! - </p> - <p> - Here is instruction how-to set up red5sip transport integration with OpenMeetings on Ubuntu 10.04. - </p> - </section> - - <section name="Setup Asterisk"> - <div> - Run the commands - <source> -<![CDATA[ -sudo apt-get update -sudo apt-get install asterisk asterisk-mysql -]]> - </source> - </div> - <div> - Ubuntu 10.04 has broken asterisk-mysql version. For other distribution next commands not needed: - <source> -<![CDATA[ -aptitude purge asterisk-mysql -cd /tmp -apt-get build-dep asterisk-mysql -apt-get -b source asterisk-mysql -dpkg -i asterisk-mysql_1.6.2.0-1_i386.deb -]]> - </source> - </div> - <div> - Enable asterisk mysql realtime module:<br/><br/> - Add string - <source> -<![CDATA[ -load => res_config_mysql.so -]]> - </source> - to the /etc/asterisk/modules.conf into the "modules" section. - </div> - <div> - Configure mysql realtime module:<br/><br/> - - Create file /etc/asterisk/res_mysql.conf and add lines: - <source> -<![CDATA[ -[general] -dbhost=127.0.0.1 -dbname=openmeetings -dbuser=root -dbpass= -dbport=3306 -]]> - </source> - </div> - <div> - Add next lines into the /etc/asterisk/extconfig.conf: - <source> -<![CDATA[ -[settings] -sipusers => mysql,general,sipusers -sippeers => mysql,general,sipusers -extensions => mysql,general,extensions -meetme => mysql,general,meetme -]]> - </source> - </div> - <div> - Add next lines into the /etc/asterisk/extensions.conf: - <source> -<![CDATA[ -[rooms] -switch => Realtime/@ -]]> - </source> - </div> - - <div> - Restart asterisk: - <source> -<![CDATA[ -service asterisk restart -]]> - </source> - Insert, for example, SIP user with name 'test': - <source> -<![CDATA[ -INSERT INTO sipusers (allow, context, disallow, host, name, secret) VALUES ('ulaw' , 'rooms', NULL, 'dynamic' , 'test', '12345'); -]]> - </source> - </div> - </section> - - <section name="Setup red5sip transport"> - <div> - Download red5sip from<tt>http://red5phone.googlecode.com/svn/branches/red5sip</tt> - </div> - <p> - Build with Apache Ant - </p> - <div> - Install jsvc: - <source> -<![CDATA[ -apt-get install jsvc -]]> - </source> - </div> - <div> - Insert proper values to the /opt/red5sip/settings.properties - - <source> -<![CDATA[ -red5.host - red5 server address (127.0.0.1) -sip.obproxy - asterisk adderss (127.0.0.1) -sip.phone - sip phone number (test) -sip.authid - sip auth id (test) -sip.secret - sip password (12345) -sip.realm - sip realm, "asterisk" by default -sip.proxy - -rooms - ids of openmeetings rooms, can be, for example, 2,3,5,6 -]]> - </source> - </div> - <div> - Add red5sip to autostart: - <source> -<![CDATA[ -ln -s /opt/red5sip/red5sip.sh /etc/init.d/red5sip -chmod a+x /etc/init.d/red5sip -update-rc.d /etc/init.d/red5sip defaults -]]> - </source> - </div> - <div> - Start openmeetings - <source> -<![CDATA[ -service red5 start -]]> - </source> - </div> - <div> - Start red5sip - <source> -<![CDATA[ -service red5sip start -]]> - </source> - </div> - </section> - </body> - +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + --> +<document xmlns="http://maven.apache.org/XDOC/2.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd"> + <properties> + <title>SIP-Transport Integration</title> + <author email="[email protected]">Apache OpenMeetings Team</author> + </properties> + + <body> + + <section name="SIP-Transport Integration"> + <p> + You need minimum version 2.0 of Apache OpenMeetings to apply this guide! + </p> + <p> + Here is instruction how-to set up red5sip transport integration with OpenMeetings on Ubuntu 10.04. + </p> + </section> + + <section name="Setup Asterisk"> + <div> + Run the commands + <source> +<![CDATA[ +sudo apt-get update +sudo apt-get install asterisk asterisk-mysql +]]> + </source> + </div> + <div> + Ubuntu 10.04 has broken asterisk-mysql version. For other distribution next commands not needed: + <source> +<![CDATA[ +aptitude purge asterisk-mysql +cd /tmp +apt-get build-dep asterisk-mysql +apt-get -b source asterisk-mysql +dpkg -i asterisk-mysql_1.6.2.0-1_i386.deb +]]> + </source> + </div> + <div> + Enable asterisk mysql realtime module:<br/><br/> + Add string + <source> +<![CDATA[ +load => res_config_mysql.so +]]> + </source> + to the /etc/asterisk/modules.conf into the "modules" section. + </div> + <div> + Configure mysql realtime module:<br/><br/> + + Create file /etc/asterisk/res_mysql.conf and add lines: + <source> +<![CDATA[ +[general] +dbhost=127.0.0.1 +dbname=openmeetings +dbuser=root +dbpass= +dbport=3306 +]]> + </source> + </div> + <div> + Add next lines into the /etc/asterisk/extconfig.conf: + <source> +<![CDATA[ +[settings] +sipusers => mysql,general,sipusers +sippeers => mysql,general,sipusers +extensions => mysql,general,extensions +meetme => mysql,general,meetme +]]> + </source> + </div> + <div> + Add next lines into the /etc/asterisk/extensions.conf: + <source> +<![CDATA[ +[rooms] +switch => Realtime/@ +]]> + </source> + </div> + + <div> + Restart asterisk: + <source> +<![CDATA[ +service asterisk restart +]]> + </source> + Insert, for example, SIP user with name 'test': + <source> +<![CDATA[ +INSERT INTO sipusers (allow, context, disallow, host, name, secret) VALUES ('ulaw' , 'rooms', NULL, 'dynamic' , 'test', '12345'); +]]> + </source> + </div> + </section> + + <section name="Setup red5sip transport"> + <div> + Download red5sip from<tt>http://red5phone.googlecode.com/svn/branches/red5sip</tt> + </div> + <p> + Build with Apache Ant + </p> + <div> + Install jsvc: + <source> +<![CDATA[ +apt-get install jsvc +]]> + </source> + </div> + <div> + Insert proper values to the /opt/red5sip/settings.properties + + <source> +<![CDATA[ +red5.host - red5 server address (127.0.0.1) +sip.obproxy - asterisk adderss (127.0.0.1) +sip.phone - sip phone number (test) +sip.authid - sip auth id (test) +sip.secret - sip password (12345) +sip.realm - sip realm, "asterisk" by default +sip.proxy - +rooms - ids of openmeetings rooms, can be, for example, 2,3,5,6 +]]> + </source> + </div> + <div> + Add red5sip to autostart: + <source> +<![CDATA[ +ln -s /opt/red5sip/red5sip.sh /etc/init.d/red5sip +chmod a+x /etc/init.d/red5sip +update-rc.d /etc/init.d/red5sip defaults +]]> + </source> + </div> + <div> + Start openmeetings + <source> +<![CDATA[ +service red5 start +]]> + </source> + </div> + <div> + Start red5sip + <source> +<![CDATA[ +service red5sip start +]]> + </source> + </div> + </section> + </body> + </document> \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/openmeetings/blob/1cb3518f/openmeetings-server/src/site/xdoc/themes-and-branding.xml ---------------------------------------------------------------------- diff --git a/openmeetings-server/src/site/xdoc/themes-and-branding.xml b/openmeetings-server/src/site/xdoc/themes-and-branding.xml index ac73b29..fb27844 100644 --- a/openmeetings-server/src/site/xdoc/themes-and-branding.xml +++ b/openmeetings-server/src/site/xdoc/themes-and-branding.xml @@ -1,61 +1,61 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - --> -<document xmlns="http://maven.apache.org/XDOC/2.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd"> - <properties> - <title>Theme and color</title> - <author email="[email protected]">Apache OpenMeetings Team</author> - </properties> - <body> - <section name="Available since Apache OpenMeetings 2.0"> - <p> - Themes are only available starting with Openmeetings 2.x. - <br /> - There are also more general client side configuration like port - configuration. Those configs are stored in the public/config.xml - </p> - </section> - <section name="Editing the theme"> - <p>To modify default theme used by OM</p> - <ul> - <li>please open following file in the Git:<br/> - <a - href="https://git-wip-us.apache.org/repos/asf/openmeetings.git/?p=openmeetings.git;a=blob;f=openmeetings-web/src/main/webapp/css/theme_om/jquery-ui.css;hb=HEAD" - target="_blank" rel="nofollow">https://git-wip-us.apache.org/repos/asf/openmeetings.git/?p=openmeetings.git;a=blob;f=openmeetings-web/src/main/webapp/css/theme_om/jquery-ui.css;hb=HEAD - </a><br/> - Or if you already installed OpenMeetings on your machine at:<br /> - <tt>/webapps/openmeetings/css/theme_om/jquery-ui.css</tt> - </li> - <li>follow the link next to "To view and modify this theme, visit" text in css comments</li> - </ul> - <p> - The file contains border, background and font color definitions as - well as paths to icons that are loaded at runtime. - <br /> - You can change the theme at runtime and just reload the browser - (eventually clear the browser cache) to see updates based on - modification in your theme. - </p> - <p>All other elements might be styled by modifying CSS files in <tt>/webapps/openmeetings/css</tt> folder</p> - </section> - <section name="Creating custom CSS file"> - <ol> - <li>create <tt>webapps/openmeetings/css/custom.css</tt> file</li> - <li>open <tt>webapps/openmeetings/WEB-INF/classes/org/apache/openmeetings/web/pages/BasePage.html</tt> add link to your new CSS file (as last link)</li> - </ol> - </section> - </body> -</document> +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + --> +<document xmlns="http://maven.apache.org/XDOC/2.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd"> + <properties> + <title>Theme and color</title> + <author email="[email protected]">Apache OpenMeetings Team</author> + </properties> + <body> + <section name="Available since Apache OpenMeetings 2.0"> + <p> + Themes are only available starting with Openmeetings 2.x. + <br /> + There are also more general client side configuration like port + configuration. Those configs are stored in the public/config.xml + </p> + </section> + <section name="Editing the theme"> + <p>To modify default theme used by OM</p> + <ul> + <li>please open following file in the Git:<br/> + <a + href="https://git-wip-us.apache.org/repos/asf/openmeetings.git/?p=openmeetings.git;a=blob;f=openmeetings-web/src/main/webapp/css/theme_om/jquery-ui.css;hb=HEAD" + target="_blank" rel="nofollow">https://git-wip-us.apache.org/repos/asf/openmeetings.git/?p=openmeetings.git;a=blob;f=openmeetings-web/src/main/webapp/css/theme_om/jquery-ui.css;hb=HEAD + </a><br/> + Or if you already installed OpenMeetings on your machine at:<br /> + <tt>/webapps/openmeetings/css/theme_om/jquery-ui.css</tt> + </li> + <li>follow the link next to "To view and modify this theme, visit" text in css comments</li> + </ul> + <p> + The file contains border, background and font color definitions as + well as paths to icons that are loaded at runtime. + <br /> + You can change the theme at runtime and just reload the browser + (eventually clear the browser cache) to see updates based on + modification in your theme. + </p> + <p>All other elements might be styled by modifying CSS files in <tt>/webapps/openmeetings/css</tt> folder</p> + </section> + <section name="Creating custom CSS file"> + <ol> + <li>create <tt>webapps/openmeetings/css/custom.css</tt> file</li> + <li>open <tt>webapps/openmeetings/WEB-INF/classes/org/apache/openmeetings/web/pages/BasePage.html</tt> add link to your new CSS file (as last link)</li> + </ol> + </section> + </body> +</document> http://git-wip-us.apache.org/repos/asf/openmeetings/blob/1cb3518f/openmeetings-server/src/site/xdoc/voip-sip-integration.xml ---------------------------------------------------------------------- diff --git a/openmeetings-server/src/site/xdoc/voip-sip-integration.xml b/openmeetings-server/src/site/xdoc/voip-sip-integration.xml index 9369ee7..56361cb 100644 --- a/openmeetings-server/src/site/xdoc/voip-sip-integration.xml +++ b/openmeetings-server/src/site/xdoc/voip-sip-integration.xml @@ -1,69 +1,69 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - --> -<document xmlns="http://maven.apache.org/XDOC/2.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd"> - <properties> - <title>VoIP and SIP Integration</title> - <author email="[email protected]">Apache OpenMeetings Team</author> - </properties> - - <body> - - <section name="VoIP and SIP Integration"> - - <p> - There are multiple ways to integrate with VoIP and or SIP. - OpenMeetings does not provide out of the box a ready to run VoIP - integration / integration to cell phone or usual land lane. - The - nature of such integrations is that it depends heavily on the - infrastructure that you are using and where you would like to - integrate OpenMeetings into. - <br /> - <br /> - It also depends on a number of factors of which OpenMeetings is - impossible to set up for you, for example setting up your VoIP - server or provide you with a range of telephone numbers reserved for - conference calls in your national phone network. - Such an integration - project is likely to become a consulting job for a - telecommunications consultant. - <br /> - <br /> - To get help on the integration you can contact the - <a href="mail-lists.html">mailing lists</a> - or for example somebody from the list of - <a href="commercial-support.html">commercial support</a> - . - <br/><br/> - <a href="red5sip-integration_2.0.html"> - Instruction how-to set up OpenMeetings SIP-Transport integration for Openmeetings 2.0 - </a>.<br/> - <a href="red5sip-integration_2.1.html"> - Instruction how-to set up OpenMeetings SIP-Transport integration for Openmeetings 2.1 - </a>.<br/> - <a href="red5sip-integration_3.0.html"> - Instruction how-to set up OpenMeetings SIP-Transport integration for Openmeetings 3.0 - </a>.<br/> - <a href="red5sip-integration_3.1.html"> - Instruction how-to set up OpenMeetings SIP-Transport integration for Openmeetings 3.1+ - </a>.<br/> - </p> - </section> - - </body> - +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + --> +<document xmlns="http://maven.apache.org/XDOC/2.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd"> + <properties> + <title>VoIP and SIP Integration</title> + <author email="[email protected]">Apache OpenMeetings Team</author> + </properties> + + <body> + + <section name="VoIP and SIP Integration"> + + <p> + There are multiple ways to integrate with VoIP and or SIP. + OpenMeetings does not provide out of the box a ready to run VoIP + integration / integration to cell phone or usual land lane. + The + nature of such integrations is that it depends heavily on the + infrastructure that you are using and where you would like to + integrate OpenMeetings into. + <br /> + <br /> + It also depends on a number of factors of which OpenMeetings is + impossible to set up for you, for example setting up your VoIP + server or provide you with a range of telephone numbers reserved for + conference calls in your national phone network. + Such an integration + project is likely to become a consulting job for a + telecommunications consultant. + <br /> + <br /> + To get help on the integration you can contact the + <a href="mail-lists.html">mailing lists</a> + or for example somebody from the list of + <a href="commercial-support.html">commercial support</a> + . + <br/><br/> + <a href="red5sip-integration_2.0.html"> + Instruction how-to set up OpenMeetings SIP-Transport integration for Openmeetings 2.0 + </a>.<br/> + <a href="red5sip-integration_2.1.html"> + Instruction how-to set up OpenMeetings SIP-Transport integration for Openmeetings 2.1 + </a>.<br/> + <a href="red5sip-integration_3.0.html"> + Instruction how-to set up OpenMeetings SIP-Transport integration for Openmeetings 3.0 + </a>.<br/> + <a href="red5sip-integration_3.1.html"> + Instruction how-to set up OpenMeetings SIP-Transport integration for Openmeetings 3.1+ + </a>.<br/> + </p> + </section> + + </body> + </document> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/openmeetings/blob/1cb3518f/openmeetings-service/src/main/java/org/apache/openmeetings/service/quartz/scheduler/CleanupJob.java ---------------------------------------------------------------------- diff --git a/openmeetings-service/src/main/java/org/apache/openmeetings/service/quartz/scheduler/CleanupJob.java b/openmeetings-service/src/main/java/org/apache/openmeetings/service/quartz/scheduler/CleanupJob.java index 400cb83..5dbdd2b 100644 --- a/openmeetings-service/src/main/java/org/apache/openmeetings/service/quartz/scheduler/CleanupJob.java +++ b/openmeetings-service/src/main/java/org/apache/openmeetings/service/quartz/scheduler/CleanupJob.java @@ -1,179 +1,179 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License") + you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.openmeetings.service.quartz.scheduler; - -import static org.apache.openmeetings.util.OmFileHelper.EXTENSION_MP4; -import static org.apache.openmeetings.util.OmFileHelper.TEST_SETUP_PREFIX; -import static org.apache.openmeetings.util.OmFileHelper.getStreamsDir; -import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey; - -import java.io.File; -import java.io.FileFilter; -import java.util.Map; - -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang3.math.NumberUtils; -import org.apache.openmeetings.core.data.whiteboard.WhiteboardCache; -import org.apache.openmeetings.core.session.SessionManager; -import org.apache.openmeetings.db.dao.server.SessiondataDao; -import org.apache.openmeetings.db.dto.room.Whiteboard; -import org.apache.openmeetings.db.dto.room.Whiteboards; -import org.apache.openmeetings.util.InitializationContainer; -import org.red5.logging.Red5LoggerFactory; -import org.slf4j.Logger; -import org.springframework.beans.factory.annotation.Autowired; - -public class CleanupJob extends AbstractJob { - private static Logger log = Red5LoggerFactory.getLogger(CleanupJob.class, webAppRootKey); - private long sessionTimeout = 30 * 60 * 1000L; - private long testSetupTimeout = 60 * 60 * 1000L; // 1 hour - private long roomFilesTtl = 60 * 60 * 1000L; // 1 hour - - @Autowired - private SessiondataDao sessionDao; - @Autowired - private SessionManager sessionManager; - @Autowired - private WhiteboardCache wbManager; - - public long getSessionTimeout() { - return sessionTimeout; - } - - public void setSessionTimeout(long sessionTimeout) { - this.sessionTimeout = sessionTimeout; - } - - public long getTestSetupTimeout() { - return testSetupTimeout; - } - - public void setTestSetupTimeout(long testSetupTimeout) { - this.testSetupTimeout = testSetupTimeout; - } - - public long getRoomFilesTtl() { - return roomFilesTtl; - } - - public void setRoomFilesTtl(long roomFilesTtl) { - this.roomFilesTtl = roomFilesTtl; - } - - public void cleanTestSetup() { - log.debug("CleanupJob.cleanTestSetup"); - if (!InitializationContainer.initComplete) { - return; - } - try { - //FIXME need to move all these staff to helper - File[] folders = getStreamsDir().listFiles(); - if (folders != null) { - for (File folder : folders) { - if (folder.isDirectory()) { - File[] files = folder.listFiles(new FileFilter() { - @Override - public boolean accept(File file) { - return file.getName().startsWith(TEST_SETUP_PREFIX); - } - }); - if (files != null) { - for (File file : files) { - if (file.isFile() && file.lastModified() + testSetupTimeout < System.currentTimeMillis()) { - log.debug("expired TEST SETUP found: " + file.getCanonicalPath()); - file.delete(); - } - } - } - } - } - } - } catch (Exception e) { - log.error("Unexpected exception while processing tests setup videous.", e); - } - } - - public void cleanRoomFiles() { - log.debug("CleanupJob.cleanRoomFiles"); - if (!InitializationContainer.initComplete) { - return; - } - try { - //FIXME need to move all these staff to helper - File[] folders = getStreamsDir().listFiles(); - if (folders != null) { - for (File folder : folders) { - Long roomId = null; - if (NumberUtils.isCreatable(folder.getName())) { - roomId = Long.valueOf(folder.getName()); - Whiteboards wbList = wbManager.get(roomId); - for (Map.Entry<Long, Whiteboard> e : wbList.getWhiteboards().entrySet()) { - if (!e.getValue().getRoomItems().isEmpty()) { - roomId = null; - break; - } - } - } - if (folder.isDirectory() && roomId != null && sessionManager.getClientListByRoom(roomId).isEmpty()) { - File[] files = folder.listFiles(); - //TODO need to rework this and remove hardcodings - if (files != null) { - for (File file : files) { - if (file.isFile() && file.lastModified() + roomFilesTtl < System.currentTimeMillis()) { - log.debug("Room files are too old and no users in the room: " + roomId); - FileUtils.deleteDirectory(folder); - break; - } - } - } - } - } - } - } catch (Exception e) { - log.error("Unexpected exception while processing tests setup videous.", e); - } - } - - public void cleanSessions() { - log.trace("CleanupJob.cleanSessions"); - if (!InitializationContainer.initComplete) { - return; - } - try { - // TODO Generate report - sessionDao.clearSessionTable(sessionTimeout); - } catch (Exception err){ - log.error("execute",err); - } - } - - public void cleanExpiredRecordings() { - log.debug("CleanupJob.cleanExpiredRecordings"); - processExpiringRecordings(true, (rec, days) -> { - if (days < 0) { - log.debug("cleanExpiredRecordings:: following recording will be deleted {}", rec); - File f = rec.getFile(EXTENSION_MP4); - if (f != null && f.exists()) { - f.delete(); - } - recordingDao.delete(rec); - } - }); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License") + you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openmeetings.service.quartz.scheduler; + +import static org.apache.openmeetings.util.OmFileHelper.EXTENSION_MP4; +import static org.apache.openmeetings.util.OmFileHelper.TEST_SETUP_PREFIX; +import static org.apache.openmeetings.util.OmFileHelper.getStreamsDir; +import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey; + +import java.io.File; +import java.io.FileFilter; +import java.util.Map; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang3.math.NumberUtils; +import org.apache.openmeetings.core.data.whiteboard.WhiteboardCache; +import org.apache.openmeetings.core.session.SessionManager; +import org.apache.openmeetings.db.dao.server.SessiondataDao; +import org.apache.openmeetings.db.dto.room.Whiteboard; +import org.apache.openmeetings.db.dto.room.Whiteboards; +import org.apache.openmeetings.util.InitializationContainer; +import org.red5.logging.Red5LoggerFactory; +import org.slf4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; + +public class CleanupJob extends AbstractJob { + private static Logger log = Red5LoggerFactory.getLogger(CleanupJob.class, webAppRootKey); + private long sessionTimeout = 30 * 60 * 1000L; + private long testSetupTimeout = 60 * 60 * 1000L; // 1 hour + private long roomFilesTtl = 60 * 60 * 1000L; // 1 hour + + @Autowired + private SessiondataDao sessionDao; + @Autowired + private SessionManager sessionManager; + @Autowired + private WhiteboardCache wbManager; + + public long getSessionTimeout() { + return sessionTimeout; + } + + public void setSessionTimeout(long sessionTimeout) { + this.sessionTimeout = sessionTimeout; + } + + public long getTestSetupTimeout() { + return testSetupTimeout; + } + + public void setTestSetupTimeout(long testSetupTimeout) { + this.testSetupTimeout = testSetupTimeout; + } + + public long getRoomFilesTtl() { + return roomFilesTtl; + } + + public void setRoomFilesTtl(long roomFilesTtl) { + this.roomFilesTtl = roomFilesTtl; + } + + public void cleanTestSetup() { + log.debug("CleanupJob.cleanTestSetup"); + if (!InitializationContainer.initComplete) { + return; + } + try { + //FIXME need to move all these staff to helper + File[] folders = getStreamsDir().listFiles(); + if (folders != null) { + for (File folder : folders) { + if (folder.isDirectory()) { + File[] files = folder.listFiles(new FileFilter() { + @Override + public boolean accept(File file) { + return file.getName().startsWith(TEST_SETUP_PREFIX); + } + }); + if (files != null) { + for (File file : files) { + if (file.isFile() && file.lastModified() + testSetupTimeout < System.currentTimeMillis()) { + log.debug("expired TEST SETUP found: " + file.getCanonicalPath()); + file.delete(); + } + } + } + } + } + } + } catch (Exception e) { + log.error("Unexpected exception while processing tests setup videous.", e); + } + } + + public void cleanRoomFiles() { + log.debug("CleanupJob.cleanRoomFiles"); + if (!InitializationContainer.initComplete) { + return; + } + try { + //FIXME need to move all these staff to helper + File[] folders = getStreamsDir().listFiles(); + if (folders != null) { + for (File folder : folders) { + Long roomId = null; + if (NumberUtils.isCreatable(folder.getName())) { + roomId = Long.valueOf(folder.getName()); + Whiteboards wbList = wbManager.get(roomId); + for (Map.Entry<Long, Whiteboard> e : wbList.getWhiteboards().entrySet()) { + if (!e.getValue().getRoomItems().isEmpty()) { + roomId = null; + break; + } + } + } + if (folder.isDirectory() && roomId != null && sessionManager.getClientListByRoom(roomId).isEmpty()) { + File[] files = folder.listFiles(); + //TODO need to rework this and remove hardcodings + if (files != null) { + for (File file : files) { + if (file.isFile() && file.lastModified() + roomFilesTtl < System.currentTimeMillis()) { + log.debug("Room files are too old and no users in the room: " + roomId); + FileUtils.deleteDirectory(folder); + break; + } + } + } + } + } + } + } catch (Exception e) { + log.error("Unexpected exception while processing tests setup videous.", e); + } + } + + public void cleanSessions() { + log.trace("CleanupJob.cleanSessions"); + if (!InitializationContainer.initComplete) { + return; + } + try { + // TODO Generate report + sessionDao.clearSessionTable(sessionTimeout); + } catch (Exception err){ + log.error("execute",err); + } + } + + public void cleanExpiredRecordings() { + log.debug("CleanupJob.cleanExpiredRecordings"); + processExpiringRecordings(true, (rec, days) -> { + if (days < 0) { + log.debug("cleanExpiredRecordings:: following recording will be deleted {}", rec); + File f = rec.getFile(EXTENSION_MP4); + if (f != null && f.exists()) { + f.delete(); + } + recordingDao.delete(rec); + } + }); + } +} http://git-wip-us.apache.org/repos/asf/openmeetings/blob/1cb3518f/openmeetings-service/src/site/site.xml ---------------------------------------------------------------------- diff --git a/openmeetings-service/src/site/site.xml b/openmeetings-service/src/site/site.xml index c26954e..0d9f35c 100644 --- a/openmeetings-service/src/site/site.xml +++ b/openmeetings-service/src/site/site.xml @@ -1,40 +1,40 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - --> -<project xmlns="http://maven.apache.org/DECORATION/1.7.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/DECORATION/1.7.0 http://maven.apache.org/xsd/decoration-1.7.0.xsd" - name="Apache OpenMeetings Project"> - - <body> - <menu ref="parent"/> - <menu name="Project"> - <item name="About" href="/index.html" /> - <item name="Info" href="/project-info.html" /> - <item name="Summary" href="/project-summary.html" /> - <item name="License" href="/license.html" /> - <item name="Dependencies" href="/dependencies.html" /> - <item name="Dependency Convergence" href="/dependency-convergence.html" /> - <item name="RAT Report" href="/rat-report.html" /> - <item name="JavaDoc" href="/apidocs/index.html" target="_blank" /> - </menu> - </body> - <custom> - <reflowSkin> - <bottomNav maxSpan="12"> - <column>Parent Project</column> - <column>Project</column> - </bottomNav> - </reflowSkin> - </custom> -</project> +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + --> +<project xmlns="http://maven.apache.org/DECORATION/1.7.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/DECORATION/1.7.0 http://maven.apache.org/xsd/decoration-1.7.0.xsd" + name="Apache OpenMeetings Project"> + + <body> + <menu ref="parent"/> + <menu name="Project"> + <item name="About" href="/index.html" /> + <item name="Info" href="/project-info.html" /> + <item name="Summary" href="/project-summary.html" /> + <item name="License" href="/license.html" /> + <item name="Dependencies" href="/dependencies.html" /> + <item name="Dependency Convergence" href="/dependency-convergence.html" /> + <item name="RAT Report" href="/rat-report.html" /> + <item name="JavaDoc" href="/apidocs/index.html" target="_blank" /> + </menu> + </body> + <custom> + <reflowSkin> + <bottomNav maxSpan="12"> + <column>Parent Project</column> + <column>Project</column> + </bottomNav> + </reflowSkin> + </custom> +</project> http://git-wip-us.apache.org/repos/asf/openmeetings/blob/1cb3518f/openmeetings-util/src/main/java/org/apache/openmeetings/util/ConnectionProperties.java ---------------------------------------------------------------------- diff --git a/openmeetings-util/src/main/java/org/apache/openmeetings/util/ConnectionProperties.java b/openmeetings-util/src/main/java/org/apache/openmeetings/util/ConnectionProperties.java index 1f184ef..cbf799e 100644 --- a/openmeetings-util/src/main/java/org/apache/openmeetings/util/ConnectionProperties.java +++ b/openmeetings-util/src/main/java/org/apache/openmeetings/util/ConnectionProperties.java @@ -1,86 +1,86 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License") + you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.openmeetings.util; - -import java.io.Serializable; - -public class ConnectionProperties implements Serializable { - private static final long serialVersionUID = 1L; - - public enum DbType { - db2 - , derby - , mssql - , mysql - , oracle - , postgresql - } - - private String driver = "org.apache.derby.jdbc.EmbeddedDriver"; - private String url = "jdbc:derby:openmeetings"; - private String login = "user"; - private String password = "secret"; - private DbType dbType = DbType.derby; - - public String getDriver() { - return driver; - } - - public void setDriver(String driverName) { - this.driver = driverName; - } - - public String getURL() { - return url; - } - - public void setURL(String connectionURL) { - this.url = connectionURL; - } - - public String getLogin() { - return login; - } - - public void setLogin(String connectionLogin) { - this.login = connectionLogin; - } - - public String getPassword() { - return password; - } - - public void setPassword(String connectionPass) { - this.password = connectionPass; - } - - public DbType getDbType() { - return dbType; - } - - public void setDbType(DbType dbType) { - this.dbType = dbType; - } - - @Override - public String toString() { - return "ConnectionProperties [type=" + dbType + ", driver=" + driver + ", url=" + url - + ", login=" + login + ", password=" + password + "]"; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License") + you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openmeetings.util; + +import java.io.Serializable; + +public class ConnectionProperties implements Serializable { + private static final long serialVersionUID = 1L; + + public enum DbType { + db2 + , derby + , mssql + , mysql + , oracle + , postgresql + } + + private String driver = "org.apache.derby.jdbc.EmbeddedDriver"; + private String url = "jdbc:derby:openmeetings"; + private String login = "user"; + private String password = "secret"; + private DbType dbType = DbType.derby; + + public String getDriver() { + return driver; + } + + public void setDriver(String driverName) { + this.driver = driverName; + } + + public String getURL() { + return url; + } + + public void setURL(String connectionURL) { + this.url = connectionURL; + } + + public String getLogin() { + return login; + } + + public void setLogin(String connectionLogin) { + this.login = connectionLogin; + } + + public String getPassword() { + return password; + } + + public void setPassword(String connectionPass) { + this.password = connectionPass; + } + + public DbType getDbType() { + return dbType; + } + + public void setDbType(DbType dbType) { + this.dbType = dbType; + } + + @Override + public String toString() { + return "ConnectionProperties [type=" + dbType + ", driver=" + driver + ", url=" + url + + ", login=" + login + ", password=" + password + "]"; + } +} http://git-wip-us.apache.org/repos/asf/openmeetings/blob/1cb3518f/openmeetings-util/src/main/java/org/apache/openmeetings/util/DaoHelper.java ---------------------------------------------------------------------- diff --git a/openmeetings-util/src/main/java/org/apache/openmeetings/util/DaoHelper.java b/openmeetings-util/src/main/java/org/apache/openmeetings/util/DaoHelper.java index 14e2f33..688bb19 100644 --- a/openmeetings-util/src/main/java/org/apache/openmeetings/util/DaoHelper.java +++ b/openmeetings-util/src/main/java/org/apache/openmeetings/util/DaoHelper.java @@ -1,107 +1,107 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License") + you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.openmeetings.util; - -import org.apache.commons.lang3.StringUtils; -import org.apache.wicket.util.string.Strings; - -public class DaoHelper { - - public static String getSearchQuery(String table, String alias, String search, boolean filterDeleted, boolean count, String sort, String... fields) { - return getSearchQuery(table, alias, search, false, filterDeleted, count, sort, fields); - } - public static String getSearchQuery(String table, String alias, String search, boolean distinct, boolean filterDeleted, boolean count, String sort, String... fields) { - return getSearchQuery(table, alias, null, search, distinct, filterDeleted, count, null, sort, fields); - } - - public static String getSearchQuery(String table, String alias, String join, String search, boolean filterDeleted, boolean count, String additionalWhere, String sort, String... fields) { - return getSearchQuery(table, alias, join, search, false, filterDeleted, count, additionalWhere, sort, fields); - } - - public static String getSearchQuery(String table, String alias, String join, String search, boolean distinct, boolean filterDeleted, boolean count, String additionalWhere, String sort, String... fields) { - StringBuilder sb = new StringBuilder("SELECT "); - if (count) { - sb.append("COUNT("); - } - if (distinct) { - sb.append("DISTINCT "); - } - sb.append(alias); - if (count) { - sb.append(")"); - } - sb.append(" FROM ").append(table).append(" ").append(alias); - if (!Strings.isEmpty(join)) { - sb.append(" ").append(join); - } - sb.append(" WHERE 1 = 1 "); - if (filterDeleted) { - sb.append("AND ").append(alias).append(".deleted = false "); - } - StringBuilder where = getWhereClause(search, alias, fields); - if (!Strings.isEmpty(where)) { - sb.append("AND ").append(where); - } - if (!Strings.isEmpty(additionalWhere)) { - sb.append("AND ").append(additionalWhere); - } - if (!Strings.isEmpty(sort)) { - sb.append(" ORDER BY ").append(alias).append(".").append(sort); - } - return sb.toString(); - } - - public static StringBuilder getWhereClause(String search, String alias, String... fields) { - StringBuilder sb = new StringBuilder(); - getWhereClause(sb, search, alias, fields); - return sb; - } - - public static void getWhereClause(StringBuilder sb, String search, String alias, String... fields) { - if (search != null) { - boolean notEmpty = false; - String[] searchItems = search.replace("\'", "").replace("\"", "").split(" "); - for (int i = 0; i < searchItems.length; ++i) { - if (searchItems[i].isEmpty()) { - continue; - } - if (i == 0) { - notEmpty = true; - sb.append(" ("); - } else { - sb.append(" OR "); - } - StringBuilder placeholder = new StringBuilder(); - placeholder.append("%").append(StringUtils.lowerCase(searchItems[i])).append("%"); - - sb.append("("); - for (int j = 0; j < fields.length; ++j) { - if (j != 0) { - sb.append(" OR "); - } - sb.append("lower(").append(alias).append(".").append(fields[j]).append(") LIKE '").append(placeholder).append("' "); - } - sb.append(")"); - } - if (notEmpty) { - sb.append(") "); - } - } - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License") + you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openmeetings.util; + +import org.apache.commons.lang3.StringUtils; +import org.apache.wicket.util.string.Strings; + +public class DaoHelper { + + public static String getSearchQuery(String table, String alias, String search, boolean filterDeleted, boolean count, String sort, String... fields) { + return getSearchQuery(table, alias, search, false, filterDeleted, count, sort, fields); + } + public static String getSearchQuery(String table, String alias, String search, boolean distinct, boolean filterDeleted, boolean count, String sort, String... fields) { + return getSearchQuery(table, alias, null, search, distinct, filterDeleted, count, null, sort, fields); + } + + public static String getSearchQuery(String table, String alias, String join, String search, boolean filterDeleted, boolean count, String additionalWhere, String sort, String... fields) { + return getSearchQuery(table, alias, join, search, false, filterDeleted, count, additionalWhere, sort, fields); + } + + public static String getSearchQuery(String table, String alias, String join, String search, boolean distinct, boolean filterDeleted, boolean count, String additionalWhere, String sort, String... fields) { + StringBuilder sb = new StringBuilder("SELECT "); + if (count) { + sb.append("COUNT("); + } + if (distinct) { + sb.append("DISTINCT "); + } + sb.append(alias); + if (count) { + sb.append(")"); + } + sb.append(" FROM ").append(table).append(" ").append(alias); + if (!Strings.isEmpty(join)) { + sb.append(" ").append(join); + } + sb.append(" WHERE 1 = 1 "); + if (filterDeleted) { + sb.append("AND ").append(alias).append(".deleted = false "); + } + StringBuilder where = getWhereClause(search, alias, fields); + if (!Strings.isEmpty(where)) { + sb.append("AND ").append(where); + } + if (!Strings.isEmpty(additionalWhere)) { + sb.append("AND ").append(additionalWhere); + } + if (!Strings.isEmpty(sort)) { + sb.append(" ORDER BY ").append(alias).append(".").append(sort); + } + return sb.toString(); + } + + public static StringBuilder getWhereClause(String search, String alias, String... fields) { + StringBuilder sb = new StringBuilder(); + getWhereClause(sb, search, alias, fields); + return sb; + } + + public static void getWhereClause(StringBuilder sb, String search, String alias, String... fields) { + if (search != null) { + boolean notEmpty = false; + String[] searchItems = search.replace("\'", "").replace("\"", "").split(" "); + for (int i = 0; i < searchItems.length; ++i) { + if (searchItems[i].isEmpty()) { + continue; + } + if (i == 0) { + notEmpty = true; + sb.append(" ("); + } else { + sb.append(" OR "); + } + StringBuilder placeholder = new StringBuilder(); + placeholder.append("%").append(StringUtils.lowerCase(searchItems[i])).append("%"); + + sb.append("("); + for (int j = 0; j < fields.length; ++j) { + if (j != 0) { + sb.append(" OR "); + } + sb.append("lower(").append(alias).append(".").append(fields[j]).append(") LIKE '").append(placeholder).append("' "); + } + sb.append(")"); + } + if (notEmpty) { + sb.append(") "); + } + } + } +} http://git-wip-us.apache.org/repos/asf/openmeetings/blob/1cb3518f/openmeetings-util/src/main/java/org/apache/openmeetings/util/OmFileHelper.java ---------------------------------------------------------------------- diff --git a/openmeetings-util/src/main/java/org/apache/openmeetings/util/OmFileHelper.java b/openmeetings-util/src/main/java/org/apache/openmeetings/util/OmFileHelper.java index 80b4ce1..3de9fdf 100644 --- a/openmeetings-util/src/main/java/org/apache/openmeetings/util/OmFileHelper.java +++ b/openmeetings-util/src/main/java/org/apache/openmeetings/util/OmFileHelper.java @@ -1,315 +1,315 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License") + you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.openmeetings.util; - -import java.io.File; -import java.io.IOException; -import java.text.DecimalFormat; - -import org.apache.openmeetings.util.ConnectionProperties.DbType; - -public class OmFileHelper { - /** - * This variable needs to point to the openmeetings webapp directory - */ - private static File OM_HOME = null; - private static final String UPLOAD_DIR = "upload"; - private static final String PUBLIC_DIR = "public"; - private static final String CLIPARTS_DIR = "cliparts"; - private static final String WEB_INF_DIR = "WEB-INF"; - private static final String GROUP_LOGO_DIR = "grouplogo"; - private static final String STREAMS_DIR = "streams"; - private static final String EMOTIONS_DIR = "emoticons"; - private static final String LANGUAGES_DIR = "languages"; - private static final String HIBERNATE_DIR = "hibernate"; - private static final String CONF_DIR = "conf"; - private static final String IMAGES_DIR = "images"; - private static final String WML_DIR = "stored"; - private static final String INSTALL_FILE = "install.xml"; - - public static final String BACKUP_DIR = "backup"; - public static final String IMPORT_DIR = "import"; - public static final String PROFILES_DIR = "profiles"; - public static final String SCREENSHARING_DIR = "screensharing"; - public static final String FILES_DIR = "files"; - public static final String PERSISTENCE_NAME = "classes/META-INF/persistence.xml"; - public static final String DB_PERSISTENCE_NAME = "classes/META-INF/%s_persistence.xml"; - public static final String profilesPrefix = "profile_"; - public static final String nameOfLanguageFile = "languages.xml"; - public static final String nameOfErrorFile = "errorvalues.xml"; - public static final String libraryFileName = "library.xml"; - public static final String defaultProfileImageName = "profile.jpg"; - public static final String profileFileName = "profile"; - public static final String recordingFileName = "flvRecording_"; - public static final String profileImagePrefix = "_profile_"; - public static final String thumbImagePrefix = "_thumb_"; - public static final String TEST_SETUP_PREFIX = "TEST_SETUP_"; - public static final String dashboardFile = "dashboard.xml"; - public static final String EXTENSION_WML = "wml"; - public static final String EXTENSION_FLV = "flv"; - public static final String EXTENSION_MP4 = "mp4"; - public static final String EXTENSION_JPG = "jpg"; - public static final String EXTENSION_SWF = "swf"; - public static final String EXTENSION_PDF = "pdf"; - public static final String WB_VIDEO_FILE_PREFIX = "UPLOADFLV_"; - public static final String MP4_MIME_TYPE = "video/" + EXTENSION_MP4; - public static final String JPG_MIME_TYPE = "image/jpeg"; - public static final String PNG_MIME_TYPE = "image/png"; - public static final String BCKP_ROOM_FILES = "roomFiles"; - public static final String BCKP_RECORD_FILES = "recordingFiles"; - - public static void setOmHome(File omHome) { - OmFileHelper.OM_HOME = omHome; - } - - public static void setOmHome(String omHome) { - OmFileHelper.OM_HOME = new File(omHome); - } - - public static File getRootDir() { - // FIXME hack !!!! - return getOmHome().getParentFile().getParentFile(); - } - - public static File getOmHome() { - return OmFileHelper.OM_HOME; - } - - private static File getDir(File parent, String name) { - File f = new File(parent, name); - if (!f.exists()) { - f.mkdirs(); - } - return f; - } - - public static File getUploadDir() { - return new File(OmFileHelper.OM_HOME, UPLOAD_DIR); - } - - public static File getUploadFilesDir() { - return getDir(getUploadDir(), FILES_DIR); - } - - public static File getUploadProfilesDir() { - return getDir(getUploadDir(), PROFILES_DIR); - } - - public static File getUploadProfilesUserDir(Long userId) { - return getDir(getUploadProfilesDir(), profilesPrefix + userId); - } - - public static File getUploadProfilesUserDir(String userId) { - return getDir(getUploadProfilesDir(), profilesPrefix + userId); - } - - public static File getGroupLogoDir() { - return getDir(getUploadDir(), GROUP_LOGO_DIR); - } - - public static File getGroupLogo(Long groupId, boolean check) { - File logo = new File(getGroupLogoDir(), String.format("logo%s.png", groupId)); - if (check && !logo.exists()) { - logo = new File(getImagesDir(), "blank.png"); - } - return logo; - } - - public static File getDefaultProfilePicture() { - return new File(getImagesDir(), defaultProfileImageName); - } - - public static File getUserProfilePicture(Long userId, String uri) { - File img = new File(getUploadProfilesUserDir(userId), profileImagePrefix + uri); - if (!img.exists()) { - img = getDefaultProfilePicture(); - } - return img; - } - - public static File getUserDashboard(Long userId) { - return new File(getUploadProfilesUserDir(userId), dashboardFile); - } - - public static File getUploadImportDir() { - return getDir(getUploadDir(), IMPORT_DIR); - } - - public static File getUploadBackupDir() { - return getDir(getUploadDir(), BACKUP_DIR); - } - - public static File getUploadRoomDir(String roomName) { - return getDir(getUploadDir(), roomName); - } - - public static File getUploadWmlDir() { - return getDir(getUploadDir(), WML_DIR); - } - - public static File getStreamsDir() { - return getDir(OmFileHelper.OM_HOME, STREAMS_DIR); - } - - public static File getStreamsHibernateDir() { - return getDir(getStreamsDir(), HIBERNATE_DIR); - } - - public static File getRecording(String name) { - return new File(getDir(getStreamsDir(), HIBERNATE_DIR), name); - } - - public static File getStreamsSubDir(Long id) { - return getStreamsSubDir("" + id); - } - - public static File getStreamsSubDir(String name) { - return getDir(getStreamsDir(), name); - } - - public static String getName(String name, String ext) { - return String.format("%s.%s", name, ext); - } - - public static File getRecordingMetaData(Long roomId, String name) { - return new File(getStreamsSubDir(roomId), getName(name, EXTENSION_FLV)); - } - - public static File getLanguagesDir() { - return new File(OmFileHelper.OM_HOME, LANGUAGES_DIR); - } - - public static File getPublicDir() { - return new File(OmFileHelper.OM_HOME, PUBLIC_DIR); - } - - public static File getPublicClipartsDir() { - return new File(getPublicDir(), CLIPARTS_DIR); - } - - public static File getPublicEmotionsDir() { - return new File(getPublicDir(), EMOTIONS_DIR); - } - - public static File getWebinfDir() { - return new File(OmFileHelper.OM_HOME, WEB_INF_DIR); - } - - public static File getPersistence() { - return getPersistence((DbType) null); - } - - public static File getPersistence(String dbType) { - return getPersistence(DbType.valueOf(dbType)); - } - - public static File getPersistence(DbType dbType) { - return new File(OmFileHelper.getWebinfDir(), dbType == null ? PERSISTENCE_NAME : String.format(DB_PERSISTENCE_NAME, dbType)); - } - - public static File getConfDir() { - return new File(OmFileHelper.OM_HOME, CONF_DIR); - } - - public static File getInstallFile() { - return new File(getConfDir(), INSTALL_FILE); - } - - public static File getScreenSharingDir() { - return new File(OmFileHelper.OM_HOME, SCREENSHARING_DIR); - } - - public static File getImagesDir() { - return new File(OmFileHelper.OM_HOME, IMAGES_DIR); - } - - public static File appendSuffix(File original, String suffix) { - File parent = original.getParentFile(); - String name = original.getName(); - String ext = ""; - int idx = name.lastIndexOf('.'); - if (idx > -1) { - name = name.substring(0, idx); - ext = name.substring(idx); - } - return new File(parent, name + suffix + ext); - } - - // FIXME need to be generalized - public static File getNewFile(File dir, String name, String ext) throws IOException { - File f = new File(dir, getName(name, ext)); - int recursiveNumber = 0; - while (f.exists()) { - f = new File(dir, name + "_" + (recursiveNumber++) + ext); - } - f.createNewFile(); - return f; - } - - public static File getNewDir(File dir, String name) throws IOException { - File f = new File(dir, name); - String baseName = f.getCanonicalPath(); - - int recursiveNumber = 0; - while (f.exists()) { - f = new File(baseName + "_" + (recursiveNumber++)); - } - f.mkdir(); - return f; - } - - public static String getHumanSize(File dir) { - return getHumanSize(getSize(dir)); - } - - public static String getHumanSize(long size) { - if (size <= 0) { - return "0"; - } - final String[] units = new String[] { "B", "KB", "MB", "GB", "TB" }; - int digitGroups = (int) (Math.log10(size) / Math.log10(1024)); - return new DecimalFormat("#,##0.#").format(size / Math.pow(1024, digitGroups)) + " " + units[digitGroups]; - } - - public static long getSize(File dir) { - long size = 0; - if (dir.isFile()) { - size = dir.length(); - } else { - for (File file : dir.listFiles()) { - if (file.isFile()) { - size += file.length(); - } else { - size += getSize(file); - } - } - } - return size; - } - - public static String getFileName(String name) { - int dotidx = name.lastIndexOf('.'); - return dotidx < 0 ? "" : name.substring(0, dotidx); - } - - public static String getFileExt(String name) { - int dotidx = name.lastIndexOf('.'); - return dotidx < 0 ? "" : name.substring(dotidx + 1).toLowerCase(); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License") + you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openmeetings.util; + +import java.io.File; +import java.io.IOException; +import java.text.DecimalFormat; + +import org.apache.openmeetings.util.ConnectionProperties.DbType; + +public class OmFileHelper { + /** + * This variable needs to point to the openmeetings webapp directory + */ + private static File OM_HOME = null; + private static final String UPLOAD_DIR = "upload"; + private static final String PUBLIC_DIR = "public"; + private static final String CLIPARTS_DIR = "cliparts"; + private static final String WEB_INF_DIR = "WEB-INF"; + private static final String GROUP_LOGO_DIR = "grouplogo"; + private static final String STREAMS_DIR = "streams"; + private static final String EMOTIONS_DIR = "emoticons"; + private static final String LANGUAGES_DIR = "languages"; + private static final String HIBERNATE_DIR = "hibernate"; + private static final String CONF_DIR = "conf"; + private static final String IMAGES_DIR = "images"; + private static final String WML_DIR = "stored"; + private static final String INSTALL_FILE = "install.xml"; + + public static final String BACKUP_DIR = "backup"; + public static final String IMPORT_DIR = "import"; + public static final String PROFILES_DIR = "profiles"; + public static final String SCREENSHARING_DIR = "screensharing"; + public static final String FILES_DIR = "files"; + public static final String PERSISTENCE_NAME = "classes/META-INF/persistence.xml"; + public static final String DB_PERSISTENCE_NAME = "classes/META-INF/%s_persistence.xml"; + public static final String profilesPrefix = "profile_"; + public static final String nameOfLanguageFile = "languages.xml"; + public static final String nameOfErrorFile = "errorvalues.xml"; + public static final String libraryFileName = "library.xml"; + public static final String defaultProfileImageName = "profile.jpg"; + public static final String profileFileName = "profile"; + public static final String recordingFileName = "flvRecording_"; + public static final String profileImagePrefix = "_profile_"; + public static final String thumbImagePrefix = "_thumb_"; + public static final String TEST_SETUP_PREFIX = "TEST_SETUP_"; + public static final String dashboardFile = "dashboard.xml"; + public static final String EXTENSION_WML = "wml"; + public static final String EXTENSION_FLV = "flv"; + public static final String EXTENSION_MP4 = "mp4"; + public static final String EXTENSION_JPG = "jpg"; + public static final String EXTENSION_SWF = "swf"; + public static final String EXTENSION_PDF = "pdf"; + public static final String WB_VIDEO_FILE_PREFIX = "UPLOADFLV_"; + public static final String MP4_MIME_TYPE = "video/" + EXTENSION_MP4; + public static final String JPG_MIME_TYPE = "image/jpeg"; + public static final String PNG_MIME_TYPE = "image/png"; + public static final String BCKP_ROOM_FILES = "roomFiles"; + public static final String BCKP_RECORD_FILES = "recordingFiles"; + + public static void setOmHome(File omHome) { + OmFileHelper.OM_HOME = omHome; + } + + public static void setOmHome(String omHome) { + OmFileHelper.OM_HOME = new File(omHome); + } + + public static File getRootDir() { + // FIXME hack !!!! + return getOmHome().getParentFile().getParentFile(); + } + + public static File getOmHome() { + return OmFileHelper.OM_HOME; + } + + private static File getDir(File parent, String name) { + File f = new File(parent, name); + if (!f.exists()) { + f.mkdirs(); + } + return f; + } + + public static File getUploadDir() { + return new File(OmFileHelper.OM_HOME, UPLOAD_DIR); + } + + public static File getUploadFilesDir() { + return getDir(getUploadDir(), FILES_DIR); + } + + public static File getUploadProfilesDir() { + return getDir(getUploadDir(), PROFILES_DIR); + } + + public static File getUploadProfilesUserDir(Long userId) { + return getDir(getUploadProfilesDir(), profilesPrefix + userId); + } + + public static File getUploadProfilesUserDir(String userId) { + return getDir(getUploadProfilesDir(), profilesPrefix + userId); + } + + public static File getGroupLogoDir() { + return getDir(getUploadDir(), GROUP_LOGO_DIR); + } + + public static File getGroupLogo(Long groupId, boolean check) { + File logo = new File(getGroupLogoDir(), String.format("logo%s.png", groupId)); + if (check && !logo.exists()) { + logo = new File(getImagesDir(), "blank.png"); + } + return logo; + } + + public static File getDefaultProfilePicture() { + return new File(getImagesDir(), defaultProfileImageName); + } + + public static File getUserProfilePicture(Long userId, String uri) { + File img = new File(getUploadProfilesUserDir(userId), profileImagePrefix + uri); + if (!img.exists()) { + img = getDefaultProfilePicture(); + } + return img; + } + + public static File getUserDashboard(Long userId) { + return new File(getUploadProfilesUserDir(userId), dashboardFile); + } + + public static File getUploadImportDir() { + return getDir(getUploadDir(), IMPORT_DIR); + } + + public static File getUploadBackupDir() { + return getDir(getUploadDir(), BACKUP_DIR); + } + + public static File getUploadRoomDir(String roomName) { + return getDir(getUploadDir(), roomName); + } + + public static File getUploadWmlDir() { + return getDir(getUploadDir(), WML_DIR); + } + + public static File getStreamsDir() { + return getDir(OmFileHelper.OM_HOME, STREAMS_DIR); + } + + public static File getStreamsHibernateDir() { + return getDir(getStreamsDir(), HIBERNATE_DIR); + } + + public static File getRecording(String name) { + return new File(getDir(getStreamsDir(), HIBERNATE_DIR), name); + } + + public static File getStreamsSubDir(Long id) { + return getStreamsSubDir("" + id); + } + + public static File getStreamsSubDir(String name) { + return getDir(getStreamsDir(), name); + } + + public static String getName(String name, String ext) { + return String.format("%s.%s", name, ext); + } + + public static File getRecordingMetaData(Long roomId, String name) { + return new File(getStreamsSubDir(roomId), getName(name, EXTENSION_FLV)); + } + + public static File getLanguagesDir() { + return new File(OmFileHelper.OM_HOME, LANGUAGES_DIR); + } + + public static File getPublicDir() { + return new File(OmFileHelper.OM_HOME, PUBLIC_DIR); + } + + public static File getPublicClipartsDir() { + return new File(getPublicDir(), CLIPARTS_DIR); + } + + public static File getPublicEmotionsDir() { + return new File(getPublicDir(), EMOTIONS_DIR); + } + + public static File getWebinfDir() { + return new File(OmFileHelper.OM_HOME, WEB_INF_DIR); + } + + public static File getPersistence() { + return getPersistence((DbType) null); + } + + public static File getPersistence(String dbType) { + return getPersistence(DbType.valueOf(dbType)); + } + + public static File getPersistence(DbType dbType) { + return new File(OmFileHelper.getWebinfDir(), dbType == null ? PERSISTENCE_NAME : String.format(DB_PERSISTENCE_NAME, dbType)); + } + + public static File getConfDir() { + return new File(OmFileHelper.OM_HOME, CONF_DIR); + } + + public static File getInstallFile() { + return new File(getConfDir(), INSTALL_FILE); + } + + public static File getScreenSharingDir() { + return new File(OmFileHelper.OM_HOME, SCREENSHARING_DIR); + } + + public static File getImagesDir() { + return new File(OmFileHelper.OM_HOME, IMAGES_DIR); + } + + public static File appendSuffix(File original, String suffix) { + File parent = original.getParentFile(); + String name = original.getName(); + String ext = ""; + int idx = name.lastIndexOf('.'); + if (idx > -1) { + name = name.substring(0, idx); + ext = name.substring(idx); + } + return new File(parent, name + suffix + ext); + } + + // FIXME need to be generalized + public static File getNewFile(File dir, String name, String ext) throws IOException { + File f = new File(dir, getName(name, ext)); + int recursiveNumber = 0; + while (f.exists()) { + f = new File(dir, name + "_" + (recursiveNumber++) + ext); + } + f.createNewFile(); + return f; + } + + public static File getNewDir(File dir, String name) throws IOException { + File f = new File(dir, name); + String baseName = f.getCanonicalPath(); + + int recursiveNumber = 0; + while (f.exists()) { + f = new File(baseName + "_" + (recursiveNumber++)); + } + f.mkdir(); + return f; + } + + public static String getHumanSize(File dir) { + return getHumanSize(getSize(dir)); + } + + public static String getHumanSize(long size) { + if (size <= 0) { + return "0"; + } + final String[] units = new String[] { "B", "KB", "MB", "GB", "TB" }; + int digitGroups = (int) (Math.log10(size) / Math.log10(1024)); + return new DecimalFormat("#,##0.#").format(size / Math.pow(1024, digitGroups)) + " " + units[digitGroups]; + } + + public static long getSize(File dir) { + long size = 0; + if (dir.isFile()) { + size = dir.length(); + } else { + for (File file : dir.listFiles()) { + if (file.isFile()) { + size += file.length(); + } else { + size += getSize(file); + } + } + } + return size; + } + + public static String getFileName(String name) { + int dotidx = name.lastIndexOf('.'); + return dotidx < 0 ? "" : name.substring(0, dotidx); + } + + public static String getFileExt(String name) { + int dotidx = name.lastIndexOf('.'); + return dotidx < 0 ? "" : name.substring(dotidx + 1).toLowerCase(); + } +} http://git-wip-us.apache.org/repos/asf/openmeetings/blob/1cb3518f/openmeetings-util/src/main/java/org/apache/openmeetings/util/Version.java ---------------------------------------------------------------------- diff --git a/openmeetings-util/src/main/java/org/apache/openmeetings/util/Version.java b/openmeetings-util/src/main/java/org/apache/openmeetings/util/Version.java index 2d677dd..7ad8c08 100644 --- a/openmeetings-util/src/main/java/org/apache/openmeetings/util/Version.java +++ b/openmeetings-util/src/main/java/org/apache/openmeetings/util/Version.java @@ -1,98 +1,98 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License") + you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.openmeetings.util; - -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.jar.Attributes; -import java.util.jar.Manifest; - -import org.red5.logging.Red5LoggerFactory; -import org.slf4j.Logger; - -public class Version { - private static final Logger log = Red5LoggerFactory.getLogger(Version.class, OpenmeetingsVariables.webAppRootKey); - private static final int startedStringLength = 78; - private static String version = null; - private static String revision = null; - private static String buildDate = null; - - private static Attributes getAttributes() throws MalformedURLException, IOException { - String jarUrl = Version.class.getResource(Version.class.getSimpleName() + ".class").toString(); - return new Manifest(new URL(jarUrl.substring(0, jarUrl.indexOf('!')) + "!/META-INF/MANIFEST.MF").openStream()).getMainAttributes(); - } - - public static String getVersion() { - if (version == null) { - try { - version = getAttributes().getValue("Product-Version"); - } catch (Exception e) { - log.error("Error", e); - } - } - return version; - } - - public static String getRevision() { - if (revision == null) { - try { - revision = getAttributes().getValue("Git-Revision"); - } catch (Exception e) { - log.error("Error", e); - } - } - return revision; - } - - public static String getBuildDate() { - if (buildDate == null) { - try { - buildDate = getAttributes().getValue("Built-On"); - } catch (Exception e) { - log.error("Error", e); - } - } - return buildDate; - } - - private static void getLine(StringBuilder sb, String text, char fill) { - sb.append("\t#"); - int l = text.length(); - int headLength = (startedStringLength - l) / 2; - for (int i = 0; i < headLength; ++i) { - sb.append(fill); - } - sb.append(text); - for (int i = 0; i < (startedStringLength - l - headLength); ++i) { - sb.append(fill); - } - sb.append("#\n"); - } - - public static void logOMStarted() { - StringBuilder sb = new StringBuilder("\n"); - getLine(sb, "", '#'); - getLine(sb, "Openmeetings is up", ' '); - getLine(sb, getVersion() + " " + getRevision() + " " + getBuildDate(), ' '); - getLine(sb, "and ready to use", ' '); - getLine(sb, "", '#'); - log.debug(sb.toString()); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License") + you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openmeetings.util; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.jar.Attributes; +import java.util.jar.Manifest; + +import org.red5.logging.Red5LoggerFactory; +import org.slf4j.Logger; + +public class Version { + private static final Logger log = Red5LoggerFactory.getLogger(Version.class, OpenmeetingsVariables.webAppRootKey); + private static final int startedStringLength = 78; + private static String version = null; + private static String revision = null; + private static String buildDate = null; + + private static Attributes getAttributes() throws MalformedURLException, IOException { + String jarUrl = Version.class.getResource(Version.class.getSimpleName() + ".class").toString(); + return new Manifest(new URL(jarUrl.substring(0, jarUrl.indexOf('!')) + "!/META-INF/MANIFEST.MF").openStream()).getMainAttributes(); + } + + public static String getVersion() { + if (version == null) { + try { + version = getAttributes().getValue("Product-Version"); + } catch (Exception e) { + log.error("Error", e); + } + } + return version; + } + + public static String getRevision() { + if (revision == null) { + try { + revision = getAttributes().getValue("Git-Revision"); + } catch (Exception e) { + log.error("Error", e); + } + } + return revision; + } + + public static String getBuildDate() { + if (buildDate == null) { + try { + buildDate = getAttributes().getValue("Built-On"); + } catch (Exception e) { + log.error("Error", e); + } + } + return buildDate; + } + + private static void getLine(StringBuilder sb, String text, char fill) { + sb.append("\t#"); + int l = text.length(); + int headLength = (startedStringLength - l) / 2; + for (int i = 0; i < headLength; ++i) { + sb.append(fill); + } + sb.append(text); + for (int i = 0; i < (startedStringLength - l - headLength); ++i) { + sb.append(fill); + } + sb.append("#\n"); + } + + public static void logOMStarted() { + StringBuilder sb = new StringBuilder("\n"); + getLine(sb, "", '#'); + getLine(sb, "Openmeetings is up", ' '); + getLine(sb, getVersion() + " " + getRevision() + " " + getBuildDate(), ' '); + getLine(sb, "and ready to use", ' '); + getLine(sb, "", '#'); + log.debug(sb.toString()); + } +} http://git-wip-us.apache.org/repos/asf/openmeetings/blob/1cb3518f/openmeetings-util/src/main/java/org/apache/openmeetings/util/mail/MailUtil.java ---------------------------------------------------------------------- diff --git a/openmeetings-util/src/main/java/org/apache/openmeetings/util/mail/MailUtil.java b/openmeetings-util/src/main/java/org/apache/openmeetings/util/mail/MailUtil.java index e43cfaa..3805521 100644 --- a/openmeetings-util/src/main/java/org/apache/openmeetings/util/mail/MailUtil.java +++ b/openmeetings-util/src/main/java/org/apache/openmeetings/util/mail/MailUtil.java @@ -1,34 +1,34 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License") + you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.openmeetings.util.mail; - -import org.apache.wicket.extensions.validation.validator.RfcCompliantEmailAddressValidator; -import org.apache.wicket.util.string.Strings; -import org.apache.wicket.validation.Validatable; - -public class MailUtil { - public static boolean isValid(String email) { - if (Strings.isEmpty(email)) { - return false; - } - Validatable<String> eml = new Validatable<>(email); - RfcCompliantEmailAddressValidator.getInstance().validate(eml); - return eml.isValid(); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License") + you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openmeetings.util.mail; + +import org.apache.wicket.extensions.validation.validator.RfcCompliantEmailAddressValidator; +import org.apache.wicket.util.string.Strings; +import org.apache.wicket.validation.Validatable; + +public class MailUtil { + public static boolean isValid(String email) { + if (Strings.isEmpty(email)) { + return false; + } + Validatable<String> eml = new Validatable<>(email); + RfcCompliantEmailAddressValidator.getInstance().validate(eml); + return eml.isValid(); + } +}
