+++ /dev/null
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
- <parent>
- <groupId>org.wamblee</groupId>
- <artifactId>wamblee-mythtv</artifactId>
- <version>0.2-SNAPSHOT</version>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.wamblee</groupId>
- <artifactId>wamblee-mythtv-ear</artifactId>
- <packaging>ear</packaging>
- <name>/mythtv/ear</name>
- <url>http://wamblee.org</url>
-
- <dependencies>
- <dependency>
- <groupId>org.wamblee</groupId>
- <artifactId>wamblee-mythtv-war</artifactId>
- <version>${project.version}</version>
- <type>war</type>
- </dependency>
- <dependency>
- <groupId>org.wamblee</groupId>
- <artifactId>wamblee-mythtv-monitor</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.wamblee</groupId>
- <artifactId>wamblee-mythtv-timer</artifactId>
- <version>${project.version}</version>
- <type>ejb</type>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-ear-plugin</artifactId>
- <configuration>
- <defaultJavaBundleDir>lib/</defaultJavaBundleDir>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
+++ /dev/null
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
- <parent>
- <groupId>org.wamblee</groupId>
- <artifactId>wamblee-mythtv</artifactId>
- <version>0.2-SNAPSHOT</version>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.wamblee</groupId>
- <artifactId>wamblee-mythtv-monitor</artifactId>
- <packaging>jar</packaging>
- <name>/mythtv/monitor</name>
- <url>http://wamblee.org</url>
-
- <dependencies>
- <dependency>
- <groupId>org.wamblee</groupId>
- <artifactId>wamblee-support-general</artifactId>
- <version>0.2-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.wamblee</groupId>
- <artifactId>wamblee-support-spring</artifactId>
- <version>0.2-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- </dependency>
- <dependency>
- <groupId>javax.persistence</groupId>
- <artifactId>persistence-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.wamblee</groupId>
- <artifactId>wamblee-hibernate-jpa</artifactId>
- <version>0.2-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>javax</groupId>
- <artifactId>javaee-api</artifactId>
- </dependency>
- </dependencies>
-
-</project>
+++ /dev/null
-/*
- * Copyright 2006 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.wamblee.mythtv;
-
-import javax.annotation.Resource;
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.MessageProducer;
-import javax.jms.ObjectMessage;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wamblee.general.BeanKernel;
-
-/**
- *
- *
- * @author Erik Brakkee
- */
-public class Application implements ServletContextListener {
- private static final Log LOG = LogFactory.getLog(Application.class);
-
- @Resource(name = "MythtvConnectionFactory")
- private ConnectionFactory connectionFactory;
-
- @Resource(name = "MythtvTimer")
- private Queue timerQueue;
-
- /*
- * (non-Javadoc)
- *
- * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
- */
- public void contextInitialized(ServletContextEvent arg0) {
- LOG.info("initializing");
-
- // Get application configuration.
- ScheduleConfig config = BeanKernel.getBeanFactory().find(
- ScheduleConfig.class);
-
- // Send object message to the timer with the timer interval.
- try {
- Connection connection = connectionFactory.createConnection();
- Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
- ObjectMessage msg = session.createObjectMessage();
- msg.setObject(config.getIntervalSeconds());
- MessageProducer producer = session.createProducer(timerQueue);
- producer.send(msg);
- LOG.info("Message sent");
- } catch (Exception e) {
- LOG.fatal("Error sending message", e);
- }
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent)
- */
- public void contextDestroyed(ServletContextEvent arg0) {
- LOG.info("terminating");
-
- // Empty.
- }
-}
+++ /dev/null
-/*
- * Copyright 2006 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.wamblee.mythtv;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-/**
- *
- *
- * @author Erik Brakkee
- */
-@Entity
-@Table(name="channel")
-public class Channel {
-
- private int _id;
-
- private String _name;
-
- protected Channel() {
- // Empty
- }
-
- /**
- * @return the id
- */
- @Id
- @Column(name="chanid")
- public int getId() {
- return _id;
- }
-
- /**
- * @param aId the id to set
- */
- public void setId(int aId) {
- _id = aId;
- }
-
- /**
- * @return the name
- */
- @Column(name="name")
- public String getName() {
- return _name;
- }
-
- /**
- * @param aName the name to set
- */
- public void setName(String aName) {
- _name = aName;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "Channel(" + _id + "," + _name + ")";
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object aObj) {
- if ( !(aObj instanceof Channel)) {
- return false;
- }
- Channel recording = (Channel)aObj;
- return _id == recording._id;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- return _id;
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2006 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.wamblee.mythtv;
-
-/**
- *
- *
- * @author Erik Brakkee
- */
-public enum FileType {
-
- MPG, AVI;
-}
+++ /dev/null
-/*
- * Copyright 2006 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.wamblee.mythtv;
-
-import java.io.File;
-import java.io.IOException;
-import java.text.SimpleDateFormat;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wamblee.io.SimpleProcess;
-import org.wamblee.io.DirectoryMonitor.Listener;
-
-/**
- * Link structure.
- *
- * @author Erik Brakkee
- */
-public class LinkStructure implements Listener {
-
- private static final Log LOG = LogFactory.getLog(LinkStructure.class);
-
- private String _monitorDir;
-
- private File _linkDir;
-
- private RecordingDatabase _database;
-
- private SimpleDateFormat _format;
-
- private Map<File,Recording> _recordings;
-
- public LinkStructure(String aMonitorDir, File aLinkDir,
- RecordingDatabase aDatabase) {
- _monitorDir = aMonitorDir + "/";
- deleteDir(aLinkDir);
- _linkDir = aLinkDir;
- _database = aDatabase;
- _format = new SimpleDateFormat("yyyy-MM-dd-HH:mm");
- _recordings = new HashMap<File,Recording>();
- }
-
- private void deleteDir(File aFile) {
- for (File file: aFile.listFiles()) {
- if ( file.isDirectory()) {
- deleteDir(file);
- }
- LOG.info("File deleted " + file + ": " + file.delete());
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.wamblee.io.DirectoryMonitor.Listener#fileChanged(java.io.File)
- */
- public void fileChanged(File aFile) {
- LOG.debug("file changed " + aFile);
-
- // Re-assess file type
- Recording recording = _recordings.get(aFile);
- LOG.info("Recording changed " + recording);
- recording.setFilesize(aFile.length());
- _database.update(recording);
- String dir = getDirectory(recording);
- FileType type = getFileType(aFile);
- String path = dir + "/" + getFilename(recording, type);
-
- if (exists(dir + "/" + getFilename(recording, type))) {
- // Nothing to do.
- } else {
- mkdir(dir);
- for (FileType t : FileType.values()) {
- rmlink(dir + "/" + getFilename(recording, t));
- }
- createSymLink(_monitorDir + aFile.getName(), dir + "/"
- + getFilename(recording, type));
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.wamblee.io.DirectoryMonitor.Listener#fileCreated(java.io.File)
- */
- public void fileCreated(File aFile) {
- LOG.debug("file created " + aFile);
- Recording recording = _database.findRecording(aFile.getName());
- if ( recording == null ) {
- LOG.warn("Spurious recording which should not exist according to mythtv: " + aFile);
- return;
- }
- _recordings.put(aFile, recording);
- LOG.info("New recording detected " + aFile + " "
- + recording);
-
- recording.setFilesize(aFile.length());
- _database.update(recording);
- String dir = getDirectory(recording);
- mkdir(dir);
- createSymLink(_monitorDir + aFile.getName(), dir + "/"
- + getFilename(recording, getFileType(aFile)));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.wamblee.io.DirectoryMonitor.Listener#fileDeleted(java.io.File)
- */
- public void fileDeleted(File aFile) {
- LOG.debug("file deleted " + aFile);
- Recording recording = _recordings.get(aFile);
- _recordings.remove(recording);
- // mythtv will remove the recording from its database itself.
- LOG.info("recording deleted " + recording);
- String dir = getDirectory(recording);
- for (FileType t: FileType.values()) {
- rmlink(dir + "/" + getFilename(recording, t));
- }
- rmdir(dir);
- }
-
- private String getDirectory(Recording aRecording) {
- return aRecording.getTitle().replaceAll("/", "-");
- }
-
- private FileType getFileType(File aFile) {
- SimpleProcess process = new SimpleProcess(new File(_monitorDir), new String[] {
- "file", aFile.getName() });
- try {
- process.run();
- if (process.getStdout().contains("RIFF")) {
- return FileType.AVI;
- } else {
- return FileType.MPG;
- }
- } catch (IOException e) {
- LOG.error("Determining filetype for " + aFile + " failed", e);
- return FileType.MPG;
- }
- }
-
- private String getFilename(Recording aRecording, FileType aType) {
- return (_format.format(aRecording.getProgstart()) + "-"
- + aRecording.getSubtitle() + "-"
- + aRecording.getChannel().getName() + "."
- + aType.toString().toLowerCase()).replaceAll("/", "-");
- }
-
- private boolean exists(String aPath) {
- LOG.debug("exists " + aPath);
- return new File(_linkDir, aPath).exists();
- }
-
- private void rmlink(String aPath) {
- LOG.debug("rmlink " + aPath);
- File link = new File(_linkDir, aPath);
- //if ( !link.exists()) {
- // return;
- // }
- if (!link.delete()) {
- LOG.warn("Delete failed: " + aPath);
- } else {
- LOG.info("Removed link " + link);
- }
- }
-
- private void mkdir(String aDir) {
- LOG.debug("mkdir " + aDir);
- File dir = new File(_linkDir, aDir);
- if ( dir.isDirectory()) {
- return;
- }
- if (!dir.mkdirs()) {
- LOG.warn("Could not create directory path: " + aDir);
- } else {
- LOG.info("Created directory " + dir);
- }
- }
-
- private void rmdir(String aDir) {
- LOG.debug("rmdir " + aDir);
- File dir = new File(_linkDir, aDir);
- if (!dir.delete()) {
- LOG.warn("Directory not deleted (still recordings left): " + aDir);
- } else {
- LOG.info("Directory " + dir + " deleted.");
- }
- }
-
- private void createSymLink(String aTarget, String aSource) {
- try {
- SimpleProcess process = new SimpleProcess(_linkDir, new String[] {
- "ln", aTarget, aSource });
- process.run();
- LOG.info("Created symlink " + aSource + " -> " + aTarget);
- } catch (IOException e) {
- LOG.error(
- "Could not create symlink: " + aTarget + " <- " + aSource,
- e);
- }
- }
-}
+++ /dev/null
-/*
- * Copyright 2005 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.wamblee.mythtv;
-import org.wamblee.general.spring.SpringBeanFactory;
-
-
-/**
- * Bean factory for the crawler application.
- *
- * @author Erik Brakkee
- */
-public class MythtvBeanFactory extends SpringBeanFactory {
- private static final String SELECTOR_NAME = "beanRefContext.xml";
- private static final String FACTORY_NAME = "mythtv";
-
- /**
- * Constructs the bean factory.
- *
- */
- public MythtvBeanFactory() {
- super(SELECTOR_NAME, FACTORY_NAME);
- }
-}
+++ /dev/null
-/*
- * Copyright 2006 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.wamblee.mythtv;
-
-import org.wamblee.persistence.hibernate.HibernateMappingFiles;
-
-/**
- *
- *
- * @author Erik Brakkee
- */
-public class MythtvHibernateMappings extends HibernateMappingFiles {
-
- public MythtvHibernateMappings() {
- super(new String[] { "Channel.hbm.xml", "Recording.hbm.xml" });
- }
-}
+++ /dev/null
-/*
- * Copyright 2006 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.wamblee.mythtv;
-
-import java.io.Serializable;
-import java.util.Date;
-
-import javax.persistence.Column;
-import javax.persistence.EmbeddedId;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.IdClass;
-import javax.persistence.JoinColumn;
-import javax.persistence.JoinColumns;
-import javax.persistence.ManyToOne;
-import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-import javax.persistence.Transient;
-
-/**
- *
- *
- * @author Erik Brakkee
- */
-@Entity
-@Table(name="recorded")
-public class Recording implements Serializable {
-
- private RecordingPk _id;
-
- private String _basename;
-
- private Date _progstart;
-
- private String _title;
-
- private String _subtitle;
-
- private long _filesize;
-
- protected Recording() {
- // Empty
- }
-
- /**
- * @return the id
- */
- @EmbeddedId
- public RecordingPk getId() {
- return _id;
- }
-
- /**
- * @param aId the id to set
- */
- public void setId(RecordingPk aId) {
- _id = aId;
- }
-
- /**
- * @return the basename
- */
- @Column(name="basename")
- public String getBasename() {
- return _basename;
- }
-
- /**
- * @param aBasename the basename to set
- */
- public void setBasename(String aBasename) {
- _basename = aBasename;
- }
-
- /**
- * @return the progstart
- */
- @Column(name="progstart")
- @Temporal(TemporalType.TIMESTAMP)
- public Date getProgstart() {
- return _progstart;
- }
-
- /**
- * @param aProgstart the progstart to set
- */
- public void setProgstart(Date aProgstart) {
- _progstart = aProgstart;
- }
-
- @Transient
- public Channel getChannel() {
- return _id.getChannel();
- }
-
- @Transient
- public Date getStarttime() {
- return _id.getStartTime();
- }
-
- /**
- * @return the title
- */
- @Column(name="title")
- public String getTitle() {
- return _title;
- }
-
- /**
- * @param aTitle the title to set
- */
- public void setTitle(String aTitle) {
- _title = aTitle;
- }
-
- /**
- * @return the subtitle
- */
- @Column(name="subtitle")
- public String getSubtitle() {
- return _subtitle;
- }
-
- /**
- * @param aSubtitle the subtitle to set
- */
- public void setSubtitle(String aSubtitle) {
- _subtitle = aSubtitle;
- }
-
- /**
- * @return the filesize
- */
- @Column(name="filesize")
- public long getFilesize() {
- return _filesize;
- }
-
- public void setFilesize(long aFilesize) {
- _filesize = aFilesize;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "Recording(" + _id + "," + _basename + "," + _progstart + "," + _title + "," + _subtitle + ")";
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object aObj) {
- if ( !(aObj instanceof Recording)) {
- return false;
- }
- Recording recording = (Recording)aObj;
- return _id.equals(recording._id);
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- return _id.hashCode();
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2006 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.wamblee.mythtv;
-
-import java.util.List;
-
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- *
- *
- * @author Erik Brakkee
- */
-public class RecordingDatabase {
-
- private static final Log LOG = LogFactory.getLog(RecordingDatabase.class);
-
- private EntityManager _entityManager;
-
- public RecordingDatabase(EntityManager aEntityManager) {
- _entityManager = aEntityManager;
- }
-
- public Recording findRecording(final String aName) {
- Query query = _entityManager.createQuery(
- "select r from Recording r where r.basename = ?1");
- query.setParameter(1, aName);
- List<Recording> result = query.getResultList();
- if ( result.size() > 1 ) {
- throw new RuntimeException("More than two recordings returned");
- }
- if ( result.size() == 0 ) {
- return null;
- }
- return result.get(0);
- }
-
- public void update(Recording aRecording) {
- _entityManager.merge(aRecording);
- }
-}
+++ /dev/null
-/*
- * Copyright 2006 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.wamblee.mythtv;
-
-import java.io.Serializable;
-import java.util.Date;
-
-import javax.persistence.Column;
-import javax.persistence.Embeddable;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-
-/**
- *
- *
- * @author Erik Brakkee
- */
-@Embeddable
-public class RecordingPk implements Serializable {
- public Channel _channel;
- public Date _starttime;
-
- public RecordingPk() {
- // Empty
- }
-
- /**
- * @return the channel
- */
- @ManyToOne
- @JoinColumn(name="chanid")
- public Channel getChannel() {
- return _channel;
- }
-
- /**
- * @param aChannel the channel to set
- */
- public void setChannel(Channel aChannel) {
- _channel = aChannel;
- }
-
- /**
- * @return the starttime
- */
- @Column(name="starttime")
- @Temporal(TemporalType.TIMESTAMP)
- public Date getStartTime() {
- return _starttime;
- }
-
- /**
- * @param aStarttime the starttime to set
- */
- public void setStartTime(Date aStarttime) {
- _starttime = aStarttime;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object aObj) {
- if ( aObj == null ) {
- return false;
- }
- if ( !(aObj instanceof RecordingPk)) {
- return false;
- }
- RecordingPk pk = (RecordingPk) aObj;
- return _channel.equals(pk._channel) && _starttime.equals(pk._starttime);
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- return _channel.hashCode() + _starttime.hashCode();
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "pk(" + _channel + ", " + _starttime + ")";
- }
-}
+++ /dev/null
-/*
- * Copyright 2006 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.wamblee.mythtv;
-
-/**
- *
- *
- * @author Erik Brakkee
- */
-public class ScheduleConfig {
-
- private int _intervalSeconds;
-
- public ScheduleConfig(int aIntervalSeconds) {
- _intervalSeconds = aIntervalSeconds;
- }
-
- /**
- * @return the intervalSeconds
- */
- public int getIntervalSeconds() {
- return _intervalSeconds;
- }
-
-}
+++ /dev/null
-<persistence xmlns="http://java.sun.com/xml/ns/persistence"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
- version="1.0">
- <persistence-unit name="mythtv">
- <provider>org.hibernate.ejb.HibernatePersistence</provider>
- <jta-data-source>jdbc/mythtv</jta-data-source>
- <class>org.wamblee.mythtv.Channel</class>
- <class>org.wamblee.mythtv.Recording</class>
- <exclude-unlisted-classes>true</exclude-unlisted-classes>
- <!-- properties>
- <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/>
- <property name="hibernate.show_sql" value="false"/>
- <property name="hibernate.cache.provider" value="org.hibernate.cache.EhCacheProvider"/>
- </properties -->
- </persistence-unit>
-</persistence>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
- "http://www.springframework.org/dtd/spring-beans.dtd">
-<beans>
-
- <bean id="dataSource"
- class="org.springframework.jdbc.datasource.DriverManagerDataSource">
- <property name="driverClassName"><value>com.mysql.jdbc.Driver</value></property>
- <property name="url"><value>jdbc:mysql://10.0.0.140/mythconverg</value></property>
- <property name="username"><value>mythtv</value></property>
- <property name="password"><value>mythtv</value></property>
- </bean>
-
-</beans>
\ No newline at end of file
+++ /dev/null
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
- <parent>
- <groupId>org.wamblee</groupId>
- <artifactId>wamblee-utils</artifactId>
- <version>0.2-SNAPSHOT</version>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.wamblee</groupId>
- <artifactId>wamblee-mythtv</artifactId>
- <packaging>pom</packaging>
- <name>/mythtv</name>
- <url>http://wamblee.org</url>
-
- <modules>
- <module>monitor</module>
- <module>war</module>
- <module>timer</module>
- <module>ear</module>
- </modules>
-
- <dependencies>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-war-plugin</artifactId>
- <configuration>
- <webXml>${basedir}/src/webapp/WEB-INF/web.xml</webXml>
- <warName>wamblee-mythtv</warName>
- <warSourceDirectory>src/webapp</warSourceDirectory>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
+++ /dev/null
-#!/bin/ksh
-
-USER="$1"
-PASSWORD="$2"
-
-asadmin create-jms-resource --restype javax.jms.QueueConnectionFactory jms/MythtvConnectionFactory
-asadmin create-jms-resource --restype javax.jms.Queue --property Name=Mythtv jms/MythtvTimer
-
-asadmin create-jdbc-connection-pool --datasourceclassname com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource --restype javax.sql.ConnectionPoolDataSource --allownoncomponentcallers=true --property URL=jdbc\\:mysql\\://shikra/mythconverg:password=$PASSWORD:user=$USER Mythtv
-asadmin create-jdbc-resource --connectionpoolid Mythtv jdbc/mythtv
-
+++ /dev/null
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
- <parent>
- <groupId>org.wamblee</groupId>
- <artifactId>wamblee-mythtv</artifactId>
- <version>0.2-SNAPSHOT</version>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.wamblee</groupId>
- <artifactId>wamblee-mythtv-timer</artifactId>
- <packaging>jar</packaging>
- <name>/mythtv/timer</name>
- <url>http://wamblee.org</url>
-
- <dependencies>
- <dependency>
- <groupId>org.wamblee</groupId>
- <artifactId>wamblee-mythtv-monitor</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>javax</groupId>
- <artifactId>javaee-api</artifactId>
- </dependency>
- </dependencies>
-
-</project>
+++ /dev/null
-/*
- * Copyright 2006 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.wamblee.mythtv.timer;
-
-import java.util.Collection;
-
-import javax.annotation.Resource;
-import javax.ejb.MessageDriven;
-import javax.ejb.Timeout;
-import javax.ejb.Timer;
-import javax.ejb.TimerService;
-import javax.ejb.TransactionAttribute;
-import javax.ejb.TransactionAttributeType;
-import javax.ejb.TransactionManagement;
-import javax.ejb.TransactionManagementType;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.ObjectMessage;
-import javax.jms.StreamMessage;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wamblee.general.BeanKernel;
-import org.wamblee.io.DirectoryMonitor;
-
-/**
- *
- *
- * @author Erik Brakkee
- */
-@MessageDriven(name = "TimerBean")
-// Spring's JTA transaction manager does not work with container managed transactions
-// because it uses the UserTransaction object which glassfish forbids.
-@TransactionManagement(TransactionManagementType.BEAN)
-public class TimerBean implements MessageListener {
-
- private static final Log LOG = LogFactory.getLog(TimerBean.class);
-
- @Resource
- private TimerService _timerService;
-
- /**
- * Initialization of the time interval. The initialization is done through a
- * StreamMessage with a single integer containing the time interval to use.
- */
- public void onMessage(Message aInitMessage) {
- ObjectMessage msg = (ObjectMessage) aInitMessage;
- try {
- int interval = (Integer)msg.getObject();
- LOG.info("Initializing timer with interval " + interval + " seconds");
- for (Timer timer: (Collection<Timer>)_timerService.getTimers()) {
- LOG.info("Canceling old timers: " + timer);
- timer.cancel();
- }
- _timerService.createTimer(1000, interval*1000, null);
- } catch (JMSException e) {
- throw new RuntimeException(e.getMessage());
- }
- }
-
- @Timeout
- private void timeout(Timer aTimer) {
- LOG.info("Timer expired!!!");
- try {
- DirectoryMonitor monitor = BeanKernel.getBeanFactory().find(
- DirectoryMonitor.class);
- monitor.poll();
- } catch (Throwable t) {
- LOG
- .error(
- "something terrible happend, ignoring it and hoping for the best",
- t);
- }
- }
-}
+++ /dev/null
-<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
- http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
- version="3.0">
-
- <enterprise-beans>
- <message-driven>
- <ejb-name>TimerBean</ejb-name>
- <ejb-class>org.wamblee.mythtv.timer.TimerBean</ejb-class>
- <messaging-type>javax.jms.MessageListener</messaging-type>
- <message-destination-type>javax.jms.Queue</message-destination-type>
- <message-destination-link>InternalBootstrapQueue</message-destination-link>
- </message-driven>
- </enterprise-beans>
- <assembly-descriptor>
- <message-destination>
- <message-destination-name>InternalBootstrapQueue</message-destination-name>
- </message-destination>
- </assembly-descriptor>
-</ejb-jar>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE sun-ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 EJB 3.0//EN" "http://www.sun.com/software/appserver/dtds/sun-ejb-jar_3_0-0.dtd">
-<sun-ejb-jar>
-
- <enterprise-beans>
- <ejb>
- <ejb-name>TimerBean</ejb-name>
- <jndi-name>jms/MythtvTimer</jndi-name>
- </ejb>
- <message-destination>
- <message-destination-name>InternalBootstrapQueue</message-destination-name>
- <jndi-name>jms/MythtvTimer</jndi-name>
- </message-destination>
-
- </enterprise-beans>
-
-</sun-ejb-jar>
\ No newline at end of file
+++ /dev/null
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
- <parent>
- <groupId>org.wamblee</groupId>
- <artifactId>wamblee-mythtv</artifactId>
- <version>0.2-SNAPSHOT</version>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.wamblee</groupId>
- <artifactId>wamblee-mythtv-war</artifactId>
- <packaging>war</packaging>
- <name>/mythtv/war</name>
- <url>http://wamblee.org</url>
-
- <dependencies>
- <dependency>
- <groupId>org.wamblee</groupId>
- <artifactId>wamblee-mythtv-monitor</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>javax</groupId>
- <artifactId>javaee-api</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-war-plugin</artifactId>
- <configuration>
- <webXml>${basedir}/src/webapp/WEB-INF/web.xml</webXml>
- <warName>wamblee-mythtv</warName>
- <warSourceDirectory>src/webapp</warSourceDirectory>
- <warSourceExcludes>WEB-INF/lib/*.jar</warSourceExcludes>
- <archive>
- <manifest>
- <addClasspath>true</addClasspath>
- <classpathPrefix>lib</classpathPrefix>
- </manifest>
- </archive>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
+++ /dev/null
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-
- <hibernate-mapping default-access="field">
-
- <class name="org.wamblee.mythtv.Recording" table="recorded" lazy="false">
-
- <composite-id>
- <key-many-to-one name="_channel" column="chanid" class="org.wamblee.mythtv.Channel"/>
- <key-property name="_starttime" column="starttime"></key-property>
- </composite-id>
-
- <property name="_basename" column="basename"/>
- <property name="_progstart" column="progstart"/>
- <property name="_title" column="title"/>
- <property name="_subtitle" column="subtitle"/>
- <property name="_filesize" column="filesize"/>
- </class>
-
- </hibernate-mapping>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
-
- <bean id="mythtv"
- class="org.springframework.context.support.ClassPathXmlApplicationContext">
- <constructor-arg>
- <list>
- <value>org.wamblee.mythtv.properties.xml</value>
- <value>org.wamblee.mythtv.datasource.xml</value>
- <value>org.wamblee.mythtv.hibernate.xml</value>
- <value>org.wamblee.mythtv.application.xml</value>
- </list>
- </constructor-arg>
- </bean>
-
- </beans>
\ No newline at end of file
+++ /dev/null
-
-##############################################################################
-# Class name of the beanfactory used by the crawler application
-##############################################################################
-
-org.wamblee.beanfactory.class=org.wamblee.mythtv.MythtvBeanFactory
-
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
-
- <bean id="linkDir" class="java.io.File">
- <constructor-arg>
- <value>${org.wamblee.mythtv.linkdir}</value>
- </constructor-arg>
- </bean>
-
- <bean id="monitorDir" class="java.io.File">
- <constructor-arg>
- <value>${org.wamblee.mythtv.monitordir}</value>
- </constructor-arg>
- </bean>
-
- <bean id="fileFilter" class="org.apache.oro.io.AwkFilenameFilter">
- <constructor-arg>
- <value>^[a-zA-Z0-9-_]*.mpg$</value>
- </constructor-arg>
- </bean>
-
-
- <bean id="org.wamblee.mythtv.RecordingDatabase" class="org.wamblee.mythtv.RecordingDatabase">
- <constructor-arg>
- <ref bean="entityManager"/>
- </constructor-arg>
- </bean>
-
- <bean id="org.wamblee.mythtv.LinkStructure"
- parent="transactionRequiredTemplate">
- <property name="target">
- <bean class="org.wamblee.mythtv.LinkStructure">
- <constructor-arg>
- <value>${org.wamblee.mythtv.monitordir}</value>
- </constructor-arg>
- <constructor-arg>
- <ref local="linkDir"/>
- </constructor-arg>
- <constructor-arg>
- <ref local="org.wamblee.mythtv.RecordingDatabase"/>
- </constructor-arg>
- </bean>
- </property>
- </bean>
-
- <bean id="org.wamblee.io.DirectoryMonitor" class="org.wamblee.io.DirectoryMonitor">
- <constructor-arg>
- <ref local="monitorDir"/>
- </constructor-arg>
- <constructor-arg>
- <ref local="fileFilter"/>
- </constructor-arg>
- <constructor-arg>
- <ref local="org.wamblee.mythtv.LinkStructure"/>
- </constructor-arg>
- </bean>
-
- <bean id="org.wamblee.mythtv.ScheduleConfig" class="org.wamblee.mythtv.ScheduleConfig">
- <constructor-arg>
- <value>${org.wamblee.mythtv.pollinterval}</value>
- </constructor-arg>
- </bean>
-
-</beans>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
-
- <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
- <property name="jndiName" value="${org.wamblee.mythtv.datasource}"/>
- </bean>
-</beans>
+++ /dev/null
-
-###################################################################################
-# dialect
-###################################################################################
-hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect
-
-###################################################################################
-# debugging settings: Log4j configuration can provide more detail.
-###################################################################################
-hibernate.show_sql=false
-
-###################################################################################
-# hibernate cache provider
-###################################################################################
-hibernate.cache.provider=org.hibernate.cache.EhCacheProvider
-
-###################################################################################
-# query cache
-###################################################################################
-hibernate.cache.use_query_cache=true
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
-
- <bean id="entityManager" class="org.springframework.jndi.JndiObjectFactoryBean">
- <property name="jndiName"><value>java:comp/env/persistence/mythtv</value></property>
- </bean>
-
- <bean id="transactionManager"
- class="org.springframework.transaction.jta.JtaTransactionManager">
-
- </bean>
-
- <!-- Abstract bean. Subclass this bean and specify the target property to
- wrap a bean with transactions -->
- <bean abstract="true" id="transactionRequiredTemplate"
- class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
- <property name="transactionManager" ref="transactionManager"/>
- <property name="transactionAttributes">
- <props>
- <prop key="*">PROPAGATION_REQUIRED</prop>
- </props>
- </property>
- </bean>
-
-
-</beans>
+++ /dev/null
-
-org.wamblee.mythtv.datasource=jdbc/mythtv
-org.wamblee.mythtv.pollinterval=120
-org.wamblee.mythtv.monitordir=/data/vcr
-org.wamblee.mythtv.linkdir=/data/vcr/links
-
-#org.wamblee.mythtv.monitordir=/ext/home/erik/java/workspace/utils/mythtv/testdata/input
-#org.wamblee.mythtv.linkdir=/ext/home/erik/java/workspace/utils/mythtv/testdata/links
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
-
- <bean id="propertyBean"
- class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
- <property name="locations">
- <list>
- <value>org.wamblee.mythtv.hibernate.properties</value>
- <value>org.wamblee.mythtv.properties</value>
- </list>
- </property>
- </bean>
- </beans>
\ No newline at end of file
+++ /dev/null
-Manifest-Version: 1.0\r
-Class-Path: \r
-\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0
-Servlet 2.5//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd">
-
-
-<sun-web-app>
-
- <resource-ref>
- <res-ref-name>MythtvConnectionFactory</res-ref-name>
- <jndi-name>jms/MythtvConnectionFactory</jndi-name>
- </resource-ref>
-
-</sun-web-app>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<web-app version="2.5"
- xmlns="http://java.sun.com/xml/ns/javaee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
- http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
-
- <listener>
- <listener-class>org.wamblee.mythtv.Application</listener-class>
- </listener>
-
- <persistence-context-ref>
- <persistence-context-ref-name>persistence/mythtv</persistence-context-ref-name>
- </persistence-context-ref>
-
- <resource-ref>
- <res-ref-name>MythtvConnectionFactory</res-ref-name>
- <res-type>javax.jms.ConnectionFactory</res-type>
- <res-auth>Container</res-auth>
- <res-sharing-scope>Shareable</res-sharing-scope>
- </resource-ref>
-
- <message-destination-ref>
- <message-destination-ref-name>MythtvTimer</message-destination-ref-name>
- <message-destination-type>javax.jms.Queue</message-destination-type>
- <message-destination-usage>Produces</message-destination-usage>
- <message-destination-link>InternalBootstrapQueue</message-destination-link>
- </message-destination-ref>
-
-</web-app>
<configuration>
<instrumentation>
<excludes>
- <exclude>org/wamblee/mythtv/**/*.class</exclude>
</excludes>
</instrumentation>
</configuration>
<name>!wamblee.release</name>
</property>
</activation>
- <modules>
- <module>mythtv</module>
- </modules>
</profile>
</profiles>