1 | /* |
---|
2 | * Copyright (C) 2013 DASISH |
---|
3 | * |
---|
4 | * This program is free software; you can redistribute it and/or |
---|
5 | * modify it under the terms of the GNU General Public License |
---|
6 | * as published by the Free Software Foundation; either version 2 |
---|
7 | * of the License, or (at your option) any later version. |
---|
8 | * |
---|
9 | * This program is distributed in the hope that it will be useful, |
---|
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
12 | * GNU General Public License for more details. |
---|
13 | * |
---|
14 | * You should have received a copy of the GNU General Public License |
---|
15 | * along with this program; if not, write to the Free Software |
---|
16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
17 | */ |
---|
18 | package eu.dasish.annotation.backend.dao; |
---|
19 | |
---|
20 | import eu.dasish.annotation.backend.NotInDataBaseException; |
---|
21 | import eu.dasish.annotation.schema.Access; |
---|
22 | import java.util.List; |
---|
23 | import java.util.Map; |
---|
24 | import java.util.UUID; |
---|
25 | |
---|
26 | /** |
---|
27 | * This interfaces describes signatures common for all resources: Annotation, Target, Cached Representation, Principal, Notebook; |
---|
28 | * the implementation must contain field "resourceTableName" whose value is one of the five names of resource tables: |
---|
29 | * "annotation", "target", "cached_representation", "principal", "notebook". |
---|
30 | * @author olhsha |
---|
31 | */ |
---|
32 | public interface ResourceDao { |
---|
33 | |
---|
34 | /** |
---|
35 | * |
---|
36 | * @param relResourcePath a string, representing "[relative-servise-url]/[resource]", e.g. "my-servlet/annotations". |
---|
37 | */ |
---|
38 | void setResourcePath(String relResourcePath); |
---|
39 | |
---|
40 | /** |
---|
41 | * |
---|
42 | * @param externalId the external UUId of a resource. |
---|
43 | * @return the internal ID of the resource. |
---|
44 | * @throws NotInDataBaseException if the resource with this id is not found. |
---|
45 | */ |
---|
46 | Number getInternalID(UUID externalId) throws NotInDataBaseException; |
---|
47 | |
---|
48 | /** |
---|
49 | * |
---|
50 | * @param internalId the internal ID of the resource. |
---|
51 | * @return the external UUID of the resource. |
---|
52 | */ |
---|
53 | UUID getExternalID(Number internalId); |
---|
54 | |
---|
55 | /** |
---|
56 | * |
---|
57 | * @param oldIdentifier the current external UUId of a resource. |
---|
58 | * @param newIdentifier the new external ID of the resource. |
---|
59 | * @return true iff the external id of the resource have been updated to the value of "newIDentifier". |
---|
60 | */ |
---|
61 | boolean updateResourceIdentifier(UUID oldIdentifier, UUID newIdentifier); |
---|
62 | |
---|
63 | /** |
---|
64 | * |
---|
65 | * @param internalID the internal databaseID of the resource. |
---|
66 | * @return the hyper-reference string of the resource with "internalID". |
---|
67 | */ |
---|
68 | String getHrefFromInternalID(Number internalID); |
---|
69 | |
---|
70 | /** |
---|
71 | * |
---|
72 | * @param href the hyper-reference of a resource. |
---|
73 | * @return the internal ID of the resource with "href". |
---|
74 | * @throws NotInDataBaseException if the resource with ""href" is not found in the corresponding database. |
---|
75 | */ |
---|
76 | Number getInternalIDFromHref(String href) throws NotInDataBaseException; |
---|
77 | |
---|
78 | /** |
---|
79 | * |
---|
80 | * @param resourceID the internal database id of a resource. |
---|
81 | * @return mapping "principal internal id" -> "access" for a given "resourceID"; |
---|
82 | * till now makes sense only for annotations and notebooks. |
---|
83 | */ |
---|
84 | List<Map<Number, String>> getPermissions(Number resourceID); |
---|
85 | |
---|
86 | /** |
---|
87 | * |
---|
88 | * @param resourceID the internal database id of a resource. |
---|
89 | * @return the public access mode for "resourceID"; till now makes sense only for annotations and notebooks. |
---|
90 | */ |
---|
91 | Access getPublicAttribute(Number resourceID); |
---|
92 | |
---|
93 | |
---|
94 | } |
---|