001: /**
002: * LibreSource
003: * Copyright (C) 2004-2008 Artenum SARL / INRIA
004: * http://www.libresource.org - contact@artenum.com
005: *
006: * This file is part of the LibreSource software,
007: * which can be used and distributed under license conditions.
008: * The license conditions are provided in the LICENSE.TXT file
009: * at the root path of the packaging that enclose this file.
010: * More information can be found at
011: * - http://dev.libresource.org/home/license
012: *
013: * Initial authors :
014: *
015: * Guillaume Bort / INRIA
016: * Francois Charoy / Universite Nancy 2
017: * Julien Forest / Artenum
018: * Claude Godart / Universite Henry Poincare
019: * Florent Jouille / INRIA
020: * Sebastien Jourdain / INRIA / Artenum
021: * Yves Lerumeur / Artenum
022: * Pascal Molli / Universite Henry Poincare
023: * Gerald Oster / INRIA
024: * Mariarosa Penzi / Artenum
025: * Gerard Sookahet / Artenum
026: * Raphael Tani / INRIA
027: *
028: * Contributors :
029: *
030: * Stephane Bagnier / Artenum
031: * Amadou Dia / Artenum-IUP Blois
032: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
033: */package org.libresource.subversion.ejb;
034:
035: import org.libresource.LibresourceResourceBase;
036:
037: import org.libresource.subversion.util.SubversionRepositoryResourceUtil;
038:
039: import javax.ejb.CreateException;
040:
041: /**
042: * A libresource Subversion repository
043: *
044: * @author <a href="mailto:jourdain@artenum.com">Sebastien Jourdain</a> - <a
045: * href="http://www.artenum.com">Artenum</a>
046: *
047: *
048: * @libresource.resource name="SubversionRepository"
049: * service="LibresourceSubversion"
050: *
051: * @ejb.finder signature= "java.util.Collection findAll()" query ="SELECT
052: * OBJECT(s) FROM SubversionRepositoryResource s"
053: * transaction-type="Supports"
054: */
055: public abstract class SubversionRepositoryResourceBean extends
056: LibresourceResourceBase {
057: /**
058: * @ejb.create-method
059: */
060: public String ejbCreate(String name, String description,
061: String commiters, String readers) throws CreateException {
062: setId(SubversionRepositoryResourceUtil.generateGUID(this ));
063: setName(name);
064: setSvnName(getId());
065: setDescription(description);
066: setCommiters(commiters);
067: setReaders(readers);
068:
069: return null;
070: }
071:
072: // persistents fields
073:
074: /**
075: * @ejb.persistent-field
076: * @ejb.interface-method
077: * @ejb.value-object match="libresource"
078: * @ejb.transaction type="Supports"
079: */
080: public abstract String getId();
081:
082: /**
083: * @ejb.persistent-field
084: * @ejb.interface-method
085: * @ejb.transaction type="Mandatory"
086: */
087: public abstract void setId(String id);
088:
089: /**
090: * @ejb.interface-method
091: * @ejb.value-object match="libresource"
092: * @ejb.transaction type="Supports"
093: */
094: public String getShortResourceName() {
095: return getName();
096: }
097:
098: /**
099: * @ejb.persistent-field
100: * @ejb.interface-method
101: * @ejb.value-object match="libresource"
102: * @ejb.transaction type="Supports"
103: */
104: public abstract String getName();
105:
106: /**
107: * @ejb.persistent-field
108: * @ejb.interface-method
109: * @ejb.transaction type="Mandatory"
110: */
111: public abstract void setName(String name);
112:
113: /**
114: * @ejb.persistent-field
115: * @ejb.interface-method
116: * @ejb.value-object match="libresource"
117: * @ejb.transaction type="Supports"
118: */
119: public abstract String getSvnName();
120:
121: /**
122: * @ejb.persistent-field
123: * @ejb.interface-method
124: * @ejb.transaction type="Mandatory"
125: */
126: public abstract void setSvnName(String svnName);
127:
128: /**
129: * @ejb.persistent-field
130: * @ejb.interface-method
131: * @ejb.value-object match="libresource"
132: * @ejb.transaction type="Supports"
133: */
134: public abstract String getDescription();
135:
136: /**
137: * @ejb.persistent-field
138: * @ejb.interface-method
139: * @ejb.transaction type="Mandatory"
140: */
141: public abstract void setDescription(String description);
142:
143: /**
144: * @ejb.persistent-field
145: * @ejb.interface-method
146: * @ejb.value-object match="libresource"
147: * @ejb.transaction type="Supports"
148: */
149: public abstract String getCommiters();
150:
151: /**
152: * @ejb.persistent-field
153: * @ejb.interface-method
154: * @ejb.transaction type="Mandatory"
155: */
156: public abstract void setCommiters(String commiters);
157:
158: /**
159: * @ejb.persistent-field
160: * @ejb.interface-method
161: * @ejb.value-object match="libresource"
162: * @ejb.transaction type="Supports"
163: */
164: public abstract String getReaders();
165:
166: /**
167: * @ejb.persistent-field
168: * @ejb.interface-method
169: * @ejb.transaction type="Mandatory"
170: */
171: public abstract void setReaders(String readers);
172:
173: /**
174: * @ejb.interface-method
175: * @ejb.value-object match="libresource"
176: * @ejb.transaction type="Supports"
177: */
178: public String[] getReaderList() {
179: if ((getReaders() == null) || getReaders().trim().equals("")
180: || getReaders().trim().equals(",")) {
181: return new String[0];
182: }
183:
184: String[] result = getReaders().trim().split(",");
185:
186: if (result.length > 0) {
187: for (int i = 0; i < result.length; i++) {
188: result[i] = result[i].trim();
189:
190: if (result[i].equals("*")) {
191: result[i] = "guest";
192: }
193: }
194: } else {
195: if (getReaders().trim().equals("*")) {
196: return new String[] { "guest" };
197: } else {
198: return new String[] { getReaders().trim() };
199: }
200: }
201:
202: return result;
203: }
204:
205: /**
206: * @ejb.interface-method
207: * @ejb.value-object match="libresource"
208: * @ejb.transaction type="Supports"
209: */
210: public String[] getCommiterList() {
211: if ((getCommiters() == null)
212: || getCommiters().trim().equals("")) {
213: return new String[0];
214: }
215:
216: String[] result = getCommiters().trim().split(",");
217:
218: if (result.length > 0) {
219: for (int i = 0; i < result.length; i++) {
220: result[i] = result[i].trim();
221:
222: if (result[i].equals("*")) {
223: result[i] = "guest";
224: } else {
225: result[i] = result[i];
226: }
227: }
228: } else {
229: if (getCommiters().trim().equals("*")) {
230: return new String[] { "guest" };
231: } else {
232: return new String[] { getCommiters().trim() };
233: }
234: }
235:
236: return result;
237: }
238: }
|