KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > node > db > NodeDaoService


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.repo.node.db;
18
19 import java.util.Collection JavaDoc;
20 import java.util.List JavaDoc;
21
22 import org.alfresco.repo.domain.ChildAssoc;
23 import org.alfresco.repo.domain.Node;
24 import org.alfresco.repo.domain.NodeAssoc;
25 import org.alfresco.repo.domain.NodeStatus;
26 import org.alfresco.repo.domain.Store;
27 import org.alfresco.service.cmr.dictionary.InvalidTypeException;
28 import org.alfresco.service.namespace.QName;
29
30 /**
31  * Service layer accessing persistent <b>node</b> entities directly
32  *
33  * @author Derek Hulley
34  */

35 public interface NodeDaoService
36 {
37     /**
38      * Are there any pending changes which must be synchronized with the store?
39      *
40      * @return true => changes are pending
41      */

42     public boolean isDirty();
43     
44     /**
45      * Fetch a list of all stores in the repository
46      *
47      * @return Returns a list of stores
48      */

49     public List JavaDoc<Store> getStores();
50     
51     /**
52      * Creates a unique store for the given protocol and identifier combination
53      *
54      * @param protocol a protocol, e.g. {@link org.alfresco.service.cmr.repository.StoreRef#PROTOCOL_WORKSPACE}
55      * @param identifier a protocol-specific identifier
56      * @return Returns the new persistent entity
57      */

58     public Store createStore(String JavaDoc protocol, String JavaDoc identifier);
59     
60     /**
61      * @param protocol the protocol that the store serves
62      * @param identifier the protocol-specific identifer
63      * @return Returns a store with the given values or null if one doesn't exist
64      */

65     public Store getStore(String JavaDoc protocol, String JavaDoc identifier);
66
67     /**
68      * @param store the store to which the node must belong
69      * @param id the node store-unique identifier
70      * @param nodeTypeQName the type of the node
71      * @return Returns a new node of the given type and attached to the store
72      * @throws InvalidTypeException if the node type is invalid or if the node type
73      * is not a valid real node
74      */

75     public Node newNode(Store store, String JavaDoc id, QName nodeTypeQName) throws InvalidTypeException;
76     
77     /**
78      * @param protocol the store protocol
79      * @param identifier the store identifier for the given protocol
80      * @param id the store-specific node identifier
81      * @return Returns the <b>node</b> entity
82      */

83     public Node getNode(String JavaDoc protocol, String JavaDoc identifier, String JavaDoc id);
84     
85     /**
86      * Deletes the node instance, taking care of any cascades that are required over
87      * and above those provided by the persistence mechanism.
88      * <p>
89      * A caller must able to delete the node using this method and not have to follow
90      * up with any other ancillary deletes
91      *
92      * @param node the entity to delete
93      * @param cascade true if the assoc deletions must cascade to primary child nodes
94      */

95     public void deleteNode(Node node, boolean cascade);
96     
97     /**
98      * @return Returns the persisted and filled association
99      *
100      * @see ChildAssoc
101      */

102     public ChildAssoc newChildAssoc(
103             Node parentNode,
104             Node childNode,
105             boolean isPrimary,
106             QName assocTypeQName,
107             QName qname);
108
109     /**
110      * @return Returns a matching association or null if one was not found
111      *
112      * @see ChildAssoc
113      */

114     public ChildAssoc getChildAssoc(
115             Node parentNode,
116             Node childNode,
117             QName assocTypeQName,
118             QName qname);
119             
120     
121     /**
122      * @param assoc the child association to remove
123      * @param cascade true if the assoc deletions must cascade to primary child nodes
124      */

125     public void deleteChildAssoc(ChildAssoc assoc, boolean cascade);
126     
127     /**
128      * Finds the association between the node's primary parent and the node itself
129      *
130      * @param node the child node
131      * @return Returns the primary <code>ChildAssoc</code> instance where the given node is the child.
132      * The return value could be null for a root node - but ONLY a root node
133      */

134     public ChildAssoc getPrimaryParentAssoc(Node node);
135     
136     /**
137      * @return Returns the persisted and filled association
138      * @see NodeAssoc
139      */

140     public NodeAssoc newNodeAssoc(
141             Node sourceNode,
142             Node targetNode,
143             QName assocTypeQName);
144     
145     /**
146      * @return Returns the node association or null if not found
147      */

148     public NodeAssoc getNodeAssoc(
149             Node sourceNode,
150             Node targetNode,
151             QName assocTypeQName);
152     
153     /**
154      * @return Returns the target nodes for the association
155      */

156     public Collection JavaDoc<Node> getNodeAssocTargets(Node sourceNode, QName assocTypeQName);
157     
158     /**
159      * @return Returns the source nodes for the association
160      */

161     public Collection JavaDoc<Node> getNodeAssocSources(Node targetNode, QName assocTypeQName);
162     
163     /**
164      * @param assoc the node association to remove
165      */

166     public void deleteNodeAssoc(NodeAssoc assoc);
167     
168     /**
169      * Gets the node's status. If the node <i>never</i> existed, then
170      * <code>null</code> is returned.
171      *
172      * @param protocol the store protocol
173      * @param identifier the store identifier for the given protocol
174      * @param id the store-specific node status identifier
175      * @return Returns the node status if the node exists or once existed, otherwise
176      * returns <code>null</code>.
177      */

178     public NodeStatus getNodeStatus(String JavaDoc protocol, String JavaDoc identifier, String JavaDoc id);
179     
180     /**
181      * Fetch all content data strings. These are all string values that begin
182      * with <b>contentUrl=</b>.
183      *
184      * @return Returns the string values for content data
185      */

186     public List JavaDoc<String JavaDoc> getContentDataStrings();
187 }
188
Popular Tags