KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > services > shares > AppsShareBaseService


1 //
2
// ____.
3
// __/\ ______| |__/\. _______
4
// __ .____| | \ | +----+ \
5
// _______| /--| | | - \ _ | : - \_________
6
// \\______: :---| : : | : | \________>
7
// |__\---\_____________:______: :____|____:_____\
8
// /_____|
9
//
10
// . . . i n j a h i a w e t r u s t . . .
11
//
12
//
13
// AppsShareBaseService
14
//
15
// NK 31.04.2001
16
//
17
package org.jahia.services.shares;
18
19 import org.jahia.data.JahiaDOMObject;
20 import org.jahia.data.applications.ApplicationBean;
21 import org.jahia.exceptions.JahiaException;
22 import org.jahia.services.sites.JahiaSite;
23
24 import java.util.Enumeration JavaDoc;
25 import java.util.Vector JavaDoc;
26
27 /**
28  * Application Share Service
29  *
30  * @author Khue ng
31  */

32 public class AppsShareBaseService extends AppsShareService {
33     private static org.apache.log4j.Logger logger =
34             org.apache.log4j.Logger.getLogger (AppsShareBaseService.class);
35
36     private static AppsShareBaseService m_Instance = null;
37
38     //--------------------------------------------------------------------------
39
protected AppsShareBaseService () throws JahiaException {
40         logger.info ("***** Starting the Apps Share Service *****");
41     }
42
43
44     //--------------------------------------------------------------------------
45
public static synchronized AppsShareBaseService getInstance () throws JahiaException {
46
47         if (m_Instance == null) {
48             m_Instance = new AppsShareBaseService ();
49         }
50         return m_Instance;
51     }
52
53     //--------------------------------------------------------------------------
54
/**
55      * return an enumeration of sites' key having access to a gived app
56      *
57      * @param ApplicationBean, the app
58      *
59      * @return Enumeration, an enumeration of sites' keys
60      */

61     public Enumeration JavaDoc getSites (ApplicationBean app) throws JahiaException {
62
63         Vector JavaDoc vec = new Vector JavaDoc ();
64         if (app == null) {
65             return vec.elements ();
66         }
67         return AppsSharePersistance.getInstance ().dbGetSites (app.getID ());
68     }
69
70
71     //--------------------------------------------------------------------------
72
/**
73      * add a share between a site and an application
74      *
75      * @param JahiaSite, the site
76      * @param ApplicationBean, the app
77      */

78     public void addShare (JahiaSite site, ApplicationBean app) throws JahiaException {
79
80         AppsSharePersistance.getInstance ().dbAddShare (app.getID (), site.getID ());
81
82     }
83
84
85     //--------------------------------------------------------------------------
86
/**
87      * remove a share between a site and an application
88      *
89      * @param JahiaSite, the site
90      * @param ApplicationBean, the app
91      */

92     public void removeShare (JahiaSite site, ApplicationBean app) throws JahiaException {
93
94         AppsSharePersistance.getInstance ().dbRemoveShare (app.getID (), site.getID ());
95
96     }
97
98
99     //--------------------------------------------------------------------------
100
/**
101      * remove all share referencing a site
102      *
103      * @param JahiaSite, the site
104      */

105     public void removeShares (JahiaSite site) throws JahiaException {
106
107         AppsSharePersistance.getInstance ().dbSiteRemoveShares (site.getID ());
108
109     }
110
111
112     //--------------------------------------------------------------------------
113
/**
114      * remove all share referencing an app
115      *
116      * @param ApplicationBean, the app
117      */

118     public void removeShares (ApplicationBean app) throws JahiaException {
119
120         AppsSharePersistance.getInstance ().dbAppRemoveShares (app.getID ());
121
122     }
123
124
125     //--------------------------------------------------------------------------
126
/**
127      * Return a share between a site and an application
128      *
129      * @param JahiaSite, the site
130      * @param ApplicationBean, the app
131      */

132     public AppShare getShare (JahiaSite site, ApplicationBean app) throws JahiaException {
133
134         return AppsSharePersistance.getInstance ().dbGetShare (app.getID (), site.getID ());
135
136     }
137
138
139     //--------------------------------------------------------------------------
140
/**
141      * return a DOM document of application shares content
142      *
143      * @param int the site id
144      *
145      * @return JahiaDOMObject a DOM representation of this object
146      *
147      * @author NK
148      */

149     public JahiaDOMObject getApplicationSharesAsDOM (int siteID)
150             throws JahiaException {
151         return AppsSharePersistance.getInstance ().getApplicationSharesAsDOM (siteID);
152     }
153
154
155 }
156
157
Popular Tags