KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > outerj > daisy > repository > commonimpl > DocumentStrategy


1 /*
2  * Copyright 2004 Outerthought bvba and Schaubroeck nv
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.outerj.daisy.repository.commonimpl;
17
18 import org.outerj.daisy.repository.RepositoryException;
19 import org.outerj.daisy.repository.LockType;
20 import org.outerj.daisy.repository.VersionState;
21 import org.outerj.daisy.repository.Document;
22
23 import java.io.InputStream JavaDoc;
24
25 /**
26  * Allows to customise some of the behaviour of the {@link CommonRepository}, and especially
27  * {@link DocumentImpl}.
28  *
29  * <p>The typical use of this is to provide two implementations of the repository API's:
30  * one for local (in-server) use, and one for remote (= client) use, by only having to
31  * implement twice those aspects which differ in each implementation.
32  *
33  * <p>The most important difference between the client and server API implementations
34  * will be how they load and store entities (such as Document objects): the client API
35  * implementation will do this by contacting the server, the server implementation will
36  * do this by using its persistence mechanisms (such as an RDBMS).
37  *
38  * <p>Note that this API is not really meant for public consumption, and the correct
39  * workings of its implementations (especially the server-side one) are crucial for
40  * the correct operation of the repository. It is important that the strategy implementation
41  * correctly initialiases, updates and interprets the internal state of the objects it handles.
42  *
43  * <p>Certain methonds, like {@link #load(AuthenticatedUser,long,long,long)}
44  * and {@link #store(org.outerj.daisy.repository.commonimpl.DocumentImpl)} need to check
45  * if the user has the rights to perform this operation. This is especially true for the serverside
46  * implementation, the client side implementation doesn't need to do this as it will contact the
47  * server which will automatically do this checks.
48  *
49  * <p>Certain methods, like {@link #store(org.outerj.daisy.repository.commonimpl.DocumentImpl)} might
50  * also need to send out events to eventlisteners.
51  */

52 public interface DocumentStrategy {
53     public Document load(AuthenticatedUser user, long documentId, long branchId, long languageId) throws RepositoryException;
54
55     /**
56      * Stores a document. After successful storage, the document object status should be
57      * updates, i.e. the lastModified and lastModifier parts should be updated, and some
58      * dirty-indication flags should be reset.
59      */

60     public void store(DocumentImpl document) throws RepositoryException;
61
62     /**
63      *
64      * @param startVersionId -1 for last version, -2 for live version
65      */

66     public Document createVariant(long documentId, long startBranchId, long startLanguageId, long startVersionId, long newBranchId, long newLanguageId, AuthenticatedUser user) throws RepositoryException;
67
68     public AvailableVariantImpl[] getAvailableVariants(long documentId, AuthenticatedUser user) throws RepositoryException;
69
70     public void deleteDocument(long documentId, AuthenticatedUser user) throws RepositoryException;
71
72     public void deleteVariant(long documentId, long branchId, long languageId, AuthenticatedUser user) throws RepositoryException;
73
74     public VersionImpl loadVersion(DocumentVariantImpl documentVariant, long versionId) throws RepositoryException;
75
76     /**
77      * Loads the additional information skipped when the version was loaded via
78      * {@link #loadShallowVersions(org.outerj.daisy.repository.commonimpl.DocumentVariantImpl)}.
79      */

80     public void completeVersion(DocumentVariantImpl variant, VersionImpl version) throws RepositoryException;
81
82     /**
83      * Loads all Version objects for this document as shallow Version objects (i.e. without
84      * their full content, but only the data necessary to show a version overview table).
85      */

86     public VersionImpl[] loadShallowVersions(DocumentVariantImpl variant) throws RepositoryException;
87
88     public void setVersionState(DocumentImpl document, VersionImpl version, VersionState versionState) throws RepositoryException;
89
90     public InputStream JavaDoc getBlob(long documentId, long branchId, long languageId, long versionId, long partTypeId, AuthenticatedUser user) throws RepositoryException;
91
92     /**
93      * This method does not check access rights (unlike {@link #getBlob(long, long, long, long, long, AuthenticatedUser)},
94      * because this one is only intended for use by Part objects.
95      */

96     public InputStream JavaDoc getBlob(String JavaDoc blobKey) throws RepositoryException;
97
98     /**
99      * Tries to create a lock on the document. If there was alread a pessimitic lock on
100      * the document, this method will return a LockInfo object containing information about
101      * that lock, so it is important to check the info in the LockInfo object to know if
102      * the lock was successful.
103      */

104     public LockInfoImpl lock(DocumentVariantImpl documentVariant, long duration, LockType lockType) throws RepositoryException;
105
106     public LockInfoImpl getLockInfo(DocumentVariantImpl documentVariant) throws RepositoryException;
107
108     public LockInfoImpl releaseLock(DocumentVariantImpl documentVariant) throws RepositoryException;
109
110     public String JavaDoc getClientVersion(AuthenticatedUser user);
111
112     public String JavaDoc getServerVersion(AuthenticatedUser user);
113 }
114
Popular Tags