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  
22  package org.opencastproject.distribution.api;
23  
24  import org.opencastproject.job.api.AbstractJobProducer;
25  import org.opencastproject.security.api.OrganizationDirectoryService;
26  import org.opencastproject.security.api.SecurityService;
27  import org.opencastproject.security.api.TrustedHttpClient;
28  import org.opencastproject.security.api.UserDirectoryService;
29  import org.opencastproject.serviceregistry.api.ServiceRegistry;
30  import org.opencastproject.workspace.api.Workspace;
31  
32  import java.io.File;
33  
34  public abstract class AbstractDistributionService extends AbstractJobProducer {
35  
36    /** Path to the distribution directory */
37    protected File distributionDirectory = null;
38  
39    /** this media download service's base URL */
40    protected String serviceUrl = null;
41  
42    /** The remote service registry */
43    protected ServiceRegistry serviceRegistry = null;
44  
45    /** The workspace reference */
46    protected Workspace workspace = null;
47  
48    /** The security service */
49    protected SecurityService securityService = null;
50  
51    /** The user directory service */
52    protected UserDirectoryService userDirectoryService = null;
53  
54    /** The organization directory service */
55    protected OrganizationDirectoryService organizationDirectoryService = null;
56  
57    protected TrustedHttpClient trustedHttpClient = null;
58  
59    /** The distribution channel for this service */
60    protected String distributionChannel = null;
61  
62    protected AbstractDistributionService(String jobType) {
63      super(jobType);
64    }
65  
66    /**
67     * Callback for the OSGi environment to set the workspace reference.
68     *
69     * @param workspace
70     *          the workspace
71     */
72    public void setWorkspace(Workspace workspace) {
73      this.workspace = workspace;
74    }
75  
76    /**
77     * Callback for the OSGi environment to set the service registry reference.
78     *
79     * @param serviceRegistry
80     *          the service registry
81     */
82    public void setServiceRegistry(ServiceRegistry serviceRegistry) {
83      this.serviceRegistry = serviceRegistry;
84    }
85  
86    /**
87     * {@inheritDoc}
88     *
89     * @see org.opencastproject.job.api.AbstractJobProducer#getServiceRegistry()
90     */
91    @Override
92    protected ServiceRegistry getServiceRegistry() {
93      return serviceRegistry;
94    }
95  
96    /**
97     * Callback for setting the security service.
98     *
99     * @param securityService
100    *          the securityService to set
101    */
102   public void setSecurityService(SecurityService securityService) {
103     this.securityService = securityService;
104   }
105 
106   /**
107    * Callback for setting the user directory service.
108    *
109    * @param userDirectoryService
110    *          the userDirectoryService to set
111    */
112   public void setUserDirectoryService(UserDirectoryService userDirectoryService) {
113     this.userDirectoryService = userDirectoryService;
114   }
115 
116   /**
117    * Sets a reference to the organization directory service.
118    *
119    * @param organizationDirectory
120    *          the organization directory
121    */
122   public void setOrganizationDirectoryService(OrganizationDirectoryService organizationDirectory) {
123     this.organizationDirectoryService = organizationDirectory;
124   }
125 
126   /**
127    * {@inheritDoc}
128    *
129    * @see org.opencastproject.job.api.AbstractJobProducer#getSecurityService()
130    */
131   @Override
132   protected SecurityService getSecurityService() {
133     return securityService;
134   }
135 
136   /**
137    * {@inheritDoc}
138    *
139    * @see org.opencastproject.job.api.AbstractJobProducer#getUserDirectoryService()
140    */
141   @Override
142   protected UserDirectoryService getUserDirectoryService() {
143     return userDirectoryService;
144   }
145 
146   /**
147    * {@inheritDoc}
148    *
149    * @see org.opencastproject.job.api.AbstractJobProducer#getOrganizationDirectoryService()
150    */
151   @Override
152   protected OrganizationDirectoryService getOrganizationDirectoryService() {
153     return organizationDirectoryService;
154   }
155 
156   /**
157    * Callback for the OSGi environment to set the trusted http clientreference.
158    *
159    * @param httpClient
160    *          the trusted http client
161    */
162   public void setTrustedHttpClient(TrustedHttpClient httpClient) {
163     this.trustedHttpClient = httpClient;
164   }
165 
166   protected TrustedHttpClient getTrustedHttpClient() {
167     return trustedHttpClient;
168   }
169 }