View Javadoc
1   /*
2    * Licensed to The Apereo Foundation under one or more contributor license
3    * agreements. See the NOTICE file distributed with this work for additional
4    * information regarding copyright ownership.
5    *
6    *
7    * The Apereo Foundation licenses this file to you under the Educational
8    * Community License, Version 2.0 (the "License"); you may not use this file
9    * except in compliance with the License. You may obtain a copy of the License
10   * at:
11   *
12   *   http://opensource.org/licenses/ecl2.txt
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
17   * License for the specific language governing permissions and limitations under
18   * the License.
19   *
20   */
21  package org.opencastproject.capture.admin.impl;
22  
23  import org.opencastproject.scheduler.api.Recording;
24  
25  import javax.xml.bind.annotation.XmlAccessType;
26  import javax.xml.bind.annotation.XmlAccessorType;
27  import javax.xml.bind.annotation.XmlElement;
28  import javax.xml.bind.annotation.XmlRootElement;
29  import javax.xml.bind.annotation.XmlType;
30  
31  /**
32   * A representation of an recording which stores its id, state and time-since-last-update value
33   */
34  @XmlType(name = "recording-state-update", namespace = "http://capture.admin.opencastproject.org")
35  @XmlRootElement(name = "recording-state-update", namespace = "http://capture.admin.opencastproject.org")
36  @XmlAccessorType(XmlAccessType.FIELD)
37  public class RecordingStateUpdate {
38  
39    /**
40     * The recording's ID.
41     */
42    @XmlElement(name = "name")
43    private String id;
44  
45    /**
46     * The state of the recording. This should be defined from {@link org.opencastproject.scheduler.api.RecordingState}.
47     *
48     * @see org.opencastproject.scheduler.api.RecordingState
49     */
50    @XmlElement(name = "state")
51    private String state;
52  
53    /**
54     * The number of milliseconds since the last time the recording checked in. Note that this is relative (ie, it's been
55     * 3000 ms) rather than absolute (milliseconds since 1970).
56     */
57    @XmlElement(name = "time-since-last-update")
58    private Long timeSinceLastUpdate;
59  
60    /**
61     * Required zero-arg. constructor. Do not use
62     */
63    public RecordingStateUpdate() {
64    }
65  
66    /**
67     * Builds an RecordingStateUpdate object about the Recording r. This calculates the time delta for you.
68     *
69     * @param r
70     *          The recording you wish to know more information about
71     */
72    public RecordingStateUpdate(Recording r) {
73      id = r.getID();
74      state = r.getState();
75      timeSinceLastUpdate = System.currentTimeMillis() - r.getLastCheckinTime();
76    }
77  
78    /**
79     * Returns the recording id.
80     *
81     * @return the id
82     */
83    public String getId() {
84      return id;
85    }
86  
87    /**
88     * Reuturns the recording state.
89     *
90     * @return the state
91     */
92    public String getState() {
93      return state;
94    }
95  
96    /**
97     * Returns the time where the recording was last updated.
98     *
99     * @return the update time
100    */
101   public Long getTimeSinceLastUpdate() {
102     return timeSinceLastUpdate;
103   }
104 
105 }