diff --git a/.devcontainer/Dockerfile.orkaudio.build b/.devcontainer/Dockerfile.orkaudio.build new file mode 100644 index 00000000..12b76a76 --- /dev/null +++ b/.devcontainer/Dockerfile.orkaudio.build @@ -0,0 +1,57 @@ +# escape=` +ARG TAG=xenial + +FROM ubuntu:$TAG + +# Configure apt +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && apt-get install -y gnupg && rm -rf /var/lib/apt/lists/* + +RUN . /etc/os-release && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 31F54F3E108EAD31 ` + && echo "deb [trusted=yes] http://ppa.launchpad.net/mhier/libboost-latest/ubuntu $UBUNTU_CODENAME main" >> /etc/apt/sources.list + +RUN apt-get update && apt-get install -y build-essential libtool automake git tree rpm libboost1.70-dev` + libpcap-dev libsndfile1-dev libapr1-dev libspeex-dev liblog4cxx-dev libace-dev ` + libopus-dev libxerces-c3-dev libssl-dev cmake libdw-dev liblzma-dev libunwind-dev` + && rm -rf /var/lib/apt/lists/* + +#silk +RUN mkdir -p /opt/silk && chmod 777 /opt/silk` + && git clone --depth 1 https://github.com/gaozehua/SILKCodec.git /opt/silk/SILKCodec ` + && cd /opt/silk/SILKCodec/SILK_SDK_SRC_FIX ` + && CFLAGS='-fPIC' make all + +#opus +RUN mkdir -p /opt/opus && chmod 777 /opt/opus` + && git clone https://github.com/xiph/opus.git /opt/opus ` + && cd /opt/opus ` + && git checkout v1.2.1 ` + && ./autogen.sh ` + && ./configure --enable-shared --with-pic --enable-static ` + && make ` + && make install ` + && ln -s /usr/local/lib/libopus.so /usr/local/lib/libopusstatic.so ` + && ln -s /usr/include/opus /opt/opus/include/opus + +#g729 +RUN mkdir -p /opt/bcg729 && chmod 777 /opt/bcg729` + && git clone --depth 1 https://github.com/BelledonneCommunications/bcg729.git /opt/bcg729 ` + && cd /opt/bcg729 ` + && cmake . -DCMAKE_INSTALL_PREFIX=/usr` + && make ` + && make install + +#backward-cpp +RUN mkdir -p /opt/backward-cpp && chmod 777 /opt/backward-cpp` + && git clone --depth 1 https://github.com/bombela/backward-cpp.git /opt/backward-cpp ` + && ln -s /opt/backward-cpp/backward.hpp /usr/local/include/backward.hpp + +COPY .devcontainer/build.sh /entrypoint.sh + +#INSERT_HERE + +ENTRYPOINT ["/entrypoint.sh"] + +# Set the default shell to bash instead of sh +ENV SHELL /bin/bash diff --git a/.devcontainer/build.sh b/.devcontainer/build.sh new file mode 100755 index 00000000..1e02e020 --- /dev/null +++ b/.devcontainer/build.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -e + +#make orkbase +cd /oreka-src/orkbasecxx +autoreconf -i +./configure CXX=g++ +make +make install + +#orkaudio +cd /oreka-src/orkaudio +autoreconf -i +./configure CXX=g++ +make +make install + +#package orkaudio deb +cd /oreka-build/distribution +bash make-orkaudio-deb.sh + +ls -ltrah *.deb diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..bf4dc5f1 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,22 @@ +// See https://aka.ms/vscode-remote/devcontainer.json for format details. +{ + "name": "oreka", + "dockerFile": "Dockerfile.orkaudio.build", + "runArgs": [ + "--cap-add=SYS_PTRACE", + "--security-opt", "seccomp=unconfined" + ], + "context" : "..", + + // "appPort": [], + + "settings": { + "terminal.integrated.shell.linux": "/bin/bash" + }, + + //"postCreateCommand": "make", + + "extensions": [ + "ms-vscode.cpptools" + ] +} \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..c6f80bb6 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,99 @@ +name: Oreka Build + +on: + release: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + oreka_cpp_job: + runs-on: ubuntu-latest + name: Build Orkaudio + services: + registry: + image: registry:2 + ports: + - 5000:5000 + strategy: + fail-fast: false + matrix: + os-version: [ "xenial", "bionic", "focal" ] + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Clone build-tool repo + run : | + git clone https://github.com/voiceip/oreka-build.git ./oreka-build + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + with: + driver-opts: network=host + - name: Cache Docker layers ${{ matrix.os-version }} + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ matrix.os-version }}-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx-${{ matrix.os-version }}- + - name: Build Docker Image for ubuntu-${{ matrix.os-version }} + uses: docker/build-push-action@v2 + with: + # using "load: true" forces the docker driver + # not necessary here, because we set it before + #load: true + push: true + tags: localhost:5000/${{ github.repository_owner }}/oreka-${{ matrix.os-version }}:latest + context: . + file: ./.devcontainer/Dockerfile.orkaudio.build + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + build-args: | + TAG=${{ matrix.os-version }} + - name: Compile + run: | + docker run -v $(pwd)/oreka-build:/oreka-build -v $(pwd):/oreka-src -i -i localhost:5000/${{ github.repository_owner }}/oreka-${{ matrix.os-version }}:latest bash /entrypoint.sh + mv ./oreka-build/distribution/orkaudio.deb ./oreka-build/distribution/orkaudio_${{ matrix.os-version }}.deb + - name: "Create release" + uses: ncipollo/release-action@v1 + if: startsWith(github.ref, 'refs/tags/v') + with: + artifacts: "./oreka-build/distribution/*.deb" + draft: true + allowUpdates: true + token: ${{ secrets.GH_TOKEN }} + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache + + oreka_java_job: + runs-on: ubuntu-latest + name: Build Orkweb & Orktrack + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 8 + uses: actions/setup-java@v2 + with: + java-version: '8' + distribution: 'adopt' + - name: Cache Maven packages + uses: actions/cache@v2 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + - name: Build with Maven + run: | + mvn clean install -DskipTests -Dmaven.test.skip=true + - name: "Create release" + uses: ncipollo/release-action@v1 + if: startsWith(github.ref, 'refs/tags/v') + with: + artifacts: "orktrack/target/*.war,orkweb/target/*.war" + draft: true + allowUpdates: true + token: ${{ secrets.GH_TOKEN }} diff --git a/.gitignore b/.gitignore index f054d6e1..f606fbc6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,20 +1,113 @@ +# Created by https://www.gitignore.io/api/c++,cmake,intellij,sublimetext + +### C++ ### +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo *.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries *.so -*.lo +*.dylib +*.dll + +# Compiled Static libraries +*.lai *.la -.libs -.deps -Makefile* --* -ReleaseVC12 -*sdf -config* +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +### CMake ### +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +Makefile +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +build +CMakeLists.txt +cmake-build-debug/ + +##Makefile## +Makefile.in +config.h.in aclocal.m4 -autom4te.cache/ -depcomp +config.h + +.deps +.libs +#temp +*~ +*.lock +*.cache + install-sh -libtool +compile +depcomp ltmain.sh missing stamp-h1 -nothing added to commit but untracked files present (use "git add" to track) + +_libs +acinclude.m4 +aclocal.m4 +atconfig +autom4te.cache +config-h.in +config.* +configure +conftest* +libtool +libtool-*.tar.bz2 +libtool-*.tar.gz +libtool-*.tar.lzma +libtool-*.tar.xz + +### Intellij ### + +# User-specific stuff: +.idea + +## File-based project format: +*.iws +*.iml + +## Plugin-specific files: + +# IntelliJ +/out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +orkaudio/orkaudio +orkaudio/audiocaptureplugins/*/AudioCapturePluginCommon.cpp +!orkaudio/audiocaptureplugins/common/* +-.s + +.vscode + +target/ +.DS_Store +.settings +.factorypath +.classpath +**/WEB-INF/classes/* + +.project \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 00000000..e8184fac --- /dev/null +++ b/README.md @@ -0,0 +1,70 @@ +## Oreka, an opensource VoIP media capture and retrieval platform + +Based on [OrecX](http://www.orecx.com/open-source/) [Oreka](https://github.com/OrecX/Oreka), this project tries to provide a complete Call Recording (SIPREC) solution. + +[![Build Status](https://travis-ci.com/voiceip/oreka.svg?branch=master)](https://travis-ci.com/voiceip/oreka) + + +### Components +- **Orkaudio**: + The audio capture and storage daemon with pluggable capture modules currently comes with modules for VoIP and sound device recording. +- **Orktrack**: + Tracks and publishes all activity from one or more orkaudio services to any mainstream database/storage system. +- **Orkweb**: + Web based user interface for retrieval + +### Improvements + +**OrkAudio** + +- Support for G729 Codec +- CallID Tracking +- Upgrade to latest version of libraries. + +**OrkTrack** + +- Switch to Maven +- CallID Tracking +- Switch to faster logging (Log4j2) +- Upgrade to java8 +- Metrics via [jmx](https://metrics.dropwizard.io/4.1.2/) +- Lombork & Aspectj code weaving for auto code generation and metrics + +**Orkweb**: +- Switch to Maven +- Call Play / Download on all platform(s)/OS(es) + + +### Building + +#### Docker + +```bash +export DOCKER_BUILDKIT=1 +distribution/docker +docker build -f Dockerfile.orkaudio -t voiceip/orkaudio . +docker run -it --net=host --restart=always --privileged=true -v /var/log/orkaudio:/var/log/orkaudio -v /etc/orkaudio:/etc/orkaudio voiceip/orkaudio:latest +``` + +#### Debian + +The build tool is separately available at [github:Oreka-build](https://github.com/voiceip/oreka-build) which builds the project on a Ubuntu14.04 Virtual Box. +You can natively build if you have all dependencies but I develop on a OSx system, so have kept it separate. + +### Distribution & Installation + +#### Docker + +Docker images are available via [docker hub](https://hub.docker.com/r/voiceip/orkaudio/tags), so just run the below command to pull images directly from hub.docker.com. Note: `--net=host` on docker works on linux systems and is a [limitation of docker](https://docs.docker.com/network/host/), so please keep that in mind. + +```bash +docker run -it --net=host --restart=always --privileged=true -v /var/log/orkaudio:/var/log/orkaudio -v /etc/orkaudio:/etc/orkaudio voiceip/orkaudio:latest +``` + +#### Debian/Ubuntu + +Binary releases are available from the [Releases Section](https://github.com/voiceip/oreka/releases). Download and refer to the [installation instructions](https://github.com/voiceip/oreka/wiki/Installation). + + +#### More Information +Read Original [Readme](README.txt) diff --git a/distribution/docker/Dockerfile.orkaudio b/distribution/docker/Dockerfile.orkaudio new file mode 100644 index 00000000..37cf77d5 --- /dev/null +++ b/distribution/docker/Dockerfile.orkaudio @@ -0,0 +1,95 @@ +# escape=` +# syntax=docker/dockerfile:experimental + +FROM ubuntu:xenial as builder +MAINTAINER Kinshuk B (hi@kinsh.uk) + +# Configure apt +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && apt-get install -y gnupg && rm -rf /var/lib/apt/lists/* + +RUN . /etc/os-release && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 31F54F3E108EAD31 ` + && echo "deb [trusted=yes] http://ppa.launchpad.net/mhier/libboost-latest/ubuntu $UBUNTU_CODENAME main" >> /etc/apt/sources.list + +RUN apt-get update && apt-get install -y build-essential libtool automake git tree rpm libboost1.70-dev` + libpcap-dev libsndfile1-dev libapr1-dev libspeex-dev liblog4cxx-dev libace-dev ` + libopus-dev libxerces-c3-dev libssl-dev cmake libdw-dev liblzma-dev libunwind-dev` + && rm -rf /var/lib/apt/lists/* + +#silk +RUN mkdir -p /opt/silk && chmod 777 /opt/silk` + && git clone --depth 1 https://github.com/gaozehua/SILKCodec.git /opt/silk/SILKCodec ` + && cd /opt/silk/SILKCodec/SILK_SDK_SRC_FIX ` + && CFLAGS='-fPIC' make all + +#opus +RUN mkdir -p /opt/opus && chmod 777 /opt/opus` + && git clone https://github.com/xiph/opus.git /opt/opus ` + && cd /opt/opus ` + && git checkout v1.2.1 ` + && ./autogen.sh ` + && ./configure --enable-shared --with-pic --enable-static ` + && make ` + && make install ` + && ln -s /usr/local/lib/libopus.so /usr/local/lib/libopusstatic.so ` + && ln -s /usr/include/opus /opt/opus/include/opus + +#g729 +RUN mkdir -p /opt/bcg729 && chmod 777 /opt/bcg729` + && git clone --depth 1 https://github.com/BelledonneCommunications/bcg729.git /opt/bcg729 ` + && cd /opt/bcg729 ` + && cmake . -DCMAKE_INSTALL_PREFIX=/usr` + && make ` + && make install + +#backward-cpp +RUN mkdir -p /opt/backward-cpp && chmod 777 /opt/backward-cpp` + && git clone --depth 1 https://github.com/bombela/backward-cpp.git /opt/backward-cpp ` + && ln -s /opt/backward-cpp/backward.hpp /usr/local/include/backward.hpp + +RUN mkdir -p /opt/oreka && chmod 777 /opt/oreka` + && git clone --depth 1 https://github.com/voiceip/oreka.git /opt/oreka ` + && cd /opt/oreka/orkbasecxx ` + && autoreconf -i ` + && ./configure CXX=g++ ` + && make ` + && make install + +RUN cd /opt/oreka/orkaudio ` + && autoreconf -i ` + && ./configure CXX=g++ ` + && make ` + && make install + +FROM ubuntu:xenial +MAINTAINER Kinshuk B (hi@kinsh.uk) + +ENV DEBIAN_FRONTEND=noninteractive +RUN apt-get update && apt-get install -y libpcap0.8 libsndfile1 libapr1 libspeex1 liblog4cxx10v5 libace-6.3.3 ` + libopus0 libxerces-c3.1 libssl1.0.0 libdw1 libunwind8 && rm -rf /var/lib/apt/lists/* + +# Mount the image from "builder" stage at `/artifacts` during this run +RUN --mount=type=bind,source=/,target=/artifacts,from=builder ` + cp /artifacts/opt/oreka/orkaudio/orkaudio /usr/sbin/orkaudio ` + && cp /artifacts/opt/oreka/orkaudio/audiocaptureplugins/voip/.libs/libvoip.so* /usr/lib/` + && cp /artifacts/opt/oreka/orkaudio/audiocaptureplugins/voip/.libs/libvoip.la /usr/lib/` + && cp /artifacts/opt/oreka/orkaudio/audiocaptureplugins/generator/.libs/libgenerator.so* /usr/lib/` + && cp /artifacts/opt/oreka/orkaudio/audiocaptureplugins/generator/.libs/libgenerator.la /usr/lib/` + && cp /artifacts/usr/lib/liborkbase.* /usr/lib/ ` + && cp /artifacts/usr/lib/x86_64-linux-gnu/libbcg729.* /usr/lib/ ` + && mkdir -p /usr/lib/orkaudio/plugins/ ` + && cp /artifacts/opt/oreka/orkaudio/plugins/*.so /usr/lib/orkaudio/plugins/ + +RUN mkdir /etc/orkaudio && chmod 777 /etc/orkaudio + +ADD https://raw.githubusercontent.com/voiceip/oreka/master/orkaudio/logging-linux-template.properties /etc/orkaudio/logging.properties +COPY config.xml /etc/orkaudio/config_default.xml +COPY entrypoint.sh /opt/entrypoint.sh + +ENV SHELL /bin/bash +ENTRYPOINT [ "/opt/entrypoint.sh" ] + +CMD ["orkaudio", "debug"] + + diff --git a/distribution/docker/config.xml b/distribution/docker/config.xml new file mode 100644 index 00000000..d44329ff --- /dev/null +++ b/distribution/docker/config.xml @@ -0,0 +1,114 @@ + + + + + /var/log/orkaudio/audio + + + + + + + libvoip.so + + + + /usr/lib + + + + pcmwav + true + 2 + 8000 + + + yes + + localhost + 8080 + + LiveMonitoring + BatchProcessing, Reporting + + true + 25 + + tomcat + tomcat + 644 + + + + + + + + + + + + 8388608 + + + X-Unique-ID + + + + + + yes + yes + + + + + + + + __INTERFACE__ + + + + yes + yes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/distribution/docker/docker-compose.yml b/distribution/docker/docker-compose.yml new file mode 100644 index 00000000..50702673 --- /dev/null +++ b/distribution/docker/docker-compose.yml @@ -0,0 +1,34 @@ +version: '3' +services: + orkaudio: + build: + context: ./ + dockerfile: Dockerfile.orkaudio + command: cat /etc/orkaudio/config.xml && orkaudio debug + volumes: + - /private/var/log/orkaudio:/var/log/orkaudio + - ./config.xml:/etc/orkaudio/config.xml + network_mode: "host" + + softphone: + image: andrius/pjsua + networks: + - docker_net + depends_on: + - orkaudio + - tcpdump + environment: + - SIP_SERVER_HOST=172.16.176.94 + - SIP_TRANSPORT=udp + command: dial username 1234 + tty: true + stdin_open: true + container_name: softphone-app + + tcpdump: + image: nicolaka/netshoot + network_mode: "host" + command: tcpdump -v -A -i eth0 port 5060 + +networks: + docker_net: diff --git a/distribution/docker/entrypoint.sh b/distribution/docker/entrypoint.sh new file mode 100755 index 00000000..24eecf40 --- /dev/null +++ b/distribution/docker/entrypoint.sh @@ -0,0 +1,20 @@ +#!/bin/bash +set -e + +INF=${INTERFACE:-eth0} + +#check if /etc/orkaudio is mounted externally + +if grep -qs '/etc/orkaudio' /proc/mounts; then + echo "Config File exists externally." +else + echo "Config File does not exist. Applying default template" + sed "s/__INTERFACE__/$INF/g" /etc/orkaudio/config_default.xml > /etc/orkaudio/config.xml +fi + +echo "---- Using Configuration -----" +cat /etc/orkaudio/config.xml +echo "---------" + +exec "$@" + diff --git a/oreka.userlibraries b/oreka.userlibraries deleted file mode 100644 index 25862e79..00000000 --- a/oreka.userlibraries +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/orkaudio/.gitignore b/orkaudio/.gitignore index 687aa497..874ccc15 100644 --- a/orkaudio/.gitignore +++ b/orkaudio/.gitignore @@ -1,3 +1,7 @@ #orkaudio is generated by linux build orkaudio *.suo +*.o +*.lo +.deps/ +.dirstamp \ No newline at end of file diff --git a/orkaudio/OrkAudio.cpp b/orkaudio/OrkAudio.cpp index 1e961299..f058b069 100644 --- a/orkaudio/OrkAudio.cpp +++ b/orkaudio/OrkAudio.cpp @@ -1,6 +1,6 @@ /* * Oreka -- A media capture and retrieval platform - * + * * Copyright (C) 2005, orecx LLC * * http://www.orecx.com @@ -11,10 +11,15 @@ * */ - +#include +#include #include "stdio.h" #include +#define BACKWARD_HAS_DW 1 +#define BACKWARD_HAS_LIBUNWIND 1 +#include "backward.hpp" + #include "MultiThreadedServer.h" #include "OrkAudio.h" #include "Utils.h" @@ -58,6 +63,15 @@ #include "apr_signal.h" #include +#ifdef linux +#include +#include +#include +#include +#include // std::abort +#include // std::cerr +#endif + static volatile bool serviceStop = false; struct orkaudio_version { @@ -225,7 +239,7 @@ void Transcode(CStdString &file) CStdString portName("SinglePort"); AudioTapeRef tape(new AudioTape(portName, file)); bp->AddAudioTape(tape); - + // Make sure it stops after processing tape.reset(); bp->AddAudioTape(tape); @@ -450,13 +464,15 @@ void MainThread() OrkLogManager::Instance()->Shutdown(); } - int main(int argc, char* argv[]) { + + backward::SignalHandling sh; //install fatal error backtrace handler. + OrkAprSingleton::Initialize(); // the "service name" reported on the tape messages uses CONFIG.m_serviceName - // which also defaults to orkaudio-[hostname] but can be different depending on the + // which also defaults to orkaudio-[hostname] but can be different depending on the // value set in config.xml char hostname[ORKMAXHOSTLEN]; OrkGetHostname(hostname, sizeof(hostname)); @@ -511,8 +527,7 @@ int main(int argc, char* argv[]) { // No arguments, launch the daemon printf("Starting orkaudio daemon ... (type 'orkaudio debug' if you prefer running attached to tty)\n"); - Daemon::Singleton()->Start(); + Daemon::Singleton()->Start(); } return 0; } - diff --git a/orkaudio/configure.in b/orkaudio/configure.in index ecef33eb..aed5b656 100644 --- a/orkaudio/configure.in +++ b/orkaudio/configure.in @@ -1,7 +1,9 @@ -AC_INIT(configure.in) +AC_INIT([orkaudio], [1.0]) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(orkaudio, 1.0) +AM_INIT_AUTOMAKE([subdir-objects]) + +speex_lib=orkspeex AC_ARG_ENABLE( [tsan], AS_HELP_STRING([--enable-tsan], [enable thread sanitizer]) @@ -11,7 +13,8 @@ AC_ARG_ENABLE( [tsan], ) AC_LANG_CPLUSPLUS -AC_PROG_CXX +AC_PROG_CXX([g++]) +AM_PROG_LIBTOOL AS_IF([test "x$enable_tsan" = "xyes"], [ CXXFLAGS+=" -fsanitize=thread " @@ -23,9 +26,6 @@ AS_IF([test "x$enable_asan" = "xyes"], [ LDFLAGS+=" -fsanitize=address " ]) -speex_lib=speex - - # Check if gcc supports cpp11 if [echo "int main(){}" | $CXX -std=c++11 -xc++ -S - &>/dev/null] ; then CXXFLAGS+=" -std=c++11 -DSUPPORTS_CPP11 -fPIC" @@ -44,12 +44,19 @@ if [ egrep -i "release [67]" /etc/redhat-release ]; then fi AM_PROG_LIBTOOL +AC_SEARCH_LIBS([dwarf_begin],[dw],[][ + LDFLAGS+=" -ldw" +], AC_MSG_ERROR([libdw is not installed.])) + +AC_SEARCH_LIBS([unw_backtrace],[unwind],[][ + LDFLAGS+=" -lunwind" +], AC_MSG_ERROR([libunwind is not installed.])) AC_PREFIX_DEFAULT(/usr) AC_SUBST(speex_lib,$speex_lib) -AC_OUTPUT(Makefile audiocaptureplugins/Makefile audiocaptureplugins/generator/Makefile audiocaptureplugins/voip/Makefile filters/Makefile filters/rtpmixer/Makefile filters/silkcodec/Makefile) +AC_OUTPUT(Makefile audiocaptureplugins/Makefile audiocaptureplugins/generator/Makefile audiocaptureplugins/voip/Makefile filters/Makefile filters/rtpmixer/Makefile filters/silkcodec/Makefile filters/g729codec/Makefile) echo "" echo "========= Configuration ===========" diff --git a/orkaudio/filters/Makefile.am b/orkaudio/filters/Makefile.am index b79b53e7..c5b78478 100644 --- a/orkaudio/filters/Makefile.am +++ b/orkaudio/filters/Makefile.am @@ -1,2 +1,2 @@ METASOURCES = AUTO -SUBDIRS = rtpmixer silkcodec +SUBDIRS = rtpmixer silkcodec g729codec diff --git a/orkaudio/filters/g729codec/G729Codec.cpp b/orkaudio/filters/g729codec/G729Codec.cpp new file mode 100644 index 00000000..e6614bcd --- /dev/null +++ b/orkaudio/filters/g729codec/G729Codec.cpp @@ -0,0 +1,154 @@ +/* + * Oreka -- A media capture and retrieval platform + * + */ +#pragma warning( disable: 4786 ) // disables truncated symbols in browse-info warning + +#define _WINSOCKAPI_ // prevents the inclusion of winsock.h + +#include "G729Codec.h" +#include +#include "AudioCapture.h" +#include +#include +#include +#include "Utils.h" + +#define G729_FRAME_LEN 10 +#define G729_SAMPLES 80 /* 10ms at 8000 hz, 160 bytes signed linear */ +#define BUFFER_SAMPLES 8000 + +static log4cxx::LoggerPtr s_log = log4cxx::Logger::getLogger("codec.g729"); + +template +std::string toString(const T &value) { + std::ostringstream os; + os << value; + return os.str(); +} + +G729CodecDecoder::G729CodecDecoder() +{ + decoder = initBcg729DecoderChannel(); +} + +G729CodecDecoder::~G729CodecDecoder() +{ + closeBcg729DecoderChannel(decoder); +} + +FilterRef G729CodecDecoder::Instanciate() +{ + FilterRef Filter(new G729CodecDecoder()); + return Filter; +} + +void G729CodecDecoder::AudioChunkIn(AudioChunkRef& inputAudioChunk) +{ + int16_t pcmdata[BUFFER_SAMPLES]; + int input_size = 0; + int output_size; + CStdString logMsg; + + memset(pcmdata, 0, sizeof(pcmdata)); + m_outputAudioChunk.reset(); + + if(inputAudioChunk.get() == NULL) { + return; + } + + if(inputAudioChunk->GetNumSamples() == 0) { + return; + } + + AudioChunkDetails outputDetails = *inputAudioChunk->GetDetails(); + if(SupportsInputRtpPayloadType(outputDetails.m_rtpPayloadType) == false) + { + logMsg.Format("Wrong input RTP payload type: %d", outputDetails.m_rtpPayloadType); + LOG4CXX_DEBUG(s_log, logMsg); + return; + } + + unsigned char* inputBuffer = (unsigned char*)inputAudioChunk->m_pBuffer; + input_size = outputDetails.m_numBytes; + + LOG4CXX_DEBUG(s_log, "G729 AudioChunkIn Size : " + toString(input_size)); + + int16_t *ddp = pcmdata; + uint8_t *edp = inputBuffer; + + if(input_size == 0){ + /* Native PLC interpolation */ + LOG4CXX_INFO(s_log, "G729 zero length frame"); + bcg729Decoder(decoder, NULL, 0, 1, 0, 0, ddp); + ddp += G729_SAMPLES; + output_size = 2 * G729_SAMPLES; + } else { + int framesize; + uint32_t new_len = 0; + for (int x = 0; x < input_size; x += framesize) { + uint8_t isSID = (input_size - x < 8) ? 1 : 0; + framesize = (isSID == 1) ? 2 : 10; + bcg729Decoder(decoder, edp, 10, 0, isSID, 0, ddp); + ddp += G729_SAMPLES; + edp += framesize; + new_len += 2 * G729_SAMPLES; + } + output_size = new_len; + } + + m_outputAudioChunk.reset(new AudioChunk()); + outputDetails.m_rtpPayloadType = -1; + outputDetails.m_encoding = PcmAudio; + outputDetails.m_numBytes = output_size; + + //LOG4CXX_DEBUG(s_log, "G729 AudioChunkOut Size : " + toString(outputDetails.m_numBytes)); + short* outputBuffer = (short*)m_outputAudioChunk->CreateBuffer(outputDetails); + memcpy(outputBuffer, pcmdata, outputDetails.m_numBytes); +} + +void G729CodecDecoder::AudioChunkOut(AudioChunkRef& chunk) +{ + chunk = m_outputAudioChunk; +} + +AudioEncodingEnum G729CodecDecoder::GetInputAudioEncoding() +{ + return G729Audio; +} + +AudioEncodingEnum G729CodecDecoder::GetOutputAudioEncoding() +{ + return PcmAudio; +} + +CStdString G729CodecDecoder::GetName() +{ + return "G729CodecDecoder"; +} + +bool G729CodecDecoder::SupportsInputRtpPayloadType(int rtpPayloadType) +{ + return rtpPayloadType == pt_G729; +} + +void G729CodecDecoder::CaptureEventIn(CaptureEventRef& event) +{ + ; +} + +void G729CodecDecoder::CaptureEventOut(CaptureEventRef& event) +{ + ; +} + +extern "C" +{ +DLL_EXPORT void __CDECL__ OrkInitialize() +{ + LOG4CXX_INFO(s_log, "G729 codec filter starting."); + FilterRef filter(new G729CodecDecoder()); + FilterRegistry::instance()->RegisterFilter(filter); + LOG4CXX_INFO(s_log, "G729 codec filter initialized."); +} +} diff --git a/orkaudio/filters/g729codec/G729Codec.h b/orkaudio/filters/g729codec/G729Codec.h new file mode 100644 index 00000000..42b34356 --- /dev/null +++ b/orkaudio/filters/g729codec/G729Codec.h @@ -0,0 +1,44 @@ +/* + * Oreka -- A media capture and retrieval platform + * + * G729 Plugin + * Author Kinshuk Bairagi + * + */ + +#ifndef __G729CODEC_H__ +#define __G729CODEC_H__ 1 + +#include "LogManager.h" +#include "Filter.h" + +extern "C" +{ + #include "bcg729/encoder.h" + #include "bcg729/decoder.h" +} + +class DLL_IMPORT_EXPORT_ORKBASE G729CodecDecoder : public Filter +{ + public: + G729CodecDecoder(); + ~G729CodecDecoder(); + + FilterRef __CDECL__ Instanciate(); + void __CDECL__ AudioChunkIn(AudioChunkRef& chunk); + void __CDECL__ AudioChunkOut(AudioChunkRef& chunk); + AudioEncodingEnum __CDECL__ GetInputAudioEncoding(); + AudioEncodingEnum __CDECL__ GetOutputAudioEncoding(); + CStdString __CDECL__ GetName(); + bool __CDECL__ SupportsInputRtpPayloadType(int rtpm_payloadType ); + void __CDECL__ CaptureEventIn(CaptureEventRef& event); + void __CDECL__ CaptureEventOut(CaptureEventRef& event); + + private: + AudioChunkRef m_outputAudioChunk; + bcg729DecoderChannelContextStruct *decoder; + bool m_initialized; + +}; + +#endif diff --git a/orkaudio/filters/g729codec/Makefile.am b/orkaudio/filters/g729codec/Makefile.am new file mode 100644 index 00000000..92b40cf6 --- /dev/null +++ b/orkaudio/filters/g729codec/Makefile.am @@ -0,0 +1,11 @@ +METASOURCES = AUTO +plugindir= $(prefix)/lib/orkaudio/plugins +plugin_LTLIBRARIES = libg729codec.la +libg729codec_la_SOURCES = G729Codec.cpp +libg729codec_la_LDFLAGS = -module +AM_CPPFLAGS = -D_REENTRANT +libg729codec_la_LIBADD = -lbcg729 -llog4cxx -L/opt/bcg729 -L/usr/lib +INCLUDES = -I@top_srcdir@ -I../../../orkbasecxx -I/opt/bcg729/include -I/opt/bcg729/src -I/usr/include/apr-1 -I/usr/include/apr-1.0 + +all-local: libg729codec.la + cp .libs/libg729codec.so.0.0.0 ../../plugins/libg729codec.so diff --git a/orkbasecxx/AudioCapture.h b/orkbasecxx/AudioCapture.h index dad22888..a093ccef 100644 --- a/orkbasecxx/AudioCapture.h +++ b/orkbasecxx/AudioCapture.h @@ -1,6 +1,6 @@ /* * Oreka -- A media capture and retrieval platform - * + * * Copyright (C) 2005, orecx LLC * * http://www.orecx.com @@ -36,10 +36,11 @@ typedef enum OpusAudio = 9, AmrNb = 10, AmrWb = 11, - InvalidAudio = 12 + G729Audio = 12, + InvalidAudio = 13 } AudioEncodingEnum; -/** +/** * Serialization friendly details struct */ #define MEDIA_CHUNK_MARKER 0x2A2A2A2A // corresponds to "****" @@ -65,12 +66,12 @@ class DLL_IMPORT_EXPORT_ORKBASE AudioChunkDetails // separated multiple channels }; -/** - * This class represents a piece of audio. +/** + * This class represents a piece of audio. */ class DLL_IMPORT_EXPORT_ORKBASE AudioChunk { -public: +public: AudioChunk(); AudioChunk(int numChannels); ~AudioChunk(); @@ -164,9 +165,9 @@ class DLL_IMPORT_EXPORT_ORKBASE CaptureEvent #define DIR_IN_SHORT "I" #define DIR_OUT_SHORT "O" #define DIR_UNKN_SHORT "U" - typedef enum { - DirIn = 0, - DirOut = 1, + typedef enum { + DirIn = 0, + DirOut = 1, DirUnkn = 2 } DirectionEnum; static CStdString DirectionToString(int); @@ -222,7 +223,7 @@ class DLL_IMPORT_EXPORT_ORKBASE CaptureEvent } EventTypeEnum; static CStdString EventTypeToString(int eventTypeEnum); static int EventTypeToEnum(CStdString&); - + time_t m_timestamp; int m_offsetMs; EventTypeEnum m_type; @@ -258,6 +259,3 @@ CStdString DLL_IMPORT_EXPORT_ORKBASE FileFormatToString(int formatEnum); CStdString DLL_IMPORT_EXPORT_ORKBASE FileFormatGetExtension(FileFormatEnum); #endif - - - diff --git a/orkbasecxx/AudioTape.cpp b/orkbasecxx/AudioTape.cpp index 3d5ee705..31eec52c 100644 --- a/orkbasecxx/AudioTape.cpp +++ b/orkbasecxx/AudioTape.cpp @@ -62,6 +62,7 @@ void AudioTapeDescription::Define(Serializer* s) s->StringValue("localIp", m_localIp); s->StringValue("remoteIp", m_remoteIp); s->StringValue("filename", m_filename); + s->StringValue("nativeCallId", m_nativeCallId); s->BoolValue("ondemand", m_onDemand); } @@ -430,6 +431,7 @@ void AudioTape::AddCaptureEvent(CaptureEventRef eventRef, bool send) atd.m_localIp = m_localIp; atd.m_remoteIp = m_remoteIp; atd.m_onDemand = m_onDemand; + atd.m_nativeCallId = m_nativeCallId; atd.m_filename = GetFilename(); CStdString description = atd.SerializeSingleLine(); LOG4CXX_INFO(LOG.tapelistLog, description); diff --git a/orkbasecxx/AudioTape.h b/orkbasecxx/AudioTape.h index 461781a2..37441b12 100644 --- a/orkbasecxx/AudioTape.h +++ b/orkbasecxx/AudioTape.h @@ -71,13 +71,14 @@ class DLL_IMPORT_EXPORT_ORKBASE AudioTapeDescription : public Object CStdString m_localEntryPoint; CStdString m_remoteParty; CaptureEvent::DirectionEnum m_direction; - CaptureEvent::LocalSideEnum m_localSide; - CaptureEvent::AudioKeepDirectionEnum m_audioKeepDirectionEnum; + CaptureEvent::LocalSideEnum m_localSide; + CaptureEvent::AudioKeepDirectionEnum m_audioKeepDirectionEnum; time_t m_beginDate; int m_duration; CStdString m_localIp; CStdString m_remoteIp; CStdString m_filename; + CStdString m_nativeCallId; bool m_onDemand; }; diff --git a/orkbasecxx/Config.cpp b/orkbasecxx/Config.cpp index 3cc8b5ac..a754e852 100644 --- a/orkbasecxx/Config.cpp +++ b/orkbasecxx/Config.cpp @@ -94,6 +94,7 @@ Config::Config() m_clientRetryPeriodSec = CLIENT_RETRY_PERIOD_SEC_DEFAULT; m_hostnameReportFqdn = HOSTNAME_REPORT_FQDN_DEFAULT; m_discardUnidirectionalCalls = false; + m_audioFileBitRate = 6000; m_audioOutputEnable = true; m_holdResumeReportEvents = HOLD_RESUME_REPORT_EVENTS_DEFAULT; m_holdResumeReportDuration = HOLD_RESUME_REPORT_DURATION_DEFAULT; @@ -256,6 +257,7 @@ void Config::Define(Serializer* s) } s->IntValue(CLIENT_RETRY_PERIOD_SEC, m_clientRetryPeriodSec); s->BoolValue("DiscardUnidirectionalCalls", m_discardUnidirectionalCalls); + s->IntValue("AudioFileBitRate", m_audioFileBitRate); s->BoolValue("AudioOutputEnable", m_audioOutputEnable); #ifdef SUPPORT_TLS_SERVER s->IntValue(TLS_SERVER_PORT_PARAM, m_tlsServerPort); diff --git a/orkbasecxx/Config.h b/orkbasecxx/Config.h index c23059f2..e4a1cdc1 100644 --- a/orkbasecxx/Config.h +++ b/orkbasecxx/Config.h @@ -31,7 +31,7 @@ #define STORAGE_AUDIO_FORMAT_DEFAULT FfGsm #define NUM_BATCH_THREADS_PARAM "NumBatchThreads" #define NUM_COMMAND_THREADS_PARAM "NumCommandThreads" -#define NUM_BATCH_THREADS_DEFAULT 1 +#define NUM_BATCH_THREADS_DEFAULT 2 #define NUM_DIRECTIONSELECTOR_THREADS_PARAM "NumDirSelectorThreads" #define NUM_DIRECTIONSELECTOR_THREADS_DEFAULT 1 #define NUM_COMMAND_THREADS_DEFAULT 1 @@ -283,6 +283,7 @@ class DLL_IMPORT_EXPORT_ORKBASE Config : public Object bool m_hostnameReportFqdn; CStdString m_audioOutputPathMcf; bool m_discardUnidirectionalCalls; + int m_audioFileBitRate; bool m_audioOutputEnable; CStdString m_partyReplaceRegex; CStdString m_partyReplaceBy; diff --git a/orkbasecxx/ConfigManager.cpp b/orkbasecxx/ConfigManager.cpp index ccaceec4..f0653766 100644 --- a/orkbasecxx/ConfigManager.cpp +++ b/orkbasecxx/ConfigManager.cpp @@ -1,6 +1,6 @@ /* * Oreka -- A media capture and retrieval platform - * + * * Copyright (C) 2005, orecx LLC * * http://www.orecx.com @@ -107,7 +107,7 @@ void ConfigManager::Initialize() // DOMNode *doc = parser->getDocument(); // ... // parser->adoptDocument(); - // doc->release(); + // doc->release(); // ... // delete parser; XercesDOMParser *m_parser = new XercesDOMParser; @@ -142,7 +142,7 @@ void ConfigManager::Initialize() CStdString toto = DomSerializer::DomNodeToString(myDoc); FILE* file = fopen("zzz.xml", "w"); fwrite((PCSTR)toto,1,toto.GetLength(),file); - fclose(file); + fclose(file); */ } else @@ -186,4 +186,3 @@ void ConfigManager::AddConfigureFunction(ConfigureFunction configureFunction) // Cal the external configure callback straight away configureFunction(m_configTopNode); } - diff --git a/orkbasecxx/audiofile/OggOpusFile.cpp b/orkbasecxx/audiofile/OggOpusFile.cpp index 2cf15554..7542a93f 100644 --- a/orkbasecxx/audiofile/OggOpusFile.cpp +++ b/orkbasecxx/audiofile/OggOpusFile.cpp @@ -151,14 +151,19 @@ OggOpusFile::OggOpusFile() m_bytesOffsetFromLastFullFrame = 0; m_extraSamplesFromLastChunk = 0; m_extraPcmBufLen = 0; + m_outBuf=NULL; + st= NULL; } OggOpusFile::~OggOpusFile() { - free(m_outBuf); - opus_multistream_encoder_destroy(st); + //Don't trigger cleanup if Init() was not called. + if(m_outBuf) free(m_outBuf); + if(st) opus_multistream_encoder_destroy(st); ogg_stream_clear(&os); - if(opt_ctls)free(opt_ctls_ctlval); + if(opt_ctls) { + if(opt_ctls_ctlval) free(opt_ctls_ctlval); + } } void OggOpusFile::Open(CStdString& filename, fileOpenModeEnum mode, bool stereo, int sampleRate) @@ -210,7 +215,7 @@ void OggOpusFile::Init() frame_size=frame_size/(48000/coding_rate); /*OggOpus headers*/ /*FIXME: broke forcemono*/ header.channels=chan; - header.channel_mapping= 0;//header.channels>8?255:chan>2; //=0 for wav + header.channel_mapping=255;//header.channels>8?255:chan>2; //=0 for wav //255 for separate channels. header.input_sample_rate=rate; header.gain=inopt.gain; //=0 here @@ -236,7 +241,7 @@ void OggOpusFile::Init() // bitrate=((64000*header.nb_streams+32000*header.nb_coupled)* // (IMIN(48,IMAX(8,((rate<44100?rate:48000)+1000)/1000))+16)+32)>>6; bitrate=6000; - + bitrate = CONFIG.m_audioFileBitRate; } if(bitrate>(1024000*chan)||bitrate<500){ diff --git a/orkbasecxx/configure.in b/orkbasecxx/configure.in index 2fb42681..d1c5f162 100644 --- a/orkbasecxx/configure.in +++ b/orkbasecxx/configure.in @@ -45,7 +45,7 @@ if [cat /etc/redhat-release | grep "release 6"]; then fi AC_SUBST(boost_lib,$boost_lib) - + # Check if gcc supports cpp11 if [echo "int main(){}" | $CXX -std=c++11 -xc++ -S - &>/dev/null]; then CXXFLAGS+=" -std=c++11 -DSUPPORTS_CPP11 -fPIC" diff --git a/orkbasecxx/serializers/DomSerializer.cpp b/orkbasecxx/serializers/DomSerializer.cpp index def2f9d5..56d0830c 100644 --- a/orkbasecxx/serializers/DomSerializer.cpp +++ b/orkbasecxx/serializers/DomSerializer.cpp @@ -1,6 +1,6 @@ /* * Oreka -- A media capture and retrieval platform - * + * * Copyright (C) 2005, orecx LLC * * http://www.orecx.com @@ -111,8 +111,8 @@ void DomSerializer::GetList(const char* key, std::list& value, Object catch (CStdString& e) { // For now, do not interrupt the deserialization process. - // in the future, we might let this exception go through if the node has been - // recognized to bear the proper tag name + // in the future, we might let this exception go through if the node has been + // recognized to bear the proper tag name ; } node = node->getNextSibling(); @@ -221,16 +221,21 @@ CStdString DomSerializer::DomNodeToString(DOMNode* node) CStdString output; DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(XStr("LS").unicodeForm()); - DOMWriter *theSerializer = ((DOMImplementationLS*)impl)->createDOMWriter(); + DOMLSSerializer *theSerializer = ((DOMImplementationLS*)impl)->createLSSerializer(); + DOMConfiguration * dc = theSerializer->getDomConfig(); // set user specified output encoding - //theSerializer->setEncoding(gOutputEncoding); - theSerializer->setFeature(XStr("format-pretty-print").unicodeForm(), true); + //dc->setEncoding(gOutputEncoding); + dc->setParameter(XStr("format-pretty-print").unicodeForm(), true); XMLFormatTarget *myFormTarget; - myFormTarget = new MemBufFormatTarget (); - theSerializer->writeNode(myFormTarget, *node); + myFormTarget = new MemBufFormatTarget (); - output = (char *)((MemBufFormatTarget*)myFormTarget)->getRawBuffer(); + DOMLSOutput *outputStream = ((DOMImplementationLS*)impl)->createLSOutput(); + outputStream->setByteStream(myFormTarget); + + theSerializer->write(node, outputStream); + + output = (char *)((MemBufFormatTarget*)myFormTarget)->getRawBuffer(); // Clean up delete theSerializer; diff --git a/orkbasej/.classpath b/orkbasej/.classpath deleted file mode 100644 index 202b0a0a..00000000 --- a/orkbasej/.classpath +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/orkbasej/.gitignore b/orkbasej/.gitignore new file mode 100644 index 00000000..376a751b --- /dev/null +++ b/orkbasej/.gitignore @@ -0,0 +1,4 @@ +/bin/ +/target/ +.settings +*.iml \ No newline at end of file diff --git a/orkbasej/.project b/orkbasej/.project deleted file mode 100644 index 41bc85df..00000000 --- a/orkbasej/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - orkbasej - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/orkbasej/build.xml b/orkbasej/build.xml deleted file mode 100644 index 8dfad7f6..00000000 --- a/orkbasej/build.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +---------------------------------------------------+ - | | - | R U N N I N G H I B E R N A T E D O C L E T | - | | - +---------------------------------------------------+ - - - - - - - - - - - \ No newline at end of file diff --git a/orkbasej/java/net/sf/oreka/util/Base64.java b/orkbasej/java/net/sf/oreka/util/Base64.java deleted file mode 100644 index 7da1ffde..00000000 --- a/orkbasej/java/net/sf/oreka/util/Base64.java +++ /dev/null @@ -1,1071 +0,0 @@ -/* - * Base64.java - * - * This code is Public Domain, see the comments below for more details. - * - */ - -package net.sf.oreka.util; - -/** - * Encodes and decodes to and from Base64 notation. - * - *

- * Change Log: - *

- *
    - *
  • v1.3.6 - Fixed OutputStream.flush() so that 'position' is reset.
  • - *
  • v1.3.5 - Added flag to turn on and off line breaks. Fixed bug in input stream - * where last buffer being read, if not completely full, was not returned.
  • - *
  • v1.3.4 - Fixed when "improperly padded stream" error was thrown at the wrong time.
  • - *
  • v1.3.3 - Fixed I/O streams which were totally messed up.
  • - *
- * - *

- * I am placing this code in the Public Domain. Do with it as you will. - * This software comes with no guarantees or warranties but with - * plenty of well-wishing instead! - * Please visit http://iharder.net/xmlizable - * periodically to check for updates or to contribute improvements. - *

- * - * @author Robert Harder - * @author rob@iharder.net - * @version 1.3.4 - */ -public class Base64 -{ - - /** Specify encoding (value is true). */ - public final static boolean ENCODE = true; - - - /** Specify decoding (value is false). */ - public final static boolean DECODE = false; - - - /** Maximum line length (76) of Base64 output. */ - private final static int MAX_LINE_LENGTH = 76; - - - /** The equals sign (=) as a byte. */ - private final static byte EQUALS_SIGN = (byte)'='; - - - /** The new line character (\n) as a byte. */ - private final static byte NEW_LINE = (byte)'\n'; - - - /** The 64 valid Base64 values. */ - private final static byte[] ALPHABET = - { - (byte)'A', (byte)'B', (byte)'C', (byte)'D', (byte)'E', (byte)'F', (byte)'G', - (byte)'H', (byte)'I', (byte)'J', (byte)'K', (byte)'L', (byte)'M', (byte)'N', - (byte)'O', (byte)'P', (byte)'Q', (byte)'R', (byte)'S', (byte)'T', (byte)'U', - (byte)'V', (byte)'W', (byte)'X', (byte)'Y', (byte)'Z', - (byte)'a', (byte)'b', (byte)'c', (byte)'d', (byte)'e', (byte)'f', (byte)'g', - (byte)'h', (byte)'i', (byte)'j', (byte)'k', (byte)'l', (byte)'m', (byte)'n', - (byte)'o', (byte)'p', (byte)'q', (byte)'r', (byte)'s', (byte)'t', (byte)'u', - (byte)'v', (byte)'w', (byte)'x', (byte)'y', (byte)'z', - (byte)'0', (byte)'1', (byte)'2', (byte)'3', (byte)'4', (byte)'5', - (byte)'6', (byte)'7', (byte)'8', (byte)'9', (byte)'+', (byte)'/' - }; - - /** - * Translates a Base64 value to either its 6-bit reconstruction value - * or a negative number indicating some other meaning. - **/ - final static byte[] DECODABET = - { - -9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 0 - 8 - -5,-5, // Whitespace: Tab and Linefeed - -9,-9, // Decimal 11 - 12 - -5, // Whitespace: Carriage Return - -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 14 - 26 - -9,-9,-9,-9,-9, // Decimal 27 - 31 - -5, // Whitespace: Space - -9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 33 - 42 - 62, // Plus sign at decimal 43 - -9,-9,-9, // Decimal 44 - 46 - 63, // Slash at decimal 47 - 52,53,54,55,56,57,58,59,60,61, // Numbers zero through nine - -9,-9,-9, // Decimal 58 - 60 - -1, // Equals sign at decimal 61 - -9,-9,-9, // Decimal 62 - 64 - 0,1,2,3,4,5,6,7,8,9,10,11,12,13, // Letters 'A' through 'N' - 14,15,16,17,18,19,20,21,22,23,24,25, // Letters 'O' through 'Z' - -9,-9,-9,-9,-9,-9, // Decimal 91 - 96 - 26,27,28,29,30,31,32,33,34,35,36,37,38, // Letters 'a' through 'm' - 39,40,41,42,43,44,45,46,47,48,49,50,51, // Letters 'n' through 'z' - -9,-9,-9,-9 // Decimal 123 - 126 - /*,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 127 - 139 - -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 140 - 152 - -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 153 - 165 - -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 166 - 178 - -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 179 - 191 - -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 192 - 204 - -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 205 - 217 - -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 218 - 230 - -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9, // Decimal 231 - 243 - -9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9,-9 // Decimal 244 - 255 */ - }; - - //private final static byte BAD_ENCODING = -9; // Indicates error in encoding - private final static byte WHITE_SPACE_ENC = -5; // Indicates white space in encoding - private final static byte EQUALS_SIGN_ENC = -1; // Indicates equals sign in encoding - - - /** Defeats instantiation. */ - private Base64 (){} - - -/* ******** E N C O D I N G M E T H O D S ******** */ - - - /** - * Encodes the first three bytes of array threeBytes - * and returns a four-byte array in Base64 notation. - * - * @param threeBytes the array to convert - * @return four byte array in Base64 notation. - * @since 1.3 - */ - - protected static byte[] encode3to4( byte[] threeBytes ) - { return encode3to4( threeBytes, 3 ); - } // end encodeToBytes - - - - /** - * Encodes up to the first three bytes of array threeBytes - * and returns a four-byte array in Base64 notation. - * The actual number of significant bytes in your array is - * given by numSigBytes. - * The array threeBytes needs only be as big as - * numSigBytes. - * - * @param threeBytes the array to convert - * @param numSigBytes the number of significant bytes in your array - * @return four byte array in Base64 notation. - * @since 1.3 - */ - static byte[] encode3to4( byte[] threeBytes, int numSigBytes ) - { byte[] dest = new byte[4]; - encode3to4( threeBytes, 0, numSigBytes, dest, 0 ); - return dest; - } - - - - /** - * Encodes up to three bytes of the array source - * and writes the resulting four Base64 bytes to destination. - * The source and destination arrays can be manipulated - * anywhere along their length by specifying - * srcOffset and destOffset. - * This method does not check to make sure your arrays - * are large enough to accomodate srcOffset + 3 for - * the source array or destOffset + 4 for - * the destination array. - * The actual number of significant bytes in your array is - * given by numSigBytes. - * - * @param source the array to convert - * @param srcOffset the index where conversion begins - * @param numSigBytes the number of significant bytes in your array - * @param destination the array to hold the conversion - * @param destOffset the index where output will be put - * @return the destination array - * @since 1.3 - */ - static byte[] encode3to4( - byte[] source, int srcOffset, int numSigBytes, - byte[] destination, int destOffset ) - { - // 1 2 3 - // 01234567890123456789012345678901 Bit position - // --------000000001111111122222222 Array position from threeBytes - // --------| || || || | Six bit groups to index ALPHABET - // >>18 >>12 >> 6 >> 0 Right shift necessary - // 0x3f 0x3f 0x3f Additional AND - - // Create buffer with zero-padding if there are only one or two - // significant bytes passed in the array. - // We have to shift left 24 in order to flush out the 1's that appear - // when Java treats a value as negative that is cast from a byte to an int. - int inBuff = ( numSigBytes > 0 ? ((source[ srcOffset ] << 24) >>> 8) : 0 ) - | ( numSigBytes > 1 ? ((source[ srcOffset + 1 ] << 24) >>> 16) : 0 ) - | ( numSigBytes > 2 ? ((source[ srcOffset + 2 ] << 24) >>> 24) : 0 ); - - switch( numSigBytes ) - { - case 3: - destination[ destOffset ] = ALPHABET[ (inBuff >>> 18) ]; - destination[ destOffset + 1 ] = ALPHABET[ (inBuff >>> 12) & 0x3f ]; - destination[ destOffset + 2 ] = ALPHABET[ (inBuff >>> 6) & 0x3f ]; - destination[ destOffset + 3 ] = ALPHABET[ (inBuff ) & 0x3f ]; - return destination; - - case 2: - destination[ destOffset ] = ALPHABET[ (inBuff >>> 18) ]; - destination[ destOffset + 1 ] = ALPHABET[ (inBuff >>> 12) & 0x3f ]; - destination[ destOffset + 2 ] = ALPHABET[ (inBuff >>> 6) & 0x3f ]; - destination[ destOffset + 3 ] = EQUALS_SIGN; - return destination; - - case 1: - destination[ destOffset ] = ALPHABET[ (inBuff >>> 18) ]; - destination[ destOffset + 1 ] = ALPHABET[ (inBuff >>> 12) & 0x3f ]; - destination[ destOffset + 2 ] = EQUALS_SIGN; - destination[ destOffset + 3 ] = EQUALS_SIGN; - return destination; - - default: - return destination; - } // end switch - } // end encode3to4 - - /** - * Serializes an object and returns the Base64-encoded - * version of that serialized object. If the object - * cannot be serialized or there is another error, - * the method will return null. - * - * @param serializableObject The object to encode - * @return The Base64-encoded object - * @since 1.4 - */ - public static String encodeObject( java.io.Serializable serializableObject ) - { - return encodeObject( serializableObject, true ); - } // end encodeObject - - /** - * Serializes an object and returns the Base64-encoded - * version of that serialized object. If the object - * cannot be serialized or there is another error, - * the method will return null. - * - * @param serializableObject The object to encode - * @param breakLines Break lines at 80 characters or less. - * @return The Base64-encoded object - * @since 1.4 - */ - public static String encodeObject( java.io.Serializable serializableObject, boolean breakLines ) - { - java.io.ByteArrayOutputStream baos = null; - java.io.OutputStream b64os = null; - java.io.ObjectOutputStream oos = null; - - try - { - baos = new java.io.ByteArrayOutputStream(); - b64os = new Base64.OutputStream( baos, Base64.ENCODE, breakLines ); - oos = new java.io.ObjectOutputStream( b64os ); - - oos.writeObject( serializableObject ); - } // end try - catch( java.io.IOException e ) - { - e.printStackTrace(); - return null; - } // end catch - finally - { - try{ oos.close(); } catch( Exception e ){} - try{ b64os.close(); } catch( Exception e ){} - try{ baos.close(); } catch( Exception e ){} - } // end finally - - return new String( baos.toByteArray() ); - } // end encode - - - /** - * Encodes a byte array into Base64 notation. - * Equivalen to calling - * encodeBytes( source, 0, source.length ) - * - * @param source The data to convert - * @since 1.4 - */ - public static String encodeBytes( byte[] source ) - { - return encodeBytes( source, true ); - } // end encodeBytes - - /** - * Encodes a byte array into Base64 notation. - * Equivalen to calling - * encodeBytes( source, 0, source.length ) - * - * @param source The data to convert - * @param breakLines Break lines at 80 characters or less. - * @since 1.4 - */ - public static String encodeBytes( byte[] source, boolean breakLines ) - { - return encodeBytes( source, 0, source.length, breakLines ); - } // end encodeBytes - - - /** - * Encodes a byte array into Base64 notation. - * - * @param source The data to convert - * @param off Offset in array where conversion should begin - * @param len Length of data to convert - * @since 1.4 - */ - public static String encodeBytes( byte[] source, int off, int len ) - { - return encodeBytes( source, off, len, true ); - } // end encodeBytes - - - /** - * Encodes a byte array into Base64 notation. - * - * @param source The data to convert - * @param off Offset in array where conversion should begin - * @param len Length of data to convert - * @param breakLines Break lines at 80 characters or less. - * @since 1.4 - */ - public static String encodeBytes( byte[] source, int off, int len, boolean breakLines ) - { - int len43 = len * 4 / 3; - byte[] outBuff = new byte[ ( len43 ) // Main 4:3 - + ( (len % 3) > 0 ? 4 : 0 ) // Account for padding - + (breakLines ? ( len43 / MAX_LINE_LENGTH ) : 0) ]; // New lines - int d = 0; - int e = 0; - int len2 = len - 2; - int lineLength = 0; - for( ; d < len2; d+=3, e+=4 ) - { - encode3to4( source, d+off, 3, outBuff, e ); - - lineLength += 4; - if( breakLines && lineLength == MAX_LINE_LENGTH ) - { - outBuff[e+4] = NEW_LINE; - e++; - lineLength = 0; - } // end if: end of line - } // en dfor: each piece of array - - if( d < len ) - { - encode3to4( source, d+off, len - d, outBuff, e ); - e += 4; - } // end if: some padding needed - - return new String( outBuff, 0, e ); - } // end encodeBytes - - - /** - * Encodes a string in Base64 notation with line breaks - * after every 75 Base64 characters. - * - * @param s the string to encode - * @return the encoded string - * @since 1.3 - */ - public static String encodeString( String s ) - { - return encodeString( s, true ); - } // end encodeString - - /** - * Encodes a string in Base64 notation with line breaks - * after every 75 Base64 characters. - * - * @param s the string to encode - * @param breakLines Break lines at 80 characters or less. - * @return the encoded string - * @since 1.3 - */ - public static String encodeString( String s, boolean breakLines ) - { - return encodeBytes( s.getBytes(), breakLines ); - } // end encodeString - - - - -/* ******** D E C O D I N G M E T H O D S ******** */ - - - /** - * Decodes the first four bytes of array fourBytes - * and returns an array up to three bytes long with the - * decoded values. - * - * @param fourBytes the array with Base64 content - * @return array with decoded values - * @since 1.3 - */ - static byte[] decode4to3( byte[] fourBytes ) - { - byte[] outBuff1 = new byte[3]; - int count = decode4to3( fourBytes, 0, outBuff1, 0 ); - byte[] outBuff2 = new byte[ count ]; - - for( int i = 0; i < count; i++ ) - outBuff2[i] = outBuff1[i]; - - return outBuff2; - } - - - - - /** - * Decodes four bytes from array source - * and writes the resulting bytes (up to three of them) - * to destination. - * The source and destination arrays can be manipulated - * anywhere along their length by specifying - * srcOffset and destOffset. - * This method does not check to make sure your arrays - * are large enough to accomodate srcOffset + 4 for - * the source array or destOffset + 3 for - * the destination array. - * This method returns the actual number of bytes that - * were converted from the Base64 encoding. - * - * - * @param source the array to convert - * @param srcOffset the index where conversion begins - * @param destination the array to hold the conversion - * @param destOffset the index where output will be put - * @return the number of decoded bytes converted - * @since 1.3 - */ - static int decode4to3( byte[] source, int srcOffset, byte[] destination, int destOffset ) - { - // Example: Dk== - if( source[ srcOffset + 2] == EQUALS_SIGN ) - { - // Two ways to do the same thing. Don't know which way I like best. - //int outBuff = ( ( DECODABET[ source[ srcOffset ] ] << 24 ) >>> 6 ) - // | ( ( DECODABET[ source[ srcOffset + 1] ] << 24 ) >>> 12 ); - int outBuff = ( ( DECODABET[ source[ srcOffset ] ] & 0xFF ) << 18 ) - | ( ( DECODABET[ source[ srcOffset + 1] ] & 0xFF ) << 12 ); - - destination[ destOffset ] = (byte)( outBuff >>> 16 ); - return 1; - } - - // Example: DkL= - else if( source[ srcOffset + 3 ] == EQUALS_SIGN ) - { - // Two ways to do the same thing. Don't know which way I like best. - //int outBuff = ( ( DECODABET[ source[ srcOffset ] ] << 24 ) >>> 6 ) - // | ( ( DECODABET[ source[ srcOffset + 1 ] ] << 24 ) >>> 12 ) - // | ( ( DECODABET[ source[ srcOffset + 2 ] ] << 24 ) >>> 18 ); - int outBuff = ( ( DECODABET[ source[ srcOffset ] ] & 0xFF ) << 18 ) - | ( ( DECODABET[ source[ srcOffset + 1 ] ] & 0xFF ) << 12 ) - | ( ( DECODABET[ source[ srcOffset + 2 ] ] & 0xFF ) << 6 ); - - destination[ destOffset ] = (byte)( outBuff >>> 16 ); - destination[ destOffset + 1 ] = (byte)( outBuff >>> 8 ); - return 2; - } - - // Example: DkLE - else - { - try{ - // Two ways to do the same thing. Don't know which way I like best. - //int outBuff = ( ( DECODABET[ source[ srcOffset ] ] << 24 ) >>> 6 ) - // | ( ( DECODABET[ source[ srcOffset + 1 ] ] << 24 ) >>> 12 ) - // | ( ( DECODABET[ source[ srcOffset + 2 ] ] << 24 ) >>> 18 ) - // | ( ( DECODABET[ source[ srcOffset + 3 ] ] << 24 ) >>> 24 ); - int outBuff = ( ( DECODABET[ source[ srcOffset ] ] & 0xFF ) << 18 ) - | ( ( DECODABET[ source[ srcOffset + 1 ] ] & 0xFF ) << 12 ) - | ( ( DECODABET[ source[ srcOffset + 2 ] ] & 0xFF ) << 6) - | ( ( DECODABET[ source[ srcOffset + 3 ] ] & 0xFF ) ); - - - destination[ destOffset ] = (byte)( outBuff >> 16 ); - destination[ destOffset + 1 ] = (byte)( outBuff >> 8 ); - destination[ destOffset + 2 ] = (byte)( outBuff ); - - return 3; - }catch( Exception e){ - System.out.println(""+source[srcOffset]+ ": " + ( DECODABET[ source[ srcOffset ] ] ) ); - System.out.println(""+source[srcOffset+1]+ ": " + ( DECODABET[ source[ srcOffset + 1 ] ] ) ); - System.out.println(""+source[srcOffset+2]+ ": " + ( DECODABET[ source[ srcOffset + 2 ] ] ) ); - System.out.println(""+source[srcOffset+3]+ ": " + ( DECODABET[ source[ srcOffset + 3 ] ] ) ); - return -1; - } //e nd catch - } - } // end decodeToBytes - - - - /** - * Decodes data from Base64 notation. - * - * @param s the string to decode - * @return the decoded data - * @since 1.4 - */ - public static byte[] decode( String s ) - { - byte[] bytes = s.getBytes(); - return decode( bytes, 0, bytes.length ); - } // end decode - - - /** - * Decodes data from Base64 notation and - * returns it as a string. - * Equivlaent to calling - * new String( decode( s ) ) - * - * @param s the strind to decode - * @return The data as a string - * @since 1.4 - */ - public static String decodeToString( String s ) - { return new String( decode( s ) ); - } // end decodeToString - - - /** - * Attempts to decode Base64 data and deserialize a Java - * Object within. Returns null if there was an error. - * - * @param encodedObject The Base64 data to decode - * @return The decoded and deserialized object - * @since 1.4 - */ - public static Object decodeToObject( String encodedObject ) - { - byte[] objBytes = decode( encodedObject ); - - java.io.ByteArrayInputStream bais = null; - java.io.ObjectInputStream ois = null; - - try - { - bais = new java.io.ByteArrayInputStream( objBytes ); - ois = new java.io.ObjectInputStream( bais ); - - return ois.readObject(); - } // end try - catch( java.io.IOException e ) - { - e.printStackTrace(); - return null; - } // end catch - catch( java.lang.ClassNotFoundException e ) - { - e.printStackTrace(); - return null; - } // end catch - finally - { - try{ bais.close(); } catch( Exception e ){} - try{ ois.close(); } catch( Exception e ){} - } // end finally - } // end decodeObject - - - /** - * Decodes Base64 content in byte array format and returns - * the decoded byte array. - * - * @param source The Base64 encoded data - * @param off The offset of where to begin decoding - * @param len The length of characters to decode - * @return decoded data - * @since 1.3 - */ - public static byte[] decode( byte[] source, int off, int len ) - { - int len34 = len * 3 / 4; - byte[] outBuff = new byte[ len34 ]; // Upper limit on size of output - int outBuffPosn = 0; - - byte[] b4 = new byte[4]; - int b4Posn = 0; - int i = 0; - byte sbiCrop = 0; - byte sbiDecode = 0; - len += off; - for( i = off; i < len; i++ ) - { - sbiCrop = (byte)(source[i] & 0x7f); // Only the low seven bits - sbiDecode = DECODABET[ sbiCrop ]; - - if( sbiDecode >= WHITE_SPACE_ENC ) // White space, Equals sign or better - { - if( sbiDecode >= EQUALS_SIGN_ENC ) - { - b4[ b4Posn++ ] = sbiCrop; - if( b4Posn > 3 ) - { - outBuffPosn += decode4to3( b4, 0, outBuff, outBuffPosn ); - b4Posn = 0; - - // If that was the equals sign, break out of 'for' loop - if( sbiCrop == EQUALS_SIGN ) - break; - } // end if: quartet built - - } // end if: equals sign or better - - } // end if: white space, equals sign or better - else - { - System.err.println( "Bad Base64 input character at " + i + ": " + source[i] + "(decimal)" ); - return null; - } // end else: - } // each input character - - byte[] out = new byte[ outBuffPosn ]; - System.arraycopy( outBuff, 0, out, 0, outBuffPosn ); - return out; - } // end decode - - - - - /* ******** I N N E R C L A S S I N P U T S T R E A M ******** */ - - - - /** - * A {@link Base64#InputStream} will read data from another - * {@link java.io.InputStream}, given in the constructor, - * and encode/decode to/from Base64 notation on the fly. - * - * @see Base64 - * @see java.io.FilterInputStream - * @since 1.3 - */ - public static class InputStream extends java.io.FilterInputStream - { - private boolean encode; // Encoding or decoding - private int position; // Current position in the buffer - private byte[] buffer; // Small buffer holding converted data - private int bufferLength; // Length of buffer (3 or 4) - private int numSigBytes; // Number of meaningful bytes in the buffer - private int lineLength; - private boolean breakLines; // Break lines at less than 80 characters - - - /** - * Constructs a {@link Base64#InputStream} in DECODE mode. - * - * @param in the {@link java.io.InputStream} from which to read data. - * @since 1.3 - */ - public InputStream( java.io.InputStream in ) - { - this( in, Base64.DECODE ); - } // end constructor - - - /** - * Constructs a {@link Base64#InputStream} in - * either ENCODE or DECODE mode. - * - * @param in the {@link java.io.InputStream} from which to read data. - * @param encode Conversion direction - * @see Base64#ENCODE - * @see Base64#DECODE - * @since 1.3 - */ - public InputStream( java.io.InputStream in, boolean encode ) - { - this( in, encode, true ); - } // end constructor - - - /** - * Constructs a {@link Base64#InputStream} in - * either ENCODE or DECODE mode. - * - * @param in the {@link java.io.InputStream} from which to read data. - * @param encode Conversion direction - * @param breakLines Break lines at less than 80 characters. - * @see Base64#ENCODE - * @see Base64#DECODE - * @since 1.3 - */ - public InputStream( java.io.InputStream in, boolean encode, boolean breakLines ) - { - super( in ); - this.breakLines = breakLines; - this.encode = encode; - this.bufferLength = encode ? 4 : 3; - this.buffer = new byte[ bufferLength ]; - this.position = -1; - this.lineLength = 0; - } // end constructor - - /** - * Reads enough of the input stream to convert - * to/from Base64 and returns the next byte. - * - * @return next byte - * @since 1.3 - */ - public int read() throws java.io.IOException - { - // Do we need to get data? - if( position < 0 ) - { - if( encode ) - { - byte[] b3 = new byte[3]; - int numBinaryBytes = 0; - for( int i = 0; i < 3; i++ ) - { - try - { - int b = in.read(); - - // If end of stream, b is -1. - if( b >= 0 ) - { - b3[i] = (byte)b; - numBinaryBytes++; - } // end if: not end of stream - - } // end try: read - catch( java.io.IOException e ) - { - // Only a problem if we got no data at all. - if( i == 0 ) - throw e; - - } // end catch - } // end for: each needed input byte - - if( numBinaryBytes > 0 ) - { - encode3to4( b3, 0, numBinaryBytes, buffer, 0 ); - position = 0; - numSigBytes = 4; - } // end if: got data - else - { - return -1; - } // end else - } // end if: encoding - - // Else decoding - else - { - byte[] b4 = new byte[4]; - int i = 0; - for( i = 0; i < 4; i++ ) - { - // Read four "meaningful" bytes: - int b = 0; - do{ b = in.read(); } - while( b >= 0 && DECODABET[ b & 0x7f ] <= WHITE_SPACE_ENC ); - - if( b < 0 ) - break; // Reads a -1 if end of stream - - b4[i] = (byte)b; - } // end for: each needed input byte - - if( i == 4 ) - { - numSigBytes = decode4to3( b4, 0, buffer, 0 ); - position = 0; - } // end if: got four characters - else if( i == 0 ){ - return -1; - } // end else if: also padded correctly - else - { - // Must have broken out from above. - throw new java.io.IOException( "Improperly padded Base64 input." ); - } // end - - } // end else: decode - } // end else: get data - - // Got data? - if( position >= 0 ) - { - // End of relevant data? - if( /*!encode &&*/ position >= numSigBytes ) - return -1; - - if( encode && breakLines && lineLength >= MAX_LINE_LENGTH ) - { - lineLength = 0; - return '\n'; - } // end if - else - { - lineLength++; // This isn't important when decoding - // but throwing an extra "if" seems - // just as wasteful. - - int b = buffer[ position++ ]; - - if( position >= bufferLength ) - position = -1; - - return b & 0xFF; // This is how you "cast" a byte that's - // intended to be unsigned. - } // end else - } // end if: position >= 0 - - // Else error - else - { - // When JDK1.4 is more accepted, use an assertion here. - throw new java.io.IOException( "Error in Base64 code reading stream." ); - } // end else - } // end read - - - /** - * Calls {@link #read} repeatedly until the end of stream - * is reached or len bytes are read. - * Returns number of bytes read into array or -1 if - * end of stream is encountered. - * - * @param dest array to hold values - * @param off offset for array - * @param len max number of bytes to read into array - * @return bytes read into array or -1 if end of stream is encountered. - * @since 1.3 - */ - public int read( byte[] dest, int off, int len ) throws java.io.IOException - { - int i; - int b; - for( i = 0; i < len; i++ ) - { - b = read(); - - //if( b < 0 && i == 0 ) - // return -1; - - if( b >= 0 ) - dest[off + i] = (byte)b; - else if( i == 0 ) - return -1; - else - break; // Out of 'for' loop - } // end for: each byte read - return i; - } // end read - - } // end inner class InputStream - - - - - - - /* ******** I N N E R C L A S S O U T P U T S T R E A M ******** */ - - - - /** - * A {@link Base64#OutputStream} will write data to another - * {@link java.io.OutputStream}, given in the constructor, - * and encode/decode to/from Base64 notation on the fly. - * - * @see Base64 - * @see java.io.FilterOutputStream - * @since 1.3 - */ - public static class OutputStream extends java.io.FilterOutputStream - { - private boolean encode; - private int position; - private byte[] buffer; - private int bufferLength; - private int lineLength; - private boolean breakLines; - - - /** - * Constructs a {@link Base64#OutputStream} in ENCODE mode. - * - * @param out the {@link java.io.OutputStream} to which data will be written. - * @since 1.3 - */ - public OutputStream( java.io.OutputStream out ) - { - this( out, Base64.ENCODE ); - } // end constructor - - - /** - * Constructs a {@link Base64#OutputStream} in - * either ENCODE or DECODE mode. - * - * @param out the {@link java.io.OutputStream} to which data will be written. - * @param encode Conversion direction - * @see Base64#ENCODE - * @see Base64#DECODE - * @since 1.3 - */ - public OutputStream( java.io.OutputStream out, boolean encode ) - { - this( out, encode, true ); - } // end constructor - - - /** - * Constructs a {@link Base64#OutputStream} in - * either ENCODE or DECODE mode. - * - * @param out the {@link java.io.OutputStream} to which data will be written. - * @param encode Conversion direction - * @param breakLines Break lines to be less than 80 characters. - * @see Base64#ENCODE - * @see Base64#DECODE - * @since 1.3 - */ - public OutputStream( java.io.OutputStream out, boolean encode, boolean breakLines ) - { - super( out ); - this.breakLines = breakLines; - this.encode = encode; - this.bufferLength = encode ? 3 : 4; - this.buffer = new byte[ bufferLength ]; - this.position = 0; - this.lineLength = 0; - } // end constructor - - - /** - * Writes the byte to the output stream after - * converting to/from Base64 notation. - * When encoding, bytes are buffered three - * at a time before the output stream actually - * gets a write() call. - * When decoding, bytes are buffered four - * at a time. - * - * @param theByte the byte to write - * @since 1.3 - */ - public void write(int theByte) throws java.io.IOException - { - if( encode ) - { - buffer[ position++ ] = (byte)theByte; - if( position >= bufferLength ) // Enough to encode. - { - out.write( Base64.encode3to4( buffer, bufferLength ) ); - - lineLength += 4; - if( breakLines && lineLength >= MAX_LINE_LENGTH ) - { - out.write( NEW_LINE ); - lineLength = 0; - } // end if: end of line - - position = 0; - } // end if: enough to output - } // end if: encoding - - // Else, Decoding - else - { - // Meaningful Base64 character? - if( DECODABET[ theByte & 0x7f ] > WHITE_SPACE_ENC ) - { - buffer[ position++ ] = (byte)theByte; - if( position >= bufferLength ) // Enough to output. - { - out.write( Base64.decode4to3( buffer ) ); - position = 0; - } // end if: enough to output - } // end if: meaningful base64 character - else if( DECODABET[ theByte & 0x7f ] != WHITE_SPACE_ENC ) - { - throw new java.io.IOException( "Invalid character in Base64 data." ); - } // end else: not white space either - } // end else: decoding - } // end write - - - - /** - * Calls {@link #write} repeatedly until len - * bytes are written. - * - * @param theBytes array from which to read bytes - * @param off offset for array - * @param len max number of bytes to read into array - * @since 1.3 - */ - public void write( byte[] theBytes, int off, int len ) throws java.io.IOException - { - for( int i = 0; i < len; i++ ) - { - write( theBytes[ off + i ] ); - } // end for: each byte written - - } // end write - - - /** - * Appropriately pads Base64 notation when encoding - * or throws an exception if Base64 input is not - * properly padded when decoding. - * - * @since 1.3 - */ - public void flush() throws java.io.IOException - { - super.flush(); - - if( position > 0 ) - { - if( encode ) - { - out.write( Base64.encode3to4( buffer, position ) ); - position = 0; - } // end if: encoding - else - { - throw new java.io.IOException( "Base64 input not properly padded." ); - } // end else: decoding - } // end if: buffer partially full - - out.flush(); - } // end flush - - - /** - * Flushes and closes (I think, in the superclass) the stream. - * - * @since 1.3 - */ - public void close() throws java.io.IOException - { - super.close(); - //this.flush(); - - out.close(); - - buffer = null; - out = null; - } // end close - - } // end inner class OutputStream - - -} // end class Base64 diff --git a/orkbasej/pom.xml b/orkbasej/pom.xml new file mode 100644 index 00000000..f99102c3 --- /dev/null +++ b/orkbasej/pom.xml @@ -0,0 +1,122 @@ + + 4.0.0 + net.sf.oreka + orkbasej + 0.0.2-SNAPSHOT + + src/main/java + + + src/resources + + + + + + maven-compiler-plugin + 3.8.1 + + 1.8 + 1.8 + + + + + + + mysql + mysql-connector-java + 8.0.20 + + + + org.hibernate + hibernate-core + 5.4.15.Final + + + + org.hibernate.common + hibernate-commons-annotations + 5.1.0.Final + + + + hsqldb + hsqldb + 1.8.0.4 + + + org.apache.commons + commons-lang3 + 3.10 + + + javax.transaction + jta + 1.1 + + + junit + junit + 4.13.1 + + + + com.cloudhopper.proxool + proxool + 0.9.1 + + + javax.servlet + servlet-api + + + log4j + log4j + + + + + + javax.servlet + javax.servlet-api + 4.0.0 + provided + + + + org.apache.logging.log4j + log4j-api + 2.17.0 + + + + org.apache.logging.log4j + log4j-core + 2.17.0 + + + + org.apache.logging.log4j + log4j-1.2-api + 2.11.0 + + + + org.apache.logging.log4j + log4j-web + 2.11.0 + + + + org.projectlombok + lombok + 1.16.20 + provided + + + + + \ No newline at end of file diff --git a/orkbasej/java/net/sf/oreka/Cycle.java b/orkbasej/src/main/java/net/sf/oreka/Cycle.java similarity index 100% rename from orkbasej/java/net/sf/oreka/Cycle.java rename to orkbasej/src/main/java/net/sf/oreka/Cycle.java diff --git a/orkbasej/java/net/sf/oreka/Day.java b/orkbasej/src/main/java/net/sf/oreka/Day.java similarity index 100% rename from orkbasej/java/net/sf/oreka/Day.java rename to orkbasej/src/main/java/net/sf/oreka/Day.java diff --git a/orkbasej/java/net/sf/oreka/Direction.java b/orkbasej/src/main/java/net/sf/oreka/Direction.java similarity index 100% rename from orkbasej/java/net/sf/oreka/Direction.java rename to orkbasej/src/main/java/net/sf/oreka/Direction.java diff --git a/orkbasej/java/net/sf/oreka/HibernateManager.java b/orkbasej/src/main/java/net/sf/oreka/HibernateManager.java similarity index 96% rename from orkbasej/java/net/sf/oreka/HibernateManager.java rename to orkbasej/src/main/java/net/sf/oreka/HibernateManager.java index 729ece00..c90013a5 100644 --- a/orkbasej/java/net/sf/oreka/HibernateManager.java +++ b/orkbasej/src/main/java/net/sf/oreka/HibernateManager.java @@ -37,7 +37,7 @@ import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; -import org.hibernate.cfg.AnnotationConfiguration; +import org.hibernate.cfg.Configuration; import org.logicalcobwebs.proxool.ProxoolFacade; @@ -58,12 +58,12 @@ public static HibernateManager instance() { } public void configure(String filename) throws Exception { - + File configFile = new File(filename); - - AnnotationConfiguration config = new AnnotationConfiguration(); + + Configuration config = new Configuration(); config.configure(configFile); - + // Configure the proxool connection pool Class.forName("org.logicalcobwebs.proxool.ProxoolDriver"); Properties info = new Properties(); @@ -79,11 +79,11 @@ public void configure(String filename) throws Exception { String driverUrl = config.getProperty("hibernate.connection.url"); String url = "proxool." + alias + ":" + driverClass + ":" + driverUrl; ProxoolFacade.registerConnectionPool(url, info); - + // Let hibernate know we want to use proxool config.setProperty("hibernate.proxool.pool_alias", alias); config.setProperty("hibernate.proxool.existing_pool", "true"); - + config.addAnnotatedClass(OrkProgram.class); config.addAnnotatedClass(OrkSession.class); config.addAnnotatedClass(OrkSegment.class); @@ -95,7 +95,7 @@ public void configure(String filename) throws Exception { config.addAnnotatedClass(OrkPort.class); config.addAnnotatedClass(OrkPortFace.class); sessionFactory = config.buildSessionFactory(); - + // Add admin user if does not exist yet Session hbnSession = null; Transaction tx = null; diff --git a/orkbasej/java/net/sf/oreka/OrkBase.java b/orkbasej/src/main/java/net/sf/oreka/OrkBase.java similarity index 100% rename from orkbasej/java/net/sf/oreka/OrkBase.java rename to orkbasej/src/main/java/net/sf/oreka/OrkBase.java diff --git a/orkbasej/java/net/sf/oreka/OrkException.java b/orkbasej/src/main/java/net/sf/oreka/OrkException.java similarity index 100% rename from orkbasej/java/net/sf/oreka/OrkException.java rename to orkbasej/src/main/java/net/sf/oreka/OrkException.java diff --git a/orkbasej/java/net/sf/oreka/OrkObject.java b/orkbasej/src/main/java/net/sf/oreka/OrkObject.java similarity index 100% rename from orkbasej/java/net/sf/oreka/OrkObject.java rename to orkbasej/src/main/java/net/sf/oreka/OrkObject.java diff --git a/orkbasej/java/net/sf/oreka/OrkObjectFactory.java b/orkbasej/src/main/java/net/sf/oreka/OrkObjectFactory.java similarity index 100% rename from orkbasej/java/net/sf/oreka/OrkObjectFactory.java rename to orkbasej/src/main/java/net/sf/oreka/OrkObjectFactory.java diff --git a/orkbasej/java/net/sf/oreka/OrkTest.java b/orkbasej/src/main/java/net/sf/oreka/OrkTest.java similarity index 100% rename from orkbasej/java/net/sf/oreka/OrkTest.java rename to orkbasej/src/main/java/net/sf/oreka/OrkTest.java diff --git a/orkbasej/java/net/sf/oreka/ServiceClass.java b/orkbasej/src/main/java/net/sf/oreka/ServiceClass.java similarity index 100% rename from orkbasej/java/net/sf/oreka/ServiceClass.java rename to orkbasej/src/main/java/net/sf/oreka/ServiceClass.java diff --git a/orkbasej/java/net/sf/oreka/bo/UserBo.java b/orkbasej/src/main/java/net/sf/oreka/bo/UserBo.java similarity index 100% rename from orkbasej/java/net/sf/oreka/bo/UserBo.java rename to orkbasej/src/main/java/net/sf/oreka/bo/UserBo.java diff --git a/orkbasej/java/net/sf/oreka/messages/AsyncMessage.java b/orkbasej/src/main/java/net/sf/oreka/messages/AsyncMessage.java similarity index 100% rename from orkbasej/java/net/sf/oreka/messages/AsyncMessage.java rename to orkbasej/src/main/java/net/sf/oreka/messages/AsyncMessage.java diff --git a/orkbasej/java/net/sf/oreka/messages/Message.java b/orkbasej/src/main/java/net/sf/oreka/messages/Message.java similarity index 100% rename from orkbasej/java/net/sf/oreka/messages/Message.java rename to orkbasej/src/main/java/net/sf/oreka/messages/Message.java diff --git a/orkbasej/java/net/sf/oreka/messages/SimpleResponseMessage.java b/orkbasej/src/main/java/net/sf/oreka/messages/SimpleResponseMessage.java similarity index 99% rename from orkbasej/java/net/sf/oreka/messages/SimpleResponseMessage.java rename to orkbasej/src/main/java/net/sf/oreka/messages/SimpleResponseMessage.java index 2da91313..8443655f 100644 --- a/orkbasej/java/net/sf/oreka/messages/SimpleResponseMessage.java +++ b/orkbasej/src/main/java/net/sf/oreka/messages/SimpleResponseMessage.java @@ -20,15 +20,13 @@ public class SimpleResponseMessage extends AsyncMessage { boolean success = false; String comment = ""; - - public void define(OrkSerializer serializer) throws OrkException { + public void define(OrkSerializer serializer) throws OrkException { success = serializer.booleanValue("success", success, true); comment = serializer.stringValue("comment", comment, false); } public String getOrkClassName() { - return "simpleresponse"; } diff --git a/orkbasej/java/net/sf/oreka/messages/SyncMessage.java b/orkbasej/src/main/java/net/sf/oreka/messages/SyncMessage.java similarity index 100% rename from orkbasej/java/net/sf/oreka/messages/SyncMessage.java rename to orkbasej/src/main/java/net/sf/oreka/messages/SyncMessage.java diff --git a/orkbasej/java/net/sf/oreka/messages/test/TestMessage.java b/orkbasej/src/main/java/net/sf/oreka/messages/test/TestMessage.java similarity index 100% rename from orkbasej/java/net/sf/oreka/messages/test/TestMessage.java rename to orkbasej/src/main/java/net/sf/oreka/messages/test/TestMessage.java diff --git a/orkbasej/java/net/sf/oreka/messages/test/TestNestedMessage.java b/orkbasej/src/main/java/net/sf/oreka/messages/test/TestNestedMessage.java similarity index 100% rename from orkbasej/java/net/sf/oreka/messages/test/TestNestedMessage.java rename to orkbasej/src/main/java/net/sf/oreka/messages/test/TestNestedMessage.java diff --git a/orkbasej/java/net/sf/oreka/messages/test/TestSubMessage.java b/orkbasej/src/main/java/net/sf/oreka/messages/test/TestSubMessage.java similarity index 100% rename from orkbasej/java/net/sf/oreka/messages/test/TestSubMessage.java rename to orkbasej/src/main/java/net/sf/oreka/messages/test/TestSubMessage.java diff --git a/orkbasej/java/net/sf/oreka/persistent/AnnotatedTestClass.java b/orkbasej/src/main/java/net/sf/oreka/persistent/AnnotatedTestClass.java similarity index 95% rename from orkbasej/java/net/sf/oreka/persistent/AnnotatedTestClass.java rename to orkbasej/src/main/java/net/sf/oreka/persistent/AnnotatedTestClass.java index f4e9c11d..a20790c6 100644 --- a/orkbasej/java/net/sf/oreka/persistent/AnnotatedTestClass.java +++ b/orkbasej/src/main/java/net/sf/oreka/persistent/AnnotatedTestClass.java @@ -37,7 +37,7 @@ public void setFirstname(String firstname) { this.firstname = firstname; } - @Id @GeneratedValue(strategy=GenerationType.AUTO) + @Id @GeneratedValue(strategy=GenerationType.IDENTITY) public long getId() { return Id; } diff --git a/orkbasej/java/net/sf/oreka/persistent/AnnotationsTest.java b/orkbasej/src/main/java/net/sf/oreka/persistent/AnnotationsTest.java similarity index 98% rename from orkbasej/java/net/sf/oreka/persistent/AnnotationsTest.java rename to orkbasej/src/main/java/net/sf/oreka/persistent/AnnotationsTest.java index aae1f911..6fad3d5a 100644 --- a/orkbasej/java/net/sf/oreka/persistent/AnnotationsTest.java +++ b/orkbasej/src/main/java/net/sf/oreka/persistent/AnnotationsTest.java @@ -23,7 +23,7 @@ import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; -import org.hibernate.cfg.AnnotationConfiguration; +import org.hibernate.cfg.Configuration; //import org.hibernate.tool.hbm2ddl.SchemaExport; //import org.hibernate.ScrollableResults; @@ -61,8 +61,8 @@ public static void main(String[] args) { // int sec = (int)(mili/1000); // long mili2 = (long)sec*1000; // Date date2 = new Date(mili2); - - AnnotationConfiguration config = (AnnotationConfiguration)new AnnotationConfiguration(); + + Configuration config = new Configuration(); // .setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect") // .setProperty("hibernate.connection.driver_class", "org.hsqldb.jdbcDriver") // .setProperty("hibernate.connection.url", "jdbc:hsqldb:mem:test") diff --git a/orkbasej/java/net/sf/oreka/persistent/HbnXmlTest.java b/orkbasej/src/main/java/net/sf/oreka/persistent/HbnXmlTest.java similarity index 100% rename from orkbasej/java/net/sf/oreka/persistent/HbnXmlTest.java rename to orkbasej/src/main/java/net/sf/oreka/persistent/HbnXmlTest.java diff --git a/orkbasej/java/net/sf/oreka/persistent/HbnXmlTestClass.java b/orkbasej/src/main/java/net/sf/oreka/persistent/HbnXmlTestClass.java similarity index 100% rename from orkbasej/java/net/sf/oreka/persistent/HbnXmlTestClass.java rename to orkbasej/src/main/java/net/sf/oreka/persistent/HbnXmlTestClass.java diff --git a/orkbasej/java/net/sf/oreka/persistent/OrkDomain.java b/orkbasej/src/main/java/net/sf/oreka/persistent/OrkDomain.java similarity index 91% rename from orkbasej/java/net/sf/oreka/persistent/OrkDomain.java rename to orkbasej/src/main/java/net/sf/oreka/persistent/OrkDomain.java index fad87bde..6d0472ca 100644 --- a/orkbasej/java/net/sf/oreka/persistent/OrkDomain.java +++ b/orkbasej/src/main/java/net/sf/oreka/persistent/OrkDomain.java @@ -1,97 +1,97 @@ -/* - * Oreka -- A media capture and retrieval platform - * - * Copyright (C) 2005, orecx LLC - * - * http://www.orecx.com - * - * This program is free software, distributed under the terms of - * the GNU General Public License. - * Please refer to http://www.gnu.org/copyleft/gpl.html - * - */ - -/** - * - */ -package net.sf.oreka.persistent; -import java.io.Serializable; - -import javax.persistence.Entity; -import javax.persistence.GenerationType; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.Table; - -/** - * @hibernate.class - */ -@Entity -@Table(name = "orkdomain") -public class OrkDomain implements Serializable { - - static final long serialVersionUID = 1l; - private int id; - private String name = ""; - private String description = ""; - - /** - * - */ - public OrkDomain() { - } - - /** - * @hibernate.property - * not-null="true" - * @return Returns the description. - */ - public String getDescription() { - return description; - } - - - /** - * @param description The description to set. - */ - public void setDescription(String description) { - this.description = description; - } - - - /** - * @hibernate.id - * generator-class="native" - * @return Returns the id. - */ - @Id @GeneratedValue(strategy=GenerationType.AUTO) - public int getId() { - return id; - } - - - /** - * @param id The id to set. - */ - public void setId(int id) { - this.id = id; - } - - - /** - * @hibernate.property - * not-null="true" - * @return Returns the name. - */ - public String getName() { - return name; - } - - - /** - * @param name The name to set. - */ - public void setName(String name) { - this.name = name; - } -} +/* + * Oreka -- A media capture and retrieval platform + * + * Copyright (C) 2005, orecx LLC + * + * http://www.orecx.com + * + * This program is free software, distributed under the terms of + * the GNU General Public License. + * Please refer to http://www.gnu.org/copyleft/gpl.html + * + */ + +/** + * + */ +package net.sf.oreka.persistent; +import java.io.Serializable; + +import javax.persistence.Entity; +import javax.persistence.GenerationType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; + +/** + * @hibernate.class + */ +@Entity +@Table(name = "orkdomain") +public class OrkDomain implements Serializable { + + static final long serialVersionUID = 1l; + private int id; + private String name = ""; + private String description = ""; + + /** + * + */ + public OrkDomain() { + } + + /** + * @hibernate.property + * not-null="true" + * @return Returns the description. + */ + public String getDescription() { + return description; + } + + + /** + * @param description The description to set. + */ + public void setDescription(String description) { + this.description = description; + } + + + /** + * @hibernate.id + * generator-class="native" + * @return Returns the id. + */ + @Id @GeneratedValue(strategy=GenerationType.IDENTITY) + public int getId() { + return id; + } + + + /** + * @param id The id to set. + */ + public void setId(int id) { + this.id = id; + } + + + /** + * @hibernate.property + * not-null="true" + * @return Returns the name. + */ + public String getName() { + return name; + } + + + /** + * @param name The name to set. + */ + public void setName(String name) { + this.name = name; + } +} diff --git a/orkbasej/java/net/sf/oreka/persistent/OrkLoginString.java b/orkbasej/src/main/java/net/sf/oreka/persistent/OrkLoginString.java similarity index 83% rename from orkbasej/java/net/sf/oreka/persistent/OrkLoginString.java rename to orkbasej/src/main/java/net/sf/oreka/persistent/OrkLoginString.java index f27ed249..3bb96f25 100644 --- a/orkbasej/java/net/sf/oreka/persistent/OrkLoginString.java +++ b/orkbasej/src/main/java/net/sf/oreka/persistent/OrkLoginString.java @@ -1,133 +1,128 @@ -/* - * Oreka -- A media capture and retrieval platform - * - * Copyright (C) 2005, orecx LLC - * - * http://www.orecx.com - * - * This program is free software, distributed under the terms of - * the GNU General Public License. - * Please refer to http://www.gnu.org/copyleft/gpl.html - * - */ - -/** - * - */ -package net.sf.oreka.persistent; - -import java.io.Serializable; - -import javax.persistence.Entity; -import javax.persistence.GenerationType; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.ManyToOne; -import javax.persistence.Table; - -/** - * @hibernate.class - */ -@Entity -@Table(name = "orkloginstring") -public class OrkLoginString implements Serializable { - - static final long serialVersionUID = 1l; - private int id; - private String loginString; - private OrkUser user; - private OrkDomain domain; - - /** - * @hibernate.many-to-one - * @return Returns the domain. - */ - @ManyToOne - public OrkDomain getDomain() { - return domain; - } - - - /** - * @param domain The domain to set. - */ - public void setDomain(OrkDomain domain) { - this.domain = domain; - } - - - /** - * @hibernate.id - * generator-class="native" - * @return Returns the id. - */ - @Id @GeneratedValue(strategy=GenerationType.AUTO) - public int getId() { - return id; - } - - - /** - * @param id The id to set. - */ - public void setId(int id) { - this.id = id; - } - - - /** - * @hibernate.property - * not-null="true" - * @return Returns the loginString. - */ - public String getLoginString() { - return loginString; - } - - - /** - * @param loginString The loginString to set. - */ - public void setLoginString(String loginString) { - this.loginString = loginString; - } - - - /** - * @hibernate.many-to-one - * @return Returns the user. - */ - @ManyToOne - public OrkUser getUser() { - return user; - } - - - /** - * @param user The user to set. - */ - public void setUser(OrkUser user) { - this.user = user; - } - -// public void bidirSetUser(User user) { -// this.user = user; -// if(user != null) { -// user.getLoginStrings().add(this); -// } -// } -// -// public void bidirRemoveUser(User user) { -// this.user = null; -// if(user != null) { -// user.getLoginStrings().remove(this); -// } -// } - - /** - * - */ - public OrkLoginString() { - } - -} +/* + * Oreka -- A media capture and retrieval platform + * + * Copyright (C) 2005, orecx LLC + * + * http://www.orecx.com + * + * This program is free software, distributed under the terms of + * the GNU General Public License. + * Please refer to http://www.gnu.org/copyleft/gpl.html + * + */ + +/** + * + */ +package net.sf.oreka.persistent; + +import java.io.Serializable; + +import javax.persistence.*; + +/** + * @hibernate.class + */ +@Entity +@Table(name = "orkloginstring") +public class OrkLoginString implements Serializable { + + static final long serialVersionUID = 1l; + private int id; + private String loginString; + private OrkUser user; + private OrkDomain domain; + + /** + * @hibernate.many-to-one + * @return Returns the domain. + */ + @ManyToOne + public OrkDomain getDomain() { + return domain; + } + + + /** + * @param domain The domain to set. + */ + public void setDomain(OrkDomain domain) { + this.domain = domain; + } + + + /** + * @hibernate.id + * generator-class="native" + * @return Returns the id. + */ + @Id @GeneratedValue(strategy=GenerationType.IDENTITY) + public int getId() { + return id; + } + + + /** + * @param id The id to set. + */ + public void setId(int id) { + this.id = id; + } + + + /** + * @hibernate.property + * not-null="true" + * @return Returns the loginString. + */ + public String getLoginString() { + return loginString; + } + + + /** + * @param loginString The loginString to set. + */ + public void setLoginString(String loginString) { + this.loginString = loginString; + } + + + /** + * @hibernate.many-to-one + * @return Returns the user. + */ + @ManyToOne + public OrkUser getUser() { + return user; + } + + + /** + * @param user The user to set. + */ + public void setUser(OrkUser user) { + this.user = user; + } + +// public void bidirSetUser(User user) { +// this.user = user; +// if(user != null) { +// user.getLoginStrings().add(this); +// } +// } +// +// public void bidirRemoveUser(User user) { +// this.user = null; +// if(user != null) { +// user.getLoginStrings().remove(this); +// } +// } + + /** + * + */ + public OrkLoginString() { + } + +} diff --git a/orkbasej/java/net/sf/oreka/persistent/OrkPort.java b/orkbasej/src/main/java/net/sf/oreka/persistent/OrkPort.java similarity index 89% rename from orkbasej/java/net/sf/oreka/persistent/OrkPort.java rename to orkbasej/src/main/java/net/sf/oreka/persistent/OrkPort.java index 5ef07339..3cdad838 100644 --- a/orkbasej/java/net/sf/oreka/persistent/OrkPort.java +++ b/orkbasej/src/main/java/net/sf/oreka/persistent/OrkPort.java @@ -1,39 +1,39 @@ -/* - * Oreka -- A media capture and retrieval platform - * - * Copyright (C) 2005, orecx LLC - * - * http://www.orecx.com - * - * This program is free software, distributed under the terms of - * the GNU General Public License. - * Please refer to http://www.gnu.org/copyleft/gpl.html - * - */ - -package net.sf.oreka.persistent; - -import java.io.Serializable; - -import javax.persistence.Entity; -import javax.persistence.GenerationType; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.Table; - -@Entity -@Table(name = "orkport") -public class OrkPort implements Serializable { - - static final long serialVersionUID = 1l; - private int id; - - @Id @GeneratedValue(strategy=GenerationType.AUTO) - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } -} +/* + * Oreka -- A media capture and retrieval platform + * + * Copyright (C) 2005, orecx LLC + * + * http://www.orecx.com + * + * This program is free software, distributed under the terms of + * the GNU General Public License. + * Please refer to http://www.gnu.org/copyleft/gpl.html + * + */ + +package net.sf.oreka.persistent; + +import java.io.Serializable; + +import javax.persistence.Entity; +import javax.persistence.GenerationType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; + +@Entity +@Table(name = "orkport") +public class OrkPort implements Serializable { + + static final long serialVersionUID = 1l; + private int id; + + @Id @GeneratedValue(strategy=GenerationType.IDENTITY) + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } +} diff --git a/orkbasej/java/net/sf/oreka/persistent/OrkPortFace.java b/orkbasej/src/main/java/net/sf/oreka/persistent/OrkPortFace.java similarity index 95% rename from orkbasej/java/net/sf/oreka/persistent/OrkPortFace.java rename to orkbasej/src/main/java/net/sf/oreka/persistent/OrkPortFace.java index bb83a2f8..96bcf90c 100644 --- a/orkbasej/java/net/sf/oreka/persistent/OrkPortFace.java +++ b/orkbasej/src/main/java/net/sf/oreka/persistent/OrkPortFace.java @@ -1,54 +1,54 @@ -/* - * Oreka -- A media capture and retrieval platform - * - * Copyright (C) 2005, orecx LLC - * - * http://www.orecx.com - * - * This program is free software, distributed under the terms of - * the GNU General Public License. - * Please refer to http://www.gnu.org/copyleft/gpl.html - * - */ - -package net.sf.oreka.persistent; - -import java.io.Serializable; - -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.ManyToOne; -import javax.persistence.Table; - -@Entity -@Table(name = "orkportface") -public class OrkPortFace implements Serializable { - - static final long serialVersionUID = 1l; - private OrkPort port; - private OrkService service; - private String name; - - @Id - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - @ManyToOne - public OrkPort getPort() { - return port; - } - public void setPort(OrkPort recPort) { - this.port = recPort; - } - @ManyToOne - public OrkService getService() { - return service; - } - public void setService(OrkService service) { - this.service = service; - } - -} +/* + * Oreka -- A media capture and retrieval platform + * + * Copyright (C) 2005, orecx LLC + * + * http://www.orecx.com + * + * This program is free software, distributed under the terms of + * the GNU General Public License. + * Please refer to http://www.gnu.org/copyleft/gpl.html + * + */ + +package net.sf.oreka.persistent; + +import java.io.Serializable; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +@Entity +@Table(name = "orkportface") +public class OrkPortFace implements Serializable { + + static final long serialVersionUID = 1l; + private OrkPort port; + private OrkService service; + private String name; + + @Id + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + @ManyToOne + public OrkPort getPort() { + return port; + } + public void setPort(OrkPort recPort) { + this.port = recPort; + } + @ManyToOne + public OrkService getService() { + return service; + } + public void setService(OrkService service) { + this.service = service; + } + +} diff --git a/orkbasej/java/net/sf/oreka/persistent/OrkProgram.java b/orkbasej/src/main/java/net/sf/oreka/persistent/OrkProgram.java similarity index 94% rename from orkbasej/java/net/sf/oreka/persistent/OrkProgram.java rename to orkbasej/src/main/java/net/sf/oreka/persistent/OrkProgram.java index 9609ccc7..fa6fc060 100644 --- a/orkbasej/java/net/sf/oreka/persistent/OrkProgram.java +++ b/orkbasej/src/main/java/net/sf/oreka/persistent/OrkProgram.java @@ -1,514 +1,514 @@ -/* - * Oreka -- A media capture and retrieval platform - * - * Copyright (C) 2005, orecx LLC - * - * http://www.orecx.com - * - * This program is free software, distributed under the terms of - * the GNU General Public License. - * Please refer to http://www.gnu.org/copyleft/gpl.html - * - */ - -/** - * - */ -package net.sf.oreka.persistent; - -import java.io.Serializable; -import java.text.SimpleDateFormat; -import java.util.Collection; -import java.util.Date; - -import javax.persistence.Entity; -import javax.persistence.GenerationType; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.JoinTable; -import javax.persistence.ManyToMany; -import javax.persistence.ManyToOne; -import javax.persistence.Table; - -import net.sf.oreka.Cycle; -import net.sf.oreka.Day; -import net.sf.oreka.Direction; - -/** - * @hibernate.class - */ -@Entity -@Table(name = "orkprogram") -public class OrkProgram implements Serializable { - - static final long serialVersionUID = 1l; - private int id; - private String name = ""; - private String description = ""; - private boolean discarded = false; - private Date timestamp; - private OrkUser creator; - private boolean active = true; - private Direction direction = Direction.ALL; - private int minDuration = 0; - private int maxDuration = 0; - private double randomPercent = 0.0; - private Cycle cycle = Cycle.PERMANENT; - private Day startDay = Day.UNKN; - private Day stopDay = Day.UNKN; - private Date startTime = null; - private Date stopTime = null; - private int recPerCycle = 0; - private int recordedSoFar = 0; - private String localParty = ""; - private String remoteParty = ""; - private int keepForHours = 0; - private OrkUser targetUser; - private OrkPort targetPort; - - //private Set RecSegments; - private Collection recSegments; - - /** - * @hibernate.set - * lazy="true" - * table="PrgToSeg" - * @hibernate.collection-key - * column="RecProgram" - * @hibernate.collection-many-to-many - * column="RecSegment" - * class="net.sf.oreka.persistent.RecSegment" - * @return Returns the recSegments. - */ - @ManyToMany -// ( -// targetEntity="net.sf.oreka.persistent.RecSegment" -// ) - @JoinTable( - name="orkprogtoseg", - joinColumns={@JoinColumn(name="progId")}, - inverseJoinColumns={@JoinColumn(name="segId")} - ) - public Collection getRecSegments() { - return recSegments; - } - - - /** - * @param recSegments The recSegments to set. - */ - public void setRecSegments(Collection recSegments) { - this.recSegments = recSegments; - } - - - public OrkProgram () { - SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); - try { - startTime = sdf.parse("00:00:00"); - stopTime = sdf.parse("00:00:00"); - } - catch (Exception e) {;} - } - - /** - * @hibernate.property - * not-null="true" - * @return Returns the active. - */ - public boolean isActive() { - return active; - } - - - /** - * @param active The active to set. - */ - public void setActive(boolean active) { - this.active = active; - } - - - /** - * @hibernate.property - * not-null="true" - * @return Returns the cycle. - */ - public Cycle getCycle() { - return cycle; - } - - - /** - * @param cycle The cycle to set. - */ - public void setCycle(Cycle cycle) { - this.cycle = cycle; - } - - - /** - * @hibernate.property - * not-null="true" - * @return Returns the description. - */ - public String getDescription() { - return description; - } - - - /** - * @param description The description to set. - */ - public void setDescription(String description) { - this.description = description; - } - - - /** - * @hibernate.property - * not-null="true" - * @return Returns the direction. - */ - public Direction getDirection() { - return direction; - } - - - /** - * @param direction The direction to set. - */ - public void setDirection(Direction direction) { - this.direction = direction; - } - - - /** - * @return Returns the discarded. - */ - public boolean isDiscarded() { - return discarded; - } - - - /** - * @param discarded The discarded to set. - */ - public void setDiscarded(boolean discarded) { - this.discarded = discarded; - } - - - /** - * @hibernate.id - * generator-class="native" - * @return Returns the id. - */ - @Id @GeneratedValue(strategy=GenerationType.AUTO) - public int getId() { - return id; - } - - - /** - * @param id The id to set. - */ - public void setId(int id) { - this.id = id; - } - - - /** - * @hibernate.property - * not-null="true" - * @return Returns the keepForHours. - */ - public int getKeepForHours() { - return keepForHours; - } - - - /** - * @param keepForHours The keepForHours to set. - */ - public void setKeepForHours(int keepForHours) { - this.keepForHours = keepForHours; - } - - - /** - * @hibernate.property - * not-null="true" - * @return Returns the localParty. - */ - public String getLocalParty() { - return localParty; - } - - - /** - * @param localParty The localParty to set. - */ - public void setLocalParty(String localParty) { - this.localParty = localParty; - } - - - /** - * @hibernate.property - * not-null="true" - * @return Returns the maxDuration. - */ - public int getMaxDuration() { - return maxDuration; - } - - - /** - * @param maxDuration The maxDuration to set. - */ - public void setMaxDuration(int maxDuration) { - this.maxDuration = maxDuration; - } - - - /** - * @hibernate.property - * not-null="true" - * @return Returns the minDuration. - */ - public int getMinDuration() { - return minDuration; - } - - - /** - * @param minDuration The minDuration to set. - */ - public void setMinDuration(int minDuration) { - this.minDuration = minDuration; - } - - - /** - * @hibernate.property - * not-null="true" - * @return Returns the name. - */ - public String getName() { - return name; - } - - - /** - * @param name The name to set. - */ - public void setName(String name) { - this.name = name; - } - - - /** - * @hibernate.property - * not-null="true" - * @return Returns the randomPercent. - */ - public double getRandomPercent() { - return randomPercent; - } - - - /** - * @param randomPercent The randomPercent to set. - */ - public void setRandomPercent(double randomPercent) { - this.randomPercent = randomPercent; - } - - - /** - * @hibernate.property - * not-null="true" - * @return Returns the recordedSoFar. - */ - public int getRecordedSoFar() { - return recordedSoFar; - } - - - /** - * @param recordedSoFar The recordedSoFar to set. - */ - public void setRecordedSoFar(int recordedSoFar) { - this.recordedSoFar = recordedSoFar; - } - - - /** - * @hibernate.property - * not-null="true" - * @return Returns the recPerCycle. - */ - public int getRecPerCycle() { - return recPerCycle; - } - - - /** - * @param recPerCycle The recPerCycle to set. - */ - public void setRecPerCycle(int recPerCycle) { - this.recPerCycle = recPerCycle; - } - - /** - * @hibernate.property - * not-null="true" - * @return Returns the remoteParty. - */ - public String getRemoteParty() { - return remoteParty; - } - - - /** - * @param remoteParty The remoteParty to set. - */ - public void setRemoteParty(String remoteParty) { - this.remoteParty = remoteParty; - } - - - /** - * @hibernate.property - * not-null="true" - * @return Returns the startTime. - */ - public Date getStartTime() { - return startTime; - } - - - /** - * @param startTime The startTime to set. - */ - public void setStartTime(Date startTime) { - this.startTime = startTime; - } - - - public Day getStartDay() { - return startDay; - } - - - - public void setStartDay(Day startDay) { - this.startDay = startDay; - } - - - - public Day getStopDay() { - return stopDay; - } - - - - public void setStopDay(Day stopDay) { - this.stopDay = stopDay; - } - - - - /** - * @hibernate.property - * not-null="true" - * @return Returns the stopTime. - */ - public Date getStopTime() { - return stopTime; - } - - - /** - * @param stopTime The stopTime to set. - */ - public void setStopTime(Date stopTime) { - this.stopTime = stopTime; - } - - - /** - * @hibernate.property - * not-null="true" - * @return Returns the targetPort. - */ - @ManyToOne - public OrkPort getTargetPort() { - return targetPort; - } - - - /** - * @param targetPort The targetPort to set. - */ - public void setTargetPort(OrkPort targetPort) { - this.targetPort = targetPort; - } - - /** - * @hibernate.many-to-one - * @return Returns the targetUser. - */ - @ManyToOne - public OrkUser getTargetUser() { - return targetUser; - } - - - - /** - * @param targetUser The targetUser to set. - */ - public void setTargetUser(OrkUser targetUser) { - this.targetUser = targetUser; - } - - /** - * @hibernate.property - * not-null="true" - * @return Returns the timestamp. - */ - public Date getTimestamp() { - return timestamp; - } - - - /** - * @param timestamp The timestamp to set. - */ - public void setTimestamp(Date timestamp) { - this.timestamp = timestamp; - } - - - /** - * @hibernate.many-to-one - * @return Returns the owner. - */ - @ManyToOne - public OrkUser getCreator() { - return creator; - } - - - - /** - * @param owner The owner to set. - */ - public void setCreator(OrkUser creator) { - this.creator = creator; - } -} +/* + * Oreka -- A media capture and retrieval platform + * + * Copyright (C) 2005, orecx LLC + * + * http://www.orecx.com + * + * This program is free software, distributed under the terms of + * the GNU General Public License. + * Please refer to http://www.gnu.org/copyleft/gpl.html + * + */ + +/** + * + */ +package net.sf.oreka.persistent; + +import java.io.Serializable; +import java.text.SimpleDateFormat; +import java.util.Collection; +import java.util.Date; + +import javax.persistence.Entity; +import javax.persistence.GenerationType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +import net.sf.oreka.Cycle; +import net.sf.oreka.Day; +import net.sf.oreka.Direction; + +/** + * @hibernate.class + */ +@Entity +@Table(name = "orkprogram") +public class OrkProgram implements Serializable { + + static final long serialVersionUID = 1l; + private int id; + private String name = ""; + private String description = ""; + private boolean discarded = false; + private Date timestamp; + private OrkUser creator; + private boolean active = true; + private Direction direction = Direction.ALL; + private int minDuration = 0; + private int maxDuration = 0; + private double randomPercent = 0.0; + private Cycle cycle = Cycle.PERMANENT; + private Day startDay = Day.UNKN; + private Day stopDay = Day.UNKN; + private Date startTime = null; + private Date stopTime = null; + private int recPerCycle = 0; + private int recordedSoFar = 0; + private String localParty = ""; + private String remoteParty = ""; + private int keepForHours = 0; + private OrkUser targetUser; + private OrkPort targetPort; + + //private Set RecSegments; + private Collection recSegments; + + /** + * @hibernate.set + * lazy="true" + * table="PrgToSeg" + * @hibernate.collection-key + * column="RecProgram" + * @hibernate.collection-many-to-many + * column="RecSegment" + * class="net.sf.oreka.persistent.RecSegment" + * @return Returns the recSegments. + */ + @ManyToMany +// ( +// targetEntity="net.sf.oreka.persistent.RecSegment" +// ) + @JoinTable( + name="orkprogtoseg", + joinColumns={@JoinColumn(name="progId")}, + inverseJoinColumns={@JoinColumn(name="segId")} + ) + public Collection getRecSegments() { + return recSegments; + } + + + /** + * @param recSegments The recSegments to set. + */ + public void setRecSegments(Collection recSegments) { + this.recSegments = recSegments; + } + + + public OrkProgram () { + SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); + try { + startTime = sdf.parse("00:00:00"); + stopTime = sdf.parse("00:00:00"); + } + catch (Exception e) {;} + } + + /** + * @hibernate.property + * not-null="true" + * @return Returns the active. + */ + public boolean isActive() { + return active; + } + + + /** + * @param active The active to set. + */ + public void setActive(boolean active) { + this.active = active; + } + + + /** + * @hibernate.property + * not-null="true" + * @return Returns the cycle. + */ + public Cycle getCycle() { + return cycle; + } + + + /** + * @param cycle The cycle to set. + */ + public void setCycle(Cycle cycle) { + this.cycle = cycle; + } + + + /** + * @hibernate.property + * not-null="true" + * @return Returns the description. + */ + public String getDescription() { + return description; + } + + + /** + * @param description The description to set. + */ + public void setDescription(String description) { + this.description = description; + } + + + /** + * @hibernate.property + * not-null="true" + * @return Returns the direction. + */ + public Direction getDirection() { + return direction; + } + + + /** + * @param direction The direction to set. + */ + public void setDirection(Direction direction) { + this.direction = direction; + } + + + /** + * @return Returns the discarded. + */ + public boolean isDiscarded() { + return discarded; + } + + + /** + * @param discarded The discarded to set. + */ + public void setDiscarded(boolean discarded) { + this.discarded = discarded; + } + + + /** + * @hibernate.id + * generator-class="native" + * @return Returns the id. + */ + @Id @GeneratedValue(strategy=GenerationType.IDENTITY) + public int getId() { + return id; + } + + + /** + * @param id The id to set. + */ + public void setId(int id) { + this.id = id; + } + + + /** + * @hibernate.property + * not-null="true" + * @return Returns the keepForHours. + */ + public int getKeepForHours() { + return keepForHours; + } + + + /** + * @param keepForHours The keepForHours to set. + */ + public void setKeepForHours(int keepForHours) { + this.keepForHours = keepForHours; + } + + + /** + * @hibernate.property + * not-null="true" + * @return Returns the localParty. + */ + public String getLocalParty() { + return localParty; + } + + + /** + * @param localParty The localParty to set. + */ + public void setLocalParty(String localParty) { + this.localParty = localParty; + } + + + /** + * @hibernate.property + * not-null="true" + * @return Returns the maxDuration. + */ + public int getMaxDuration() { + return maxDuration; + } + + + /** + * @param maxDuration The maxDuration to set. + */ + public void setMaxDuration(int maxDuration) { + this.maxDuration = maxDuration; + } + + + /** + * @hibernate.property + * not-null="true" + * @return Returns the minDuration. + */ + public int getMinDuration() { + return minDuration; + } + + + /** + * @param minDuration The minDuration to set. + */ + public void setMinDuration(int minDuration) { + this.minDuration = minDuration; + } + + + /** + * @hibernate.property + * not-null="true" + * @return Returns the name. + */ + public String getName() { + return name; + } + + + /** + * @param name The name to set. + */ + public void setName(String name) { + this.name = name; + } + + + /** + * @hibernate.property + * not-null="true" + * @return Returns the randomPercent. + */ + public double getRandomPercent() { + return randomPercent; + } + + + /** + * @param randomPercent The randomPercent to set. + */ + public void setRandomPercent(double randomPercent) { + this.randomPercent = randomPercent; + } + + + /** + * @hibernate.property + * not-null="true" + * @return Returns the recordedSoFar. + */ + public int getRecordedSoFar() { + return recordedSoFar; + } + + + /** + * @param recordedSoFar The recordedSoFar to set. + */ + public void setRecordedSoFar(int recordedSoFar) { + this.recordedSoFar = recordedSoFar; + } + + + /** + * @hibernate.property + * not-null="true" + * @return Returns the recPerCycle. + */ + public int getRecPerCycle() { + return recPerCycle; + } + + + /** + * @param recPerCycle The recPerCycle to set. + */ + public void setRecPerCycle(int recPerCycle) { + this.recPerCycle = recPerCycle; + } + + /** + * @hibernate.property + * not-null="true" + * @return Returns the remoteParty. + */ + public String getRemoteParty() { + return remoteParty; + } + + + /** + * @param remoteParty The remoteParty to set. + */ + public void setRemoteParty(String remoteParty) { + this.remoteParty = remoteParty; + } + + + /** + * @hibernate.property + * not-null="true" + * @return Returns the startTime. + */ + public Date getStartTime() { + return startTime; + } + + + /** + * @param startTime The startTime to set. + */ + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + + public Day getStartDay() { + return startDay; + } + + + + public void setStartDay(Day startDay) { + this.startDay = startDay; + } + + + + public Day getStopDay() { + return stopDay; + } + + + + public void setStopDay(Day stopDay) { + this.stopDay = stopDay; + } + + + + /** + * @hibernate.property + * not-null="true" + * @return Returns the stopTime. + */ + public Date getStopTime() { + return stopTime; + } + + + /** + * @param stopTime The stopTime to set. + */ + public void setStopTime(Date stopTime) { + this.stopTime = stopTime; + } + + + /** + * @hibernate.property + * not-null="true" + * @return Returns the targetPort. + */ + @ManyToOne + public OrkPort getTargetPort() { + return targetPort; + } + + + /** + * @param targetPort The targetPort to set. + */ + public void setTargetPort(OrkPort targetPort) { + this.targetPort = targetPort; + } + + /** + * @hibernate.many-to-one + * @return Returns the targetUser. + */ + @ManyToOne + public OrkUser getTargetUser() { + return targetUser; + } + + + + /** + * @param targetUser The targetUser to set. + */ + public void setTargetUser(OrkUser targetUser) { + this.targetUser = targetUser; + } + + /** + * @hibernate.property + * not-null="true" + * @return Returns the timestamp. + */ + public Date getTimestamp() { + return timestamp; + } + + + /** + * @param timestamp The timestamp to set. + */ + public void setTimestamp(Date timestamp) { + this.timestamp = timestamp; + } + + + /** + * @hibernate.many-to-one + * @return Returns the owner. + */ + @ManyToOne + public OrkUser getCreator() { + return creator; + } + + + + /** + * @param owner The owner to set. + */ + public void setCreator(OrkUser creator) { + this.creator = creator; + } +} diff --git a/orkbasej/java/net/sf/oreka/persistent/OrkSegment.java b/orkbasej/src/main/java/net/sf/oreka/persistent/OrkSegment.java similarity index 94% rename from orkbasej/java/net/sf/oreka/persistent/OrkSegment.java rename to orkbasej/src/main/java/net/sf/oreka/persistent/OrkSegment.java index b1a02eb2..e22043da 100644 --- a/orkbasej/java/net/sf/oreka/persistent/OrkSegment.java +++ b/orkbasej/src/main/java/net/sf/oreka/persistent/OrkSegment.java @@ -1,335 +1,335 @@ -/* - * Oreka -- A media capture and retrieval platform - * - * Copyright (C) 2005, orecx LLC - * - * http://www.orecx.com - * - * This program is free software, distributed under the terms of - * the GNU General Public License. - * Please refer to http://www.gnu.org/copyleft/gpl.html - * - */ - -package net.sf.oreka.persistent; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; - -import javax.persistence.Entity; -import javax.persistence.GenerationType; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.JoinTable; -import javax.persistence.ManyToMany; -import javax.persistence.ManyToOne; -import javax.persistence.Table; -import javax.persistence.Transient; - -import net.sf.oreka.Direction; - -/** - * @hibernate.class - */ -@Entity -@Table(name = "orksegment") -public class OrkSegment implements Serializable { - - static final long serialVersionUID = 1l; - private int id; - private OrkSession session; - private long sessionOffset; - private OrkTape tape; - private long tapeOffset; - private Date timestamp = new Date(0); - private long duration; - private String localParty = ""; - private String localEntryPoint = ""; - private String remoteParty = ""; - private Direction direction; - private OrkUser user; - private String loginString = ""; - private OrkPort port; - private String portName; - //private java.util.Set RecPrograms; - private Collection recPrograms; - - public OrkSegment() { - direction = Direction.UNKN; - recPrograms = new ArrayList(); - } - - /** - * @hibernate.property - * - * @hibernate.column - * name="direction" - * index="direction" - * not-null="true" - * @return Returns the direction. - */ - public Direction getDirection() { - return direction; - } - - /** - * @param direction The direction to set. - */ - public void setDirection(Direction direction) { - this.direction = direction; - } - - /** - * @hibernate.property - * not-null="true" - * @return Returns the duration. - */ - public long getDuration() { - return duration; - } - - /** - * @param duration The duration to set. - */ - public void setDuration(long duration) { - this.duration = duration; - } - - /** - * @hibernate.id - * generator-class="native" - * @hibernate.collection-many-to-many - * column="RecSegmentId" - * class="RecProgram" - * @return Returns the id. - */ - @Id @GeneratedValue(strategy=GenerationType.AUTO) - public int getId() { - return id; - } - - /** - * @param id The id to set. - */ - public void setId(int id) { - this.id = id; - } - - /** - * @hibernate.property - * - * @hibernate.column - * name="localParty" - * index="localParty" - * not-null="true" - * - * @return Returns the localParty. - */ - public String getLocalParty() { - return localParty; - } - - /** - * @param localParty The localParty to set. - */ - public void setLocalParty(String localParty) { - this.localParty = localParty; - } - - /** - * @hibernate.property - * not-null="true" - * @return Returns the loginString. - */ - public String getLoginString() { - return loginString; - } - - /** - * @param loginString The loginString to set. - */ - public void setLoginString(String loginString) { - this.loginString = loginString; - } - - /** - * @hibernate.property - * not-null="true" - * @return Returns the remoteParty. - */ - public String getRemoteParty() { - return remoteParty; - } - - /** - * @param remoteParty The remoteParty to set. - */ - public void setRemoteParty(String remoteParty) { - this.remoteParty = remoteParty; - } - - /** - * @hibernate.property - * not-null="true" - * @return Returns the RecTapeOffset. - */ - public long getTapeOffset() { - return tapeOffset; - } - - /** - * @param RecTapeOffset The RecTapeOffset to set. - */ - public void setTapeOffset(long recTapeOffset) { - this.tapeOffset = recTapeOffset; - } - - /** - * @hibernate.property - * not-null="true" - * @return Returns the timestamp. - */ - public Date getTimestamp() { - return timestamp; - } - - /** - * @param timestamp The timestamp to set. - */ - public void setTimestamp(Date timestamp) { - this.timestamp = timestamp; - } - - /** - * @hibernate.many-to-one - * @return Returns the RecSession. - */ - @ManyToOne - public OrkSession getSession() { - return session; - } - - /** - * @param OrkSession The RecSession to set. - */ - public void setSession(OrkSession recSession) { - this.session = recSession; - } - - /** - * @hibernate.property - * not-null="true" - * @return Returns the RecSessionOffset. - */ - public long getSessionOffset() { - return sessionOffset; - } - - /** - * @param RecSessionOffset The RecSessionOffset to set. - */ - public void setSessionOffset(long recSessionOffset) { - this.sessionOffset = recSessionOffset; - } - - /** - * @hibernate.many-to-one - * @return Returns the recTape. - */ - @ManyToOne - public OrkTape getTape() { - return tape; - } - - - /** - * @param recTape The recTape to set. - */ - public void setTape(OrkTape recTape) { - this.tape = recTape; - } - - /** - * @hibernate.set - * lazy="true" - * table="PrgToSeg" - * @hibernate.collection-key - * column="RecSegment" - * @hibernate.collection-many-to-many - * column="RecProgram" - * class="net.sf.oreka.persistent.RecProgram" - * @return Returns the recPrograms. - */ - @ManyToMany - @JoinTable( - name="orkprogtoseg", - joinColumns={@JoinColumn(name="segId")}, - inverseJoinColumns={@JoinColumn(name="progId")} - ) - public Collection getRecPrograms() { - return recPrograms; - } - - - /** - * @param recPrograms The recPrograms to set. - */ - public void setRecPrograms(Collection recPrograms) { - this.recPrograms = recPrograms; - } - - /** - * @hibernate.many-to-one - * @return Returns the user. - */ - @ManyToOne - public OrkUser getUser() { - return user; - } - - - /** - * @param user The user to set. - */ - public void setUser(OrkUser user) { - this.user = user; - } - - public String getLocalEntryPoint() { - return localEntryPoint; - } - - public void setLocalEntryPoint(String localEntryPoint) { - this.localEntryPoint = localEntryPoint; - } - - @Transient - public long getStopTime() { - return timestamp.getTime() + duration; - } - - @ManyToOne - public OrkPort getPort() { - return port; - } - - public void setPort(OrkPort port) { - this.port = port; - } - - public String getPortName() { - return portName; - } - - - public void setPortName(String recPortName) { - this.portName = recPortName; - } - - - - -} +/* + * Oreka -- A media capture and retrieval platform + * + * Copyright (C) 2005, orecx LLC + * + * http://www.orecx.com + * + * This program is free software, distributed under the terms of + * the GNU General Public License. + * Please refer to http://www.gnu.org/copyleft/gpl.html + * + */ + +package net.sf.oreka.persistent; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; + +import javax.persistence.Entity; +import javax.persistence.GenerationType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; +import javax.persistence.ManyToOne; +import javax.persistence.Table; +import javax.persistence.Transient; + +import net.sf.oreka.Direction; + +/** + * @hibernate.class + */ +@Entity +@Table(name = "orksegment") +public class OrkSegment implements Serializable { + + static final long serialVersionUID = 1l; + private int id; + private OrkSession session; + private long sessionOffset; + private OrkTape tape; + private long tapeOffset; + private Date timestamp = new Date(0); + private long duration; + private String localParty = ""; + private String localEntryPoint = ""; + private String remoteParty = ""; + private Direction direction; + private OrkUser user; + private String loginString = ""; + private OrkPort port; + private String portName; + //private java.util.Set RecPrograms; + private Collection recPrograms; + + public OrkSegment() { + direction = Direction.UNKN; + recPrograms = new ArrayList(); + } + + /** + * @hibernate.property + * + * @hibernate.column + * name="direction" + * index="direction" + * not-null="true" + * @return Returns the direction. + */ + public Direction getDirection() { + return direction; + } + + /** + * @param direction The direction to set. + */ + public void setDirection(Direction direction) { + this.direction = direction; + } + + /** + * @hibernate.property + * not-null="true" + * @return Returns the duration. + */ + public long getDuration() { + return duration; + } + + /** + * @param duration The duration to set. + */ + public void setDuration(long duration) { + this.duration = duration; + } + + /** + * @hibernate.id + * generator-class="native" + * @hibernate.collection-many-to-many + * column="RecSegmentId" + * class="RecProgram" + * @return Returns the id. + */ + @Id @GeneratedValue(strategy=GenerationType.IDENTITY) + public int getId() { + return id; + } + + /** + * @param id The id to set. + */ + public void setId(int id) { + this.id = id; + } + + /** + * @hibernate.property + * + * @hibernate.column + * name="localParty" + * index="localParty" + * not-null="true" + * + * @return Returns the localParty. + */ + public String getLocalParty() { + return localParty; + } + + /** + * @param localParty The localParty to set. + */ + public void setLocalParty(String localParty) { + this.localParty = localParty; + } + + /** + * @hibernate.property + * not-null="true" + * @return Returns the loginString. + */ + public String getLoginString() { + return loginString; + } + + /** + * @param loginString The loginString to set. + */ + public void setLoginString(String loginString) { + this.loginString = loginString; + } + + /** + * @hibernate.property + * not-null="true" + * @return Returns the remoteParty. + */ + public String getRemoteParty() { + return remoteParty; + } + + /** + * @param remoteParty The remoteParty to set. + */ + public void setRemoteParty(String remoteParty) { + this.remoteParty = remoteParty; + } + + /** + * @hibernate.property + * not-null="true" + * @return Returns the RecTapeOffset. + */ + public long getTapeOffset() { + return tapeOffset; + } + + /** + * @param RecTapeOffset The RecTapeOffset to set. + */ + public void setTapeOffset(long recTapeOffset) { + this.tapeOffset = recTapeOffset; + } + + /** + * @hibernate.property + * not-null="true" + * @return Returns the timestamp. + */ + public Date getTimestamp() { + return timestamp; + } + + /** + * @param timestamp The timestamp to set. + */ + public void setTimestamp(Date timestamp) { + this.timestamp = timestamp; + } + + /** + * @hibernate.many-to-one + * @return Returns the RecSession. + */ + @ManyToOne + public OrkSession getSession() { + return session; + } + + /** + * @param OrkSession The RecSession to set. + */ + public void setSession(OrkSession recSession) { + this.session = recSession; + } + + /** + * @hibernate.property + * not-null="true" + * @return Returns the RecSessionOffset. + */ + public long getSessionOffset() { + return sessionOffset; + } + + /** + * @param RecSessionOffset The RecSessionOffset to set. + */ + public void setSessionOffset(long recSessionOffset) { + this.sessionOffset = recSessionOffset; + } + + /** + * @hibernate.many-to-one + * @return Returns the recTape. + */ + @ManyToOne + public OrkTape getTape() { + return tape; + } + + + /** + * @param recTape The recTape to set. + */ + public void setTape(OrkTape recTape) { + this.tape = recTape; + } + + /** + * @hibernate.set + * lazy="true" + * table="PrgToSeg" + * @hibernate.collection-key + * column="RecSegment" + * @hibernate.collection-many-to-many + * column="RecProgram" + * class="net.sf.oreka.persistent.RecProgram" + * @return Returns the recPrograms. + */ + @ManyToMany + @JoinTable( + name="orkprogtoseg", + joinColumns={@JoinColumn(name="segId")}, + inverseJoinColumns={@JoinColumn(name="progId")} + ) + public Collection getRecPrograms() { + return recPrograms; + } + + + /** + * @param recPrograms The recPrograms to set. + */ + public void setRecPrograms(Collection recPrograms) { + this.recPrograms = recPrograms; + } + + /** + * @hibernate.many-to-one + * @return Returns the user. + */ + @ManyToOne + public OrkUser getUser() { + return user; + } + + + /** + * @param user The user to set. + */ + public void setUser(OrkUser user) { + this.user = user; + } + + public String getLocalEntryPoint() { + return localEntryPoint; + } + + public void setLocalEntryPoint(String localEntryPoint) { + this.localEntryPoint = localEntryPoint; + } + + @Transient + public long getStopTime() { + return timestamp.getTime() + duration; + } + + @ManyToOne + public OrkPort getPort() { + return port; + } + + public void setPort(OrkPort port) { + this.port = port; + } + + public String getPortName() { + return portName; + } + + + public void setPortName(String recPortName) { + this.portName = recPortName; + } + + + + +} diff --git a/orkbasej/java/net/sf/oreka/persistent/OrkService.java b/orkbasej/src/main/java/net/sf/oreka/persistent/OrkService.java similarity index 94% rename from orkbasej/java/net/sf/oreka/persistent/OrkService.java rename to orkbasej/src/main/java/net/sf/oreka/persistent/OrkService.java index 48ceffcc..7a7ab287 100644 --- a/orkbasej/java/net/sf/oreka/persistent/OrkService.java +++ b/orkbasej/src/main/java/net/sf/oreka/persistent/OrkService.java @@ -1,217 +1,219 @@ -/* - * Oreka -- A media capture and retrieval platform - * - * Copyright (C) 2005, orecx LLC - * - * http://www.orecx.com - * - * This program is free software, distributed under the terms of - * the GNU General Public License. - * Please refer to http://www.gnu.org/copyleft/gpl.html - * - */ - -/** - * - */ -package net.sf.oreka.persistent; - -import java.io.Serializable; - -import javax.persistence.Entity; -import javax.persistence.GenerationType; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.Table; -import javax.persistence.Transient; - -import net.sf.oreka.ServiceClass; -import net.sf.oreka.util.TomcatServerXMLParser; - -/** - * @hibernate.class - */ -@Entity -@Table(name = "orkservice") -public class OrkService implements Serializable { - - static final long serialVersionUID = 1l; - private int id; - private String name = ""; - private String hostname = ""; - private int tcpPort = 0; - private String fileServeProtocol = ""; - private int fileServeTcpPort = 0; - private String fileServePath = ""; - private ServiceClass serviceClass; - private boolean recordMaster = false; - private String contextPath = ""; - - /** - * - */ - public OrkService() { - serviceClass = ServiceClass.UNKN; - contextPath = TomcatServerXMLParser.getAudioContextPath(); - } - - /** - * - * @hibernate.property - * not-null="true" - * @return Returns the fileServePath. - */ - public String getFileServePath() { - if (fileServePath==null) - fileServePath=""; - return fileServePath; - } - - - /** - * @param fileServePath The fileServePath to set. - */ - public void setFileServePath(String fileServePath) { - this.fileServePath = fileServePath; - } - - public int getFileServeTcpPort() { - return fileServeTcpPort; - } - - public void setFileServeTcpPort(int fileServeTcpPort) { - this.fileServeTcpPort = fileServeTcpPort; - } - - public int getTcpPort() { - return tcpPort; - } - - public void setTcpPort(int tcpPort) { - this.tcpPort = tcpPort; - } - - /** - * @hibernate.property - * not-null="true" - * @return Returns the fileServeProtocol. - */ - public String getFileServeProtocol() { - return fileServeProtocol; - } - - - /** - * @param fileServeProtocol The fileServeProtocol to set. - */ - public void setFileServeProtocol(String fileServeProtocol) { - this.fileServeProtocol = fileServeProtocol; - } - - - /** - * @hibernate.property - * unique="true" - * not-null="true" - * @return Returns the gUID. - */ - public String getName() { - return name; - } - - - /** - * @param name The name to set. - */ - public void setName(String name) { - this.name = name; - } - - - /** - * @hibernate.property - * not-null="true" - * @return Returns the hostname. - */ - public String getHostname() { - return hostname; - } - - - /** - * @param hostname The hostname to set. - */ - public void setHostname(String hostname) { - this.hostname = hostname; - } - - - /** - * @hibernate.id - * generator-class="native" - * @return Returns the id. - */ - @Id @GeneratedValue(strategy=GenerationType.AUTO) - public int getId() { - return id; - } - - - /** - * @param id The id to set. - */ - public void setId(int id) { - this.id = id; - } - - public ServiceClass getServiceClass() { - return serviceClass; - } - - public void setServiceClass(ServiceClass serviceClass) { - this.serviceClass = serviceClass; - } - - public boolean isRecordMaster() { - return recordMaster; - } - - public void setRecordMaster(boolean cdrMaster) { - this.recordMaster = cdrMaster; - } - - public String getContextPath() { - if (contextPath==null) - contextPath=""; - return contextPath; - } - - public void setContextPath(String contextPath) { - this.contextPath = contextPath; - } - - @Transient - public String getContextPathWithPrefix() { - - String contextPathWithPrefix = getContextPath(); - - // Add / prefix if non-existent - if (contextPathWithPrefix.trim().length()!=0 && !contextPathWithPrefix.startsWith("/")) - contextPathWithPrefix = "/" + contextPathWithPrefix; - - return contextPathWithPrefix; - } - - @Transient - public String getFileServePathWithPrefix() { - - String fileServePathWithPrefix = getFileServePath(); - - // Add / prefix if non-existent - if (fileServePathWithPrefix.trim().length()!=0 && !fileServePathWithPrefix.startsWith("/")) - fileServePathWithPrefix = "/" + fileServePathWithPrefix; - - return fileServePathWithPrefix; - } - -} +/* + * Oreka -- A media capture and retrieval platform + * + * Copyright (C) 2005, orecx LLC + * + * http://www.orecx.com + * + * This program is free software, distributed under the terms of + * the GNU General Public License. + * Please refer to http://www.gnu.org/copyleft/gpl.html + * + */ + +/** + * + */ +package net.sf.oreka.persistent; + +import java.io.Serializable; + +import javax.persistence.Entity; +import javax.persistence.GenerationType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.Transient; + +import lombok.ToString; +import net.sf.oreka.ServiceClass; +import net.sf.oreka.util.TomcatServerXMLParser; + +/** + * @hibernate.class + */ +@Entity +@Table(name = "orkservice") +@ToString +public class OrkService implements Serializable { + + static final long serialVersionUID = 1l; + private int id; + private String name = ""; + private String hostname = ""; + private int tcpPort = 0; + private String fileServeProtocol = ""; + private int fileServeTcpPort = 0; + private String fileServePath = ""; + private ServiceClass serviceClass; + private boolean recordMaster = false; + private String contextPath = ""; + + /** + * + */ + public OrkService() { + serviceClass = ServiceClass.UNKN; + contextPath = TomcatServerXMLParser.getAudioContextPath(); + } + + /** + * + * @hibernate.property + * not-null="true" + * @return Returns the fileServePath. + */ + public String getFileServePath() { + if (fileServePath==null) + fileServePath=""; + return fileServePath; + } + + + /** + * @param fileServePath The fileServePath to set. + */ + public void setFileServePath(String fileServePath) { + this.fileServePath = fileServePath; + } + + public int getFileServeTcpPort() { + return fileServeTcpPort; + } + + public void setFileServeTcpPort(int fileServeTcpPort) { + this.fileServeTcpPort = fileServeTcpPort; + } + + public int getTcpPort() { + return tcpPort; + } + + public void setTcpPort(int tcpPort) { + this.tcpPort = tcpPort; + } + + /** + * @hibernate.property + * not-null="true" + * @return Returns the fileServeProtocol. + */ + public String getFileServeProtocol() { + return fileServeProtocol; + } + + + /** + * @param fileServeProtocol The fileServeProtocol to set. + */ + public void setFileServeProtocol(String fileServeProtocol) { + this.fileServeProtocol = fileServeProtocol; + } + + + /** + * @hibernate.property + * unique="true" + * not-null="true" + * @return Returns the gUID. + */ + public String getName() { + return name; + } + + + /** + * @param name The name to set. + */ + public void setName(String name) { + this.name = name; + } + + + /** + * @hibernate.property + * not-null="true" + * @return Returns the hostname. + */ + public String getHostname() { + return hostname; + } + + + /** + * @param hostname The hostname to set. + */ + public void setHostname(String hostname) { + this.hostname = hostname; + } + + + /** + * @hibernate.id + * generator-class="native" + * @return Returns the id. + */ + @Id @GeneratedValue(strategy=GenerationType.IDENTITY) + public int getId() { + return id; + } + + + /** + * @param id The id to set. + */ + public void setId(int id) { + this.id = id; + } + + public ServiceClass getServiceClass() { + return serviceClass; + } + + public void setServiceClass(ServiceClass serviceClass) { + this.serviceClass = serviceClass; + } + + public boolean isRecordMaster() { + return recordMaster; + } + + public void setRecordMaster(boolean cdrMaster) { + this.recordMaster = cdrMaster; + } + + public String getContextPath() { + if (contextPath==null) + contextPath=""; + return contextPath; + } + + public void setContextPath(String contextPath) { + this.contextPath = contextPath; + } + + @Transient + public String getContextPathWithPrefix() { + + String contextPathWithPrefix = getContextPath(); + + // Add / prefix if non-existent + if (contextPathWithPrefix.trim().length()!=0 && !contextPathWithPrefix.startsWith("/")) + contextPathWithPrefix = "/" + contextPathWithPrefix; + + return contextPathWithPrefix; + } + + @Transient + public String getFileServePathWithPrefix() { + + String fileServePathWithPrefix = getFileServePath(); + + // Add / prefix if non-existent + if (fileServePathWithPrefix.trim().length()!=0 && !fileServePathWithPrefix.startsWith("/")) + fileServePathWithPrefix = "/" + fileServePathWithPrefix; + + return fileServePathWithPrefix; + } + +} diff --git a/orkbasej/java/net/sf/oreka/persistent/OrkSession.java b/orkbasej/src/main/java/net/sf/oreka/persistent/OrkSession.java similarity index 91% rename from orkbasej/java/net/sf/oreka/persistent/OrkSession.java rename to orkbasej/src/main/java/net/sf/oreka/persistent/OrkSession.java index 9dfc8ce2..30c9581e 100644 --- a/orkbasej/java/net/sf/oreka/persistent/OrkSession.java +++ b/orkbasej/src/main/java/net/sf/oreka/persistent/OrkSession.java @@ -1,85 +1,85 @@ -/* - * Oreka -- A media capture and retrieval platform - * - * Copyright (C) 2005, orecx LLC - * - * http://www.orecx.com - * - * This program is free software, distributed under the terms of - * the GNU General Public License. - * Please refer to http://www.gnu.org/copyleft/gpl.html - * - */ - -package net.sf.oreka.persistent; - -import java.io.Serializable; -import java.util.Date; - -import javax.persistence.Entity; -import javax.persistence.GenerationType; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.Table; -import javax.persistence.Transient; - -/** - * @hibernate.class - */ -@Entity -@Table(name = "orksession") -public class OrkSession implements Serializable { - - static final long serialVersionUID = 1l; - private int id; - private Date timestamp = new Date(0); - private long duration; - - /** - * @hibernate.property - * not-null="true" - * @return - */ - public long getDuration() { - return duration; - } - - public void setDuration(long duration) { - this.duration = duration; - } - - /** - * @hibernate.id - * generator-class="native" - */ - @Id @GeneratedValue(strategy=GenerationType.AUTO) - public int getId() { - return id; - } - - - public void setId(int id) { - this.id = id; - } - - /** - * @hibernate.property - * @return - */ - public Date getTimestamp() { - return timestamp; - } - - public void setTimestamp(Date timestamp) { - this.timestamp = timestamp; - } - - @Transient - public long getStopTime() { - return timestamp.getTime() + duration; - } - - public void setStopTime(long stopTime) { - duration = stopTime - timestamp.getTime(); - } -} +/* + * Oreka -- A media capture and retrieval platform + * + * Copyright (C) 2005, orecx LLC + * + * http://www.orecx.com + * + * This program is free software, distributed under the terms of + * the GNU General Public License. + * Please refer to http://www.gnu.org/copyleft/gpl.html + * + */ + +package net.sf.oreka.persistent; + +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Entity; +import javax.persistence.GenerationType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.Transient; + +/** + * @hibernate.class + */ +@Entity +@Table(name = "orksession") +public class OrkSession implements Serializable { + + static final long serialVersionUID = 1l; + private int id; + private Date timestamp = new Date(0); + private long duration; + + /** + * @hibernate.property + * not-null="true" + * @return + */ + public long getDuration() { + return duration; + } + + public void setDuration(long duration) { + this.duration = duration; + } + + /** + * @hibernate.id + * generator-class="native" + */ + @Id @GeneratedValue(strategy=GenerationType.IDENTITY) + public int getId() { + return id; + } + + + public void setId(int id) { + this.id = id; + } + + /** + * @hibernate.property + * @return + */ + public Date getTimestamp() { + return timestamp; + } + + public void setTimestamp(Date timestamp) { + this.timestamp = timestamp; + } + + @Transient + public long getStopTime() { + return timestamp.getTime() + duration; + } + + public void setStopTime(long stopTime) { + duration = stopTime - timestamp.getTime(); + } +} diff --git a/orkbasej/java/net/sf/oreka/persistent/OrkTape.java b/orkbasej/src/main/java/net/sf/oreka/persistent/OrkTape.java similarity index 87% rename from orkbasej/java/net/sf/oreka/persistent/OrkTape.java rename to orkbasej/src/main/java/net/sf/oreka/persistent/OrkTape.java index 17466310..8b1d566c 100644 --- a/orkbasej/java/net/sf/oreka/persistent/OrkTape.java +++ b/orkbasej/src/main/java/net/sf/oreka/persistent/OrkTape.java @@ -1,264 +1,283 @@ -/* - * Oreka -- A media capture and retrieval platform - * - * Copyright (C) 2005, orecx LLC - * - * http://www.orecx.com - * - * This program is free software, distributed under the terms of - * the GNU General Public License. - * Please refer to http://www.gnu.org/copyleft/gpl.html - * - */ - -package net.sf.oreka.persistent; - -import java.io.Serializable; -import java.util.Date; - -import javax.persistence.Entity; -import javax.persistence.GenerationType; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.ManyToOne; -import javax.persistence.Table; -import javax.persistence.Transient; - -import net.sf.oreka.Direction; - -/** - * @hibernate.class - */ -@Entity -@Table(name = "orktape") -public class OrkTape implements Serializable { - - static final long serialVersionUID = 1l; - private int id; - private Date timestamp = new Date(0); - private long duration; - private String filename = ""; - private OrkService service; - private String localParty = ""; - private String localEntryPoint = ""; - private String remoteParty = ""; - private Direction direction; - private OrkPort port; - private String portName; - private Date expiryTimestamp = new Date(0); - - public OrkTape() - { - // Defaults - direction = Direction.UNKN; - } - - /** - * @hibernate.property - * @hibernate.column - * name="direction" - * index="direction" - * not-null="true" - * @return Returns the direction. - */ - public Direction getDirection() { - return direction; - } - - /** - * @param direction The direction to set. - */ - public void setDirection(Direction direction) { - this.direction = direction; - } - - /** - * @hibernate.property - * not-null="true" - * @return Returns the duration. - */ - public long getDuration() { - return duration; - } - - /** - * @param duration The duration to set. - */ - public void setDuration(long duration) { - this.duration = duration; - } - - /** - * @hibernate.property - * not-null="true" - * @return Returns the expiryTimestamp. - */ - public Date getExpiryTimestamp() { - return expiryTimestamp; - } - - /** - * @param expiryTimestamp The expiryTimestamp to set. - */ - public void setExpiryTimestamp(Date expiryTimestamp) { - this.expiryTimestamp = expiryTimestamp; - } - - /** - * @hibernate.property - * not-null="true" - * @return Returns the filename. - */ - public String getFilename() { - return filename; - } - - /** - * @param filename The filename to set. - */ - public void setFilename(String filename) { - this.filename = filename; - } - - /** - * @hibernate.id - * generator-class="native" - * @return Returns the id. - */ - @Id @GeneratedValue(strategy=GenerationType.AUTO) - public int getId() { - return id; - } - - /** - * @param id The id to set. - */ - public void setId(int id) { - this.id = id; - } - - /** - * @hibernate.property - * not-null="true" - * @return Returns the localParty. - */ - public String getLocalParty() { - return localParty; - } - - /** - * @param localParty The localParty to set. - */ - public void setLocalParty(String localParty) { - this.localParty = localParty; - } - - /** - * @hibernate.property - * not-null="true" - * @return Returns the port. - */ - @ManyToOne - public OrkPort getPort() { - return port; - } - - /** - * @param port The port to set. - */ - public void setPort(OrkPort port) { - this.port = port; - } - - /** - * @hibernate.property - * not-null="true" - * @return Returns the remoteParty. - */ - public String getRemoteParty() { - return remoteParty; - } - - /** - * @param remoteParty The remoteParty to set. - */ - public void setRemoteParty(String remoteParty) { - this.remoteParty = remoteParty; - } - - /** - * @hibernate.property - * not-null="true" - * @return Returns the timestamp. - */ - public Date getTimestamp() { - return timestamp; - } - - /** - * @param timestamp The timestamp to set. - */ - public void setTimestamp(Date timestamp) { - this.timestamp = timestamp; - } - - /** - * @hibernate.many-to-one - * @return Returns the service. - */ - @ManyToOne - public OrkService getService() { - return service; - } - - - /** - * @param server The service to set. - */ - public void setService(OrkService service) { - this.service = service; - } - - public String getLocalEntryPoint() { - return localEntryPoint; - } - - public void setLocalEntryPoint(String localEntryPoint) { - this.localEntryPoint = localEntryPoint; - } - - @Transient - public long getStopTime() { - return timestamp.getTime() + duration; - } - - @Transient - public String getUrl() { - - if(service != null) { - return service.getFileServeProtocol() + "://" + - service.getHostname() + ":" + service.getFileServeTcpPort() + - service.getContextPathWithPrefix() + service.getFileServePathWithPrefix() + "/" + filename; - } - else { - return ""; - } - } - - @Transient - public String getPlayUrl() { - - return "javascript:play('" + getUrl() + "')"; - } - - public String getPortName() { - return portName; - } - - - public void setPortName(String recPortName) { - this.portName = recPortName; - } - - -} +/* + * Oreka -- A media capture and retrieval platform + * + * Copyright (C) 2005, orecx LLC + * + * http://www.orecx.com + * + * This program is free software, distributed under the terms of + * the GNU General Public License. + * Please refer to http://www.gnu.org/copyleft/gpl.html + * + */ + +package net.sf.oreka.persistent; + +import java.io.Serializable; +import java.util.Date; + +import lombok.ToString; +import net.sf.oreka.Direction; +import javax.persistence.*; + +@Entity +@Table(name = "orktape", indexes = { + @Index(columnList = "timestamp,portName", name = "timestamp_portName_idx"), + @Index(columnList = "nativeCallId", name = "nativeCallId") +}) +@ToString +public class OrkTape implements Serializable { + + static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private int id; + + private Date timestamp = new Date(0); + private long duration; + private String filename = ""; + + @ManyToOne + private OrkService service; + + private String localParty = ""; + private String localEntryPoint = ""; + private String remoteParty = ""; + private Direction direction; + + @ManyToOne + private OrkPort port; + + private String portName; + private Date expiryTimestamp = new Date(0); + + private String nativeCallId; + private String state; + + public OrkTape() + { + // Defaults + direction = Direction.UNKN; + } + + /** + * @hibernate.property + * @hibernate.column + * name="direction" + * index="direction" + * not-null="true" + * @return Returns the direction. + */ + public Direction getDirection() { + return direction; + } + + /** + * @param direction The direction to set. + */ + public void setDirection(Direction direction) { + this.direction = direction; + } + + /** + * @hibernate.property + * not-null="true" + * @return Returns the duration. + */ + public long getDuration() { + return duration; + } + + /** + * @param duration The duration to set. + */ + public void setDuration(long duration) { + this.duration = duration; + } + + /** + * @hibernate.property + * not-null="true" + * @return Returns the expiryTimestamp. + */ + public Date getExpiryTimestamp() { + return expiryTimestamp; + } + + /** + * @param expiryTimestamp The expiryTimestamp to set. + */ + public void setExpiryTimestamp(Date expiryTimestamp) { + this.expiryTimestamp = expiryTimestamp; + } + + /** + * @hibernate.property + * not-null="true" + * @return Returns the filename. + */ + public String getFilename() { + return filename; + } + + /** + * @param filename The filename to set. + */ + public void setFilename(String filename) { + this.filename = filename; + } + + /** + * @hibernate.id + * generator-class="native" + * @return Returns the id. + */ + + public int getId() { + return id; + } + + /** + * @param id The id to set. + */ + public void setId(int id) { + this.id = id; + } + + /** + * @hibernate.property + * not-null="true" + * @return Returns the localParty. + */ + public String getLocalParty() { + return localParty; + } + + /** + * @param localParty The localParty to set. + */ + public void setLocalParty(String localParty) { + this.localParty = localParty; + } + + /** + * @hibernate.property + * not-null="true" + * @return Returns the port. + */ + public OrkPort getPort() { + return port; + } + + /** + * @param port The port to set. + */ + public void setPort(OrkPort port) { + this.port = port; + } + + /** + * @hibernate.property + * not-null="true" + * @return Returns the remoteParty. + */ + public String getRemoteParty() { + return remoteParty; + } + + /** + * @param remoteParty The remoteParty to set. + */ + public void setRemoteParty(String remoteParty) { + this.remoteParty = remoteParty; + } + + /** + * @hibernate.property + * not-null="true" + * @return Returns the timestamp. + */ + public Date getTimestamp() { + return timestamp; + } + + /** + * @param timestamp The timestamp to set. + */ + public void setTimestamp(Date timestamp) { + this.timestamp = timestamp; + } + + /** + * @hibernate.many-to-one + * @return Returns the service. + */ + public OrkService getService() { + return service; + } + + + /** + * @param server The service to set. + */ + public void setService(OrkService service) { + this.service = service; + } + + public String getLocalEntryPoint() { + return localEntryPoint; + } + + public void setLocalEntryPoint(String localEntryPoint) { + this.localEntryPoint = localEntryPoint; + } + + @Transient + public long getStopTime() { + return timestamp.getTime() + duration; + } + + @Transient + public String getUrl() { + + if(service != null) { + return service.getFileServeProtocol() + "://" + + service.getHostname() + ":" + service.getFileServeTcpPort() + + service.getContextPathWithPrefix() + service.getFileServePathWithPrefix() + "/" + filename; + } + else { + return ""; + } + } + + @Transient + public String getPlayUrl() { + return "javascript:play('" + getUrl() + "')"; + } + + public String getPortName() { + return portName; + } + + public void setPortName(String recPortName) { + this.portName = recPortName; + } + + public String getNativeCallId() { + return nativeCallId; + } + + public void setNativeCallId(String nativeCallId) { + this.nativeCallId = nativeCallId; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + +} diff --git a/orkbasej/java/net/sf/oreka/persistent/OrkUser.java b/orkbasej/src/main/java/net/sf/oreka/persistent/OrkUser.java similarity index 92% rename from orkbasej/java/net/sf/oreka/persistent/OrkUser.java rename to orkbasej/src/main/java/net/sf/oreka/persistent/OrkUser.java index 159b2a78..f342d521 100644 --- a/orkbasej/java/net/sf/oreka/persistent/OrkUser.java +++ b/orkbasej/src/main/java/net/sf/oreka/persistent/OrkUser.java @@ -1,207 +1,207 @@ -/* - * Oreka -- A media capture and retrieval platform - * - * Copyright (C) 2005, orecx LLC - * - * http://www.orecx.com - * - * This program is free software, distributed under the terms of - * the GNU General Public License. - * Please refer to http://www.gnu.org/copyleft/gpl.html - * - */ - -/** - * - */ -package net.sf.oreka.persistent; - -import java.io.Serializable; -import java.util.Date; - -import javax.persistence.Entity; -import javax.persistence.GenerationType; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.Table; - -/** - * @hibernate.class - */ -@Entity -@Table(name = "orkuser") -public class OrkUser implements Serializable { - - static final long serialVersionUID = 1l; - private int id = 0; - private String password = ""; - private String firstname = ""; - private String lastname = ""; - private String email = ""; - private boolean deleted = false; - private boolean disabled = false; - private Date dateCreated = new Date(0); - private Date dateDisabled = new Date(0); - private Date dateDeleted = new Date(0); - - //private Set loginStrings; - - /** - * @hibernate.property - * not-null="true" - * @return Returns the email. - */ - public String getEmail() { - return email; - } - - - /** - * @param email The email to set. - */ - public void setEmail(String email) { - this.email = email; - } - - - /** - * @hibernate.property - * not-null="true" - * @return Returns the firstname. - */ - public String getFirstname() { - return firstname; - } - - - /** - * @param firstname The firstname to set. - */ - public void setFirstname(String firstname) { - this.firstname = firstname; - } - - - /** - * @hibernate.id - * generator-class="native" - * @return Returns the id. - */ - @Id @GeneratedValue(strategy=GenerationType.AUTO) - public int getId() { - return id; - } - - - /** - * @param id The id to set. - */ - public void setId(int id) { - this.id = id; - } - - - /** - * @hibernate.property - * not-null="true" - * @return Returns the lastname. - */ - public String getLastname() { - return lastname; - } - - - /** - * @param lastname The lastname to set. - */ - public void setLastname(String lastname) { - this.lastname = lastname; - } - - - /** - * @hibernate.property - * not-null="true" - * @return Returns the password. - */ - public String getPassword() { - return password; - } - - - /** - * @param password The password to set. - */ - public void setPassword(String password) { - this.password = password; - } - - - /** - * - */ - public OrkUser() { - //loginStrings = new HashSet(); - } - - public Date getDateCreated() { - return dateCreated; - } - - - - public void setDateCreated(Date dateCreated) { - this.dateCreated = dateCreated; - } - - - - public Date getDateDeleted() { - return dateDeleted; - } - - - - public void setDateDeleted(Date dateDeleted) { - this.dateDeleted = dateDeleted; - } - - - - public Date getDateDisabled() { - return dateDisabled; - } - - - - public void setDateDisabled(Date dateDisabled) { - this.dateDisabled = dateDisabled; - } - - - - public boolean isDeleted() { - return deleted; - } - - - - public void setDeleted(boolean deleted) { - this.deleted = deleted; - } - - - - public boolean isDisabled() { - return disabled; - } - - - - public void setDisabled(boolean disabled) { - this.disabled = disabled; - } - - - -} +/* + * Oreka -- A media capture and retrieval platform + * + * Copyright (C) 2005, orecx LLC + * + * http://www.orecx.com + * + * This program is free software, distributed under the terms of + * the GNU General Public License. + * Please refer to http://www.gnu.org/copyleft/gpl.html + * + */ + +/** + * + */ +package net.sf.oreka.persistent; + +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Entity; +import javax.persistence.GenerationType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; + +/** + * @hibernate.class + */ +@Entity +@Table(name = "orkuser") +public class OrkUser implements Serializable { + + static final long serialVersionUID = 1l; + private int id = 0; + private String password = ""; + private String firstname = ""; + private String lastname = ""; + private String email = ""; + private boolean deleted = false; + private boolean disabled = false; + private Date dateCreated = new Date(0); + private Date dateDisabled = new Date(0); + private Date dateDeleted = new Date(0); + + //private Set loginStrings; + + /** + * @hibernate.property + * not-null="true" + * @return Returns the email. + */ + public String getEmail() { + return email; + } + + + /** + * @param email The email to set. + */ + public void setEmail(String email) { + this.email = email; + } + + + /** + * @hibernate.property + * not-null="true" + * @return Returns the firstname. + */ + public String getFirstname() { + return firstname; + } + + + /** + * @param firstname The firstname to set. + */ + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + + /** + * @hibernate.id + * generator-class="native" + * @return Returns the id. + */ + @Id @GeneratedValue(strategy=GenerationType.IDENTITY) + public int getId() { + return id; + } + + + /** + * @param id The id to set. + */ + public void setId(int id) { + this.id = id; + } + + + /** + * @hibernate.property + * not-null="true" + * @return Returns the lastname. + */ + public String getLastname() { + return lastname; + } + + + /** + * @param lastname The lastname to set. + */ + public void setLastname(String lastname) { + this.lastname = lastname; + } + + + /** + * @hibernate.property + * not-null="true" + * @return Returns the password. + */ + public String getPassword() { + return password; + } + + + /** + * @param password The password to set. + */ + public void setPassword(String password) { + this.password = password; + } + + + /** + * + */ + public OrkUser() { + //loginStrings = new HashSet(); + } + + public Date getDateCreated() { + return dateCreated; + } + + + + public void setDateCreated(Date dateCreated) { + this.dateCreated = dateCreated; + } + + + + public Date getDateDeleted() { + return dateDeleted; + } + + + + public void setDateDeleted(Date dateDeleted) { + this.dateDeleted = dateDeleted; + } + + + + public Date getDateDisabled() { + return dateDisabled; + } + + + + public void setDateDisabled(Date dateDisabled) { + this.dateDisabled = dateDisabled; + } + + + + public boolean isDeleted() { + return deleted; + } + + + + public void setDeleted(boolean deleted) { + this.deleted = deleted; + } + + + + public boolean isDisabled() { + return disabled; + } + + + + public void setDisabled(boolean disabled) { + this.disabled = disabled; + } + + + +} diff --git a/orkbasej/java/net/sf/oreka/serializers/DomSerializer.java b/orkbasej/src/main/java/net/sf/oreka/serializers/DomSerializer.java similarity index 100% rename from orkbasej/java/net/sf/oreka/serializers/DomSerializer.java rename to orkbasej/src/main/java/net/sf/oreka/serializers/DomSerializer.java diff --git a/orkbasej/java/net/sf/oreka/serializers/KeyValueSerializer.java b/orkbasej/src/main/java/net/sf/oreka/serializers/KeyValueSerializer.java similarity index 100% rename from orkbasej/java/net/sf/oreka/serializers/KeyValueSerializer.java rename to orkbasej/src/main/java/net/sf/oreka/serializers/KeyValueSerializer.java diff --git a/orkbasej/java/net/sf/oreka/serializers/OrkSerializer.java b/orkbasej/src/main/java/net/sf/oreka/serializers/OrkSerializer.java similarity index 100% rename from orkbasej/java/net/sf/oreka/serializers/OrkSerializer.java rename to orkbasej/src/main/java/net/sf/oreka/serializers/OrkSerializer.java diff --git a/orkbasej/java/net/sf/oreka/serializers/ServletRequestSerializer.java b/orkbasej/src/main/java/net/sf/oreka/serializers/ServletRequestSerializer.java similarity index 100% rename from orkbasej/java/net/sf/oreka/serializers/ServletRequestSerializer.java rename to orkbasej/src/main/java/net/sf/oreka/serializers/ServletRequestSerializer.java diff --git a/orkbasej/java/net/sf/oreka/serializers/SingleLineSerializer.java b/orkbasej/src/main/java/net/sf/oreka/serializers/SingleLineSerializer.java similarity index 100% rename from orkbasej/java/net/sf/oreka/serializers/SingleLineSerializer.java rename to orkbasej/src/main/java/net/sf/oreka/serializers/SingleLineSerializer.java diff --git a/orkbasej/java/net/sf/oreka/serializers/test/DomSerializerTest.java b/orkbasej/src/main/java/net/sf/oreka/serializers/test/DomSerializerTest.java similarity index 100% rename from orkbasej/java/net/sf/oreka/serializers/test/DomSerializerTest.java rename to orkbasej/src/main/java/net/sf/oreka/serializers/test/DomSerializerTest.java diff --git a/orkbasej/java/net/sf/oreka/serializers/test/NullHttpServletRequest.java b/orkbasej/src/main/java/net/sf/oreka/serializers/test/NullHttpServletRequest.java similarity index 76% rename from orkbasej/java/net/sf/oreka/serializers/test/NullHttpServletRequest.java rename to orkbasej/src/main/java/net/sf/oreka/serializers/test/NullHttpServletRequest.java index 71cb22f7..088ae2a2 100644 --- a/orkbasej/java/net/sf/oreka/serializers/test/NullHttpServletRequest.java +++ b/orkbasej/src/main/java/net/sf/oreka/serializers/test/NullHttpServletRequest.java @@ -17,16 +17,10 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; import java.security.Principal; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Locale; -import java.util.Map; +import java.util.*; -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletInputStream; -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; +import javax.servlet.*; +import javax.servlet.http.*; public class NullHttpServletRequest implements HttpServletRequest { @@ -62,7 +56,37 @@ public Enumeration getParameterNames(){ public boolean isRequestedSessionIdValid(){return false;} public boolean isRequestedSessionIdFromCookie(){return false;} public boolean isRequestedSessionIdFromUrl(){return false;} + + public boolean authenticate(HttpServletResponse httpServletResponse) throws IOException, ServletException { + return false; + } + + public void login(String s, String s1) throws ServletException { + + } + + public void logout() throws ServletException { + + } + + public Collection getParts() throws IOException, ServletException { + return null; + } + + public Part getPart(String s) throws IOException, ServletException { + return null; + } + + public T upgrade(Class aClass) throws IOException, ServletException { + return null; + } + public int getContentLength(){return 0;} + + public long getContentLengthLong() { + return 0; + } + public String getContentType(){return null;} public String getProtocol(){return null;} public String getScheme(){return null;} @@ -76,6 +100,11 @@ public Enumeration getParameterNames(){ public Enumeration getAttributeNames(){return null;} public Object getAttribute(String name){return null;} public HttpSession getSession(){return null;} + + public String changeSessionId() { + return null; + } + public BufferedReader getReader() throws IOException{return null;} public String getCharacterEncoding(){return null;} public void setAttribute(String name, Object o) {} @@ -131,6 +160,34 @@ public int getLocalPort() { return 0; } + public ServletContext getServletContext() { + return null; + } + + public AsyncContext startAsync() throws IllegalStateException { + return null; + } + + public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse) throws IllegalStateException { + return null; + } + + public boolean isAsyncStarted() { + return false; + } + + public boolean isAsyncSupported() { + return false; + } + + public AsyncContext getAsyncContext() { + return null; + } + + public DispatcherType getDispatcherType() { + return null; + } + public Map getParameterMap() { // TODO Auto-generated method stub return null; diff --git a/orkbasej/java/net/sf/oreka/serializers/test/ServletRequestSerializerTest.java b/orkbasej/src/main/java/net/sf/oreka/serializers/test/ServletRequestSerializerTest.java similarity index 100% rename from orkbasej/java/net/sf/oreka/serializers/test/ServletRequestSerializerTest.java rename to orkbasej/src/main/java/net/sf/oreka/serializers/test/ServletRequestSerializerTest.java diff --git a/orkbasej/java/net/sf/oreka/serializers/test/SingleLineSerializerTest.java b/orkbasej/src/main/java/net/sf/oreka/serializers/test/SingleLineSerializerTest.java similarity index 100% rename from orkbasej/java/net/sf/oreka/serializers/test/SingleLineSerializerTest.java rename to orkbasej/src/main/java/net/sf/oreka/serializers/test/SingleLineSerializerTest.java diff --git a/orkbasej/java/net/sf/oreka/serializers/test/TestMessageSimple.xml b/orkbasej/src/main/java/net/sf/oreka/serializers/test/TestMessageSimple.xml similarity index 100% rename from orkbasej/java/net/sf/oreka/serializers/test/TestMessageSimple.xml rename to orkbasej/src/main/java/net/sf/oreka/serializers/test/TestMessageSimple.xml diff --git a/orkbasej/java/net/sf/oreka/serializers/test/TestNestedMessage.xml b/orkbasej/src/main/java/net/sf/oreka/serializers/test/TestNestedMessage.xml similarity index 100% rename from orkbasej/java/net/sf/oreka/serializers/test/TestNestedMessage.xml rename to orkbasej/src/main/java/net/sf/oreka/serializers/test/TestNestedMessage.xml diff --git a/orkbasej/java/net/sf/oreka/srvc/ObjectService.java b/orkbasej/src/main/java/net/sf/oreka/srvc/ObjectService.java similarity index 100% rename from orkbasej/java/net/sf/oreka/srvc/ObjectService.java rename to orkbasej/src/main/java/net/sf/oreka/srvc/ObjectService.java diff --git a/orkbasej/java/net/sf/oreka/srvc/ObjectServiceHbn.java b/orkbasej/src/main/java/net/sf/oreka/srvc/ObjectServiceHbn.java similarity index 100% rename from orkbasej/java/net/sf/oreka/srvc/ObjectServiceHbn.java rename to orkbasej/src/main/java/net/sf/oreka/srvc/ObjectServiceHbn.java diff --git a/orkbasej/java/net/sf/oreka/srvc/UserFilter.java b/orkbasej/src/main/java/net/sf/oreka/srvc/UserFilter.java similarity index 100% rename from orkbasej/java/net/sf/oreka/srvc/UserFilter.java rename to orkbasej/src/main/java/net/sf/oreka/srvc/UserFilter.java diff --git a/orkbasej/java/net/sf/oreka/srvc/UserService.java b/orkbasej/src/main/java/net/sf/oreka/srvc/UserService.java similarity index 100% rename from orkbasej/java/net/sf/oreka/srvc/UserService.java rename to orkbasej/src/main/java/net/sf/oreka/srvc/UserService.java diff --git a/orkbasej/java/net/sf/oreka/srvc/UserServiceHbn.java b/orkbasej/src/main/java/net/sf/oreka/srvc/UserServiceHbn.java similarity index 99% rename from orkbasej/java/net/sf/oreka/srvc/UserServiceHbn.java rename to orkbasej/src/main/java/net/sf/oreka/srvc/UserServiceHbn.java index 402b8627..ae74c0bf 100644 --- a/orkbasej/java/net/sf/oreka/srvc/UserServiceHbn.java +++ b/orkbasej/src/main/java/net/sf/oreka/srvc/UserServiceHbn.java @@ -13,7 +13,7 @@ import net.sf.oreka.persistent.OrkLoginString; import net.sf.oreka.persistent.OrkUser; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; import org.hibernate.Criteria; import org.hibernate.HibernateException; diff --git a/orkbasej/java/net/sf/oreka/srvc/test/UserServiceHbnTest.java b/orkbasej/src/main/java/net/sf/oreka/srvc/test/UserServiceHbnTest.java similarity index 100% rename from orkbasej/java/net/sf/oreka/srvc/test/UserServiceHbnTest.java rename to orkbasej/src/main/java/net/sf/oreka/srvc/test/UserServiceHbnTest.java diff --git a/orkbasej/java/net/sf/oreka/test/FillDatabase.java b/orkbasej/src/main/java/net/sf/oreka/test/FillDatabase.java similarity index 100% rename from orkbasej/java/net/sf/oreka/test/FillDatabase.java rename to orkbasej/src/main/java/net/sf/oreka/test/FillDatabase.java diff --git a/orkbasej/java/net/sf/oreka/test/FillDatabaseProgram.java b/orkbasej/src/main/java/net/sf/oreka/test/FillDatabaseProgram.java similarity index 100% rename from orkbasej/java/net/sf/oreka/test/FillDatabaseProgram.java rename to orkbasej/src/main/java/net/sf/oreka/test/FillDatabaseProgram.java diff --git a/orkbasej/java/net/sf/oreka/test/FillDatabaseUser.java b/orkbasej/src/main/java/net/sf/oreka/test/FillDatabaseUser.java similarity index 100% rename from orkbasej/java/net/sf/oreka/test/FillDatabaseUser.java rename to orkbasej/src/main/java/net/sf/oreka/test/FillDatabaseUser.java diff --git a/orkbasej/java/net/sf/oreka/util/TomcatServerXMLParser.java b/orkbasej/src/main/java/net/sf/oreka/util/TomcatServerXMLParser.java similarity index 96% rename from orkbasej/java/net/sf/oreka/util/TomcatServerXMLParser.java rename to orkbasej/src/main/java/net/sf/oreka/util/TomcatServerXMLParser.java index 05da2cab..e5eebbed 100644 --- a/orkbasej/java/net/sf/oreka/util/TomcatServerXMLParser.java +++ b/orkbasej/src/main/java/net/sf/oreka/util/TomcatServerXMLParser.java @@ -1,367 +1,368 @@ -/* - * Oreka -- A media capture and retrieval platform - * - * Copyright (C) 2013, Orecx LLC - * - * http://www.orecx.com - * - * This program is free software, distributed under the terms of - * the GNU General Public License. - * Please refer to http://www.gnu.org/copyleft/gpl.html - * - */ -package net.sf.oreka.util; - -import java.io.File; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - -import org.apache.log4j.Logger; -import org.apache.log4j.PropertyConfigurator; -import org.w3c.dom.Document; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -public class TomcatServerXMLParser { - - static Logger logger = Logger.getLogger(TomcatServerXMLParser.class); - private static String serverTcpPort = null; - private static String audioContextPath = ""; - private static String audioFilePath = ""; - private static String scheme = null; - - private static String DEFAULT_TCPPORT = "8080"; - private static String DEFAULT_HOSTNAME = "localhost"; - private static String DEFAULT_SCHEME = "http"; - private static String tomcatHome = ""; - private static String defaultRecordingPath = ""; - - private static final String TOMCAT_RECORDINGS_PATH = "/webapps/ROOT/"; - - public static String getOrkTrackTcpPort(){ - - // Default to 8080 - if (serverTcpPort == null) - serverTcpPort = "8080"; - - return serverTcpPort; - } - - public static String getOrkWebTcpPort(){ - - // Default to 8080 - if (serverTcpPort == null) - serverTcpPort = "8080"; - - return serverTcpPort; - } - - public static String getTomcatTcpPort(){ - - if (serverTcpPort == null) - return DEFAULT_TCPPORT; - - return serverTcpPort; - } - - // FOR NOW USE DEFAULTS - public static String getOrkTrackHostName(){ - -// if (serverHostName == null) -// return DEFAULT_HOSTNAME; - - return DEFAULT_HOSTNAME; - } - - public static String getOrkWebHostName(){ - -// if (serverHostName == null) -// return DEFAULT_HOSTNAME; - - return DEFAULT_HOSTNAME; - } - - public static String getScheme(){ - - if (scheme==null) - return DEFAULT_SCHEME; - - return scheme; - } - - public static String getStartURLFromTomcatConfig(){ - return getScheme() + "://" + getOrkWebHostName() + ":" + getOrkWebTcpPort() + "/"; - } - - // Assumes parseServerXML was already called by ContextListener at tomcat start - public static String getAudioContextPath(){ - if (audioContextPath==null) - audioContextPath=""; - return audioContextPath; - } - - // Assumes parseServerXML was already called by ContextListener at tomcat start - public static String getAudioFilePath() { - if (audioFilePath==null) - audioFilePath=""; - return audioFilePath; - } - - public static String getDefaultRecordingPath() { - return defaultRecordingPath; - } - - public static void setDefaultRecordingPath(String defaultRecordingPath) { - TomcatServerXMLParser.defaultRecordingPath = defaultRecordingPath; - } - - public static String getTomcatHome() { - return tomcatHome; - } - - public static void setTomcatHome(String tomcatHome) { - if (tomcatHome!=null && !tomcatHome.equals("")) { - TomcatServerXMLParser.tomcatHome = tomcatHome; - setDefaultRecordingPath(tomcatHome + TOMCAT_RECORDINGS_PATH); - } else { - tomcatHome = ""; - setDefaultRecordingPath(""); - } - } - - // Parse server.xml file - public static void parseServerXML(String tomcatHome) throws Exception { - - if (tomcatHome == null || tomcatHome.equals("")){ - if (logger.isDebugEnabled()) - logger.debug("parseServerXML() - no server.xml provided, will use defaults"); - return; - } - - String serverXmlPath = tomcatHome + "/conf/server.xml"; - - if (logger.isDebugEnabled()) - logger.debug("parseServerXML() - parsing Tomcat server.xml file, path: " + serverXmlPath); - - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - DocumentBuilder builder = factory.newDocumentBuilder(); - - File serverConf = new File(serverXmlPath); - Document document = builder.parse(serverConf); - document.getDocumentElement().normalize(); - - // Find Server node - Node serverNode = document.getLastChild(); - NodeList serverNodeChildren = serverNode.getChildNodes(); - - // Find Service node - Node serviceNode = null; - for (int i=0;i - - - - org.hibernate.dialect.MySQLInnoDBDialect - 100 - com.mysql.jdbc.Driver - jdbc:mysql://localhost/test - password - root - - update - false - - true - 1 - org.hibernate.cache.HashtableCacheProvider - + + + + + org.hibernate.dialect.MySQLInnoDBDialect + 100 + com.mysql.jdbc.Driver + jdbc:mysql://localhost/test + password + root + + update + false + + true + 1 + org.hibernate.cache.HashtableCacheProvider + \ No newline at end of file diff --git a/orkbasej/java/database.hbm.xml b/orkbasej/src/resources/database.hbm.xml similarity index 71% rename from orkbasej/java/database.hbm.xml rename to orkbasej/src/resources/database.hbm.xml index af840175..b34df04d 100644 --- a/orkbasej/java/database.hbm.xml +++ b/orkbasej/src/resources/database.hbm.xml @@ -1,21 +1,21 @@ - - - - - org.hibernate.dialect.MySQLInnoDBDialect - 100 - com.mysql.jdbc.Driver - jdbc:mysql://localhost/test - password - root - - update - false - - true - 1 - org.hibernate.cache.HashtableCacheProvider - - + + + + + org.hibernate.dialect.MySQL55Dialect + 256 + com.mysql.cj.jdbc.Driver + jdbc:mysql://localhost/oreka?useSSL=false + password + root + + update + false + + true + 1 + org.hibernate.cache.HashtableCacheProvider + + diff --git a/orkbasej/java/hsqldb.hbm.template.xml b/orkbasej/src/resources/hsqldb.hbm.template.xml similarity index 100% rename from orkbasej/java/hsqldb.hbm.template.xml rename to orkbasej/src/resources/hsqldb.hbm.template.xml diff --git a/orkbasej/java/logging-example.properties b/orkbasej/src/resources/logging-example.properties similarity index 98% rename from orkbasej/java/logging-example.properties rename to orkbasej/src/resources/logging-example.properties index f0c657ea..82a763a0 100644 --- a/orkbasej/java/logging-example.properties +++ b/orkbasej/src/resources/logging-example.properties @@ -3,34 +3,34 @@ log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.Target=System.out log4j.appender.stdout.layout=org.apache.log4j.PatternLayout #log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %c %5p %C{1}:%L - %m%n -log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} %c %5p - %m%n +log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} %c %5p - %m%n ### orkweb.log ### log4j.appender.file=org.apache.log4j.RollingFileAppender -log4j.appender.file.File=c:/orkweb.log -log4j.appender.file.MaxFileSize=7000KB +log4j.appender.file.File=c:/orkweb.log +log4j.appender.file.MaxFileSize=7000KB log4j.appender.file.MaxBackupIndex=20 log4j.appender.file.layout=org.apache.log4j.PatternLayout -log4j.appender.file.layout.ConversionPattern=%d{ISO8601} %c %5p - %m%n - -### orklicense.log ### -log4j.logger.net.sf.oreka.orkweb.LicenseManager=info, license -log4j.appender.license=org.apache.log4j.RollingFileAppender -log4j.appender.license.File=c:/orklicense.log -log4j.appender.license.MaxFileSize=200KB -log4j.appender.license.MaxBackupIndex=3 -log4j.appender.license.layout=org.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern=%d{ISO8601} %c %5p - %m%n + +### orklicense.log ### +log4j.logger.net.sf.oreka.orkweb.LicenseManager=info, license +log4j.appender.license=org.apache.log4j.RollingFileAppender +log4j.appender.license.File=c:/orklicense.log +log4j.appender.license.MaxFileSize=200KB +log4j.appender.license.MaxBackupIndex=3 +log4j.appender.license.layout=org.apache.log4j.PatternLayout log4j.appender.license.layout.ConversionPattern=%d{ISO8601} %c %5p - %m%n - -log4j.rootLogger=info, file, stdout -log4j.logger.net.sf.oreka=info -log4j.logger.net.sf.oreka.orktrack=info -log4j.logger.org.hibernate=error -log4j.logger.org.hibernate.SQL=off -log4j.logger.org.apache.tapestry=info -log4j.logger.tapestry=error -log4j.logger.org.apache.hivemind=info -log4j.logger.hivemind=error -log4j.logger.org.logicalcobwebs.proxool=error -log4j.logger.org.apache.catalina=error -log4j.logger.uk.ltd.getahead=warn + +log4j.rootLogger=info, file, stdout +log4j.logger.net.sf.oreka=info +log4j.logger.net.sf.oreka.orktrack=info +log4j.logger.org.hibernate=error +log4j.logger.org.hibernate.SQL=off +log4j.logger.org.apache.tapestry=info +log4j.logger.tapestry=error +log4j.logger.org.apache.hivemind=info +log4j.logger.hivemind=error +log4j.logger.org.logicalcobwebs.proxool=error +log4j.logger.org.apache.catalina=error +log4j.logger.uk.ltd.getahead=warn diff --git a/orkbasej/java/logging.properties b/orkbasej/src/resources/logging.properties similarity index 98% rename from orkbasej/java/logging.properties rename to orkbasej/src/resources/logging.properties index f0c657ea..82a763a0 100644 --- a/orkbasej/java/logging.properties +++ b/orkbasej/src/resources/logging.properties @@ -3,34 +3,34 @@ log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.Target=System.out log4j.appender.stdout.layout=org.apache.log4j.PatternLayout #log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %c %5p %C{1}:%L - %m%n -log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} %c %5p - %m%n +log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} %c %5p - %m%n ### orkweb.log ### log4j.appender.file=org.apache.log4j.RollingFileAppender -log4j.appender.file.File=c:/orkweb.log -log4j.appender.file.MaxFileSize=7000KB +log4j.appender.file.File=c:/orkweb.log +log4j.appender.file.MaxFileSize=7000KB log4j.appender.file.MaxBackupIndex=20 log4j.appender.file.layout=org.apache.log4j.PatternLayout -log4j.appender.file.layout.ConversionPattern=%d{ISO8601} %c %5p - %m%n - -### orklicense.log ### -log4j.logger.net.sf.oreka.orkweb.LicenseManager=info, license -log4j.appender.license=org.apache.log4j.RollingFileAppender -log4j.appender.license.File=c:/orklicense.log -log4j.appender.license.MaxFileSize=200KB -log4j.appender.license.MaxBackupIndex=3 -log4j.appender.license.layout=org.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern=%d{ISO8601} %c %5p - %m%n + +### orklicense.log ### +log4j.logger.net.sf.oreka.orkweb.LicenseManager=info, license +log4j.appender.license=org.apache.log4j.RollingFileAppender +log4j.appender.license.File=c:/orklicense.log +log4j.appender.license.MaxFileSize=200KB +log4j.appender.license.MaxBackupIndex=3 +log4j.appender.license.layout=org.apache.log4j.PatternLayout log4j.appender.license.layout.ConversionPattern=%d{ISO8601} %c %5p - %m%n - -log4j.rootLogger=info, file, stdout -log4j.logger.net.sf.oreka=info -log4j.logger.net.sf.oreka.orktrack=info -log4j.logger.org.hibernate=error -log4j.logger.org.hibernate.SQL=off -log4j.logger.org.apache.tapestry=info -log4j.logger.tapestry=error -log4j.logger.org.apache.hivemind=info -log4j.logger.hivemind=error -log4j.logger.org.logicalcobwebs.proxool=error -log4j.logger.org.apache.catalina=error -log4j.logger.uk.ltd.getahead=warn + +log4j.rootLogger=info, file, stdout +log4j.logger.net.sf.oreka=info +log4j.logger.net.sf.oreka.orktrack=info +log4j.logger.org.hibernate=error +log4j.logger.org.hibernate.SQL=off +log4j.logger.org.apache.tapestry=info +log4j.logger.tapestry=error +log4j.logger.org.apache.hivemind=info +log4j.logger.hivemind=error +log4j.logger.org.logicalcobwebs.proxool=error +log4j.logger.org.apache.catalina=error +log4j.logger.uk.ltd.getahead=warn diff --git a/orkbasej/src/resources/logging.xml b/orkbasej/src/resources/logging.xml new file mode 100644 index 00000000..25008db4 --- /dev/null +++ b/orkbasej/src/resources/logging.xml @@ -0,0 +1,84 @@ + + + + + /var/log/orkweb/orkweb.log + /var/log/orkweb/access.log + /var/log/orkweb/orklicense.log + + + + + + + + + + %d %p %c{1} [%t] %m%n + + + + + + + + + + %d %p %c{1} [%t] %m%n + + + + + + + + + + %d %p %c{1} [%t] %m%n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/orkbasej/java/proxool-template.properties b/orkbasej/src/resources/proxool-template.properties similarity index 100% rename from orkbasej/java/proxool-template.properties rename to orkbasej/src/resources/proxool-template.properties diff --git a/orktrack/.classpath b/orktrack/.classpath deleted file mode 100644 index 3a2bbaca..00000000 --- a/orktrack/.classpath +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/orktrack/.gitignore b/orktrack/.gitignore new file mode 100644 index 00000000..69d7cf60 --- /dev/null +++ b/orktrack/.gitignore @@ -0,0 +1,4 @@ +target/ +.settings +classes/ +*.iml \ No newline at end of file diff --git a/orktrack/.project b/orktrack/.project deleted file mode 100644 index 92ab63c8..00000000 --- a/orktrack/.project +++ /dev/null @@ -1,18 +0,0 @@ - - - orktrack - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - com.sysdeo.eclipse.tomcat.tomcatnature - - diff --git a/orktrack/deploy-template.xml b/orktrack/deploy-template.xml index 21cf4876..208ec457 100644 --- a/orktrack/deploy-template.xml +++ b/orktrack/deploy-template.xml @@ -61,7 +61,7 @@ + source="1.8"> @@ -75,7 +75,7 @@ + source="1.8"> diff --git a/orktrack/pom.xml b/orktrack/pom.xml new file mode 100644 index 00000000..d3cd35a6 --- /dev/null +++ b/orktrack/pom.xml @@ -0,0 +1,150 @@ + + 4.0.0 + net.sf.oreka + orktrack + 0.0.2-SNAPSHOT + war + + src/main/java + + + maven-compiler-plugin + 3.1 + + 1.8 + 1.8 + false + + + + + org.apache.maven.plugins + maven-war-plugin + 2.4 + + + + + src/main/webapp + + + + + + + org.apache.tomcat.maven + tomcat7-maven-plugin + 2.1 + + / + + + + + + com.github.m50d + aspectj-maven-plugin + 1.11.1 + + + + 1.8 + 1.8 + 1.8 + + true + true + ignore + UTF-8 + + true + + + + ${project.build.directory}/classes + + + + + io.astefanutti.metrics.aspectj + metrics-aspectj + + + + + + + compile + test-compile + + + + + + + + + + + net.sf.oreka + orkbasej + 0.0.2-SNAPSHOT + + + + + javax.servlet + javax.servlet-api + 4.0.0 + provided + + + + org.projectlombok + lombok + 1.16.20 + provided + + + + io.dropwizard.metrics + metrics-core + 3.1.0 + + + + io.dropwizard.metrics + metrics-annotation + 3.1.0 + + + + io.astefanutti.metrics.aspectj + metrics-aspectj + 1.2.0 + + + + org.aspectj + aspectjrt + 1.9.1 + + + + org.apache.logging.log4j + log4j-api + 2.17.0 + + + + org.apache.logging.log4j + log4j-core + 2.17.0 + + + + \ No newline at end of file diff --git a/orktrack/src/net/sf/oreka/orktrack/ConfigManager.java b/orktrack/src/main/java/net/sf/oreka/orktrack/ConfigManager.java similarity index 98% rename from orktrack/src/net/sf/oreka/orktrack/ConfigManager.java rename to orktrack/src/main/java/net/sf/oreka/orktrack/ConfigManager.java index 84fb2688..279f8c37 100644 --- a/orktrack/src/net/sf/oreka/orktrack/ConfigManager.java +++ b/orktrack/src/main/java/net/sf/oreka/orktrack/ConfigManager.java @@ -27,7 +27,7 @@ import net.sf.oreka.OrkException; import net.sf.oreka.serializers.DomSerializer; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; import org.w3c.dom.Document; /** diff --git a/orktrack/src/main/java/net/sf/oreka/orktrack/Constants.java b/orktrack/src/main/java/net/sf/oreka/orktrack/Constants.java new file mode 100644 index 00000000..bad31460 --- /dev/null +++ b/orktrack/src/main/java/net/sf/oreka/orktrack/Constants.java @@ -0,0 +1,8 @@ +package net.sf.oreka.orktrack; + +public class Constants { + public static final String APP_NAME = "OrkTrack"; + public static final String DEFAULT_REGISTRY_NAME = "metrics-registry"; + + +} diff --git a/orktrack/src/net/sf/oreka/orktrack/LogManager.java b/orktrack/src/main/java/net/sf/oreka/orktrack/LogManager.java similarity index 60% rename from orktrack/src/net/sf/oreka/orktrack/LogManager.java rename to orktrack/src/main/java/net/sf/oreka/orktrack/LogManager.java index bf395683..9c043f9c 100644 --- a/orktrack/src/net/sf/oreka/orktrack/LogManager.java +++ b/orktrack/src/main/java/net/sf/oreka/orktrack/LogManager.java @@ -13,42 +13,39 @@ package net.sf.oreka.orktrack; -import java.io.File; - import net.sf.oreka.OrkException; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.core.LoggerContext; +import org.apache.logging.log4j.core.config.ConfigurationSource; +import org.apache.logging.log4j.core.config.xml.XmlConfiguration; -import org.apache.log4j.BasicConfigurator; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.apache.log4j.PropertyConfigurator; +import java.io.File; /** * This singleton class manages all application log4j loggers */ public class LogManager { - static LogManager logManager = null; - - String ConfigFilename = null; - - Logger rootLogger = null; - Logger configLogger = null; - Logger contextLogger = null; - Logger portLogger = null; - Logger userLogger = null; - Logger recurrentLogger = null; // special logger for recurrent messages (annoying to have normally) + private static LogManager logManager = null; + + private String ConfigFilename = null; + + private Logger rootLogger = null; + private Logger configLogger = null; + private Logger contextLogger = null; + private Logger portLogger = null; + private Logger userLogger = null; + private Logger recurrentLogger = null; // special logger for recurrent messages (annoying to have normally) - private LogManager() + private LogManager() { - rootLogger = Logger.getRootLogger(); - rootLogger.setLevel(Level.INFO); - configLogger = Logger.getLogger("config"); - contextLogger = Logger.getLogger("context"); - portLogger = Logger.getLogger("port"); - userLogger = Logger.getLogger("user"); - recurrentLogger = Logger.getLogger("net.sf.oreka.recurrent"); + rootLogger = org.apache.logging.log4j.LogManager.getRootLogger(); + configLogger = org.apache.logging.log4j.LogManager.getLogger("config"); + contextLogger = org.apache.logging.log4j.LogManager.getLogger("context"); + portLogger = org.apache.logging.log4j.LogManager.getLogger("port"); + userLogger = org.apache.logging.log4j.LogManager.getLogger("user"); + recurrentLogger = org.apache.logging.log4j.LogManager.getLogger("net.sf.oreka.recurrent"); - BasicConfigurator.configure(); // in case there is no properties file } public static LogManager getInstance() @@ -73,7 +70,11 @@ public void configure() throws OrkException { if (file.exists()) { // Attempt to configure log4j - PropertyConfigurator.configure(ConfigFilename); + //PropertyConfigurator.configure(ConfigFilename); + LoggerContext context = (org.apache.logging.log4j.core.LoggerContext) org.apache.logging.log4j.LogManager.getContext(false); + XmlConfiguration config = new XmlConfiguration(context, ConfigurationSource.fromUri(file.toURI())); + context.start(config); + } else { throw new OrkException("Log4j properties file does not exist:" + ConfigFilename + " check your web.xml"); diff --git a/orktrack/src/net/sf/oreka/orktrack/OrkTrack.java b/orktrack/src/main/java/net/sf/oreka/orktrack/OrkTrack.java similarity index 61% rename from orktrack/src/net/sf/oreka/orktrack/OrkTrack.java rename to orktrack/src/main/java/net/sf/oreka/orktrack/OrkTrack.java index 75da7c42..2ecdfe31 100644 --- a/orktrack/src/net/sf/oreka/orktrack/OrkTrack.java +++ b/orktrack/src/main/java/net/sf/oreka/orktrack/OrkTrack.java @@ -16,46 +16,41 @@ */ package net.sf.oreka.orktrack; -import java.util.Date; - +import com.codahale.metrics.JmxReporter; +import com.codahale.metrics.MetricRegistry; +import com.codahale.metrics.SharedMetricRegistries; import net.sf.oreka.HibernateManager; import net.sf.oreka.OrkObjectFactory; -import net.sf.oreka.orktrack.messages.ConfigureLogMessage; -import net.sf.oreka.orktrack.messages.InitMessage; -import net.sf.oreka.orktrack.messages.MetadataMessage; -import net.sf.oreka.orktrack.messages.PingMessage; -import net.sf.oreka.orktrack.messages.TapeMessage; -import net.sf.oreka.orktrack.messages.UserStateMessage; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; +import net.sf.oreka.orktrack.messages.*; +import org.apache.logging.log4j.Logger; +import java.util.Date; +import java.util.concurrent.TimeUnit; +import static net.sf.oreka.orktrack.Constants.*; public class OrkTrack { - public static final String APP_NAME = "OrkTrack"; - public static HibernateManager hibernateManager = HibernateManager.instance(); private static Date lastInMemoryObjectsSync = new Date(0); - - static Logger logger = Logger.getLogger(OrkTrack.class); - + public static MetricRegistry METRIC_REGISTRY; + private static JmxReporter reporter; + + private static Logger log = LogManager.getInstance().getRootLogger(); + public OrkTrack() { - - LogManager.getInstance().getConfigLogger().log(Level.INFO, "Entering OrkTrack"); + LogManager.getInstance().getConfigLogger().info("Entering OrkTrack"); } - public static void initialize(String log4jConfigFile, String hibernateConfigFile, String configFile) { - - try { + public static void initialize(String log4jConfigFile, String hibernateConfigFile, String configFile) throws Exception { + try { LogManager.getInstance().configure(log4jConfigFile); - logger.info("========================================"); - logger.info(OrkTrack.APP_NAME + " starting ..."); - + log.info("========================================"); + log.info(APP_NAME + " starting ..."); + // Register all OrkObjects - OrkObjectFactory.instance().registerOrkObject(new OrkTrackConfig()); + OrkObjectFactory.instance().registerOrkObject(new OrkTrackConfig()); OrkObjectFactory.instance().registerOrkObject(new MetadataMessage()); OrkObjectFactory.instance().registerOrkObject(new TapeMessage()); OrkObjectFactory.instance().registerOrkObject(new UserStateMessage()); @@ -65,11 +60,22 @@ public static void initialize(String log4jConfigFile, String hibernateConfigFile ConfigManager.getInstance().load(configFile); hibernateManager.configure(hibernateConfigFile); + + METRIC_REGISTRY = SharedMetricRegistries.getOrCreate(DEFAULT_REGISTRY_NAME); + + reporter = JmxReporter.forRegistry(METRIC_REGISTRY) + .convertDurationsTo(TimeUnit.MILLISECONDS) + .convertRatesTo(TimeUnit.SECONDS) + .inDomain("orktrack") + .build(); + reporter.start(); + } - catch (Exception e) { - logger.error("OrkTrack.initialize: Error configuring Hibernate:" + e.getMessage()); + catch (Throwable e) { + log.error("OrkTrack.initialize: Error configuring Hibernate:" + e.getMessage()); + throw e ; } - + /* boolean initOk = false; //while(initOk == false) { @@ -82,9 +88,10 @@ public static void initialize(String log4jConfigFile, String hibernateConfigFile */ refreshInMemoryObjects(); - logger.info(OrkTrack.APP_NAME + " started successfully."); - logger.info("----------------------------------------"); + log.info(APP_NAME + " started successfully."); + log.info("----------------------------------------"); + METRIC_REGISTRY.counter(APP_NAME).inc(); } public static void refreshInMemoryObjects() { @@ -98,12 +105,4 @@ public static void refreshInMemoryObjects() { } } - public static void main(String[] args) - { - //System.out.println("hello"); - //RecSegment seg = new RecSegment(); - //System.out.println(seg.getDuration()); - //OrkTrack orkTrack = new OrkTrack(); - } - } diff --git a/orktrack/src/net/sf/oreka/orktrack/OrkTrackConfig.java b/orktrack/src/main/java/net/sf/oreka/orktrack/OrkTrackConfig.java similarity index 84% rename from orktrack/src/net/sf/oreka/orktrack/OrkTrackConfig.java rename to orktrack/src/main/java/net/sf/oreka/orktrack/OrkTrackConfig.java index 24d04892..9b98a1a8 100644 --- a/orktrack/src/net/sf/oreka/orktrack/OrkTrackConfig.java +++ b/orktrack/src/main/java/net/sf/oreka/orktrack/OrkTrackConfig.java @@ -13,10 +13,14 @@ package net.sf.oreka.orktrack; +import lombok.Getter; +import lombok.Setter; import net.sf.oreka.OrkException; import net.sf.oreka.OrkObject; import net.sf.oreka.serializers.OrkSerializer; +@Getter +@Setter public class OrkTrackConfig implements OrkObject { boolean ctiDriven = false; @@ -33,14 +37,5 @@ public String getOrkClassName() { public void validate() { } - - public boolean isCtiDriven() { - return ctiDriven; - } - - public void setCtiDriven(boolean ctiDriven) { - this.ctiDriven = ctiDriven; - } - } diff --git a/orktrack/src/net/sf/oreka/orktrack/Port.java b/orktrack/src/main/java/net/sf/oreka/orktrack/Port.java similarity index 99% rename from orktrack/src/net/sf/oreka/orktrack/Port.java rename to orktrack/src/main/java/net/sf/oreka/orktrack/Port.java index e14b1273..a8b6d027 100644 --- a/orktrack/src/net/sf/oreka/orktrack/Port.java +++ b/orktrack/src/main/java/net/sf/oreka/orktrack/Port.java @@ -221,6 +221,7 @@ else if (tapeMessage.getStage() == TapeMessage.CaptureStage.STOP){ recTape.setPort(recPort); recTape.setRemoteParty(stopMessage.getRemoteParty()); recTape.setTimestamp(timestamp); + recTape.setNativeCallId(stopMessage.getNativeCallId()); recTape.setService(srv); hbnSession.save(recTape); logger.info("#" + tapeMessage.getCapturePort() + ": written tape " + recTape.getId()); diff --git a/orktrack/src/net/sf/oreka/orktrack/PortManager.java b/orktrack/src/main/java/net/sf/oreka/orktrack/PortManager.java similarity index 100% rename from orktrack/src/net/sf/oreka/orktrack/PortManager.java rename to orktrack/src/main/java/net/sf/oreka/orktrack/PortManager.java diff --git a/orktrack/src/net/sf/oreka/orktrack/ProgramManager.java b/orktrack/src/main/java/net/sf/oreka/orktrack/ProgramManager.java similarity index 100% rename from orktrack/src/net/sf/oreka/orktrack/ProgramManager.java rename to orktrack/src/main/java/net/sf/oreka/orktrack/ProgramManager.java diff --git a/orktrack/src/net/sf/oreka/orktrack/ServiceManager.java b/orktrack/src/main/java/net/sf/oreka/orktrack/ServiceManager.java similarity index 100% rename from orktrack/src/net/sf/oreka/orktrack/ServiceManager.java rename to orktrack/src/main/java/net/sf/oreka/orktrack/ServiceManager.java diff --git a/orktrack/src/main/java/net/sf/oreka/orktrack/TapeManager.java b/orktrack/src/main/java/net/sf/oreka/orktrack/TapeManager.java new file mode 100644 index 00000000..4f47bb40 --- /dev/null +++ b/orktrack/src/main/java/net/sf/oreka/orktrack/TapeManager.java @@ -0,0 +1,141 @@ +package net.sf.oreka.orktrack; + +import net.sf.oreka.orktrack.messages.TapeMessage; +import net.sf.oreka.persistent.OrkSegment; +import net.sf.oreka.persistent.OrkService; +import net.sf.oreka.persistent.OrkTape; +import net.sf.oreka.persistent.OrkUser; +import org.apache.log4j.Logger; +import org.hibernate.Session; +import org.hibernate.query.Query; + +import java.util.Date; +import java.util.Optional; + + +public class TapeManager { + + private Logger logger = Logger.getLogger(TapeManager.class); + + static TapeManager tapeManager = null; + + private TapeManager () { + } + + public static TapeManager instance() { + if (tapeManager == null) { + tapeManager = new TapeManager(); + } + return tapeManager; + } + + public Optional getTapeByNativeCallID(Session hbnSession, String callId) { + Query query = hbnSession.createQuery("from OrkTape where nativeCallId=:nativeCallId order by id desc", OrkTape.class); + query.setParameter("nativeCallId", callId); + query.setMaxResults(1); + return query.uniqueResultOptional(); + } + + public Optional getBestMatchingRunningTape(Session hbnSession, TapeMessage tapeMessage) { + Query query = hbnSession.createQuery("from OrkTape where portName=:portName and nativeCallId=:nativeCallId and DATEDIFF(timestamp, NOW()) < :timeOffSet order by id desc", OrkTape.class); + query.setParameter("portName", tapeMessage.getCapturePort()); + query.setParameter("nativeCallId", tapeMessage.getNativeCallId()); + + if (!tapeMessage.getNativeCallId().equals("")){ + query.setParameter("timeOffSet", 7); + } else { + query.setParameter("timeOffSet", 1); + } + query.setMaxResults(1); + return query.uniqueResultOptional(); + } + + /** + * @param tapeMessage + * @param hbnSession + * @param srv + * @return false if the tape is rejected and should be deleted, otherwise true + */ + public boolean notifyTapeMessage(TapeMessage tapeMessage, Session hbnSession, OrkService srv) { + + boolean keepTape = true; + long date = ((long)tapeMessage.getTimestamp()) * 1000; + Date timestamp = new Date(date); + + // create a new tape record + OrkTape recTape = new OrkTape(); + recTape.setDirection(tapeMessage.getDirection()); + recTape.setDuration(tapeMessage.getDuration()); + recTape.setExpiryTimestamp(new Date()); + recTape.setLocalParty(tapeMessage.getLocalParty()); + recTape.setPortName(tapeMessage.getCapturePort()); + recTape.setRemoteParty(tapeMessage.getRemoteParty()); + recTape.setTimestamp(timestamp); + recTape.setNativeCallId(tapeMessage.getNativeCallId()); + recTape.setState(tapeMessage.getStage().name()); + recTape.setService(srv); + + if (tapeMessage.getStage() == TapeMessage.CaptureStage.START) { + //also insert into db for tracking + // create a new tape record + recTape.setFilename(tapeMessage.getFilename()+".mcf"); + hbnSession.save(recTape); + logger.info("Written start tape:" + tapeMessage.getRecId() + " as " + recTape.getId()); + } else if (tapeMessage.getStage() == TapeMessage.CaptureStage.STOP) { + //Update if present + Optional existingTape = getBestMatchingRunningTape(hbnSession, tapeMessage); + if (existingTape.isPresent()){ + recTape = existingTape.get(); + recTape.setDuration(tapeMessage.getDuration()); + recTape.setLocalParty(tapeMessage.getLocalParty()); + recTape.setRemoteParty(tapeMessage.getRemoteParty()); + recTape.setFilename(tapeMessage.getFilename()); + recTape.setState(tapeMessage.getStage().name()); + hbnSession.update(recTape); + logger.info("Updated stop tape:" + tapeMessage.getRecId() + " as " + recTape.getId()); + } + } else if (tapeMessage.getStage() == TapeMessage.CaptureStage.READY){ + // Tape stop message + //Retrieve Existing Tape if any + String currentCallState = null; + Optional existingTape = getBestMatchingRunningTape(hbnSession, tapeMessage); + if (existingTape.isPresent()){ + recTape = existingTape.get(); + currentCallState = recTape.getState(); + recTape.setFilename(tapeMessage.getFilename()); + recTape.setState(tapeMessage.getStage().name()); + + hbnSession.update(recTape); + logger.info("Updated ready tape:" + tapeMessage.getRecId() + " as " + recTape.getId()); + } else { + recTape.setFilename(tapeMessage.getFilename()); + hbnSession.save(recTape); + logger.info("Added ready tape:" + tapeMessage.getRecId() + " as " + recTape.getId()); + } + + OrkSegment recSegment = new OrkSegment(); + recSegment.setTimestamp(timestamp); + recSegment.setDirection(tapeMessage.getDirection()); + recSegment.setDuration(tapeMessage.getDuration()); + recSegment.setRemoteParty(tapeMessage.getRemoteParty()); + recSegment.setLocalParty(tapeMessage.getLocalParty()); + recSegment.setLocalEntryPoint(tapeMessage.getLocalEntryPoint()); + recSegment.setTape(recTape); + recSegment.setPortName(recTape.getPortName()); + + if(tapeMessage.getLocalParty() != "") { + OrkUser user = UserManager.instance().getByLoginString(tapeMessage.getLocalParty(), hbnSession); + recSegment.setUser(user); + } + if (ProgramManager.instance().filterSegmentAgainstAllPrograms(recSegment, hbnSession)) { + hbnSession.save(recSegment); + logger.info("Written segment:" + tapeMessage.getRecId() + " as " + recSegment.getId()); + } + else { + logger.info("Tape:" + tapeMessage.getRecId() + " not retained by any program"); + keepTape = false; + } + } + return keepTape; + } +} diff --git a/orktrack/src/net/sf/oreka/orktrack/UserManager.java b/orktrack/src/main/java/net/sf/oreka/orktrack/UserManager.java similarity index 97% rename from orktrack/src/net/sf/oreka/orktrack/UserManager.java rename to orktrack/src/main/java/net/sf/oreka/orktrack/UserManager.java index 22f490cc..11761670 100644 --- a/orktrack/src/net/sf/oreka/orktrack/UserManager.java +++ b/orktrack/src/main/java/net/sf/oreka/orktrack/UserManager.java @@ -18,7 +18,7 @@ import net.sf.oreka.persistent.OrkUser; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; import org.hibernate.Session; public class UserManager { diff --git a/orktrack/src/net/sf/oreka/orktrack/messages/ConfigureLogMessage.java b/orktrack/src/main/java/net/sf/oreka/orktrack/messages/ConfigureLogMessage.java similarity index 89% rename from orktrack/src/net/sf/oreka/orktrack/messages/ConfigureLogMessage.java rename to orktrack/src/main/java/net/sf/oreka/orktrack/messages/ConfigureLogMessage.java index ee1f6b5c..714222a3 100644 --- a/orktrack/src/net/sf/oreka/orktrack/messages/ConfigureLogMessage.java +++ b/orktrack/src/main/java/net/sf/oreka/orktrack/messages/ConfigureLogMessage.java @@ -20,16 +20,8 @@ import net.sf.oreka.orktrack.LogManager; import net.sf.oreka.serializers.OrkSerializer; -import org.apache.log4j.Logger; - public class ConfigureLogMessage extends SyncMessage { - static Logger logger = Logger.getLogger(ConfigureLogMessage.class); - - - public ConfigureLogMessage() { - } - @Override public AsyncMessage process() { diff --git a/orktrack/src/net/sf/oreka/orktrack/messages/InitMessage.java b/orktrack/src/main/java/net/sf/oreka/orktrack/messages/InitMessage.java similarity index 100% rename from orktrack/src/net/sf/oreka/orktrack/messages/InitMessage.java rename to orktrack/src/main/java/net/sf/oreka/orktrack/messages/InitMessage.java diff --git a/orktrack/src/net/sf/oreka/orktrack/messages/MetadataMessage.java b/orktrack/src/main/java/net/sf/oreka/orktrack/messages/MetadataMessage.java similarity index 66% rename from orktrack/src/net/sf/oreka/orktrack/messages/MetadataMessage.java rename to orktrack/src/main/java/net/sf/oreka/orktrack/messages/MetadataMessage.java index c815d4cd..c2f4615d 100644 --- a/orktrack/src/net/sf/oreka/orktrack/messages/MetadataMessage.java +++ b/orktrack/src/main/java/net/sf/oreka/orktrack/messages/MetadataMessage.java @@ -13,25 +13,26 @@ package net.sf.oreka.orktrack.messages; +import lombok.Getter; +import lombok.Setter; import net.sf.oreka.Direction; import net.sf.oreka.OrkException; import net.sf.oreka.messages.AsyncMessage; import net.sf.oreka.messages.SimpleResponseMessage; import net.sf.oreka.messages.SyncMessage; +import net.sf.oreka.orktrack.*; import net.sf.oreka.orktrack.LogManager; -import net.sf.oreka.orktrack.OrkTrack; -import net.sf.oreka.orktrack.Port; -import net.sf.oreka.orktrack.PortManager; -import net.sf.oreka.orktrack.ServiceManager; import net.sf.oreka.orktrack.messages.TapeMessage.CaptureStage; import net.sf.oreka.persistent.OrkService; import net.sf.oreka.serializers.OrkSerializer; import net.sf.oreka.serializers.SingleLineSerializer; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; import org.hibernate.Session; import org.hibernate.Transaction; +@Getter +@Setter public class MetadataMessage extends SyncMessage { Logger log = null; @@ -115,92 +116,5 @@ public void validate() { } - public String getCapturePort() { - return capturePort; - } - - public void setCapturePort(String capturePort) { - this.capturePort = capturePort; - } - - public Direction getDirection() { - return direction; - } - - public void setDirection(Direction direction) { - this.direction = direction; - } - - public int getDuration() { - return duration; - } - - public void setDuration(int duration) { - this.duration = duration; - } - - public String getLocalEntryPoint() { - return localEntryPoint; - } - - public void setLocalEntryPoint(String localEntryPoint) { - this.localEntryPoint = localEntryPoint; - } - - public String getLocalParty() { - return localParty; - } - - public void setLocalParty(String localParty) { - this.localParty = localParty; - } - - public Logger getLog() { - return log; - } - - public void setLog(Logger log) { - this.log = log; - } - - public String getLoginString() { - return loginString; - } - - public void setLoginString(String loginString) { - this.loginString = loginString; - } - - public String getRemoteParty() { - return remoteParty; - } - - public void setRemoteParty(String remoteParty) { - this.remoteParty = remoteParty; - } - - public String getService() { - return service; - } - - public void setService(String service) { - this.service = service; - } - - public CaptureStage getStage() { - return stage; - } - - public void setStage(CaptureStage stage) { - this.stage = stage; - } - - public int getTimestamp() { - return timestamp; - } - - public void setTimestamp(int timestamp) { - this.timestamp = timestamp; - } } diff --git a/orktrack/src/net/sf/oreka/orktrack/messages/PingMessage.java b/orktrack/src/main/java/net/sf/oreka/orktrack/messages/PingMessage.java similarity index 83% rename from orktrack/src/net/sf/oreka/orktrack/messages/PingMessage.java rename to orktrack/src/main/java/net/sf/oreka/orktrack/messages/PingMessage.java index 9c53cf2b..252b0bf1 100644 --- a/orktrack/src/net/sf/oreka/orktrack/messages/PingMessage.java +++ b/orktrack/src/main/java/net/sf/oreka/orktrack/messages/PingMessage.java @@ -13,27 +13,23 @@ package net.sf.oreka.orktrack.messages; +import com.codahale.metrics.annotation.Timed; +import io.astefanutti.metrics.aspectj.Metrics; import net.sf.oreka.OrkException; import net.sf.oreka.messages.AsyncMessage; import net.sf.oreka.messages.SimpleResponseMessage; import net.sf.oreka.messages.SyncMessage; import net.sf.oreka.serializers.OrkSerializer; -import org.apache.log4j.Logger; - +@Metrics(registry = "appMetrics") public class PingMessage extends SyncMessage { - static Logger logger = Logger.getLogger(PingMessage.class); - - - public PingMessage() { - } - @Override + @Timed(name = "process") public AsyncMessage process() { - SimpleResponseMessage response = new SimpleResponseMessage(); response.setSuccess(true); + response.setComment("pong"); return response; } diff --git a/orktrack/src/net/sf/oreka/orktrack/messages/TapeMessage.java b/orktrack/src/main/java/net/sf/oreka/orktrack/messages/TapeMessage.java similarity index 52% rename from orktrack/src/net/sf/oreka/orktrack/messages/TapeMessage.java rename to orktrack/src/main/java/net/sf/oreka/orktrack/messages/TapeMessage.java index d942436b..9ba1ac39 100644 --- a/orktrack/src/net/sf/oreka/orktrack/messages/TapeMessage.java +++ b/orktrack/src/main/java/net/sf/oreka/orktrack/messages/TapeMessage.java @@ -13,10 +13,16 @@ package net.sf.oreka.orktrack.messages; +import com.codahale.metrics.SharedMetricRegistries; +import com.codahale.metrics.annotation.Timed; +import io.astefanutti.metrics.aspectj.Metrics; +import lombok.Getter; +import lombok.Setter; import net.sf.oreka.Direction; import net.sf.oreka.OrkException; import net.sf.oreka.messages.AsyncMessage; import net.sf.oreka.messages.SyncMessage; +import net.sf.oreka.orktrack.Constants; import net.sf.oreka.orktrack.OrkTrack; import net.sf.oreka.orktrack.ServiceManager; import net.sf.oreka.orktrack.TapeManager; @@ -28,11 +34,14 @@ import org.hibernate.Session; import org.hibernate.Transaction; +@Getter +@Setter +@Metrics public class TapeMessage extends SyncMessage { - public enum CaptureStage {START , STOP, READY, COMPLETE, UNKN}; + public enum CaptureStage {START , STOP, READY, COMPLETE, UNKN}; - static Logger logger = Logger.getLogger(TapeMessage.class); + static Logger log = Logger.getLogger(TapeMessage.class); CaptureStage stage = CaptureStage.UNKN; int timestamp = 0; @@ -53,31 +62,27 @@ public enum CaptureStage {START , STOP, READY, COMPLETE, UNKN}; int dstTcpPort = 0; String srcMac = ""; String dstMac = ""; + String nativeCallId = ""; public TapeMessage() { } - - public String getService() { - return service; - } - - public void setService(String service) { - this.service = service; - } @Override + @Timed(name = "process") public AsyncMessage process() { - TapeResponse response = new TapeResponse(); + SharedMetricRegistries.getOrCreate(Constants.DEFAULT_REGISTRY_NAME) + .meter(getClass().getName()+".processing."+stage).mark(); + + TapeResponse response = new TapeResponse(); Session session = null; - Transaction tx = null; - + try { session = OrkTrack.hibernateManager.getSession(); - tx = session.beginTransaction(); - + Transaction tx = session.beginTransaction(); + SingleLineSerializer ser = new SingleLineSerializer(); - logger.info("Message: " + ser.serialize(this)); + log.info("Message: " + ser.serialize(this)); OrkService service = ServiceManager.retrieveOrCreate(this.service, this.getHostname(), session); @@ -85,14 +90,14 @@ public AsyncMessage process() { //port.notifyTapeMessage(this, session, service); if (TapeManager.instance().notifyTapeMessage(this, session, service) == false) { response.setDeleteTape(true); - logger.debug("Tape deletion requested:" + this.getFilename()); + log.debug("Tape deletion requested:" + this.getFilename()); } response.setSuccess(true); tx.commit(); } catch (Exception e) { - logger.error("TapeMessage.process: ", e); + log.error("TapeMessage.process: ", e); response.setSuccess(false); response.setComment(e.getMessage()); } @@ -118,6 +123,7 @@ public void define(OrkSerializer serializer) throws OrkException { direction = (Direction)serializer.enumValue("direction", direction, false); loginString = serializer.stringValue("loginString", loginString, false); service = serializer.stringValue("service", service, true); + nativeCallId = serializer.stringValue("nativecallid", nativeCallId, false); } public String getOrkClassName() { @@ -126,167 +132,8 @@ public String getOrkClassName() { public void validate() { // TODO Auto-generated method stub - - } - - public String getCapturePort() { - return capturePort; - } - - public void setCapturePort(String capturePort) { - this.capturePort = capturePort; - } - - public Direction getDirection() { - return direction; - } - - public void setDirection(Direction direction) { - this.direction = direction; - } - - public String getFilename() { - return filename; - } - - public void setFilename(String filename) { - this.filename = filename; - } - - public String getLocalEntryPoint() { - return localEntryPoint; - } - - public void setLocalEntryPoint(String localEntryPoint) { - this.localEntryPoint = localEntryPoint; - } - - public String getLocalParty() { - return localParty; - } - - public void setLocalParty(String localParty) { - this.localParty = localParty; - } - - public String getLoginString() { - return loginString; - } - - public void setLoginString(String loginString) { - this.loginString = loginString; - } - - public String getRemoteParty() { - return remoteParty; - } - - public void setRemoteParty(String remoteParty) { - this.remoteParty = remoteParty; - } - - public CaptureStage getStage() { - return stage; - } - - public void setStage(CaptureStage stage) { - this.stage = stage; - } - - public int getTimestamp() { - return timestamp; - } - - public void setTimestamp(int timestamp) { - this.timestamp = timestamp; - } - - public int getDuration() { - return duration; - } - - public void setDuration(int duration) { - this.duration = duration; - } - - public String getCaptureId() { - return captureId; - } - - - public void setCaptureId(String captureId) { - this.captureId = captureId; - } - - - public String getDstIp() { - return dstIp; - } - - - public void setDstIp(String dstIp) { - this.dstIp = dstIp; - } - - - public String getDstMac() { - return dstMac; - } - - - public void setDstMac(String dstMac) { - this.dstMac = dstMac; - } - - - public int getDstTcpPort() { - return dstTcpPort; - } - - public void setDstTcpPort(int dstTcpPort) { - this.dstTcpPort = dstTcpPort; } - public String getSrcIp() { - return srcIp; - } - - - public void setSrcIp(String srcIp) { - this.srcIp = srcIp; - } - - - public String getSrcMac() { - return srcMac; - } - - - public void setSrcMac(String srcMac) { - this.srcMac = srcMac; - } - - - public int getSrcTcpPort() { - return srcTcpPort; - } - - - public void setSrcTcpPort(int srcTcpPort) { - this.srcTcpPort = srcTcpPort; - } - - public String getRecId() { - return recId; - } - - - public void setRecId(String recId) { - this.recId = recId; - } - - - } diff --git a/orktrack/src/net/sf/oreka/orktrack/messages/TapeResponse.java b/orktrack/src/main/java/net/sf/oreka/orktrack/messages/TapeResponse.java similarity index 79% rename from orktrack/src/net/sf/oreka/orktrack/messages/TapeResponse.java rename to orktrack/src/main/java/net/sf/oreka/orktrack/messages/TapeResponse.java index 7d40db7e..69d3627d 100644 --- a/orktrack/src/net/sf/oreka/orktrack/messages/TapeResponse.java +++ b/orktrack/src/main/java/net/sf/oreka/orktrack/messages/TapeResponse.java @@ -1,15 +1,18 @@ package net.sf.oreka.orktrack.messages; +import lombok.Getter; +import lombok.Setter; import net.sf.oreka.OrkException; import net.sf.oreka.messages.SimpleResponseMessage; import net.sf.oreka.serializers.OrkSerializer; +@Getter +@Setter public class TapeResponse extends SimpleResponseMessage { private boolean deleteTape = false; public void define(OrkSerializer serializer) throws OrkException { - super.define(serializer); deleteTape = serializer.booleanValue("deletetape", deleteTape, false); } @@ -24,14 +27,5 @@ public void validate() { } - public boolean isDeleteTape() { - return deleteTape; - } - - public void setDeleteTape(boolean deleteTape) { - this.deleteTape = deleteTape; - } - - } diff --git a/orktrack/src/net/sf/oreka/orktrack/messages/UserStateMessage.java b/orktrack/src/main/java/net/sf/oreka/orktrack/messages/UserStateMessage.java similarity index 94% rename from orktrack/src/net/sf/oreka/orktrack/messages/UserStateMessage.java rename to orktrack/src/main/java/net/sf/oreka/orktrack/messages/UserStateMessage.java index 937e3f34..3c84c256 100644 --- a/orktrack/src/net/sf/oreka/orktrack/messages/UserStateMessage.java +++ b/orktrack/src/main/java/net/sf/oreka/orktrack/messages/UserStateMessage.java @@ -17,15 +17,12 @@ import net.sf.oreka.messages.AsyncMessage; import net.sf.oreka.messages.SimpleResponseMessage; import net.sf.oreka.messages.SyncMessage; +import net.sf.oreka.orktrack.*; import net.sf.oreka.orktrack.LogManager; -import net.sf.oreka.orktrack.OrkTrack; -import net.sf.oreka.orktrack.Port; -import net.sf.oreka.orktrack.PortManager; -import net.sf.oreka.orktrack.UserManager; import net.sf.oreka.persistent.OrkUser; import net.sf.oreka.serializers.OrkSerializer; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; import org.hibernate.Session; import org.hibernate.Transaction; diff --git a/orktrack/src/main/java/net/sf/oreka/orktrack/servlets/AccessLogFilter.java b/orktrack/src/main/java/net/sf/oreka/orktrack/servlets/AccessLogFilter.java new file mode 100644 index 00000000..e388daf6 --- /dev/null +++ b/orktrack/src/main/java/net/sf/oreka/orktrack/servlets/AccessLogFilter.java @@ -0,0 +1,59 @@ +package net.sf.oreka.orktrack.servlets; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import javax.servlet.*; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +public class AccessLogFilter implements Filter { + + private static final Logger logger = LogManager.getLogger("ACCESS"); + private static final String logFormat = "%s %s %s %d %d"; + + @Override + public void init(FilterConfig filterConfig) throws ServletException { + + } + + @Override + public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { + long startTime = System.currentTimeMillis(); + + HttpServletRequest httpServletRequest = (HttpServletRequest)servletRequest; + HttpServletResponse httpServletResponse = (HttpServletResponse)servletResponse; + + filterChain.doFilter (httpServletRequest, servletResponse); + + long elapsed = System.currentTimeMillis() - startTime; + + logger.info(String.format(logFormat, getIpAddr(httpServletRequest), httpServletRequest.getMethod(), getFullURL(httpServletRequest), httpServletResponse.getStatus() , elapsed )); + + } + + @Override + public void destroy() { + + } + + public static String getFullURL(HttpServletRequest request) { + StringBuffer requestURL = request.getRequestURL(); + String queryString = request.getQueryString(); + + if (queryString == null) { + return requestURL.toString(); + } else { + return requestURL.append('?').append(queryString).toString(); + } + } + + public static String getIpAddr(HttpServletRequest request){ + String ipAddress = request.getHeader("X-FORWARDED-FOR"); + if (ipAddress == null) { + ipAddress = request.getRemoteAddr(); + } + return ipAddress; + } +} diff --git a/orktrack/src/main/java/net/sf/oreka/orktrack/servlets/CommandServlet.java b/orktrack/src/main/java/net/sf/oreka/orktrack/servlets/CommandServlet.java new file mode 100644 index 00000000..5475f266 --- /dev/null +++ b/orktrack/src/main/java/net/sf/oreka/orktrack/servlets/CommandServlet.java @@ -0,0 +1,67 @@ +/* + * Oreka -- A media capture and retrieval platform + * + * Copyright (C) 2005, orecx LLC + * + * http://www.orecx.com + * + * This program is free software, distributed under the terms of + * the GNU General Public License. + * Please refer to http://www.gnu.org/copyleft/gpl.html + * + */ + +package net.sf.oreka.orktrack.servlets; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import net.sf.oreka.messages.AsyncMessage; +import net.sf.oreka.messages.SimpleResponseMessage; +import net.sf.oreka.messages.SyncMessage; +import net.sf.oreka.orktrack.OrkTrack; +import net.sf.oreka.serializers.ServletRequestSerializer; +import net.sf.oreka.serializers.SingleLineSerializer; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + + +public class CommandServlet extends HttpServlet { + + static Logger logger = LogManager.getLogger(CommandServlet.class); + + public void doGet(HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + //#####OrkObjectFactory.instance().registerOrkObject(new TestMessage()); + OrkTrack.refreshInMemoryObjects(); + + ServletRequestSerializer ser = new ServletRequestSerializer(); + SingleLineSerializer ser2 = new SingleLineSerializer(); + + try { + SyncMessage obj = (SyncMessage) ser.deSerialize(request); + AsyncMessage rsp = obj.process(); + logger.debug("Request: {}", ser2.serialize(obj)); + String resp = ser2.serialize(rsp); + logger.debug("Response: " + resp); + response.getWriter().println(resp); + } catch (Throwable e) { + logger.error("Servlet Process threw Exception",e); + SimpleResponseMessage rsp = new SimpleResponseMessage(); + rsp.setComment(e.getMessage()); + rsp.setSuccess(false); + try { + String resp = ser2.serialize(rsp); + logger.debug("Request: " + request.getQueryString() + ", Response: " + resp); + response.getWriter().println(resp); + } catch (Exception ae) { + logger.error("Request: " + request.getQueryString() + ", Error:" + ae.getMessage()); + } + } + + } +} diff --git a/orktrack/src/main/java/net/sf/oreka/orktrack/servlets/ContextListener.java b/orktrack/src/main/java/net/sf/oreka/orktrack/servlets/ContextListener.java new file mode 100644 index 00000000..c9294d9a --- /dev/null +++ b/orktrack/src/main/java/net/sf/oreka/orktrack/servlets/ContextListener.java @@ -0,0 +1,96 @@ +/* + * Oreka -- A media capture and retrieval platform + * + * Copyright (C) 2005, orecx LLC + * + * http://www.orecx.com + * + * This program is free software, distributed under the terms of + * the GNU General Public License. + * Please refer to http://www.gnu.org/copyleft/gpl.html + * + */ +package net.sf.oreka.orktrack.servlets; + +import net.sf.oreka.orktrack.Constants; +import net.sf.oreka.orktrack.LogManager; +import net.sf.oreka.orktrack.OrkTrack; +import net.sf.oreka.util.TomcatServerXMLParser; +import org.apache.logging.log4j.Logger; + +import javax.servlet.ServletContext; +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; + + +public class ContextListener implements ServletContextListener { + + Logger log = LogManager.getInstance().getRootLogger(); + + public void contextDestroyed(ServletContextEvent arg0) { + log.info(Constants.APP_NAME + " shutting down."); + } + + public void contextInitialized(ServletContextEvent servletContextEvent) { + + ServletContext context = servletContextEvent.getServletContext(); + + String configFolder = context.getInitParameter("ConfigDirectory"); + if (configFolder == null) { + configFolder = "c:/oreka/"; + } + + String log4jConfigFile = context.getInitParameter("Log4jConfigFile"); + if (log4jConfigFile == null) { + log.error("OrkTrack ContextInitialized() Log4jConfigFile context-param missing in web.xml"); + } else { + log.info("OrkTrack ContextInitialized() log4jConfigFile is " + log4jConfigFile); + log4jConfigFile = configFolder + "/" + log4jConfigFile; + } + + String configFile = context.getInitParameter("ConfigFile"); + if (configFile == null) { + log.error("OrkTrack ContextInitialized() ConfigFile context-param missing in web.xml"); + } else { + log.info("OrkTrack ContextInitialized() configFile is " + configFile); + configFile = configFolder + "/" + configFile; + } + + String hibernateConfigFile = context.getInitParameter("HibernateConfigFile"); + if (hibernateConfigFile == null) { + log.error("OrkTrack ContextInitialized() HibernateConfigFile context-param missing in web.xml"); + } else { + log.info("OrkTrack ContextInitialized() HibernateConfigFile is " + hibernateConfigFile); + hibernateConfigFile = configFolder + "/" + hibernateConfigFile; + } + + // Get path to server.xml file + if (log.isDebugEnabled()) + log.debug("OrkTrack ContextInitialized(): get Tomcat Home..."); + + String tomcatHome = context.getInitParameter("TomcatHome"); + + if (tomcatHome == null) { + log.warn("OrkTrack ContextInitialized(): TomcatHome context-param missing in web.xml"); + } else { + TomcatServerXMLParser.setTomcatHome(tomcatHome); + log.info("OrkTrack ContextInitialized(): TomcatHome is set to " + tomcatHome); + + // Parse Tomcat's server.xml file and set the audio and screen paths among other things + try { + TomcatServerXMLParser.parseServerXML(tomcatHome); + } catch (Exception e) { + log.error("OrkTrack ContextInitialized() error parsing server.xml at " + tomcatHome); + } + } + + try{ + //PortManager.instance().initialize(); + OrkTrack.initialize(log4jConfigFile, hibernateConfigFile, configFile); + } catch (Throwable e){ + log.error("OrkTrack ContextInitialized() threw exception",e); + } + } + + +} diff --git a/orktrack/src/net/sf/oreka/orktrack/test/InitMessageGenerator.java b/orktrack/src/main/java/net/sf/oreka/orktrack/test/InitMessageGenerator.java similarity index 95% rename from orktrack/src/net/sf/oreka/orktrack/test/InitMessageGenerator.java rename to orktrack/src/main/java/net/sf/oreka/orktrack/test/InitMessageGenerator.java index 1aca620b..b6cf6cf1 100644 --- a/orktrack/src/net/sf/oreka/orktrack/test/InitMessageGenerator.java +++ b/orktrack/src/main/java/net/sf/oreka/orktrack/test/InitMessageGenerator.java @@ -1,72 +1,72 @@ -/* - * Oreka -- A media capture and retrieval platform - * - * Copyright (C) 2017, orecx LLC - * - * http://www.orecx.com - * - */ -package net.sf.oreka.orktrack.test; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.net.MalformedURLException; -import java.net.URL; - -public class InitMessageGenerator { - private static StringBuffer msg = new StringBuffer(); - private static String hostName = "localhost"; - - public static void main(String[] args) { - - InitMessageGenerator initMessageGenerator = new InitMessageGenerator(); - initMessageGenerator.setHostName("localhost"); - - initMessageGenerator.sendURLRequest(initMessageGenerator.generateInitMessage()); - } - - public void sendURLRequest(String requestString) { - - // http://localhost:8080/orktrack/command?cmd=init - - String responseLine = ""; - StringBuffer responseSB = new StringBuffer(); - - try { - URL url = new URL(requestString); - BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); - - while ((responseLine = in.readLine()) != null) { - responseSB.append(responseLine); - } - in.close(); - - } catch (MalformedURLException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - System.out.println(responseSB.toString()); - } - - private StringBuffer getMessageBody() { - - msg = new StringBuffer(); - msg.append("http://").append(hostName).append(":8080/orktrack/command?cmd=init"); - return msg; - } - - public String generateInitMessage() { - - StringBuffer sb = getMessageBody(); - - System.out.println("Request: " + sb.toString()); - - return sb.toString(); - } - - private void setHostName(String hostName) { - InitMessageGenerator.hostName = hostName; - } -} +/* + * Oreka -- A media capture and retrieval platform + * + * Copyright (C) 2017, orecx LLC + * + * http://www.orecx.com + * + */ +package net.sf.oreka.orktrack.test; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.MalformedURLException; +import java.net.URL; + +public class InitMessageGenerator { + private static StringBuffer msg = new StringBuffer(); + private static String hostName = "localhost"; + + public static void main(String[] args) { + + InitMessageGenerator initMessageGenerator = new InitMessageGenerator(); + initMessageGenerator.setHostName("localhost"); + + initMessageGenerator.sendURLRequest(initMessageGenerator.generateInitMessage()); + } + + public void sendURLRequest(String requestString) { + + // http://localhost:8080/orktrack/command?cmd=init + + String responseLine = ""; + StringBuffer responseSB = new StringBuffer(); + + try { + URL url = new URL(requestString); + BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); + + while ((responseLine = in.readLine()) != null) { + responseSB.append(responseLine); + } + in.close(); + + } catch (MalformedURLException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + System.out.println(responseSB.toString()); + } + + private StringBuffer getMessageBody() { + + msg = new StringBuffer(); + msg.append("http://").append(hostName).append(":8080/orktrack/command?cmd=init"); + return msg; + } + + public String generateInitMessage() { + + StringBuffer sb = getMessageBody(); + + System.out.println("Request: " + sb.toString()); + + return sb.toString(); + } + + private void setHostName(String hostName) { + InitMessageGenerator.hostName = hostName; + } +} diff --git a/orktrack/src/net/sf/oreka/orktrack/test/PortTest.java b/orktrack/src/main/java/net/sf/oreka/orktrack/test/PortTest.java similarity index 100% rename from orktrack/src/net/sf/oreka/orktrack/test/PortTest.java rename to orktrack/src/main/java/net/sf/oreka/orktrack/test/PortTest.java diff --git a/orktrack/src/net/sf/oreka/orktrack/test/ProgramTest.java b/orktrack/src/main/java/net/sf/oreka/orktrack/test/ProgramTest.java similarity index 100% rename from orktrack/src/net/sf/oreka/orktrack/test/ProgramTest.java rename to orktrack/src/main/java/net/sf/oreka/orktrack/test/ProgramTest.java diff --git a/orktrack/src/main/resources/log4j2.xml b/orktrack/src/main/resources/log4j2.xml new file mode 100644 index 00000000..927b3eae --- /dev/null +++ b/orktrack/src/main/resources/log4j2.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/orktrack/context/WEB-INF/web.xml b/orktrack/src/main/webapp/WEB-INF/web.xml similarity index 60% rename from orktrack/context/WEB-INF/web.xml rename to orktrack/src/main/webapp/WEB-INF/web.xml index 3316f3b0..5c924350 100644 --- a/orktrack/context/WEB-INF/web.xml +++ b/orktrack/src/main/webapp/WEB-INF/web.xml @@ -1,16 +1,18 @@ + PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" + "http://java.sun.com/dtd/web-app_2_3.dtd"> + + orktrack ConfigDirectory - c:/oreka/ + /etc/oreka/ Log4jConfigFile - logging.properties + logging.xml ConfigFile @@ -22,26 +24,29 @@ TomcatHome - C:/Program Files/Apache Software Foundation/Tomcat 7.0 + - - redirect - org.apache.tapestry.RedirectFilter - - - redirect - / - - net.sf.oreka.orktrack.ContextListener + net.sf.oreka.orktrack.servlets.ContextListener command - net.sf.oreka.orktrack.CommandServlet + net.sf.oreka.orktrack.servlets.CommandServlet 1 command /command + + + AccessLogFilter + net.sf.oreka.orktrack.servlets.AccessLogFilter + + + + AccessLogFilter + /* + + diff --git a/orktrack/src/net/sf/oreka/orktrack/CommandServlet.java b/orktrack/src/net/sf/oreka/orktrack/CommandServlet.java deleted file mode 100644 index 2d8b7e0b..00000000 --- a/orktrack/src/net/sf/oreka/orktrack/CommandServlet.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Oreka -- A media capture and retrieval platform - * - * Copyright (C) 2005, orecx LLC - * - * http://www.orecx.com - * - * This program is free software, distributed under the terms of - * the GNU General Public License. - * Please refer to http://www.gnu.org/copyleft/gpl.html - * - */ - -package net.sf.oreka.orktrack; - -import java.io.IOException; -import java.io.PrintWriter; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import net.sf.oreka.messages.AsyncMessage; -import net.sf.oreka.messages.SimpleResponseMessage; -import net.sf.oreka.messages.SyncMessage; -import net.sf.oreka.serializers.ServletRequestSerializer; -import net.sf.oreka.serializers.SingleLineSerializer; - -import org.apache.log4j.Logger; - -public class CommandServlet extends HttpServlet { - - static final long serialVersionUID = 1l; - static Logger logger = Logger.getLogger(CommandServlet.class); - - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException - { - //#####OrkObjectFactory.instance().registerOrkObject(new TestMessage()); - OrkTrack.refreshInMemoryObjects(); - - ServletRequestSerializer ser = new ServletRequestSerializer(); - - try { - SyncMessage obj = (SyncMessage)ser.deSerialize(request); - AsyncMessage rsp = obj.process(); - SingleLineSerializer ser2 = new SingleLineSerializer(); - String req = ser2.serialize(obj); - logger.debug("Request: " + req); - PrintWriter out = response.getWriter(); - String resp = ser2.serialize(rsp); - logger.debug("Reponse: " + resp); - out.println(resp); - } - catch (Exception e) { - logger.debug("Request: " + request.getQueryString()); - SimpleResponseMessage rsp = new SimpleResponseMessage(); - rsp.setComment(e.getMessage()); - rsp.setSuccess(false); - SingleLineSerializer ser2 = new SingleLineSerializer(); - PrintWriter out = response.getWriter(); - try { - String resp = ser2.serialize(rsp); - logger.debug("Reponse: " + resp); - out.println(resp); - } - catch (Exception ae) { - logger.error("Error:" + ae.getMessage()); - } - } - -// SingleLineSerializer ser2 = new SingleLineSerializer(); -// try { -// OrkObject obj = ser.deSerialize(request); -// response.setContentType("text/html"); -// PrintWriter out = response.getWriter(); -// out.println(""); -// out.println(""); -// out.println("Sucess"); -// out.println(""); -// out.println(""); -// out.println("

"); -// out.println(ser2.serialize(obj)); -// out.println("

"); -// out.println(""); -// out.println(""); -// } -// catch (OrkException e) { -// response.setContentType("text/html"); -// PrintWriter out = response.getWriter(); -// out.println(""); -// out.println(""); -// out.println("Error"); -// out.println(""); -// out.println(""); -// out.println("

"); -// out.println(e.getMessage()); -// out.println("

"); -// out.println(""); -// out.println(""); -// } - -// logger.log(Level.INFO, request.getPathInfo()); -// logger.log(Level.INFO, request.getRequestURL()); -// logger.log(Level.INFO, request.getQueryString()); -// logger.log(Level.INFO, request.getParameter("toto")); -// logger.log(Level.INFO, request.getParameter("titi")); -// -// response.setContentType("text/html"); -// PrintWriter out = response.getWriter(); -// out.println(""); -// out.println(""); -// out.println("Hello World!"); -// out.println(""); -// out.println(""); -// out.println("

Hello World!

"); -// out.println(""); -// out.println(""); - } -} diff --git a/orktrack/src/net/sf/oreka/orktrack/ContextListener.java b/orktrack/src/net/sf/oreka/orktrack/ContextListener.java deleted file mode 100644 index c943626d..00000000 --- a/orktrack/src/net/sf/oreka/orktrack/ContextListener.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Oreka -- A media capture and retrieval platform - * - * Copyright (C) 2005, orecx LLC - * - * http://www.orecx.com - * - * This program is free software, distributed under the terms of - * the GNU General Public License. - * Please refer to http://www.gnu.org/copyleft/gpl.html - * - */ -package net.sf.oreka.orktrack; - -import net.sf.oreka.util.TomcatServerXMLParser; - -import javax.servlet.ServletContext; -import javax.servlet.ServletContextEvent; -import javax.servlet.ServletContextListener; - -import org.apache.log4j.Logger; - -public class ContextListener implements ServletContextListener { - - Logger log = LogManager.getInstance().getContextLogger(); - - public void contextDestroyed(ServletContextEvent arg0) { - - log.info(OrkTrack.APP_NAME + " shutting down."); - } - - public void contextInitialized(ServletContextEvent servletContextEvent) { - - ServletContext context = servletContextEvent.getServletContext(); - - String configFolder = context.getInitParameter("ConfigDirectory"); - if (configFolder == null) { - configFolder = "c:/oreka/"; - } - - String log4jConfigFile = context.getInitParameter("Log4jConfigFile"); - if (log4jConfigFile == null) { - log.error("OrkTrack ContextInitialized() Log4jConfigFile context-param missing in web.xml"); - } else { - log.info("OrkTrack ContextInitialized() log4jConfigFile is " + log4jConfigFile); - log4jConfigFile = configFolder + "/" + log4jConfigFile; - } - - String configFile = context.getInitParameter("ConfigFile"); - if (configFile == null) { - log.error("OrkTrack ContextInitialized() ConfigFile context-param missing in web.xml"); - } else { - log.info("OrkTrack ContextInitialized() configFile is " + configFile); - configFile = configFolder + "/" + configFile; - } - - String hibernateConfigFile = context.getInitParameter("HibernateConfigFile"); - if (hibernateConfigFile == null) { - log.error("OrkTrack ContextInitialized() HibernateConfigFile context-param missing in web.xml"); - } else { - log.info("OrkTrack ContextInitialized() HibernateConfigFile is " + hibernateConfigFile); - hibernateConfigFile = configFolder + "/" + hibernateConfigFile ; - } - - // Get path to server.xml file - if (log.isDebugEnabled()) - log.debug("OrkTrack ContextInitialized(): get Tomcat Home..."); - - String tomcatHome = context.getInitParameter("TomcatHome"); - - if (tomcatHome == null) { - log.warn("OrkTrack ContextInitialized(): TomcatHome context-param missing in web.xml"); - } else { - TomcatServerXMLParser.setTomcatHome(tomcatHome); - log.info("OrkTrack ContextInitialized(): TomcatHome is set to " + tomcatHome); - - // Parse Tomcat's server.xml file and set the audio and screen paths among other things - try { - TomcatServerXMLParser.parseServerXML(tomcatHome); - } catch (Exception e) { - log.error("OrkTrack ContextInitialized() error parsing server.xml at " + tomcatHome); - } - } - - //PortManager.instance().initialize(); - - OrkTrack.initialize(log4jConfigFile, hibernateConfigFile, configFile); - } - - -} diff --git a/orktrack/src/net/sf/oreka/orktrack/OrkTest.java b/orktrack/src/net/sf/oreka/orktrack/OrkTest.java deleted file mode 100644 index b1750b3c..00000000 --- a/orktrack/src/net/sf/oreka/orktrack/OrkTest.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Oreka -- A media capture and retrieval platform - * - * Copyright (C) 2005, orecx LLC - * - * http://www.orecx.com - * - * This program is free software, distributed under the terms of - * the GNU General Public License. - * Please refer to http://www.gnu.org/copyleft/gpl.html - * - */ - -package net.sf.oreka.orktrack; - -import org.apache.log4j.Logger; - -public class OrkTest { - - public static void main(String args[]) throws Exception - { - Logger log = LogManager.getInstance().getContextLogger(); - } -} diff --git a/orktrack/src/net/sf/oreka/orktrack/TapeManager.java b/orktrack/src/net/sf/oreka/orktrack/TapeManager.java deleted file mode 100644 index 9bbd3491..00000000 --- a/orktrack/src/net/sf/oreka/orktrack/TapeManager.java +++ /dev/null @@ -1,87 +0,0 @@ -package net.sf.oreka.orktrack; - -import java.util.Date; - -import net.sf.oreka.orktrack.messages.TapeMessage; -import net.sf.oreka.persistent.OrkSegment; -import net.sf.oreka.persistent.OrkTape; -import net.sf.oreka.persistent.OrkService; -import net.sf.oreka.persistent.OrkUser; - -import org.apache.log4j.Logger; -import org.hibernate.Session; - -public class TapeManager { - - static Logger logger = Logger.getLogger(TapeManager.class); - - static TapeManager tapeManager = null; - - private TapeManager () { - } - - public static TapeManager instance() { - if (tapeManager == null) { - tapeManager = new TapeManager(); - } - return tapeManager; - } - - /** - * @param tapeMessage - * @param hbnSession - * @param srv - * @return false if the tape is rejected and should be deleted, otherwise true - */ - public boolean notifyTapeMessage(TapeMessage tapeMessage, Session hbnSession, OrkService srv) { - - boolean keepTape = true; - - if (tapeMessage.getStage() == TapeMessage.CaptureStage.START) { - ; // tape start message - } - else if (tapeMessage.getStage() == TapeMessage.CaptureStage.READY){ - // Tape stop message - long date = ((long)tapeMessage.getTimestamp()) * 1000; - Date timestamp = new Date(date); - - // create a new tape record - OrkTape recTape = new OrkTape(); - recTape.setDirection(tapeMessage.getDirection()); - recTape.setDuration(tapeMessage.getDuration()); - recTape.setExpiryTimestamp(new Date()); - recTape.setFilename(tapeMessage.getFilename()); - recTape.setLocalParty(tapeMessage.getLocalParty()); - recTape.setPortName(tapeMessage.getCapturePort()); - recTape.setRemoteParty(tapeMessage.getRemoteParty()); - recTape.setTimestamp(timestamp); - recTape.setService(srv); - hbnSession.save(recTape); - logger.info("Written tape:" + tapeMessage.getRecId() + " as " + recTape.getId()); - - OrkSegment recSegment = new OrkSegment(); - recSegment.setTimestamp(timestamp); - recSegment.setDirection(tapeMessage.getDirection()); - recSegment.setDuration(tapeMessage.getDuration()); - recSegment.setRemoteParty(tapeMessage.getRemoteParty()); - recSegment.setLocalParty(tapeMessage.getLocalParty()); - recSegment.setLocalEntryPoint(tapeMessage.getLocalEntryPoint()); - recSegment.setTape(recTape); - recSegment.setPortName(recTape.getPortName()); - - if(tapeMessage.getLocalParty() != "") { - OrkUser user = UserManager.instance().getByLoginString(tapeMessage.getLocalParty(), hbnSession); - recSegment.setUser(user); - } - if (ProgramManager.instance().filterSegmentAgainstAllPrograms(recSegment, hbnSession)) { - hbnSession.save(recSegment); - logger.info("Written segment:" + tapeMessage.getRecId() + " as " + recSegment.getId()); - } - else { - logger.info("Tape:" + tapeMessage.getRecId() + " not retained by any program"); - keepTape = false; - } - } - return keepTape; - } -} diff --git a/orkweb/.classpath b/orkweb/.classpath deleted file mode 100644 index c5f75ffb..00000000 --- a/orkweb/.classpath +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/orkweb/.project b/orkweb/.project deleted file mode 100644 index 56a2e2b2..00000000 --- a/orkweb/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - orkweb - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/orkweb/context/WEB-INF/RecSegments.html b/orkweb/context/WEB-INF/RecSegments.html index 93ccfdba..1d546680 100644 --- a/orkweb/context/WEB-INF/RecSegments.html +++ b/orkweb/context/WEB-INF/RecSegments.html @@ -67,34 +67,12 @@ - - - - - - - - - - - - - - - - + + + + @@ -130,7 +108,7 @@ - Play + Play @@ -169,5 +147,27 @@ + + + \ No newline at end of file diff --git a/orkweb/context/WEB-INF/web.xml b/orkweb/context/WEB-INF/web.xml index a9db1bae..a3918f11 100644 --- a/orkweb/context/WEB-INF/web.xml +++ b/orkweb/context/WEB-INF/web.xml @@ -9,11 +9,11 @@ orkweb ConfigDirectory - c:/oreka/ + /etc/oreka/ Log4jConfigFile - logging.properties + logging.xml HibernateConfigFile @@ -21,8 +21,9 @@ TomcatHome - C:/Program Files/Apache Software Foundation/Tomcat 7.0 - + /var/lib/tomcat8 + + Debug false @@ -43,8 +44,17 @@ org.apache.tapestry.ApplicationServlet 1 + + tapeStream + net.sf.oreka.orkweb.TapeStream + orkweb /app + + tapeStream + /stream/* + + diff --git a/orkweb/pom.xml b/orkweb/pom.xml new file mode 100644 index 00000000..1d5236ee --- /dev/null +++ b/orkweb/pom.xml @@ -0,0 +1,117 @@ + + 4.0.0 + net.sf.oreka + orkweb + 0.0.2-SNAPSHOT + war + + src + + + maven-compiler-plugin + 3.1 + + 1.8 + 1.8 + + + + + org.apache.maven.plugins + maven-war-plugin + 2.4 + + + + context + + + src + WEB-INF/classes + + **/*.java + + + + + + + + org.apache.tomcat.maven + tomcat7-maven-plugin + 2.1 + + / + + + + + + + + + org.javassist + javassist + 3.18.2-GA + + + + net.sf.oreka + orkbasej + 0.0.2-SNAPSHOT + + + + javax.servlet + javax.servlet-api + 4.0.0 + provided + + + + org.projectlombok + lombok + 1.16.20 + provided + + + + tapestry + tapestry + 4.0.2 + + + jboss + javassist + + + + + + tapestry + tapestry-annotations + 4.0.2 + + + + commons-lang + commons-lang + 2.6 + + + + org.apache.logging.log4j + log4j-api + 2.17.0 + + + + org.apache.logging.log4j + log4j-core + 2.17.0 + + + + + \ No newline at end of file diff --git a/orkweb/src/net/sf/oreka/orkweb/ContextListener.java b/orkweb/src/net/sf/oreka/orkweb/ContextListener.java index 6c26fc34..b92d2d03 100644 --- a/orkweb/src/net/sf/oreka/orkweb/ContextListener.java +++ b/orkweb/src/net/sf/oreka/orkweb/ContextListener.java @@ -19,13 +19,13 @@ import net.sf.oreka.util.TomcatServerXMLParser; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Logger; public class ContextListener implements ServletContextListener { - - Logger log = null; + + Logger log = org.apache.logging.log4j.LogManager.getRootLogger(); public static boolean debugSwitch = false; // Enables application debugging (e.g. no login phase) - + public void contextInitialized(ServletContextEvent servletContextEvent) { ServletContext context = servletContextEvent.getServletContext(); @@ -35,14 +35,19 @@ public void contextInitialized(ServletContextEvent servletContextEvent) { configFolder = "c:/oreka/"; } - String log4jConfigFile = context.getInitParameter("Log4jConfigFile"); + String log4jConfigFile = context.getInitParameter("Log4jConfigFile"); if (log4jConfigFile == null) { log.error("OrkWeb ContextInitialized(): Log4jConfigFile context-param missing in web.xml"); } else { log4jConfigFile = configFolder + "/" + log4jConfigFile; - LogManager.getInstance().configure(log4jConfigFile); - log = LogManager.getInstance().getRootLogger(); - log.info("OrkWeb ContextInitialized(): log4jConfigFile is " + log4jConfigFile); + try { + LogManager.getInstance().configure(log4jConfigFile); + log.info("OrkWeb ContextInitialized(): log4jConfigFile is " + log4jConfigFile); + } catch (Throwable e){ + e.printStackTrace(); + log.error("OrkWeb ContextInitialized(): Error configuring log4j: " + e.getMessage()); + } + } log.info("========================================"); @@ -59,8 +64,9 @@ public void contextInitialized(ServletContextEvent servletContextEvent) { try { OrkWeb.hibernateManager.configure(hibernateConfigFile); } - catch (Exception e) { - log.error("OrkWeb ContextInitialized(): Error configuring Hibernate: " + e.getMessage()); + catch (Throwable e) { + e.printStackTrace(); + log.error("OrkWeb ContextInitialized(): Error configuring Hibernate: " + e.getMessage()); } // Get path to server.xml file diff --git a/orkweb/src/net/sf/oreka/orkweb/LogManager.java b/orkweb/src/net/sf/oreka/orkweb/LogManager.java index 40691001..3a3ad323 100644 --- a/orkweb/src/net/sf/oreka/orkweb/LogManager.java +++ b/orkweb/src/net/sf/oreka/orkweb/LogManager.java @@ -13,27 +13,28 @@ package net.sf.oreka.orkweb; -import java.io.File; - +import net.sf.oreka.OrkException; import org.apache.log4j.BasicConfigurator; -import org.apache.log4j.Logger; -import org.apache.log4j.PropertyConfigurator; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.core.LoggerContext; +import org.apache.logging.log4j.core.config.ConfigurationSource; +import org.apache.logging.log4j.core.config.xml.XmlConfiguration; + +import java.io.File; /** * This singleton class manages all application log4j loggers */ public class LogManager { - static LogManager logManager = null; - - Logger rootLogger = null; + private static LogManager logManager = null; - - private LogManager() + private Logger rootLogger = null; + + private LogManager() { - rootLogger = Logger.getRootLogger(); - - BasicConfigurator.configure(); // in case there is no properties file + rootLogger = org.apache.logging.log4j.LogManager.getRootLogger(); + BasicConfigurator.configure(); // in case there is no properties file } public static LogManager getInstance() @@ -51,7 +52,10 @@ public void configure(String filename) { File file = new File(filename); if (file.exists()) { // Attempt to configure log4j - PropertyConfigurator.configure(filename); + //PropertyConfigurator.configure(ConfigFilename); + LoggerContext context = (LoggerContext) org.apache.logging.log4j.LogManager.getContext(false); + XmlConfiguration config = new XmlConfiguration(context, ConfigurationSource.fromUri(file.toURI())); + context.start(config); } else { rootLogger.warn("Log4j properties file does not exist:" + filename + " check your web.xml"); @@ -72,4 +76,5 @@ public Logger getRootLogger() { public void setRootLogger(Logger rootLogger) { this.rootLogger = rootLogger; } -} + +} \ No newline at end of file diff --git a/orkweb/src/net/sf/oreka/orkweb/TapeStream.java b/orkweb/src/net/sf/oreka/orkweb/TapeStream.java new file mode 100644 index 00000000..52b1e9be --- /dev/null +++ b/orkweb/src/net/sf/oreka/orkweb/TapeStream.java @@ -0,0 +1,48 @@ +package net.sf.oreka.orkweb; + +import lombok.extern.log4j.Log4j; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.logging.log4j.Logger; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Path; + +public class TapeStream extends HttpServlet { + + private final String BASE_PATH = "/var/log/orkaudio/audio/"; + private Logger logger = LogManager.getInstance().getRootLogger(); + + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + String fileParam = request.getPathInfo(); + String fileName = StringUtils.removeStart(fileParam, "/"); + + String absoluteFilename = BASE_PATH + fileName; + Path path = new File(absoluteFilename).toPath(); + + logger.info("Serve Media File File {}", absoluteFilename); + + String mimeType = Files.probeContentType(path); + response.setContentType(mimeType); + response.setHeader("Content-Disposition", "inline;filename=" + path.getFileName().toString()); + + OutputStream out = response.getOutputStream(); + FileInputStream in = new FileInputStream(absoluteFilename); + IOUtils.copy(in, out); + in.close(); + out.flush(); + } + +} diff --git a/orkweb/src/net/sf/oreka/services/RecSegmentServiceHbn.java b/orkweb/src/net/sf/oreka/services/RecSegmentServiceHbn.java index 334a4f20..2bddd454 100644 --- a/orkweb/src/net/sf/oreka/services/RecSegmentServiceHbn.java +++ b/orkweb/src/net/sf/oreka/services/RecSegmentServiceHbn.java @@ -109,10 +109,10 @@ else if (filter.getEndDate() != null) queryString.append(" where 1=1 "); if(filter.getLocalParty().length() > 0) { - queryString.append(" and seg.localParty=:localParty "); + queryString.append(" and seg.localParty LIKE :localParty "); } if(filter.getRemoteParty().length() > 0) { - queryString.append(" and seg.remoteParty=:remoteParty "); + queryString.append(" and seg.remoteParty LIKE :remoteParty "); } if(filter.getMinDuration().length() > 0) { queryString.append(" and seg.duration>:minDuration "); @@ -149,10 +149,10 @@ else if (filter.getEndDate() != null) } if(filter.getLocalParty().length() > 0) { - query.setString("localParty", filter.getLocalParty()); + query.setString("localParty", filter.getLocalParty() + "%"); } if(filter.getRemoteParty().length() > 0) { - query.setString("remoteParty", filter.getRemoteParty()); + query.setString("remoteParty", filter.getRemoteParty() + "%"); } if(filter.getMinDuration().length() > 0) { query.setString("minDuration", filter.getMinDuration()); diff --git a/pom.xml b/pom.xml new file mode 100644 index 00000000..f6dc6efe --- /dev/null +++ b/pom.xml @@ -0,0 +1,30 @@ + + + 4.0.0 + + net.sf.oreka + orekaj-parent + 0.0.2-SNAPSHOT + pom + + + + maven-central + https://repo1.maven.org/maven2/ + + + apache-maven + https://repo.maven.apache.org/maven2/ + + + + + orkbasej + orktrack + orkweb + + + +