Project

General

Profile

« Previous | Next » 

Revision 8795

take advantage of the ezidclient for multi-threaded/asynchronous DOI registration. This will be most useful for doing large batch updates and not so much for the one-at-a-time publish actions but works in either context. https://projects.ecoinformatics.org/ecoinfo/issues/6440

View differences:

RegisterDOITest.java
180 180
			Identifier guid = MNodeService.getInstance(request).generateIdentifier(session, "DOI", null);
181 181
			
182 182
			// check that EZID knows about it
183
			HashMap<String, String> metadata = ezid.getMetadata(guid.getValue());
183
			HashMap<String, String> metadata = null;
184
			int count = 0;
185
			do {
186
				try {
187
					metadata = ezid.getMetadata(guid.getValue());
188
				} catch (Exception e) {
189
					Thread.sleep(1000);
190
				}
191
				count++;
192
			} while (metadata == null && count < 10);
184 193
			assertNotNull(metadata);
185 194

  
186 195
			// add the actual object for the newly-minted DOI
......
201 210
			assertEquals(guid.getValue(), pid.getValue());
202 211

  
203 212
			// check for the metadata for title element
204
			metadata = ezid.getMetadata(pid.getValue());
213
			count = 0;
214
			metadata = null;
215
			do {
216
				try {
217
					metadata = ezid.getMetadata(pid.getValue());
218
					// check if the update thread finished yet, otherwise try again
219
					if (metadata != null && isMetadata) {
220
						String registeredTarget = metadata.get(InternalProfile.TARGET.toString());
221
						if (!registeredTarget.endsWith("/#view/" + pid.getValue())) {
222
							// try fetching it again
223
							metadata = null;
224
						}
225
					}
226
				} catch (Exception e) {
227
					Thread.sleep(1000);
228
				}
229
				count++;
230
			} while (metadata == null && count < 10);
205 231
			assertNotNull(metadata);
206 232
			assertTrue(metadata.containsKey(DataCiteProfile.TITLE.toString()));
207 233
			
......
243 269
			// check for the metadata explicitly, using ezid service
244 270
			EZIDService ezid = new EZIDService(ezidServiceBaseUrl);
245 271
			ezid.login(ezidUsername, ezidPassword);
246
			HashMap<String, String> metadata = ezid.getMetadata(pid.getValue());
272
			int count = 0;
273
			HashMap<String, String> metadata = null;
274
			do {
275
				try {
276
					metadata = ezid.getMetadata(pid.getValue());
277
				} catch (Exception e) {
278
					Thread.sleep(1000);
279
				}
280
				count++;
281
			} while (metadata == null && count < 10);
282
			
247 283
			assertNotNull(metadata);
248 284
			assertTrue(metadata.containsKey(DataCiteProfile.TITLE.toString()));
249 285
			
......
288 324
	            // check for the metadata explicitly, using ezid service
289 325
	            EZIDService ezid = new EZIDService(ezidServiceBaseUrl);
290 326
	            ezid.login(ezidUsername, ezidPassword);
291
	            HashMap<String, String> metadata = ezid.getMetadata(publishedIdentifier.getValue());
327
	            int count = 0;
328
				HashMap<String, String> metadata = null;
329
				do {
330
					try {
331
						metadata = ezid.getMetadata(publishedIdentifier.getValue());
332
					} catch (Exception e) {
333
						Thread.sleep(1000);
334
					}
335
					count++;
336
				} while (metadata == null && count < 10);
337
	            
292 338
	            assertNotNull(metadata);
293 339
	            assertTrue(metadata.containsKey(DataCiteProfile.TITLE.toString()));
294 340
	            content.close();

Also available in: Unified diff