source: ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/ComponentRegistry.java @ 4098

Last change on this file since 4098 was 4098, checked in by George.Georgovassilis@mpi.nl, 10 years ago

#360, #431, #432: JPA and unified component entities

File size: 8.2 KB
Line 
1package clarin.cmdi.componentregistry;
2
3import clarin.cmdi.componentregistry.components.CMDComponentSpec;
4import clarin.cmdi.componentregistry.model.BaseDescription;
5import clarin.cmdi.componentregistry.model.Comment;
6import clarin.cmdi.componentregistry.model.ComponentDescription;
7import clarin.cmdi.componentregistry.model.ProfileDescription;
8import java.io.IOException;
9import java.io.OutputStream;
10import java.security.Principal;
11import java.util.List;
12
13/**
14 * @author twagoo@mpi.nl
15 * @author george.georgovassilis@mpi.nl
16 *
17 */
18public interface ComponentRegistry {
19
20    // Attention! REGISTRY_ID here and the client's Config.REGISTRY_ID must be the same
21    // If you change REGISTRY_ID here, then change the client's  Config.REGISTRY_ID
22    public static final String REGISTRY_ID = "clarin.eu:cr1:";
23    public static final String PUBLIC_NAME = "Public Registry";
24
25    /**
26     * @return List of component descriptions ordered by name ascending
27     * @throws ComponentRegistryException
28     */
29    List<ComponentDescription> getComponentDescriptions() throws ComponentRegistryException;
30
31    /**
32     * @param principalName
33     * @param groupId
34     * @return List of component descriptions ordered by name ascending
35     * @throws ComponentRegistryException
36     */
37    List<ComponentDescription> getComponentDescriptionsInGroup(String principalName, String groupId) throws ComponentRegistryException;
38
39    ComponentDescription getComponentDescription(String id) throws ComponentRegistryException;
40
41    /**
42     *
43     * @return List of profile descriptions ordered by name ascending
44     * @throws ComponentRegistryException
45     */
46    List<ProfileDescription> getProfileDescriptions() throws ComponentRegistryException;
47
48    /**
49    * @param groupId
50    * @return List of profile descriptions ordered by name ascending
51    * @throws ComponentRegistryException
52    */
53   List<ProfileDescription> getProfileDescriptionsInGroup(String groupId) throws ComponentRegistryException;
54
55   /**
56     *
57     * @return List of profile descriptions ordered by name ascending, only the ones marked for showing in metadata editor
58     * @throws ComponentRegistryException
59     */
60    List<ProfileDescription> getProfileDescriptionsForMetadaEditor() throws ComponentRegistryException;
61
62    /**
63    * @param groupId
64    * @return List of profile descriptions ordered by name ascending, only the ones marked for showing in metadata editor
65    * @throws ComponentRegistryException
66    */
67   List<ProfileDescription> getProfileDescriptionsForMetadaEditor(String groupId) throws ComponentRegistryException;
68
69   ProfileDescription getProfileDescription(String id) throws ComponentRegistryException;
70
71    CMDComponentSpec getMDProfile(String id) throws ComponentRegistryException;
72
73    CMDComponentSpec getMDComponent(String id) throws ComponentRegistryException;
74
75    /**
76     *
77     * @return -1 if profile could not be registered
78     */
79    int register(BaseDescription desc, CMDComponentSpec spec);
80
81    /**
82     *
83     * @param comment
84     * @return -1 if comment could not be registered
85     */
86    int registerComment(Comment comment, String userId) throws ComponentRegistryException;
87
88    /**
89     *
90     * @return -1 if component could not be updated
91     */
92    int update(BaseDescription description, CMDComponentSpec spec, Principal principal, boolean forceUpdate);
93
94    /**
95     *
96     * @return -1 if component could not be published. Published means move from
97     * current (private) workspace to public workspace.
98     */
99    int publish(BaseDescription desc, CMDComponentSpec spec, Principal principal);
100
101    void getMDProfileAsXml(String profileId, OutputStream output) throws ComponentRegistryException;
102
103    void getMDProfileAsXsd(String profileId, OutputStream outputStream) throws ComponentRegistryException;
104
105    void getMDComponentAsXml(String componentId, OutputStream output) throws ComponentRegistryException;
106
107    void getMDComponentAsXsd(String componentId, OutputStream outputStream) throws ComponentRegistryException;
108
109    /**
110     *
111     * @param profileId
112     * @param principal
113     * @throws IOException
114     * @throws UserUnauthorizedException
115     * thrown when principal does not match creator of profile
116     * @throws DeleteFailedException
117     */
118    void deleteMDProfile(String profileId, Principal principal) throws IOException, UserUnauthorizedException, ComponentRegistryException, DeleteFailedException;
119
120    /**
121     *
122     * @param componentId
123     * @param principal
124     * @param forceDelete
125     * ignores the fact that the component is still in use by other
126     * components and just deletes.
127     * @throws IOException
128     * @throws UserUnauthorizedException
129     * thrown when principal does not match creator of component
130     * @throws DeleteFailedException
131     */
132    void deleteMDComponent(String componentId, Principal principal, boolean forceDelete) throws IOException, ComponentRegistryException, UserUnauthorizedException,
133            DeleteFailedException;
134
135    /**
136     *
137     * @param componentId
138     * @return List of ComponentDescriptions of Components that use the given
139     * Component.
140     */
141    List<ComponentDescription> getUsageInComponents(String componentId) throws ComponentRegistryException;
142
143    /**
144     *
145     * @param componentId
146     * @return List of ProfileDescriptions of Profiles that use the given
147     * Component.
148     */
149    List<ProfileDescription> getUsageInProfiles(String componentId) throws ComponentRegistryException;
150
151    /**
152     * Return true if this registry is the public registry as opposed to a
153     * registry used for the user privately.
154     * */
155    boolean isPublic();
156
157    ComponentStatus getStatus();
158
159    Owner getOwner();
160
161    /**
162     * @return {@link ComponentRegistry.PUBLIC_NAME} or name of the user's workspace
163     */
164    String getName();
165
166    /**
167     *
168     * @return List of profile descriptions ordered by name ascending
169     */
170    List<ProfileDescription> getDeletedProfileDescriptions();
171
172    /**
173     *
174     * @return List of component descriptions ordered by name ascending
175     */
176    List<ComponentDescription> getDeletedComponentDescriptions();
177
178    /**
179     *
180     * @param profileId
181     * @return List of comments fro a specific profile
182     * @throws ComponentRegistryException
183     */
184    List<Comment> getCommentsInProfile(String profileId, Principal principal) throws ComponentRegistryException;
185
186    /**
187     *
188     * @param profileId Id of profile to retrieve comment from
189     * @param commentId Id of comment to retrieve
190     * @return a specific comment from a profile
191     * @throws ComponentRegistryException
192     */
193    Comment getSpecifiedCommentInProfile(String profileId, String commentId, Principal principal) throws ComponentRegistryException;
194
195    /**
196     *
197     * @param componentId
198     * @return List of comments from a specific component
199     * @throws ComponentRegistryException
200     */
201    List<Comment> getCommentsInComponent(String componentId, Principal principal) throws ComponentRegistryException;
202
203    /**
204     *
205     * @param componentId Id of component to retrieve comment from
206     * @param commentId Id of comment to retrieve
207     * @return a specific comment from a component
208     * @throws ComponentRegistryException
209     */
210    Comment getSpecifiedCommentInComponent(String componentId, String commentId, Principal principal) throws ComponentRegistryException;
211
212    /**
213     *
214     * @param commentId Id of comment to delete
215     * @param principal User principal
216     * @throws IOException
217     * @throws ComponentRegistryException When comment cannot be successfully retrieved from registry
218     * @throws UserUnauthorizedException
219     * @throws DeleteFailedException
220     */
221    public void deleteComment(String commentId, Principal principal) throws IOException, ComponentRegistryException, UserUnauthorizedException,
222            DeleteFailedException;
223
224    /**
225     *
226     * @return a component specification expander for this registry
227     */
228    public CMDComponentSpecExpander getExpander();
229   
230    /**
231     * Get a list of ids ({@link BaseDescription#getId()}) of all non-deleted profiles
232     * @return
233     */
234    List<String> getAllNonDeletedProfileIds();
235
236    /**
237     * Get a list of ids ({@link BaseDescription#getId()}) of all non-deleted components
238     * @return
239     */
240    List<String> getAllNonDeletedComponentIds();
241}
Note: See TracBrowser for help on using the repository browser.