View Javadoc

1   /*
2    * This file is part of Domingo
3    * an Open Source Java-API to Lotus Notes/Domino
4    * hosted at http://domingo.sourceforge.net
5    *
6    * Copyright (c) 2003-2007 Beck et al. projects GmbH Munich, Germany (http://www.bea.de)
7    *
8    * This library is free software; you can redistribute it and/or
9    * modify it under the terms of the GNU Lesser General Public
10   * License as published by the Free Software Foundation; either
11   * version 2.1 of the License, or (at your option) any later version.
12   *
13   * This library is distributed in the hope that it will be useful,
14   * but WITHOUT ANY WARRANTY; without even the implied warranty of
15   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16   * Lesser General Public License for more details.
17   *
18   * You should have received a copy of the GNU Lesser General Public
19   * License along with this library; if not, write to the Free Software
20   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21   */
22  
23  package de.bea.domingo.http;
24  
25  import java.io.IOException;
26  import java.util.Calendar;
27  import java.util.Iterator;
28  import java.util.List;
29  
30  import de.bea.domingo.DAgent;
31  import de.bea.domingo.DBase;
32  import de.bea.domingo.DDatabase;
33  import de.bea.domingo.DDocument;
34  import de.bea.domingo.DForm;
35  import de.bea.domingo.DNotesException;
36  import de.bea.domingo.DNotesMonitor;
37  import de.bea.domingo.DProfileDocument;
38  import de.bea.domingo.DSession;
39  import de.bea.domingo.DView;
40  
41  /***
42   *
43   * @author <a href=mailto:kriede@users.sourceforge.net>Kurt Riede</a>
44   */
45  public final class DatabaseHttp extends BaseHttp implements DDatabase {
46  
47      /*** serial version ID for serialization. */
48      private static final long serialVersionUID = 1484836582323425207L;
49  
50      private String fFilePath;
51  
52      private String fReplicaId;
53  
54      /***
55       * Private Constructor for this class.
56       *
57       * @param factory the controlling factory
58       * @param session the session that produced the database
59       * @param database Notes database object
60       * @param monitor the monitor that handles logging
61       * @param forceOpen whether the database should be forced to be open or not
62       * @see lotus.domino.Database
63       */
64      private DatabaseHttp(final NotesHttpFactory factory, final DBase parent, final String filePath,
65              final DNotesMonitor monitor) {
66          super(factory, parent, monitor);
67          fFilePath = filePath.replace('//', '/');
68          readDatabase();
69      }
70  
71      /***
72       * Factory method for instances of this class.
73       *
74       * @param factory the controlling factory
75       * @param parent the session that produced the database
76       * @param filePath file/path to the Notes database
77       * @param monitor the monitor that handles logging
78       *
79       * @return Returns a DDatabase instance of type DatabaseProxy
80       */
81      static DDatabase getInstance(final NotesHttpFactory factory, final DBase parent, final String filePath,
82              final DNotesMonitor monitor) {
83          return new DatabaseHttp(factory, parent, filePath, monitor);
84      }
85  
86      /***
87       * Creates a connection to the server and reads necessary database
88       * properties.
89       */
90      private void readDatabase() {
91          // TODO create a connection to the server and read necessary database
92          // TODO do we reallly need this?
93          // properties
94      }
95  
96      /***
97       * @see java.lang.Object#toString()
98       * @return the file/path
99       */
100     public String toString() {
101         return fFilePath;
102     }
103 
104     /***
105      * {@inheritDoc}
106      *
107      * @see de.bea.domingo.DDatabase#getSession()
108      */
109     public DSession getSession() {
110         return (DSession) getParent();
111     }
112 
113     /***
114      * {@inheritDoc}
115      *
116      * @see de.bea.domingo.DDatabase#replicate(java.lang.String)
117      */
118     public boolean replicate(final String server) {
119         // TODO Auto-generated method stub
120         return false;
121     }
122 
123     /***
124      * {@inheritDoc}
125      *
126      * @see de.bea.domingo.DDatabase#remove()
127      */
128     public boolean remove() {
129         // TODO Auto-generated method stub
130         return false;
131     }
132 
133     /***
134      * {@inheritDoc}
135      *
136      * @see de.bea.domingo.DDatabase#getAllDocuments()
137      */
138     public Iterator getAllDocuments() {
139         // TODO Auto-generated method stub
140         return null;
141     }
142 
143     /***
144      * {@inheritDoc}
145      *
146      * @see de.bea.domingo.DDatabase#getDocumentByUNID(java.lang.String)
147      */
148     public DDocument getDocumentByUNID(final String universalId) {
149         if (universalId != null && universalId.length() > 0) {
150             return DocumentHttp.getInstance(getFactory(), getParent(), universalId, getMonitor());
151         } else {
152             return null;
153         }
154     }
155 
156     /***
157      * {@inheritDoc}
158      *
159      * @see de.bea.domingo.DDatabase#getDocumentByID(java.lang.String)
160      */
161     public DDocument getDocumentByID(final String noteId) {
162         // TODO Auto-generated method stub
163         return null;
164     }
165 
166     /***
167      * {@inheritDoc}
168      *
169      * @see de.bea.domingo.DDatabase#getProfileDocument(java.lang.String,
170      *      java.lang.String)
171      */
172     public DProfileDocument getProfileDocument(final String profileName, final String profileKey) {
173         // TODO Auto-generated method stub
174         return null;
175     }
176 
177     /***
178      * {@inheritDoc}
179      *
180      * @see de.bea.domingo.DDatabase#createDocument()
181      */
182     public DDocument createDocument() {
183         return DocumentHttp.getInstance(getFactory(), this, getMonitor());
184     }
185 
186     /***
187      * {@inheritDoc}
188      *
189      * @see de.bea.domingo.DDatabase#getView(java.lang.String)
190      */
191     public DView getView(final String viewName) {
192         return ViewHttp.getInstance(getFactory(), this, viewName, getMonitor());
193     }
194 
195     /***
196      * {@inheritDoc}
197      *
198      * @see de.bea.domingo.DDatabase#getFilePath()
199      */
200     public String getFilePath() {
201         return fFilePath;
202     }
203 
204     /***
205      * {@inheritDoc}
206      *
207      * @see de.bea.domingo.DDatabase#getFileName()
208      */
209     public String getFileName() {
210         final int pos = fFilePath.indexOf("/");
211         if (pos >= 0) {
212             return fFilePath.substring(pos + 1);
213         }
214         return fFilePath;
215     }
216 
217     /***
218      * {@inheritDoc}
219      *
220      * @see de.bea.domingo.DDatabase#createDatabaseFromTemplate(java.lang.String,
221      *      java.lang.String, boolean)
222      */
223     public DDatabase createDatabaseFromTemplate(final String serverName, final String databaseName, final boolean inherit)
224             throws DNotesException {
225         final String templatePath = fFilePath;
226         final String path = databaseName.replace('//', '/');
227         final String bs;
228         try {
229             bs = execute("cmd=CreateDatabaseFromTemplate&template=" + templatePath + "&file=" + path);
230         } catch (IOException e) {
231             throw new NotesHttpRuntimeException("Cannot create database from template: " + path, e);
232         }
233         if (bs.indexOf("Database created") >= 0) {
234             return DatabaseHttp.getInstance(getFactory(), this, databaseName, getMonitor());
235         }
236         return null;
237     }
238 
239     /***
240      * {@inheritDoc}
241      *
242      * @see de.bea.domingo.DDatabase#createReplica(java.lang.String,
243      *      java.lang.String)
244      */
245     public DDatabase createReplica(final String server, final String fPath) throws DNotesException {
246         final String databasePath = fFilePath.replace('//', '/');
247         final String path = fPath.replace('//', '/');
248         final String bs;
249         try {
250             bs = execute("cmd=CreateReplica&database=" + databasePath + "&file=" + path);
251         } catch (IOException e) {
252             throw new NotesHttpRuntimeException("Cannot create replica: " + path, e);
253         }
254         if (bs.indexOf("Database created") >= 0) {
255             return DatabaseHttp.getInstance(getFactory(), this, path, getMonitor());
256         }
257         return null;
258     }
259 
260     /***
261      * {@inheritDoc}
262      *
263      * @see de.bea.domingo.DDatabase#getCurrentAccessLevel()
264      */
265     public int getCurrentAccessLevel() {
266         // TODO Auto-generated method stub
267         return 0;
268     }
269 
270     /***
271      * {@inheritDoc}
272      *
273      * @see de.bea.domingo.DDatabase#getServer()
274      */
275     public String getServer() {
276         // TODO Auto-generated method stub
277         return null;
278     }
279 
280     /***
281      * {@inheritDoc}
282      *
283      * @see de.bea.domingo.DDatabase#getAgent(java.lang.String)
284      */
285     public DAgent getAgent(final String name) {
286         return AgentHttp.getInstance(getFactory(), this, getMonitor(), name);
287     }
288 
289     /***
290      * {@inheritDoc}
291      *
292      * @see de.bea.domingo.DDatabase#isPublicAddressBook()
293      */
294     public boolean isPublicAddressBook() {
295         // TODO Auto-generated method stub
296         return false;
297     }
298 
299     /***
300      * {@inheritDoc}
301      *
302      * @see de.bea.domingo.DDatabase#isPrivateAddressBook()
303      */
304     public boolean isPrivateAddressBook() {
305         // TODO Auto-generated method stub
306         return false;
307     }
308 
309     /***
310      * {@inheritDoc}
311      *
312      * @see de.bea.domingo.DDatabase#isOpen()
313      */
314     public boolean isOpen() {
315         // TODO Auto-generated method stub
316         return false;
317     }
318 
319     /***
320      * {@inheritDoc}
321      *
322      * @see de.bea.domingo.DDatabase#open()
323      */
324     public boolean open() {
325         // TODO Auto-generated method stub
326         return false;
327     }
328 
329     /***
330      * {@inheritDoc}
331      *
332      * @see de.bea.domingo.DDatabase#getCategories()
333      */
334     public String getCategories() {
335         // TODO Auto-generated method stub
336         return null;
337     }
338 
339     /***
340      * {@inheritDoc}
341      *
342      * @see de.bea.domingo.DDatabase#isDelayUpdates()
343      */
344     public boolean isDelayUpdates() {
345         // TODO Auto-generated method stub
346         return false;
347     }
348 
349     /***
350      * {@inheritDoc}
351      *
352      * @see de.bea.domingo.DDatabase#getReplicaID()
353      */
354     public String getReplicaID() {
355         return fReplicaId;
356     }
357 
358     /***
359      * {@inheritDoc}
360      *
361      * @see de.bea.domingo.DDatabase#getSizeQuota()
362      */
363     public int getSizeQuota() {
364         // TODO Auto-generated method stub
365         return 0;
366     }
367 
368     /***
369      * {@inheritDoc}
370      *
371      * @see de.bea.domingo.DDatabase#getTemplateName()
372      */
373     public String getTemplateName() {
374         // TODO Auto-generated method stub
375         return null;
376     }
377 
378     /***
379      * {@inheritDoc}
380      *
381      * @see de.bea.domingo.DDatabase#getTitle()
382      */
383     public String getTitle() {
384         // TODO Auto-generated method stub
385         return null;
386     }
387 
388     /***
389      * {@inheritDoc}
390      *
391      * @see de.bea.domingo.DDatabase#setTitle(String)
392      */
393     public void setTitle(final String title) {
394         // TODO Auto-generated method stub
395     }
396 
397     /***
398      * {@inheritDoc}
399      *
400      * @see de.bea.domingo.DDatabase#getDesignTemplateName()
401      */
402     public String getDesignTemplateName() {
403         // TODO Auto-generated method stub
404         return null;
405     }
406 
407     /***
408      * {@inheritDoc}
409      *
410      * @see de.bea.domingo.DDatabase#search(java.lang.String,
411      *      java.util.Calendar, int)
412      */
413     public Iterator search(final String formula, final Calendar dt, final int max) {
414         // TODO Auto-generated method stub
415         return null;
416     }
417 
418     /***
419      * {@inheritDoc}
420      *
421      * @see de.bea.domingo.DDatabase#search(java.lang.String,
422      *      java.util.Calendar)
423      */
424     public Iterator search(final String formula, final Calendar dt) {
425         // TODO Auto-generated method stub
426         return null;
427     }
428 
429     /***
430      * {@inheritDoc}
431      *
432      * @see de.bea.domingo.DDatabase#search(java.lang.String)
433      */
434     public Iterator search(final String formula) {
435         // TODO Auto-generated method stub
436         return null;
437     }
438 
439     /***
440      * {@inheritDoc}
441      *
442      * @see de.bea.domingo.DDatabase#isFTIndexed()
443      */
444     public boolean isFTIndexed() {
445         // TODO Auto-generated method stub
446         return false;
447     }
448 
449     /***
450      * {@inheritDoc}
451      *
452      * @see de.bea.domingo.DDatabase#updateFTIndex(boolean)
453      */
454     public void updateFTIndex(final boolean create) {
455         // TODO Auto-generated method stub
456     }
457 
458     /***
459      * {@inheritDoc}
460      *
461      * @see de.bea.domingo.DDatabase#fullTextSearchRange(java.lang.String, int,
462      *      int, int, int)
463      */
464     public Iterator fullTextSearchRange(final String query, final int max, final int sortopt, final int otheropt,
465             final int start) {
466         // TODO Auto-generated method stub
467         return null;
468     }
469 
470     /***
471      * {@inheritDoc}
472      *
473      * @see de.bea.domingo.DDatabase#fullTextSearch(java.lang.String)
474      */
475     public Iterator fullTextSearch(final String query) {
476         // TODO Auto-generated method stub
477         return null;
478     }
479 
480     /***
481      * {@inheritDoc}
482      *
483      * @see de.bea.domingo.DDatabase#fullTextSearch(java.lang.String, int)
484      */
485     public Iterator fullTextSearch(final String query, final int max) {
486         // TODO Auto-generated method stub
487         return null;
488     }
489 
490     /***
491      * {@inheritDoc}
492      *
493      * @see de.bea.domingo.DDatabase#fullTextSearch(java.lang.String, int, int,
494      *      int)
495      */
496     public Iterator fullTextSearch(final String query, final int max, final int sortopt, final int otheropt) {
497         // TODO Auto-generated method stub
498         return null;
499     }
500 
501     /***
502      * {@inheritDoc}
503      *
504      * @see de.bea.domingo.DDatabase#isDocumentLockingEnabled()
505      */
506     public boolean isDocumentLockingEnabled() {
507         // TODO Auto-generated method stub
508         return false;
509     }
510 
511     /***
512      * {@inheritDoc}
513      *
514      * @see de.bea.domingo.DDatabase#setDocumentLockingEnabled(boolean)
515      */
516     public void setDocumentLockingEnabled(final boolean flag) {
517         // TODO Auto-generated method stub
518 
519     }
520 
521     /***
522      * {@inheritDoc}
523      *
524      * @see de.bea.domingo.DDatabase#getFolderReferencesEnabled()
525      */
526     public boolean getFolderReferencesEnabled() {
527         // TODO Auto-generated method stub
528         return false;
529     }
530 
531     /***
532      * {@inheritDoc}
533      *
534      * @see de.bea.domingo.DDatabase#setFolderReferencesEnabled(boolean)
535      */
536     public void setFolderReferencesEnabled(final boolean flag) {
537         // TODO Auto-generated method stub
538     }
539 
540     /***
541      * {@inheritDoc}
542      *
543      * @see de.bea.domingo.DDatabase#getViews()
544      */
545     public List getViews() {
546         // TODO Auto-generated method stub
547         return null;
548     }
549 
550     /***
551      * {@inheritDoc}
552      * @see de.bea.domingo.DDatabase#getForm(java.lang.String)
553      */
554     public DForm getForm(final String name) {
555         // TODO Auto-generated method stub
556         return null;
557     }
558 
559     /***
560      * {@inheritDoc}
561      * @see de.bea.domingo.DDatabase#getForms()
562      */
563     public List getForms() {
564         // TODO Auto-generated method stub
565         return null;
566     }
567 }