1 | package clarin.cmdi.componentregistry; |
---|
2 | |
---|
3 | import java.io.IOException; |
---|
4 | import java.io.OutputStream; |
---|
5 | import java.security.Principal; |
---|
6 | import java.util.List; |
---|
7 | |
---|
8 | import clarin.cmdi.componentregistry.components.CMDComponentSpec; |
---|
9 | import clarin.cmdi.componentregistry.model.AbstractDescription; |
---|
10 | import clarin.cmdi.componentregistry.model.Comment; |
---|
11 | import clarin.cmdi.componentregistry.model.ComponentDescription; |
---|
12 | import clarin.cmdi.componentregistry.model.ProfileDescription; |
---|
13 | |
---|
14 | public interface ComponentRegistry { |
---|
15 | |
---|
16 | public static final String REGISTRY_ID = "clarin.eu:cr1:"; |
---|
17 | public static final String PUBLIC_NAME = "Public Registry"; |
---|
18 | |
---|
19 | /** |
---|
20 | * |
---|
21 | * @return List of component descriptions ordered by name ascending |
---|
22 | * @throws ComponentRegistryException |
---|
23 | */ |
---|
24 | List<ComponentDescription> getComponentDescriptions() throws ComponentRegistryException; |
---|
25 | |
---|
26 | ComponentDescription getComponentDescription(String id) throws ComponentRegistryException; |
---|
27 | |
---|
28 | /** |
---|
29 | * |
---|
30 | * @return List of profile descriptions ordered by name ascending |
---|
31 | * @throws ComponentRegistryException |
---|
32 | */ |
---|
33 | List<ProfileDescription> getProfileDescriptions() throws ComponentRegistryException; |
---|
34 | |
---|
35 | /** |
---|
36 | * |
---|
37 | * @return List of profile descriptions ordered by name ascending, only the ones marked for showing in metadata editor |
---|
38 | * @throws ComponentRegistryException |
---|
39 | */ |
---|
40 | List<ProfileDescription> getProfileDescriptionsForMetadaEditor() throws ComponentRegistryException; |
---|
41 | |
---|
42 | ProfileDescription getProfileDescription(String id) throws ComponentRegistryException; |
---|
43 | |
---|
44 | CMDComponentSpec getMDProfile(String id) throws ComponentRegistryException; |
---|
45 | |
---|
46 | CMDComponentSpec getMDComponent(String id) throws ComponentRegistryException; |
---|
47 | |
---|
48 | /** |
---|
49 | * |
---|
50 | * @return -1 if profile could not be registered |
---|
51 | */ |
---|
52 | int register(AbstractDescription desc, CMDComponentSpec spec); |
---|
53 | |
---|
54 | /** |
---|
55 | * |
---|
56 | * @param comment |
---|
57 | * @return -1 if comment could not be registered |
---|
58 | */ |
---|
59 | int registerComment(Comment comment, String userId) throws ComponentRegistryException; |
---|
60 | |
---|
61 | /** |
---|
62 | * |
---|
63 | * @return -1 if component could not be updated |
---|
64 | */ |
---|
65 | int update(AbstractDescription description, CMDComponentSpec spec, Principal principal, boolean forceUpdate); |
---|
66 | |
---|
67 | /** |
---|
68 | * |
---|
69 | * @return -1 if component could not be published. Published means move from |
---|
70 | * current (private) workspace to public workspace. |
---|
71 | */ |
---|
72 | int publish(AbstractDescription desc, CMDComponentSpec spec, Principal principal); |
---|
73 | |
---|
74 | void getMDProfileAsXml(String profileId, OutputStream output) throws ComponentRegistryException; |
---|
75 | |
---|
76 | void getMDProfileAsXsd(String profileId, OutputStream outputStream) throws ComponentRegistryException; |
---|
77 | |
---|
78 | void getMDComponentAsXml(String componentId, OutputStream output) throws ComponentRegistryException; |
---|
79 | |
---|
80 | void getMDComponentAsXsd(String componentId, OutputStream outputStream) throws ComponentRegistryException; |
---|
81 | |
---|
82 | /** |
---|
83 | * |
---|
84 | * @param profileId |
---|
85 | * @param principal |
---|
86 | * @throws IOException |
---|
87 | * @throws UserUnauthorizedException |
---|
88 | * thrown when principal does not match creator of profile |
---|
89 | * @throws DeleteFailedException |
---|
90 | */ |
---|
91 | void deleteMDProfile(String profileId, Principal principal) throws IOException, UserUnauthorizedException, ComponentRegistryException, DeleteFailedException; |
---|
92 | |
---|
93 | /** |
---|
94 | * |
---|
95 | * @param componentId |
---|
96 | * @param principal |
---|
97 | * @param forceDelete |
---|
98 | * ignores the fact that the component is still in use by other |
---|
99 | * components and just deletes. |
---|
100 | * @throws IOException |
---|
101 | * @throws UserUnauthorizedException |
---|
102 | * thrown when principal does not match creator of component |
---|
103 | * @throws DeleteFailedException |
---|
104 | */ |
---|
105 | void deleteMDComponent(String componentId, Principal principal, boolean forceDelete) throws IOException, ComponentRegistryException, UserUnauthorizedException, |
---|
106 | DeleteFailedException; |
---|
107 | |
---|
108 | /** |
---|
109 | * |
---|
110 | * @param componentId |
---|
111 | * @return List of ComponentDescriptions of Components that use the given |
---|
112 | * Component. |
---|
113 | */ |
---|
114 | List<ComponentDescription> getUsageInComponents(String componentId) throws ComponentRegistryException; |
---|
115 | |
---|
116 | /** |
---|
117 | * |
---|
118 | * @param componentId |
---|
119 | * @return List of ProfileDescriptions of Profiles that use the given |
---|
120 | * Component. |
---|
121 | */ |
---|
122 | List<ProfileDescription> getUsageInProfiles(String componentId) throws ComponentRegistryException; |
---|
123 | |
---|
124 | /** |
---|
125 | * Return true if this registry is the public registry as opposed to a |
---|
126 | * registry used for the user privately. |
---|
127 | **/ |
---|
128 | boolean isPublic(); |
---|
129 | |
---|
130 | /** |
---|
131 | * @return {@link ComponentRegistry.PUBLIC_NAME} or name of the user's workspace |
---|
132 | */ |
---|
133 | String getName(); |
---|
134 | |
---|
135 | /** |
---|
136 | * |
---|
137 | * @return List of profile descriptions ordered by name ascending |
---|
138 | */ |
---|
139 | List<ProfileDescription> getDeletedProfileDescriptions(); |
---|
140 | |
---|
141 | /** |
---|
142 | * |
---|
143 | * @return List of component descriptions ordered by name ascending |
---|
144 | */ |
---|
145 | List<ComponentDescription> getDeletedComponentDescriptions(); |
---|
146 | |
---|
147 | /** |
---|
148 | * |
---|
149 | * @param profileId |
---|
150 | * @return List of comments fro a specific profile |
---|
151 | * @throws ComponentRegistryException |
---|
152 | */ |
---|
153 | List<Comment> getCommentsInProfile(String profileId) throws ComponentRegistryException; |
---|
154 | |
---|
155 | /** |
---|
156 | * |
---|
157 | * @param profileId Id of profile to retrieve comment from |
---|
158 | * @param commentId Id of comment to retrieve |
---|
159 | * @return a specific comment from a profile |
---|
160 | * @throws ComponentRegistryException |
---|
161 | */ |
---|
162 | Comment getSpecifiedCommentInProfile(String profileId, String commentId) throws ComponentRegistryException; |
---|
163 | |
---|
164 | /** |
---|
165 | * |
---|
166 | * @param componentId |
---|
167 | * @return List of comments from a specific component |
---|
168 | * @throws ComponentRegistryException |
---|
169 | */ |
---|
170 | List<Comment> getCommentsInComponent(String componentId) throws ComponentRegistryException; |
---|
171 | |
---|
172 | /** |
---|
173 | * |
---|
174 | * @param componentId Id of component to retrieve comment from |
---|
175 | * @param commentId Id of comment to retrieve |
---|
176 | * @return a specific comment from a component |
---|
177 | * @throws ComponentRegistryException |
---|
178 | */ |
---|
179 | Comment getSpecifiedCommentInComponent(String componentId, String commentId) throws ComponentRegistryException; |
---|
180 | |
---|
181 | /** |
---|
182 | * |
---|
183 | * @param commentId Id of comment to delete |
---|
184 | * @param principal User principal |
---|
185 | * @throws IOException |
---|
186 | * @throws ComponentRegistryException When comment cannot be successfully retrieved from registry |
---|
187 | * @throws UserUnauthorizedException |
---|
188 | * @throws DeleteFailedException |
---|
189 | */ |
---|
190 | public void deleteComment(String commentId, Principal principal) throws IOException, ComponentRegistryException, UserUnauthorizedException, |
---|
191 | DeleteFailedException; |
---|
192 | |
---|
193 | /** |
---|
194 | * |
---|
195 | * @return a component specification expander for this registry |
---|
196 | */ |
---|
197 | public CMDComponentSpecExpander getExpander(); |
---|
198 | } |
---|