Revision 37050
Added by Sandro La Bruzzo over 9 years ago
modules/dnet-modular-objectstore-service/tags/dnet-modular-objectstore-service-4.1.0/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
|
3 |
<parent> |
|
4 |
<groupId>eu.dnetlib</groupId> |
|
5 |
<artifactId>dnet-parent</artifactId> |
|
6 |
<version>1.0.0</version> |
|
7 |
</parent> |
|
8 |
<modelVersion>4.0.0</modelVersion> |
|
9 |
<groupId>eu.dnetlib</groupId> |
|
10 |
<artifactId>dnet-modular-objectstore-service</artifactId> |
|
11 |
<packaging>jar</packaging> |
|
12 |
<version>4.1.0</version> |
|
13 |
<scm> |
|
14 |
<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-modular-objectstore-service/tags/dnet-modular-objectstore-service-4.1.0</developerConnection> |
|
15 |
</scm> |
|
16 |
<dependencies> |
|
17 |
<dependency> |
|
18 |
<groupId>eu.dnetlib</groupId> |
|
19 |
<artifactId>dnet-objectstore-rmi</artifactId> |
|
20 |
<version>[2.0.0,3.0.0)</version> |
|
21 |
</dependency> |
|
22 |
<dependency> |
|
23 |
<groupId>eu.dnetlib</groupId> |
|
24 |
<artifactId>cnr-resultset-service</artifactId> |
|
25 |
<version>[2.0.0,3.0.0)</version> |
|
26 |
</dependency> |
|
27 |
<dependency> |
|
28 |
<groupId>eu.dnetlib</groupId> |
|
29 |
<artifactId>cnr-resultset-client</artifactId> |
|
30 |
<version>[2.0.0,3.0.0)</version> |
|
31 |
</dependency> |
|
32 |
<dependency> |
|
33 |
<groupId>eu.dnetlib</groupId> |
|
34 |
<artifactId>cnr-blackboard-common</artifactId> |
|
35 |
<version>[2.0.0,3.0.0)</version> |
|
36 |
</dependency> |
|
37 |
<dependency> |
|
38 |
<groupId>eu.dnetlib</groupId> |
|
39 |
<artifactId>cnr-inspector</artifactId> |
|
40 |
<version>[1.0.0,2.0.0)</version> |
|
41 |
</dependency> |
|
42 |
<dependency> |
|
43 |
<groupId>junit</groupId> |
|
44 |
<artifactId>junit</artifactId> |
|
45 |
<version>${junit.version}</version> |
|
46 |
<scope>test</scope> |
|
47 |
</dependency> |
|
48 |
<dependency> |
|
49 |
<groupId>apache</groupId> |
|
50 |
<artifactId>commons-net</artifactId> |
|
51 |
<version>2.2</version> |
|
52 |
</dependency> |
|
53 |
<dependency> |
|
54 |
<groupId>apache</groupId> |
|
55 |
<artifactId>commons-net-ftp</artifactId> |
|
56 |
<version>2.0</version> |
|
57 |
</dependency> |
|
58 |
<dependency> |
|
59 |
<groupId>javax.servlet</groupId> |
|
60 |
<artifactId>javax.servlet-api</artifactId> |
|
61 |
<version>${javax.servlet.version}</version> |
|
62 |
<scope>provided</scope> |
|
63 |
</dependency> |
|
64 |
|
|
65 |
</dependencies> |
|
66 |
</project> |
modules/dnet-modular-objectstore-service/tags/dnet-modular-objectstore-service-4.1.0/src/main/resources/eu/dnetlib/test/schemas/LinkedDataDSResourceType.xsd | ||
---|---|---|
1 |
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
|
2 |
<xs:complexType name="DATA_SOURCEType"> |
|
3 |
<xs:sequence> |
|
4 |
<xs:element name="DATA_SOURCE" type="xs:string" minOccurs="1" maxOccurs="unbounded"/> |
|
5 |
</xs:sequence> |
|
6 |
</xs:complexType> |
|
7 |
<xs:complexType name="SOURCE_METADATA_FORMATSType"> |
|
8 |
<xs:sequence> |
|
9 |
<xs:element name="SOURCE_METADATA_FORMAT" minOccurs="0" maxOccurs="unbounded" type="METADATA_FORMATType"/> |
|
10 |
</xs:sequence> |
|
11 |
</xs:complexType> |
|
12 |
<xs:complexType name="METADATA_FORMATType"> |
|
13 |
<xs:attribute name="name" type="xs:string"/> |
|
14 |
<xs:attribute name="interpretation" type="xs:string"/> |
|
15 |
<xs:attribute name="layout" type="xs:string"/> |
|
16 |
</xs:complexType> |
|
17 |
<xs:complexType name="SCHEDULINGType"> |
|
18 |
<xs:all> |
|
19 |
<xs:element name="CRON" minOccurs="0" type="CRONType"/> |
|
20 |
<xs:element name="EVENT" minOccurs="0" type="EVENTType"/> |
|
21 |
</xs:all> |
|
22 |
</xs:complexType> |
|
23 |
<xs:complexType name="CRONType"> |
|
24 |
<xs:sequence> |
|
25 |
<xs:element name="WHEN" type="xs:string"/> |
|
26 |
<xs:element name="MININTERVAL" type="xs:string"/> |
|
27 |
</xs:sequence> |
|
28 |
</xs:complexType> |
|
29 |
<xs:complexType name="EVENTType"> |
|
30 |
<xs:sequence> |
|
31 |
<xs:element name="TOPIC" type="xs:string"/> |
|
32 |
<xs:element name="XPATH" type="xs:string" minOccurs="0"/> |
|
33 |
</xs:sequence> |
|
34 |
</xs:complexType> |
|
35 |
<xs:complexType name="STATUSType"> |
|
36 |
<xs:all> |
|
37 |
<xs:element name="LAST_UPDATE_DATE" type="xs:string"/> |
|
38 |
<xs:element name="LAST_UPDATE_STATUS" type="xs:string"/> |
|
39 |
<xs:element name="LAST_UPDATE_ERROR_MESSAGE" type="xs:string"/> |
|
40 |
</xs:all> |
|
41 |
</xs:complexType> |
|
42 |
<xs:element name="RESOURCE_PROFILE"> |
|
43 |
<xs:complexType> |
|
44 |
<xs:sequence> |
|
45 |
<xs:element name="HEADER" type="HEADERType"/> |
|
46 |
<xs:element name="BODY" type="BODYType"/> |
|
47 |
</xs:sequence> |
|
48 |
</xs:complexType> |
|
49 |
</xs:element> |
|
50 |
<xs:complexType name="RESOURCE_TYPEType"> |
|
51 |
<xs:attribute name="value" use="required"> |
|
52 |
<xs:simpleType> |
|
53 |
<xs:restriction base="xs:string"> |
|
54 |
<xs:enumeration value="LinkedDataDSResourceType"/> |
|
55 |
</xs:restriction> |
|
56 |
</xs:simpleType> |
|
57 |
</xs:attribute> |
|
58 |
</xs:complexType> |
|
59 |
<xs:complexType name="RESOURCE_URIType"> |
|
60 |
<xs:attribute name="value" type="xs:string" use="required"/> |
|
61 |
</xs:complexType> |
|
62 |
<xs:complexType name="RESOURCE_KINDType"> |
|
63 |
<xs:attribute name="value" use="required"> |
|
64 |
<xs:simpleType> |
|
65 |
<xs:restriction base="xs:string"> |
|
66 |
<xs:enumeration value="LinkedDataDSResources"/> |
|
67 |
</xs:restriction> |
|
68 |
</xs:simpleType> |
|
69 |
</xs:attribute> |
|
70 |
</xs:complexType> |
|
71 |
<xs:complexType name="RESOURCE_IDENTIFIERType"> |
|
72 |
<xs:attribute name="value" type="xs:string" use="required"/> |
|
73 |
</xs:complexType> |
|
74 |
<xs:complexType name="DATE_OF_CREATIONType"> |
|
75 |
<xs:attribute name="value" type="xs:dateTime" use="required"/> |
|
76 |
</xs:complexType> |
|
77 |
<xs:complexType name="HEADERType"> |
|
78 |
<xs:all> |
|
79 |
<xs:element name="RESOURCE_IDENTIFIER" type="RESOURCE_IDENTIFIERType"/> |
|
80 |
<xs:element name="RESOURCE_TYPE" type="RESOURCE_TYPEType"/> |
|
81 |
<xs:element name="RESOURCE_KIND" type="RESOURCE_KINDType"/> |
|
82 |
<xs:element name="RESOURCE_URI" type="RESOURCE_URIType"/> |
|
83 |
<xs:element name="DATE_OF_CREATION" type="DATE_OF_CREATIONType"/> |
|
84 |
</xs:all> |
|
85 |
</xs:complexType> |
|
86 |
<xs:complexType name="CONFIGURATIONType"> |
|
87 |
<xs:all> |
|
88 |
<xs:element name="REPOSITORY_SERVICE_IDENTIFIER" type="xs:string" minOccurs="0"/> |
|
89 |
<xs:element name="LINKEDDATA_MANAGER_SERVICE_IDENTIFIER" type="xs:string"/> |
|
90 |
<xs:element name="LINKEDDATA_MANAGER_SERVICE_URI" type="xs:string"/> |
|
91 |
<xs:element name="SOURCE_METADATA_FORMATS" type="SOURCE_METADATA_FORMATSType"/> |
|
92 |
<xs:element name="SINK_METADATA_FORMAT" type="METADATA_FORMATType"/> |
|
93 |
<xs:element name="DATA_SOURCES" type="DATA_SOURCEType"/> |
|
94 |
<xs:element name="DATA_SINK" type="xs:string"/> |
|
95 |
<xs:element name="SCHEDULING" type="SCHEDULINGType"/> |
|
96 |
</xs:all> |
|
97 |
</xs:complexType> |
|
98 |
<xs:complexType name="BODYType"> |
|
99 |
<xs:sequence> |
|
100 |
<xs:element name="CONFIGURATION" type="CONFIGURATIONType"/> |
|
101 |
<xs:element name="STATUS" type="STATUSType"/> |
|
102 |
<xs:element name="SECURITY_PARAMETERS" type="xs:string"/> |
|
103 |
</xs:sequence> |
|
104 |
</xs:complexType> |
|
105 |
</xs:schema> |
modules/dnet-modular-objectstore-service/tags/dnet-modular-objectstore-service-4.1.0/src/main/java/eu/dnetlib/data/objectstore/modular/CreateObjectStoreAction.java | ||
---|---|---|
1 |
package eu.dnetlib.data.objectstore.modular; |
|
2 |
|
|
3 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob; |
|
4 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction; |
|
5 |
import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler; |
|
6 |
|
|
7 |
/** |
|
8 |
* The Class CreateObjectStoreAction is responsible to execute the blacboard action of type CREATE. |
|
9 |
*/ |
|
10 |
public class CreateObjectStoreAction extends AbstractObjectStoreAction |
|
11 |
implements BlackboardServerAction<ObjectStoreActions> { |
|
12 |
|
|
13 |
/** The profile creator. */ |
|
14 |
private ObjectStoreProfileCreator profileCreator; |
|
15 |
|
|
16 |
/* (non-Javadoc) |
|
17 |
* @see eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction#execute(eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler, eu.dnetlib.enabling.tools.blackboard.BlackboardJob) |
|
18 |
*/ |
|
19 |
@Override |
|
20 |
public void execute(final BlackboardServerHandler handler, final BlackboardJob job) |
|
21 |
throws Exception { |
|
22 |
|
|
23 |
final String interpretation = job.getParameters().get("interpretation"); |
|
24 |
|
|
25 |
final String basePath = job.getParameters().get("basePath"); |
|
26 |
|
|
27 |
final String objID = profileCreator.registerProfile(interpretation); |
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
getDao().createObjectStore(objID, interpretation,basePath); |
|
32 |
|
|
33 |
job.getParameters().put("objectStoreId", objID); |
|
34 |
|
|
35 |
handler.done(job); |
|
36 |
|
|
37 |
} |
|
38 |
|
|
39 |
/** |
|
40 |
* Gets the profile creator. |
|
41 |
* |
|
42 |
* @return the profile creator |
|
43 |
*/ |
|
44 |
public ObjectStoreProfileCreator getProfileCreator() { |
|
45 |
return profileCreator; |
|
46 |
} |
|
47 |
|
|
48 |
/** |
|
49 |
* Sets the profile creator. |
|
50 |
* |
|
51 |
* @param profileCreator the new profile creator |
|
52 |
*/ |
|
53 |
public void setProfileCreator(final ObjectStoreProfileCreator profileCreator) { |
|
54 |
this.profileCreator = profileCreator; |
|
55 |
} |
|
56 |
|
|
57 |
} |
modules/dnet-modular-objectstore-service/tags/dnet-modular-objectstore-service-4.1.0/src/main/java/eu/dnetlib/data/objectstore/modular/inspector/ObjectStoreInspector.java | ||
---|---|---|
1 |
package eu.dnetlib.data.objectstore.modular.inspector; |
|
2 |
|
|
3 |
import static eu.dnetlib.miscutils.collections.MappedCollection.listMap; |
|
4 |
|
|
5 |
import java.util.List; |
|
6 |
|
|
7 |
import org.springframework.beans.factory.annotation.Autowired; |
|
8 |
import org.springframework.stereotype.Controller; |
|
9 |
import org.springframework.ui.Model; |
|
10 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
11 |
import org.springframework.web.bind.annotation.RequestMethod; |
|
12 |
import org.springframework.web.bind.annotation.RequestParam; |
|
13 |
|
|
14 |
import com.google.gson.Gson; |
|
15 |
|
|
16 |
import eu.dnetlib.data.objectstore.modular.connector.ObjectStore; |
|
17 |
import eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao; |
|
18 |
import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile; |
|
19 |
import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException; |
|
20 |
import eu.dnetlib.enabling.inspector.AbstractInspectorController; |
|
21 |
import eu.dnetlib.enabling.resultset.ResultSetListener; |
|
22 |
import eu.dnetlib.miscutils.collections.MappedCollection; |
|
23 |
import eu.dnetlib.miscutils.functional.UnaryFunction; |
|
24 |
|
|
25 |
/** |
|
26 |
* The Class ObjectStoreInspector is the inspector controller of the objectStore. |
|
27 |
*/ |
|
28 |
@Controller |
|
29 |
public class ObjectStoreInspector extends AbstractInspectorController { |
|
30 |
|
|
31 |
// private static final Log log = LogFactory.getLog(ObjectStoreInspector.class); |
|
32 |
|
|
33 |
/** The object store dao. */ |
|
34 |
@Autowired |
|
35 |
private ObjectStoreDao objectStoreDao; |
|
36 |
|
|
37 |
/** |
|
38 |
* The Class ObjectStoreDescription. |
|
39 |
*/ |
|
40 |
class ObjectStoreDescription { |
|
41 |
|
|
42 |
/** The id. */ |
|
43 |
private String id; |
|
44 |
|
|
45 |
/** The size. */ |
|
46 |
private int size; |
|
47 |
|
|
48 |
/** |
|
49 |
* Instantiates a new object store description. |
|
50 |
* |
|
51 |
* @param id |
|
52 |
* the id |
|
53 |
* @param size |
|
54 |
* the size |
|
55 |
*/ |
|
56 |
public ObjectStoreDescription(final String id, final int size) { |
|
57 |
|
|
58 |
this.id = id; |
|
59 |
this.size = size; |
|
60 |
} |
|
61 |
|
|
62 |
/** |
|
63 |
* Gets the interpretation. |
|
64 |
* |
|
65 |
* @return the interpretation |
|
66 |
* @throws ObjectStoreServiceException |
|
67 |
*/ |
|
68 |
public String getInterpretation() throws ObjectStoreServiceException { |
|
69 |
|
|
70 |
ObjectStore objectStore = objectStoreDao.getObjectStore(id); |
|
71 |
return objectStore.getInterpretation(); |
|
72 |
} |
|
73 |
|
|
74 |
/** |
|
75 |
* Gets the id. |
|
76 |
* |
|
77 |
* @return the id |
|
78 |
*/ |
|
79 |
public String getId() { |
|
80 |
return id; |
|
81 |
} |
|
82 |
|
|
83 |
/** |
|
84 |
* Sets the id. |
|
85 |
* |
|
86 |
* @param id |
|
87 |
* the new id |
|
88 |
*/ |
|
89 |
public void setId(final String id) { |
|
90 |
this.id = id; |
|
91 |
} |
|
92 |
|
|
93 |
/** |
|
94 |
* Gets the size. |
|
95 |
* |
|
96 |
* @return the size |
|
97 |
*/ |
|
98 |
public int getSize() { |
|
99 |
return size; |
|
100 |
} |
|
101 |
|
|
102 |
/** |
|
103 |
* Sets the size. |
|
104 |
* |
|
105 |
* @param size |
|
106 |
* the new size |
|
107 |
*/ |
|
108 |
public void setSize(final int size) { |
|
109 |
this.size = size; |
|
110 |
} |
|
111 |
} |
|
112 |
|
|
113 |
/** |
|
114 |
* Object stores. |
|
115 |
* |
|
116 |
* @param model |
|
117 |
* the model |
|
118 |
*/ |
|
119 |
@RequestMapping(value = "/inspector/objectstores.do") |
|
120 |
public void objectStores(final Model model) { |
|
121 |
List<String> objectStores = objectStoreDao.listObjectStores(); |
|
122 |
model.addAttribute("objectstores", MappedCollection.listMap(objectStores, new UnaryFunction<ObjectStoreDescription, String>() { |
|
123 |
|
|
124 |
@Override |
|
125 |
public ObjectStoreDescription evaluate(final String id) { |
|
126 |
try { |
|
127 |
ObjectStore objStore = objectStoreDao.getObjectStore(id); |
|
128 |
return new ObjectStoreDescription(id, objStore.getSize()); |
|
129 |
} catch (ObjectStoreServiceException e) { |
|
130 |
return null; |
|
131 |
} |
|
132 |
} |
|
133 |
})); |
|
134 |
} |
|
135 |
|
|
136 |
/** |
|
137 |
* Object store. |
|
138 |
* |
|
139 |
* @param model |
|
140 |
* the model |
|
141 |
* @param id |
|
142 |
* the id |
|
143 |
* @param startParam |
|
144 |
* the start param |
|
145 |
* @param regex |
|
146 |
* the regex |
|
147 |
* @throws ObjectStoreServiceException |
|
148 |
*/ |
|
149 |
@RequestMapping(value = "/inspector/objectstore.do", method = RequestMethod.GET) |
|
150 |
public void objectStore(final Model model, |
|
151 |
@RequestParam("id") final String id, |
|
152 |
@RequestParam(value = "start", required = false) final Integer startParam, |
|
153 |
@RequestParam(value = "regex", required = false) final String regex) throws ObjectStoreServiceException { |
|
154 |
int pageSize = 10; |
|
155 |
int start = 0; |
|
156 |
|
|
157 |
if (startParam != null) { |
|
158 |
start = startParam; |
|
159 |
} |
|
160 |
ObjectStore objctStore = objectStoreDao.getObjectStore(id); |
|
161 |
ResultSetListener rs = objctStore.deliver((long) 0, System.currentTimeMillis()); |
|
162 |
List<String> page = rs.getResult((1 + start), (start + pageSize)); |
|
163 |
final Gson g = new Gson(); |
|
164 |
model.addAttribute("id", id); |
|
165 |
model.addAttribute("start", start); |
|
166 |
model.addAttribute("regex", regex); |
|
167 |
model.addAttribute("nextPage", start + pageSize); |
|
168 |
model.addAttribute("prevPage", Math.max(0, start - pageSize)); |
|
169 |
model.addAttribute("size", rs.getSize()); |
|
170 |
model.addAttribute("page", listMap(page, new UnaryFunction<ObjectStoreFile, String>() { |
|
171 |
|
|
172 |
@Override |
|
173 |
public ObjectStoreFile evaluate(final String json) { |
|
174 |
return g.fromJson(json, ObjectStoreFile.class); |
|
175 |
} |
|
176 |
})); |
|
177 |
|
|
178 |
} |
|
179 |
|
|
180 |
/** |
|
181 |
* Gets the object store dao. |
|
182 |
* |
|
183 |
* @return the object store dao |
|
184 |
*/ |
|
185 |
public ObjectStoreDao getObjectStoreDao() { |
|
186 |
return objectStoreDao; |
|
187 |
} |
|
188 |
|
|
189 |
/** |
|
190 |
* Sets the object store dao. |
|
191 |
* |
|
192 |
* @param objectStoreDao |
|
193 |
* the new object store dao |
|
194 |
*/ |
|
195 |
public void setObjectStoreDao(final ObjectStoreDao objectStoreDao) { |
|
196 |
this.objectStoreDao = objectStoreDao; |
|
197 |
} |
|
198 |
|
|
199 |
} |
modules/dnet-modular-objectstore-service/tags/dnet-modular-objectstore-service-4.1.0/src/main/java/eu/dnetlib/data/objectstore/modular/connector/ObjectStoreDao.java | ||
---|---|---|
1 |
package eu.dnetlib.data.objectstore.modular.connector; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException; |
|
6 |
|
|
7 |
/** |
|
8 |
* The Interface ObjectStoreDao. |
|
9 |
*/ |
|
10 |
public interface ObjectStoreDao { |
|
11 |
|
|
12 |
/** |
|
13 |
* Gets an Object Store with the given identifier. |
|
14 |
* <p> |
|
15 |
* If an Object Store with the given identifier does not exist, a new one is created. |
|
16 |
* </p> |
|
17 |
* |
|
18 |
* @param obsId |
|
19 |
* the object store identifier |
|
20 |
* @return the object store |
|
21 |
* @throws ObjectStoreServiceException |
|
22 |
*/ |
|
23 |
ObjectStore getObjectStore(String obsId) throws ObjectStoreServiceException; |
|
24 |
|
|
25 |
/** |
|
26 |
* List all the Object stores. |
|
27 |
* |
|
28 |
* @return the list of object store ids |
|
29 |
*/ |
|
30 |
List<String> listObjectStores(); |
|
31 |
|
|
32 |
/** |
|
33 |
* Creates an Object Store with the given identifier. |
|
34 |
* <p> |
|
35 |
* If an Object Store with the given identifier already exists this method does nothing. |
|
36 |
* </p> |
|
37 |
* |
|
38 |
* @param obsId the object store identifier |
|
39 |
* @param interpretation the interpretation of the store |
|
40 |
* @param basePath the base path to store the object Store in case of file system implementation |
|
41 |
* @return true, if successful |
|
42 |
* @throws ObjectStoreServiceException |
|
43 |
*/ |
|
44 |
boolean createObjectStore(String obsId, String interpretation, String basePath) throws ObjectStoreServiceException; |
|
45 |
|
|
46 |
/** |
|
47 |
* Upddate an Object Store metadata with the given identifier. |
|
48 |
* <p> |
|
49 |
* If an Object Store with the given identifier does not exist, a new one is created. |
|
50 |
* </p> |
|
51 |
* |
|
52 |
* @param obsId |
|
53 |
* the object store identifier |
|
54 |
* @param interpretation |
|
55 |
* the interpretation of the store |
|
56 |
* @return true, if successful |
|
57 |
*/ |
|
58 |
boolean updateObjectStore(String obsId, String interpretation); |
|
59 |
|
|
60 |
/** |
|
61 |
* Delete object store. |
|
62 |
* |
|
63 |
* @param obsId |
|
64 |
* the object store identifier |
|
65 |
* @return true, if successful |
|
66 |
* @throws ObjectStoreServiceException |
|
67 |
*/ |
|
68 |
boolean deleteObjectStore(String obsId) throws ObjectStoreServiceException; |
|
69 |
|
|
70 |
} |
modules/dnet-modular-objectstore-service/tags/dnet-modular-objectstore-service-4.1.0/src/main/java/eu/dnetlib/data/objectstore/modular/connector/ObjectStore.java | ||
---|---|---|
1 |
package eu.dnetlib.data.objectstore.modular.connector; |
|
2 |
|
|
3 |
import java.io.InputStream; |
|
4 |
|
|
5 |
import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord; |
|
6 |
import eu.dnetlib.data.objectstore.rmi.MetadataObjectRecord; |
|
7 |
import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile; |
|
8 |
import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException; |
|
9 |
import eu.dnetlib.enabling.resultset.ResultSetListener; |
|
10 |
|
|
11 |
/** |
|
12 |
* The Interface ObjectStore. |
|
13 |
*/ |
|
14 |
public interface ObjectStore { |
|
15 |
|
|
16 |
/** |
|
17 |
* Gets the id of the objectStore. |
|
18 |
* |
|
19 |
* @return the id |
|
20 |
*/ |
|
21 |
String getId(); |
|
22 |
|
|
23 |
/** |
|
24 |
* Gets the interpretation the objectStore. |
|
25 |
* |
|
26 |
* @return the interpretation |
|
27 |
*/ |
|
28 |
String getInterpretation(); |
|
29 |
|
|
30 |
/** |
|
31 |
* Feed record into the objectstore. |
|
32 |
* |
|
33 |
* @param records |
|
34 |
* the records |
|
35 |
* @param incremental |
|
36 |
* the incremental |
|
37 |
* @return the int |
|
38 |
*/ |
|
39 |
int feed(Iterable<ObjectStoreRecord> records, boolean incremental) throws ObjectStoreServiceException; |
|
40 |
|
|
41 |
/** |
|
42 |
* Feed metadata record into the objectStore. |
|
43 |
* |
|
44 |
* @param records |
|
45 |
* the records |
|
46 |
* @param incremental |
|
47 |
* the incremental |
|
48 |
* @return the int |
|
49 |
*/ |
|
50 |
int feedMetadataRecord(Iterable<MetadataObjectRecord> records, boolean incremental) throws ObjectStoreServiceException; |
|
51 |
|
|
52 |
/** |
|
53 |
* Feed a single object record into the objectStore. |
|
54 |
* |
|
55 |
* @param record |
|
56 |
* the record |
|
57 |
* @return the string |
|
58 |
*/ |
|
59 |
String feedObjectRecord(ObjectStoreRecord record) throws ObjectStoreServiceException; |
|
60 |
|
|
61 |
/** |
|
62 |
* Deliver Object from the objectStore. |
|
63 |
* |
|
64 |
* @param from |
|
65 |
* : start date which you want to filter |
|
66 |
* @param until |
|
67 |
* : end date which you want to filter |
|
68 |
* @return the result set listener |
|
69 |
*/ |
|
70 |
ResultSetListener deliver(Long from, Long until) throws ObjectStoreServiceException; |
|
71 |
|
|
72 |
/** |
|
73 |
* Deliver ids. |
|
74 |
* |
|
75 |
* @param ids |
|
76 |
* the ids |
|
77 |
* @return the result set listener |
|
78 |
*/ |
|
79 |
ResultSetListener deliverIds(Iterable<String> ids) throws ObjectStoreServiceException; |
|
80 |
|
|
81 |
/** |
|
82 |
* Deliver object. |
|
83 |
* |
|
84 |
* @param objectId |
|
85 |
* the object id |
|
86 |
* @return the object store file |
|
87 |
* @throws ObjectStoreServiceException |
|
88 |
*/ |
|
89 |
ObjectStoreFile deliverObject(String objectId) throws ObjectStoreServiceException; |
|
90 |
|
|
91 |
/** |
|
92 |
* Deliver stream. |
|
93 |
* |
|
94 |
* @param objectId |
|
95 |
* the object id |
|
96 |
* @return the input stream |
|
97 |
*/ |
|
98 |
InputStream deliverStream(String objectId) throws ObjectStoreServiceException; |
|
99 |
|
|
100 |
/** |
|
101 |
* Gets the size. |
|
102 |
* |
|
103 |
* @return the size |
|
104 |
*/ |
|
105 |
int getSize() throws ObjectStoreServiceException; |
|
106 |
|
|
107 |
/** |
|
108 |
* Delete object. |
|
109 |
* |
|
110 |
* @param objectId |
|
111 |
* the object id |
|
112 |
*/ |
|
113 |
void deleteObject(String objectId) throws ObjectStoreServiceException; |
|
114 |
|
|
115 |
/** |
|
116 |
* Gets the object. |
|
117 |
* |
|
118 |
* @param recordId |
|
119 |
* the record id |
|
120 |
* @return the object |
|
121 |
*/ |
|
122 |
String getObject(String recordId) throws ObjectStoreServiceException; |
|
123 |
|
|
124 |
/** |
|
125 |
* Find if exist an ID startingwith the string startId. |
|
126 |
* |
|
127 |
* @param startId |
|
128 |
* the start id |
|
129 |
* @return if exist or less an id |
|
130 |
*/ |
|
131 |
boolean existIDStartsWith(String startId) throws ObjectStoreServiceException; |
|
132 |
|
|
133 |
} |
modules/dnet-modular-objectstore-service/tags/dnet-modular-objectstore-service-4.1.0/src/main/java/eu/dnetlib/data/objectstore/modular/ModularObjectStoreFeeder.java | ||
---|---|---|
1 |
package eu.dnetlib.data.objectstore.modular; |
|
2 |
|
|
3 |
import org.apache.commons.logging.Log; |
|
4 |
import org.apache.commons.logging.LogFactory; |
|
5 |
import org.springframework.beans.factory.annotation.Required; |
|
6 |
|
|
7 |
import com.google.common.base.Function; |
|
8 |
import com.google.common.collect.Iterables; |
|
9 |
import com.google.common.collect.Lists; |
|
10 |
|
|
11 |
import eu.dnetlib.data.objectstore.modular.connector.ObjectStore; |
|
12 |
import eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao; |
|
13 |
import eu.dnetlib.data.objectstore.rmi.MetadataObjectRecord; |
|
14 |
import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile; |
|
15 |
import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException; |
|
16 |
import eu.dnetlib.data.objectstore.rmi.Protocols; |
|
17 |
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService; |
|
18 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
19 |
import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory; |
|
20 |
import eu.dnetlib.miscutils.datetime.DateUtils; |
|
21 |
|
|
22 |
/** |
|
23 |
* The Class ModularObjectStoreFeeder, responsible to feed data into the object Store |
|
24 |
*/ |
|
25 |
public class ModularObjectStoreFeeder { |
|
26 |
|
|
27 |
private static final Log log = LogFactory.getLog(ModularObjectStoreFeeder.class); |
|
28 |
|
|
29 |
/** The dao of the objectStore. */ |
|
30 |
private ObjectStoreDao dao; |
|
31 |
|
|
32 |
/** The result set client factory. */ |
|
33 |
private ResultSetClientFactory resultSetClientFactory; |
|
34 |
|
|
35 |
/** The service locator. */ |
|
36 |
private UniqueServiceLocator serviceLocator; |
|
37 |
|
|
38 |
/** |
|
39 |
* Gets the dao. |
|
40 |
* |
|
41 |
* @return the dao |
|
42 |
*/ |
|
43 |
public ObjectStoreDao getDao() { |
|
44 |
return dao; |
|
45 |
} |
|
46 |
|
|
47 |
/** |
|
48 |
* Sets the dao. |
|
49 |
* |
|
50 |
* @param dao |
|
51 |
* the new dao |
|
52 |
*/ |
|
53 |
@Required |
|
54 |
public void setDao(final ObjectStoreDao dao) { |
|
55 |
this.dao = dao; |
|
56 |
} |
|
57 |
|
|
58 |
/** |
|
59 |
* Gets the result set client factory. |
|
60 |
* |
|
61 |
* @return the result set client factory |
|
62 |
*/ |
|
63 |
public ResultSetClientFactory getResultSetClientFactory() { |
|
64 |
return resultSetClientFactory; |
|
65 |
} |
|
66 |
|
|
67 |
/** |
|
68 |
* Sets the result set client factory. |
|
69 |
* |
|
70 |
* @param resultSetClientFactory |
|
71 |
* the new result set client factory |
|
72 |
*/ |
|
73 |
|
|
74 |
@Required |
|
75 |
public void setResultSetClientFactory(final ResultSetClientFactory resultSetClientFactory) { |
|
76 |
this.resultSetClientFactory = resultSetClientFactory; |
|
77 |
} |
|
78 |
|
|
79 |
/** |
|
80 |
* Feed metadata object record. |
|
81 |
* |
|
82 |
* @param objectStoreID |
|
83 |
* the object store id |
|
84 |
* @param rsEpr |
|
85 |
* the rs epr |
|
86 |
* @param mime |
|
87 |
* the mime |
|
88 |
* @throws ObjectStoreServiceException |
|
89 |
*/ |
|
90 |
public void feedMetadataObjectRecord(final String objectStoreID, final String rsEpr, final String mime) throws ObjectStoreServiceException { |
|
91 |
|
|
92 |
final Iterable<String> records = resultSetClientFactory.getClient(rsEpr); |
|
93 |
Iterable<MetadataObjectRecord> toIngest = Iterables.transform(records, new Function<String, MetadataObjectRecord>() { |
|
94 |
|
|
95 |
@Override |
|
96 |
public MetadataObjectRecord apply(final String input) { |
|
97 |
MetadataObjectRecord record = MetadataObjectRecord.initFromJson(input); |
|
98 |
if (record != null) { |
|
99 |
record.setMime(mime); |
|
100 |
} else { |
|
101 |
log.error("An input record is null :" + input); |
|
102 |
} |
|
103 |
return record; |
|
104 |
} |
|
105 |
}); |
|
106 |
ObjectStore store = dao.getObjectStore(objectStoreID); |
|
107 |
int size = store.feedMetadataRecord(toIngest, true); |
|
108 |
touch(objectStoreID, size); |
|
109 |
} |
|
110 |
|
|
111 |
/** |
|
112 |
* Feed object in the object store starting from an EPR of objectMetadata |
|
113 |
* |
|
114 |
* @param obsId |
|
115 |
* the objectStore id |
|
116 |
* @param rsEpr |
|
117 |
* the result set Endpoint-reference |
|
118 |
* @param protocol |
|
119 |
* the protocol |
|
120 |
* @param login |
|
121 |
* the login |
|
122 |
* @param password |
|
123 |
* the password |
|
124 |
* @param mime |
|
125 |
* the mime type |
|
126 |
* @throws ObjectStoreServiceException |
|
127 |
*/ |
|
128 |
public void feed(final String obsId, final String rsEpr, final Protocols protocol, final String login, final String password, final String mime) |
|
129 |
throws ObjectStoreServiceException { |
|
130 |
final Iterable<String> records = resultSetClientFactory.getClient(rsEpr); |
|
131 |
ObjectBroker objectBroker = new ObjectBroker(protocol, login, password, mime); |
|
132 |
Iterable<ObjectStoreRecord> toIngest = Iterables.transform(records, objectBroker); |
|
133 |
ObjectStore store = dao.getObjectStore(obsId); |
|
134 |
int size = store.feed(toIngest, true); |
|
135 |
touch(obsId, size); |
|
136 |
} |
|
137 |
|
|
138 |
/** |
|
139 |
* Feed a single object in the object Stroe. |
|
140 |
* |
|
141 |
* @param objectStoreID |
|
142 |
* the object store id |
|
143 |
* @param objectID |
|
144 |
* the object id |
|
145 |
* @param URIObject |
|
146 |
* the URI of object |
|
147 |
* @param protocol |
|
148 |
* the protocol |
|
149 |
* @param login |
|
150 |
* the login |
|
151 |
* @param password |
|
152 |
* the password |
|
153 |
* @param mime |
|
154 |
* the mime type |
|
155 |
* @throws ObjectStoreServiceException |
|
156 |
*/ |
|
157 |
public void feedObject(final String objectStoreID, |
|
158 |
final String objectID, |
|
159 |
final String URIObject, |
|
160 |
final Protocols protocol, |
|
161 |
final String login, |
|
162 |
final String password, |
|
163 |
final String mime) throws ObjectStoreServiceException { |
|
164 |
ObjectStoreFile inputFile = new ObjectStoreFile(); |
|
165 |
inputFile.setURI(URIObject); |
|
166 |
inputFile.setObjectID(objectID); |
|
167 |
ObjectBroker objectBroker = new ObjectBroker(protocol, login, password, mime); |
|
168 |
Iterable<ObjectStoreRecord> toIngest = Iterables.transform(Lists.newArrayList(inputFile.toJSON()), objectBroker); |
|
169 |
ObjectStore store = dao.getObjectStore(objectStoreID); |
|
170 |
int size = store.feed(toIngest, true); |
|
171 |
touch(objectStoreID, size); |
|
172 |
} |
|
173 |
|
|
174 |
/** |
|
175 |
* Feed object record. |
|
176 |
* |
|
177 |
* @param objectStoreID |
|
178 |
* the object store id |
|
179 |
* @param record |
|
180 |
* the record |
|
181 |
* @return the string |
|
182 |
* @throws ObjectStoreServiceException |
|
183 |
*/ |
|
184 |
public String feedObjectRecord(final String objectStoreID, final ObjectStoreRecord record) throws ObjectStoreServiceException { |
|
185 |
ObjectStore store = dao.getObjectStore(objectStoreID); |
|
186 |
return store.feedObjectRecord(record); |
|
187 |
} |
|
188 |
|
|
189 |
/** |
|
190 |
* Sets the last modified date in the profile. |
|
191 |
* |
|
192 |
* @param obsId |
|
193 |
* the obs id |
|
194 |
* @param size |
|
195 |
* the size |
|
196 |
*/ |
|
197 |
public void touch(final String obsId, final int size) { |
|
198 |
try { |
|
199 |
final String now = DateUtils.now_ISO8601(); |
|
200 |
|
|
201 |
final String mdstoreXUpdate = "for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + obsId + "']" |
|
202 |
+ "return update value $x//LAST_STORAGE_DATE with '" + now + "'"; |
|
203 |
|
|
204 |
serviceLocator.getService(ISRegistryService.class, true).executeXUpdate(mdstoreXUpdate); |
|
205 |
|
|
206 |
touchSize(obsId, size); |
|
207 |
} catch (final Exception e) { |
|
208 |
throw new IllegalStateException(e); |
|
209 |
} |
|
210 |
} |
|
211 |
|
|
212 |
/** |
|
213 |
* Touch size. |
|
214 |
* |
|
215 |
* @param obsId |
|
216 |
* the obs id |
|
217 |
* @param size |
|
218 |
* the size |
|
219 |
*/ |
|
220 |
public void touchSize(final String obsId, final int size) { |
|
221 |
try { |
|
222 |
final String mdstoreNumberXUpdate = "for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + obsId + "']" |
|
223 |
+ "return update value $x//COUNT_STORE with '" + size + "'"; |
|
224 |
|
|
225 |
serviceLocator.getService(ISRegistryService.class, true).executeXUpdate(mdstoreNumberXUpdate); |
|
226 |
} catch (final Exception e) { |
|
227 |
throw new IllegalStateException(e); |
|
228 |
} |
|
229 |
} |
|
230 |
|
|
231 |
public UniqueServiceLocator getServiceLocator() { |
|
232 |
return serviceLocator; |
|
233 |
} |
|
234 |
|
|
235 |
@Required |
|
236 |
public void setServiceLocator(final UniqueServiceLocator serviceLocator) { |
|
237 |
this.serviceLocator = serviceLocator; |
|
238 |
} |
|
239 |
|
|
240 |
} |
modules/dnet-modular-objectstore-service/tags/dnet-modular-objectstore-service-4.1.0/src/main/java/eu/dnetlib/data/objectstore/modular/ObjectStoreProfileCreator.java | ||
---|---|---|
1 |
package eu.dnetlib.data.objectstore.modular; |
|
2 |
|
|
3 |
import javax.xml.ws.Endpoint; |
|
4 |
|
|
5 |
import org.antlr.stringtemplate.StringTemplate; |
|
6 |
import org.springframework.beans.factory.annotation.Required; |
|
7 |
|
|
8 |
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException; |
|
9 |
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService; |
|
10 |
import eu.dnetlib.enabling.locators.UniqueServiceLocator; |
|
11 |
import eu.dnetlib.soap.EndpointReferenceBuilder; |
|
12 |
|
|
13 |
// TODO: Auto-generated Javadoc |
|
14 |
/** |
|
15 |
* The Class ObjectStoreProfileCreator is responsible of creating profile of the ObjectStore |
|
16 |
*/ |
|
17 |
public class ObjectStoreProfileCreator { |
|
18 |
|
|
19 |
/** |
|
20 |
* service locator. |
|
21 |
*/ |
|
22 |
private UniqueServiceLocator serviceLocator; |
|
23 |
|
|
24 |
/** |
|
25 |
* mdstore ds template. |
|
26 |
*/ |
|
27 |
private StringTemplate objectstoreDsTemplate; |
|
28 |
|
|
29 |
/** |
|
30 |
* service endpoint. |
|
31 |
*/ |
|
32 |
private Endpoint endpoint; |
|
33 |
|
|
34 |
/** |
|
35 |
* endpoint builder. |
|
36 |
*/ |
|
37 |
private EndpointReferenceBuilder<Endpoint> eprBuilder; |
|
38 |
|
|
39 |
/** |
|
40 |
* Register profile. |
|
41 |
* |
|
42 |
* @param interpretation |
|
43 |
* the interpretation |
|
44 |
* @return the string |
|
45 |
* @throws ISRegistryException |
|
46 |
* the IS registry exception |
|
47 |
*/ |
|
48 |
public String registerProfile(final String interpretation) |
|
49 |
throws ISRegistryException { |
|
50 |
// XXX: mini hack |
|
51 |
StringTemplate template = new StringTemplate( |
|
52 |
objectstoreDsTemplate.getTemplate()); |
|
53 |
template.setAttribute("serviceUri", eprBuilder.getAddress(endpoint)); |
|
54 |
template.setAttribute("interpretation", interpretation); |
|
55 |
|
|
56 |
return serviceLocator.getService(ISRegistryService.class, true).registerProfile(template.toString()); |
|
57 |
} |
|
58 |
|
|
59 |
/** |
|
60 |
* Gets the endpoint. |
|
61 |
* |
|
62 |
* @return the endpoint |
|
63 |
*/ |
|
64 |
public Endpoint getEndpoint() { |
|
65 |
return endpoint; |
|
66 |
} |
|
67 |
|
|
68 |
/** |
|
69 |
* Sets the endpoint. |
|
70 |
* |
|
71 |
* @param endpoint |
|
72 |
* the new endpoint |
|
73 |
*/ |
|
74 |
@Required |
|
75 |
public void setEndpoint(final Endpoint endpoint) { |
|
76 |
this.endpoint = endpoint; |
|
77 |
} |
|
78 |
|
|
79 |
/** |
|
80 |
* Gets the epr builder. |
|
81 |
* |
|
82 |
* @return the epr builder |
|
83 |
*/ |
|
84 |
public EndpointReferenceBuilder<Endpoint> getEprBuilder() { |
|
85 |
return eprBuilder; |
|
86 |
} |
|
87 |
|
|
88 |
/** |
|
89 |
* Sets the epr builder. |
|
90 |
* |
|
91 |
* @param eprBuilder |
|
92 |
* the new epr builder |
|
93 |
*/ |
|
94 |
@Required |
|
95 |
public void setEprBuilder(final EndpointReferenceBuilder<Endpoint> eprBuilder) { |
|
96 |
this.eprBuilder = eprBuilder; |
|
97 |
} |
|
98 |
|
|
99 |
/** |
|
100 |
* Gets the objectstore ds template. |
|
101 |
* |
|
102 |
* @return the objectstore ds template |
|
103 |
*/ |
|
104 |
public StringTemplate getObjectstoreDsTemplate() { |
|
105 |
return objectstoreDsTemplate; |
|
106 |
} |
|
107 |
|
|
108 |
/** |
|
109 |
* Sets the objectstore ds template. |
|
110 |
* |
|
111 |
* @param objectstoreDsTemplate |
|
112 |
* the new objectstore ds template |
|
113 |
*/ |
|
114 |
@Required |
|
115 |
public void setObjectstoreDsTemplate(final StringTemplate objectstoreDsTemplate) { |
|
116 |
this.objectstoreDsTemplate = objectstoreDsTemplate; |
|
117 |
} |
|
118 |
|
|
119 |
public UniqueServiceLocator getServiceLocator() { |
|
120 |
return serviceLocator; |
|
121 |
} |
|
122 |
|
|
123 |
@Required |
|
124 |
public void setServiceLocator(final UniqueServiceLocator serviceLocator) { |
|
125 |
this.serviceLocator = serviceLocator; |
|
126 |
} |
|
127 |
|
|
128 |
} |
modules/dnet-modular-objectstore-service/tags/dnet-modular-objectstore-service-4.1.0/src/main/java/eu/dnetlib/data/objectstore/modular/ModularObjectStoreDeliver.java | ||
---|---|---|
1 |
package eu.dnetlib.data.objectstore.modular; |
|
2 |
|
|
3 |
import java.io.InputStream; |
|
4 |
|
|
5 |
import javax.annotation.Resource; |
|
6 |
import javax.xml.ws.wsaddressing.W3CEndpointReference; |
|
7 |
|
|
8 |
import org.springframework.beans.factory.annotation.Required; |
|
9 |
|
|
10 |
import eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao; |
|
11 |
import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile; |
|
12 |
import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException; |
|
13 |
import eu.dnetlib.enabling.resultset.ResultSetFactory; |
|
14 |
import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory; |
|
15 |
|
|
16 |
/** |
|
17 |
* The Class ModularObjectStoreDeliver is responsible of delivering data from the object Store. |
|
18 |
*/ |
|
19 |
public class ModularObjectStoreDeliver { |
|
20 |
|
|
21 |
/** The dao. */ |
|
22 |
private ObjectStoreDao dao; |
|
23 |
|
|
24 |
/** The result set factory. */ |
|
25 |
@Resource |
|
26 |
private ResultSetFactory resultSetFactory; |
|
27 |
|
|
28 |
/** The result set client factory. */ |
|
29 |
private ResultSetClientFactory resultSetClientFactory; |
|
30 |
|
|
31 |
/** |
|
32 |
* Gets the dao. |
|
33 |
* |
|
34 |
* @return the dao |
|
35 |
*/ |
|
36 |
public ObjectStoreDao getDao() { |
|
37 |
return dao; |
|
38 |
} |
|
39 |
|
|
40 |
/** |
|
41 |
* Sets the dao. |
|
42 |
* |
|
43 |
* @param dao |
|
44 |
* the new dao |
|
45 |
*/ |
|
46 |
@Required |
|
47 |
public void setDao(final ObjectStoreDao dao) { |
|
48 |
this.dao = dao; |
|
49 |
} |
|
50 |
|
|
51 |
/** |
|
52 |
* Deliver. |
|
53 |
* |
|
54 |
* @param objectStoreID |
|
55 |
* the object store id |
|
56 |
* @param from |
|
57 |
* the from |
|
58 |
* @param until |
|
59 |
* the until |
|
60 |
* @return the w3 c endpoint reference |
|
61 |
* @throws ObjectStoreServiceException |
|
62 |
*/ |
|
63 |
public W3CEndpointReference deliver(final String objectStoreID, final Long from, final Long until) throws ObjectStoreServiceException { |
|
64 |
return resultSetFactory.createResultSet(dao.getObjectStore(objectStoreID).deliver(from, until)); |
|
65 |
} |
|
66 |
|
|
67 |
/** |
|
68 |
* Deliver ids. |
|
69 |
* |
|
70 |
* @param objectStoreID |
|
71 |
* the object store id |
|
72 |
* @param eprId |
|
73 |
* the epr id |
|
74 |
* @return the w3 c endpoint reference |
|
75 |
* @throws ObjectStoreServiceException |
|
76 |
*/ |
|
77 |
public W3CEndpointReference deliverIds(final String objectStoreID, final W3CEndpointReference eprId) throws ObjectStoreServiceException { |
|
78 |
|
|
79 |
Iterable<String> ids = resultSetClientFactory.getClient(eprId); |
|
80 |
return resultSetFactory.createResultSet(dao.getObjectStore(objectStoreID).deliverIds(ids)); |
|
81 |
} |
|
82 |
|
|
83 |
/** |
|
84 |
* Exist id starts with. |
|
85 |
* |
|
86 |
* @param obsId |
|
87 |
* the obs id |
|
88 |
* @param startId |
|
89 |
* the start id |
|
90 |
* @return true, if successful |
|
91 |
* @throws ObjectStoreServiceException |
|
92 |
*/ |
|
93 |
public boolean existIDStartsWith(final String obsId, final String startId) throws ObjectStoreServiceException { |
|
94 |
return dao.getObjectStore(obsId).existIDStartsWith(startId); |
|
95 |
} |
|
96 |
|
|
97 |
/** |
|
98 |
* Deliver object. |
|
99 |
* |
|
100 |
* @param objectStoreID |
|
101 |
* the object store id |
|
102 |
* @param objectId |
|
103 |
* the object id |
|
104 |
* @return the object store file |
|
105 |
* @throws ObjectStoreServiceException |
|
106 |
*/ |
|
107 |
public ObjectStoreFile deliverObject(final String objectStoreID, final String objectId) throws ObjectStoreServiceException { |
|
108 |
return dao.getObjectStore(objectStoreID).deliverObject(objectId); |
|
109 |
} |
|
110 |
|
|
111 |
/** |
|
112 |
* Deliver stream. |
|
113 |
* |
|
114 |
* @param objectStoreID |
|
115 |
* the object store id |
|
116 |
* @param objectId |
|
117 |
* the object id |
|
118 |
* @return the input stream |
|
119 |
* @throws ObjectStoreServiceException |
|
120 |
*/ |
|
121 |
public InputStream deliverStream(final String objectStoreID, final String objectId) throws ObjectStoreServiceException { |
|
122 |
return dao.getObjectStore(objectStoreID).deliverStream(objectId); |
|
123 |
} |
|
124 |
|
|
125 |
/** |
|
126 |
* Gets the result set client factory. |
|
127 |
* |
|
128 |
* @return the result set client factory |
|
129 |
*/ |
|
130 |
public ResultSetClientFactory getResultSetClientFactory() { |
|
131 |
return resultSetClientFactory; |
|
132 |
} |
|
133 |
|
|
134 |
/** |
|
135 |
* Sets the result set client factory. |
|
136 |
* |
|
137 |
* @param resultSetClientFactory |
|
138 |
* the new result set client factory |
|
139 |
*/ |
|
140 |
@Required |
|
141 |
public void setResultSetClientFactory(final ResultSetClientFactory resultSetClientFactory) { |
|
142 |
this.resultSetClientFactory = resultSetClientFactory; |
|
143 |
} |
|
144 |
|
|
145 |
} |
modules/dnet-modular-objectstore-service/tags/dnet-modular-objectstore-service-4.1.0/src/main/java/eu/dnetlib/data/objectstore/modular/ModularObjectStoreService.java | ||
---|---|---|
1 |
package eu.dnetlib.data.objectstore.modular; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import javax.xml.ws.wsaddressing.W3CEndpointReference; |
|
6 |
|
|
7 |
import org.springframework.beans.factory.annotation.Required; |
|
8 |
|
|
9 |
import com.google.gson.Gson; |
|
10 |
|
|
11 |
import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile; |
|
12 |
import eu.dnetlib.data.objectstore.rmi.ObjectStoreService; |
|
13 |
import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException; |
|
14 |
import eu.dnetlib.enabling.tools.AbstractBaseService; |
|
15 |
import eu.dnetlib.enabling.tools.blackboard.NotificationHandler; |
|
16 |
|
|
17 |
// TODO: Auto-generated Javadoc |
|
18 |
/** |
|
19 |
* The Class ModularObjectStoreService is the implementation of the ObjectStoreService interface. |
|
20 |
*/ |
|
21 |
public class ModularObjectStoreService extends AbstractBaseService implements ObjectStoreService { |
|
22 |
|
|
23 |
/** The feeder. */ |
|
24 |
private ModularObjectStoreFeeder feeder; |
|
25 |
|
|
26 |
/** The object store deliver. */ |
|
27 |
private ModularObjectStoreDeliver objectStoreDeliver; |
|
28 |
|
|
29 |
/** The notification handler. */ |
|
30 |
private NotificationHandler notificationHandler; |
|
31 |
|
|
32 |
/* |
|
33 |
* (non-Javadoc) |
|
34 |
* |
|
35 |
* @see eu.dnetlib.data.objectstore.rmi.ObjectStoreService#deliverObjects(java.lang.String, java.lang.Double, java.lang.Double) |
|
36 |
*/ |
|
37 |
/** |
|
38 |
* Deliver objects. |
|
39 |
* |
|
40 |
* @param obsId |
|
41 |
* the obs id |
|
42 |
* @param from |
|
43 |
* the from |
|
44 |
* @param until |
|
45 |
* the until |
|
46 |
* @return the w3 c endpoint reference |
|
47 |
* @throws ObjectStoreServiceException |
|
48 |
* the object store service exception |
|
49 |
*/ |
|
50 |
@Override |
|
51 |
public W3CEndpointReference deliverObjects(final String obsId, final Long from, final Long until) throws ObjectStoreServiceException { |
|
52 |
|
|
53 |
return objectStoreDeliver.deliver(obsId, from, until); |
|
54 |
} |
|
55 |
|
|
56 |
/* |
|
57 |
* (non-Javadoc) |
|
58 |
* |
|
59 |
* @see eu.dnetlib.data.objectstore.rmi.ObjectStoreService#deliverObjectsByIds(java.lang.String, |
|
60 |
* javax.xml.ws.wsaddressing.W3CEndpointReference) |
|
61 |
*/ |
|
62 |
/** |
|
63 |
* Deliver objects by ids. |
|
64 |
* |
|
65 |
* @param obsId |
|
66 |
* the obs id |
|
67 |
* @param eprId |
|
68 |
* the epr id |
|
69 |
* @return the w3 c endpoint reference |
|
70 |
* @throws ObjectStoreServiceException |
|
71 |
* the object store service exception |
|
72 |
*/ |
|
73 |
@Override |
|
74 |
public W3CEndpointReference deliverObjectsByIds(final String obsId, final W3CEndpointReference eprId) throws ObjectStoreServiceException { |
|
75 |
return objectStoreDeliver.deliverIds(obsId, eprId); |
|
76 |
} |
|
77 |
|
|
78 |
/* |
|
79 |
* (non-Javadoc) |
|
80 |
* |
|
81 |
* @see eu.dnetlib.data.objectstore.rmi.ObjectStoreService#deliverRecord(java.lang.String, java.lang.String) |
|
82 |
*/ |
|
83 |
/** |
|
84 |
* Deliver record. |
|
85 |
* |
|
86 |
* @param obsId |
|
87 |
* the obs id |
|
88 |
* @param objectId |
|
89 |
* the object id |
|
90 |
* @return the string |
|
91 |
* @throws ObjectStoreServiceException |
|
92 |
* the object store service exception |
|
93 |
*/ |
|
94 |
@Override |
|
95 |
public String deliverRecord(final String obsId, final String objectId) throws ObjectStoreServiceException { |
|
96 |
return objectStoreDeliver.deliverObject(obsId, objectId).toJSON(); |
|
97 |
} |
|
98 |
|
|
99 |
/* |
|
100 |
* (non-Javadoc) |
|
101 |
* |
|
102 |
* @see eu.dnetlib.data.objectstore.rmi.ObjectStoreService#getListOfObjectStores() |
|
103 |
*/ |
|
104 |
/** |
|
105 |
* Gets the list of object stores. |
|
106 |
* |
|
107 |
* @return the list of object stores |
|
108 |
*/ |
|
109 |
@Override |
|
110 |
public List<String> getListOfObjectStores() { |
|
111 |
return objectStoreDeliver.getDao().listObjectStores(); |
|
112 |
} |
|
113 |
|
|
114 |
/** |
|
115 |
* Gets the feeder. |
|
116 |
* |
|
117 |
* @return the feeder |
|
118 |
*/ |
|
119 |
public ModularObjectStoreFeeder getFeeder() { |
|
120 |
return feeder; |
|
121 |
} |
|
122 |
|
|
123 |
/** |
|
124 |
* Sets the feeder. |
|
125 |
* |
|
126 |
* @param feeder |
|
127 |
* the new feeder |
|
128 |
*/ |
|
129 |
@Required |
|
130 |
public void setFeeder(final ModularObjectStoreFeeder feeder) { |
|
131 |
this.feeder = feeder; |
|
132 |
} |
|
133 |
|
|
134 |
/** |
|
135 |
* Gets the notification handler. |
|
136 |
* |
|
137 |
* @return the notification handler |
|
138 |
*/ |
|
139 |
public NotificationHandler getNotificationHandler() { |
|
140 |
return notificationHandler; |
|
141 |
} |
|
142 |
|
|
143 |
/** |
|
144 |
* Sets the notification handler. |
|
145 |
* |
|
146 |
* @param notificationHandler |
|
147 |
* the new notification handler |
|
148 |
*/ |
|
149 |
@Required |
|
150 |
public void setNotificationHandler(final NotificationHandler notificationHandler) { |
|
151 |
this.notificationHandler = notificationHandler; |
|
152 |
} |
|
153 |
|
|
154 |
/** |
|
155 |
* {@inheritDoc} |
|
156 |
* |
|
157 |
* @see eu.dnetlib.enabling.tools.AbstractBaseService#notify(java.lang.String, java.lang.String, java.lang.String, java.lang.String) |
|
158 |
*/ |
|
159 |
@Override |
|
160 |
public void notify(final String subscriptionId, final String topic, final String isId, final String message) { |
|
161 |
getNotificationHandler().notified(subscriptionId, topic, isId, message); |
|
162 |
} |
|
163 |
|
|
164 |
/** |
|
165 |
* Gets the object store deliver. |
|
166 |
* |
|
167 |
* @return the object store deliver |
|
168 |
*/ |
|
169 |
public ModularObjectStoreDeliver getObjectStoreDeliver() { |
|
170 |
return objectStoreDeliver; |
|
171 |
} |
|
172 |
|
|
173 |
/** |
|
174 |
* Sets the object store deliver. |
|
175 |
* |
|
176 |
* @param objectStoreDeliver |
|
177 |
* the new object store deliver |
|
178 |
*/ |
|
179 |
@Required |
|
180 |
public void setObjectStoreDeliver(final ModularObjectStoreDeliver objectStoreDeliver) { |
|
181 |
this.objectStoreDeliver = objectStoreDeliver; |
|
182 |
} |
|
183 |
|
|
184 |
/* |
|
185 |
* (non-Javadoc) |
|
186 |
* |
|
187 |
* @see eu.dnetlib.data.objectstore.rmi.ObjectStoreService#feedObject(java.lang.String, java.lang.String) |
|
188 |
*/ |
|
189 |
/** |
|
190 |
* Feed object. |
|
191 |
* |
|
192 |
* @param obsId |
|
193 |
* the obs id |
|
194 |
* @param objectMetadata |
|
195 |
* the object metadata |
|
196 |
* @throws ObjectStoreServiceException |
|
197 |
* the object store service exception |
|
198 |
*/ |
|
199 |
@Override |
|
200 |
public void feedObject(final String obsId, final String objectMetadata) throws ObjectStoreServiceException { |
|
201 |
Gson g = new Gson(); |
|
202 |
try { |
|
203 |
ObjectStoreFile file = g.fromJson(objectMetadata, ObjectStoreFile.class); |
|
204 |
feeder.feedObject(obsId, file.getObjectID(), file.getURI(), file.getAccessProtocol(), file.getUsernameAuth(), file.getPasswordAuth(), |
|
205 |
file.getMimeType()); |
|
206 |
|
|
207 |
} catch (Exception e) { |
|
208 |
throw new ObjectStoreServiceException(e.getMessage()); |
|
209 |
} |
|
210 |
|
|
211 |
} |
|
212 |
|
|
213 |
/** |
|
214 |
* Exist id starts with. |
|
215 |
* |
|
216 |
* @param obsId |
|
217 |
* the obs id |
|
218 |
* @param startId |
|
219 |
* the start id |
|
220 |
* @return true, if successful |
|
221 |
* @throws ObjectStoreServiceException |
|
222 |
* the object store service exception |
|
223 |
*/ |
|
224 |
public boolean existIDStartsWith(final String obsId, final String startId) throws ObjectStoreServiceException { |
|
225 |
return objectStoreDeliver.existIDStartsWith(obsId, startId); |
|
226 |
} |
|
227 |
|
|
228 |
/** |
|
229 |
* Feed object. |
|
230 |
* |
|
231 |
* @param obsId |
|
232 |
* the obs id |
|
233 |
* @param record |
|
234 |
* the record |
|
235 |
* @return the string |
|
236 |
* @throws ObjectStoreServiceException |
|
237 |
* the object store service exception |
|
238 |
*/ |
|
239 |
public String feedObject(final String obsId, final ObjectStoreRecord record) throws ObjectStoreServiceException { |
|
240 |
|
|
241 |
try { |
|
242 |
|
|
243 |
return feeder.feedObjectRecord(obsId, record); |
|
244 |
|
|
245 |
} catch (Exception e) { |
|
246 |
throw new ObjectStoreServiceException(e.getMessage()); |
|
247 |
} |
|
248 |
|
|
249 |
} |
|
250 |
|
|
251 |
/** |
|
252 |
* Gets the size. |
|
253 |
* |
|
254 |
* @param obsId |
|
255 |
* the obs id |
|
256 |
* @return the size |
|
257 |
* @throws ObjectStoreServiceException |
|
258 |
* the object store service exception |
|
259 |
*/ |
|
260 |
@Override |
|
261 |
public int getSize(final String obsId) throws ObjectStoreServiceException { |
|
262 |
return objectStoreDeliver.getDao().getObjectStore(obsId).getSize(); |
|
263 |
|
|
264 |
} |
|
265 |
} |
modules/dnet-modular-objectstore-service/tags/dnet-modular-objectstore-service-4.1.0/src/main/java/eu/dnetlib/data/objectstore/modular/ModularObjectStoreRESTService.java | ||
---|---|---|
1 |
package eu.dnetlib.data.objectstore.modular; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
import java.io.InputStream; |
|
5 |
|
|
6 |
import javax.annotation.Resource; |
|
7 |
import javax.servlet.ServletOutputStream; |
|
8 |
import javax.servlet.http.HttpServletResponse; |
|
9 |
|
|
10 |
import org.apache.commons.io.IOUtils; |
|
11 |
import org.springframework.stereotype.Controller; |
|
12 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
13 |
import org.springframework.web.bind.annotation.RequestParam; |
|
14 |
|
|
15 |
import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile; |
|
16 |
import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException; |
|
17 |
|
|
18 |
// TODO: Auto-generated Javadoc |
|
19 |
/** |
|
20 |
* The Class ModularObjectStoreRESTService implement the controller REST of the object Store. |
|
21 |
*/ |
|
22 |
@Controller |
|
23 |
public class ModularObjectStoreRESTService { |
|
24 |
|
|
25 |
/** The object store deliver. */ |
|
26 |
@Resource |
|
27 |
ModularObjectStoreDeliver objectStoreDeliver; |
|
28 |
|
|
29 |
/** |
|
30 |
* Retrieve. |
|
31 |
* |
|
32 |
* @param res |
|
33 |
* the res |
|
34 |
* @param objectStoreId |
|
35 |
* the object store id |
|
36 |
* @param objectId |
|
37 |
* the object id |
|
38 |
* @throws IOException |
Also available in: Unified diff
[maven-release-plugin] copy for tag dnet-modular-objectstore-service-4.1.0