target
stringlengths
20
113k
src_fm
stringlengths
11
86.3k
src_fm_fc
stringlengths
21
86.4k
src_fm_fc_co
stringlengths
30
86.4k
src_fm_fc_ms
stringlengths
42
86.8k
src_fm_fc_ms_ff
stringlengths
43
86.8k
@Test(expected = RecordNotExistsException.class) public void exceptionShouldBeThrowForRecordWithoutRepresentations() throws RecordNotExistsException, ProviderNotExistsException { recordsResource.getRecord(null, PROVIDER_ID, LOCAL_ID_FOR_RECORD_WITHOUT_REPRESENTATIONS); }
@GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) public @ResponseBody Record getRecord( HttpServletRequest httpServletRequest, @PathVariable String providerId, @PathVariable String localId) throws RecordNotExistsException, ProviderNotExistsException { final String cloudId = findCloudIdFor(providerId, localId); Record record = recordService.getRecord(cloudId); prepare(httpServletRequest, record); return record; }
SimplifiedRecordsResource { @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) public @ResponseBody Record getRecord( HttpServletRequest httpServletRequest, @PathVariable String providerId, @PathVariable String localId) throws RecordNotExistsException, ProviderNotExistsException { final String cloudId = findCloudIdFor(providerId, localId); Record record = recordService.getRecord(cloudId); prepare(httpServletRequest, record); return record; } }
SimplifiedRecordsResource { @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) public @ResponseBody Record getRecord( HttpServletRequest httpServletRequest, @PathVariable String providerId, @PathVariable String localId) throws RecordNotExistsException, ProviderNotExistsException { final String cloudId = findCloudIdFor(providerId, localId); Record record = recordService.getRecord(cloudId); prepare(httpServletRequest, record); return record; } SimplifiedRecordsResource(RecordService recordService, UISClientHandler uisHandler); }
SimplifiedRecordsResource { @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) public @ResponseBody Record getRecord( HttpServletRequest httpServletRequest, @PathVariable String providerId, @PathVariable String localId) throws RecordNotExistsException, ProviderNotExistsException { final String cloudId = findCloudIdFor(providerId, localId); Record record = recordService.getRecord(cloudId); prepare(httpServletRequest, record); return record; } SimplifiedRecordsResource(RecordService recordService, UISClientHandler uisHandler); @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody Record getRecord( HttpServletRequest httpServletRequest, @PathVariable String providerId, @PathVariable String localId); }
SimplifiedRecordsResource { @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) public @ResponseBody Record getRecord( HttpServletRequest httpServletRequest, @PathVariable String providerId, @PathVariable String localId) throws RecordNotExistsException, ProviderNotExistsException { final String cloudId = findCloudIdFor(providerId, localId); Record record = recordService.getRecord(cloudId); prepare(httpServletRequest, record); return record; } SimplifiedRecordsResource(RecordService recordService, UISClientHandler uisHandler); @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody Record getRecord( HttpServletRequest httpServletRequest, @PathVariable String providerId, @PathVariable String localId); }
@Test public void properRecordShouldBeReturned() throws RecordNotExistsException, ProviderNotExistsException { HttpServletRequest info = mockHttpServletRequest(); Record record = recordsResource.getRecord(info, PROVIDER_ID, LOCAL_ID_FOR_EXISTING_RECORD); Assert.assertNotNull(record); for (Representation representation : record.getRepresentations()) { Assert.assertTrue(representation.getCloudId() == null); } }
@GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) public @ResponseBody Record getRecord( HttpServletRequest httpServletRequest, @PathVariable String providerId, @PathVariable String localId) throws RecordNotExistsException, ProviderNotExistsException { final String cloudId = findCloudIdFor(providerId, localId); Record record = recordService.getRecord(cloudId); prepare(httpServletRequest, record); return record; }
SimplifiedRecordsResource { @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) public @ResponseBody Record getRecord( HttpServletRequest httpServletRequest, @PathVariable String providerId, @PathVariable String localId) throws RecordNotExistsException, ProviderNotExistsException { final String cloudId = findCloudIdFor(providerId, localId); Record record = recordService.getRecord(cloudId); prepare(httpServletRequest, record); return record; } }
SimplifiedRecordsResource { @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) public @ResponseBody Record getRecord( HttpServletRequest httpServletRequest, @PathVariable String providerId, @PathVariable String localId) throws RecordNotExistsException, ProviderNotExistsException { final String cloudId = findCloudIdFor(providerId, localId); Record record = recordService.getRecord(cloudId); prepare(httpServletRequest, record); return record; } SimplifiedRecordsResource(RecordService recordService, UISClientHandler uisHandler); }
SimplifiedRecordsResource { @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) public @ResponseBody Record getRecord( HttpServletRequest httpServletRequest, @PathVariable String providerId, @PathVariable String localId) throws RecordNotExistsException, ProviderNotExistsException { final String cloudId = findCloudIdFor(providerId, localId); Record record = recordService.getRecord(cloudId); prepare(httpServletRequest, record); return record; } SimplifiedRecordsResource(RecordService recordService, UISClientHandler uisHandler); @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody Record getRecord( HttpServletRequest httpServletRequest, @PathVariable String providerId, @PathVariable String localId); }
SimplifiedRecordsResource { @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) public @ResponseBody Record getRecord( HttpServletRequest httpServletRequest, @PathVariable String providerId, @PathVariable String localId) throws RecordNotExistsException, ProviderNotExistsException { final String cloudId = findCloudIdFor(providerId, localId); Record record = recordService.getRecord(cloudId); prepare(httpServletRequest, record); return record; } SimplifiedRecordsResource(RecordService recordService, UISClientHandler uisHandler); @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody Record getRecord( HttpServletRequest httpServletRequest, @PathVariable String providerId, @PathVariable String localId); }
@Test @Parameters(method = "mimeTypes") public void testGetRepresentationVersion(MediaType mediaType) throws Exception { Representation expected = new Representation(representation); URITools.enrich(expected, getBaseUri()); when(recordService.getRepresentation(globalId, schema, version)).thenReturn(new Representation(representation)); ResultActions response = mockMvc.perform(get(URITools.getVersionPath(globalId, schema, version)).accept(mediaType)) .andExpect(status().isOk()) .andExpect(content().contentType(mediaType)); Representation entity = responseContent(response, Representation.class, mediaType); assertThat(entity, is(expected)); verify(recordService, times(1)).getRepresentation(globalId, schema, version); verifyNoMoreInteractions(recordService); }
@GetMapping(value = REPRESENTATION_VERSION, produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") public @ResponseBody Representation getRepresentationVersion( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version) throws RepresentationNotExistsException { Representation representation = recordService.getRepresentation(cloudId, representationName, version); EnrichUriUtil.enrich(httpServletRequest, representation); return representation; }
RepresentationVersionResource { @GetMapping(value = REPRESENTATION_VERSION, produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") public @ResponseBody Representation getRepresentationVersion( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version) throws RepresentationNotExistsException { Representation representation = recordService.getRepresentation(cloudId, representationName, version); EnrichUriUtil.enrich(httpServletRequest, representation); return representation; } }
RepresentationVersionResource { @GetMapping(value = REPRESENTATION_VERSION, produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") public @ResponseBody Representation getRepresentationVersion( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version) throws RepresentationNotExistsException { Representation representation = recordService.getRepresentation(cloudId, representationName, version); EnrichUriUtil.enrich(httpServletRequest, representation); return representation; } RepresentationVersionResource(RecordService recordService, MutableAclService mutableAclService); }
RepresentationVersionResource { @GetMapping(value = REPRESENTATION_VERSION, produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") public @ResponseBody Representation getRepresentationVersion( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version) throws RepresentationNotExistsException { Representation representation = recordService.getRepresentation(cloudId, representationName, version); EnrichUriUtil.enrich(httpServletRequest, representation); return representation; } RepresentationVersionResource(RecordService recordService, MutableAclService mutableAclService); @GetMapping(value = REPRESENTATION_VERSION, produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") @ResponseBody Representation getRepresentationVersion( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @DeleteMapping(value = REPRESENTATION_VERSION) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', delete)") @ResponseStatus(HttpStatus.NO_CONTENT) void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @PostMapping(value = REPRESENTATION_VERSION_PERSIST) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', write)") ResponseEntity<Void> persistRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @PostMapping(value = REPRESENTATION_VERSION_COPY) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") ResponseEntity<Void> copyRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); }
RepresentationVersionResource { @GetMapping(value = REPRESENTATION_VERSION, produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") public @ResponseBody Representation getRepresentationVersion( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version) throws RepresentationNotExistsException { Representation representation = recordService.getRepresentation(cloudId, representationName, version); EnrichUriUtil.enrich(httpServletRequest, representation); return representation; } RepresentationVersionResource(RecordService recordService, MutableAclService mutableAclService); @GetMapping(value = REPRESENTATION_VERSION, produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") @ResponseBody Representation getRepresentationVersion( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @DeleteMapping(value = REPRESENTATION_VERSION) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', delete)") @ResponseStatus(HttpStatus.NO_CONTENT) void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @PostMapping(value = REPRESENTATION_VERSION_PERSIST) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', write)") ResponseEntity<Void> persistRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @PostMapping(value = REPRESENTATION_VERSION_COPY) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") ResponseEntity<Void> copyRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); }
@Test public void testDeleteRepresentation() throws Exception { mockMvc.perform(delete(URITools.getVersionPath(globalId, schema, version))) .andExpect(status().isNoContent()); verify(recordService, times(1)).deleteRepresentation(globalId, schema, version); verifyNoMoreInteractions(recordService); }
@DeleteMapping(value = REPRESENTATION_VERSION) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', delete)") @ResponseStatus(HttpStatus.NO_CONTENT) public void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version) throws RepresentationNotExistsException, CannotModifyPersistentRepresentationException { recordService.deleteRepresentation(cloudId, representationName, version); ObjectIdentity dataSetIdentity = new ObjectIdentityImpl(REPRESENTATION_CLASS_NAME, cloudId + "/" + representationName + "/" + version); mutableAclService.deleteAcl(dataSetIdentity, false); }
RepresentationVersionResource { @DeleteMapping(value = REPRESENTATION_VERSION) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', delete)") @ResponseStatus(HttpStatus.NO_CONTENT) public void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version) throws RepresentationNotExistsException, CannotModifyPersistentRepresentationException { recordService.deleteRepresentation(cloudId, representationName, version); ObjectIdentity dataSetIdentity = new ObjectIdentityImpl(REPRESENTATION_CLASS_NAME, cloudId + "/" + representationName + "/" + version); mutableAclService.deleteAcl(dataSetIdentity, false); } }
RepresentationVersionResource { @DeleteMapping(value = REPRESENTATION_VERSION) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', delete)") @ResponseStatus(HttpStatus.NO_CONTENT) public void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version) throws RepresentationNotExistsException, CannotModifyPersistentRepresentationException { recordService.deleteRepresentation(cloudId, representationName, version); ObjectIdentity dataSetIdentity = new ObjectIdentityImpl(REPRESENTATION_CLASS_NAME, cloudId + "/" + representationName + "/" + version); mutableAclService.deleteAcl(dataSetIdentity, false); } RepresentationVersionResource(RecordService recordService, MutableAclService mutableAclService); }
RepresentationVersionResource { @DeleteMapping(value = REPRESENTATION_VERSION) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', delete)") @ResponseStatus(HttpStatus.NO_CONTENT) public void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version) throws RepresentationNotExistsException, CannotModifyPersistentRepresentationException { recordService.deleteRepresentation(cloudId, representationName, version); ObjectIdentity dataSetIdentity = new ObjectIdentityImpl(REPRESENTATION_CLASS_NAME, cloudId + "/" + representationName + "/" + version); mutableAclService.deleteAcl(dataSetIdentity, false); } RepresentationVersionResource(RecordService recordService, MutableAclService mutableAclService); @GetMapping(value = REPRESENTATION_VERSION, produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") @ResponseBody Representation getRepresentationVersion( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @DeleteMapping(value = REPRESENTATION_VERSION) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', delete)") @ResponseStatus(HttpStatus.NO_CONTENT) void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @PostMapping(value = REPRESENTATION_VERSION_PERSIST) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', write)") ResponseEntity<Void> persistRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @PostMapping(value = REPRESENTATION_VERSION_COPY) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") ResponseEntity<Void> copyRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); }
RepresentationVersionResource { @DeleteMapping(value = REPRESENTATION_VERSION) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', delete)") @ResponseStatus(HttpStatus.NO_CONTENT) public void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version) throws RepresentationNotExistsException, CannotModifyPersistentRepresentationException { recordService.deleteRepresentation(cloudId, representationName, version); ObjectIdentity dataSetIdentity = new ObjectIdentityImpl(REPRESENTATION_CLASS_NAME, cloudId + "/" + representationName + "/" + version); mutableAclService.deleteAcl(dataSetIdentity, false); } RepresentationVersionResource(RecordService recordService, MutableAclService mutableAclService); @GetMapping(value = REPRESENTATION_VERSION, produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") @ResponseBody Representation getRepresentationVersion( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @DeleteMapping(value = REPRESENTATION_VERSION) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', delete)") @ResponseStatus(HttpStatus.NO_CONTENT) void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @PostMapping(value = REPRESENTATION_VERSION_PERSIST) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', write)") ResponseEntity<Void> persistRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @PostMapping(value = REPRESENTATION_VERSION_COPY) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") ResponseEntity<Void> copyRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); }
@Test @Parameters(method = "errors") public void testDeleteRepresentationReturns404IfRecordOrRepresentationDoesNotExists(Throwable exception, String errorCode, int statusCode) throws Exception { Mockito.doThrow(exception).when(recordService).deleteRepresentation(globalId, schema, version); ResultActions response = mockMvc.perform(delete(URITools.getVersionPath(globalId, schema, version))) .andExpect(status().is(statusCode)); ErrorInfo errorInfo = responseContentAsErrorInfo(response); assertThat(errorInfo.getErrorCode(), is(errorCode)); verify(recordService, times(1)).deleteRepresentation(globalId, schema, version); verifyNoMoreInteractions(recordService); }
@DeleteMapping(value = REPRESENTATION_VERSION) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', delete)") @ResponseStatus(HttpStatus.NO_CONTENT) public void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version) throws RepresentationNotExistsException, CannotModifyPersistentRepresentationException { recordService.deleteRepresentation(cloudId, representationName, version); ObjectIdentity dataSetIdentity = new ObjectIdentityImpl(REPRESENTATION_CLASS_NAME, cloudId + "/" + representationName + "/" + version); mutableAclService.deleteAcl(dataSetIdentity, false); }
RepresentationVersionResource { @DeleteMapping(value = REPRESENTATION_VERSION) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', delete)") @ResponseStatus(HttpStatus.NO_CONTENT) public void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version) throws RepresentationNotExistsException, CannotModifyPersistentRepresentationException { recordService.deleteRepresentation(cloudId, representationName, version); ObjectIdentity dataSetIdentity = new ObjectIdentityImpl(REPRESENTATION_CLASS_NAME, cloudId + "/" + representationName + "/" + version); mutableAclService.deleteAcl(dataSetIdentity, false); } }
RepresentationVersionResource { @DeleteMapping(value = REPRESENTATION_VERSION) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', delete)") @ResponseStatus(HttpStatus.NO_CONTENT) public void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version) throws RepresentationNotExistsException, CannotModifyPersistentRepresentationException { recordService.deleteRepresentation(cloudId, representationName, version); ObjectIdentity dataSetIdentity = new ObjectIdentityImpl(REPRESENTATION_CLASS_NAME, cloudId + "/" + representationName + "/" + version); mutableAclService.deleteAcl(dataSetIdentity, false); } RepresentationVersionResource(RecordService recordService, MutableAclService mutableAclService); }
RepresentationVersionResource { @DeleteMapping(value = REPRESENTATION_VERSION) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', delete)") @ResponseStatus(HttpStatus.NO_CONTENT) public void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version) throws RepresentationNotExistsException, CannotModifyPersistentRepresentationException { recordService.deleteRepresentation(cloudId, representationName, version); ObjectIdentity dataSetIdentity = new ObjectIdentityImpl(REPRESENTATION_CLASS_NAME, cloudId + "/" + representationName + "/" + version); mutableAclService.deleteAcl(dataSetIdentity, false); } RepresentationVersionResource(RecordService recordService, MutableAclService mutableAclService); @GetMapping(value = REPRESENTATION_VERSION, produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") @ResponseBody Representation getRepresentationVersion( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @DeleteMapping(value = REPRESENTATION_VERSION) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', delete)") @ResponseStatus(HttpStatus.NO_CONTENT) void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @PostMapping(value = REPRESENTATION_VERSION_PERSIST) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', write)") ResponseEntity<Void> persistRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @PostMapping(value = REPRESENTATION_VERSION_COPY) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") ResponseEntity<Void> copyRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); }
RepresentationVersionResource { @DeleteMapping(value = REPRESENTATION_VERSION) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', delete)") @ResponseStatus(HttpStatus.NO_CONTENT) public void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version) throws RepresentationNotExistsException, CannotModifyPersistentRepresentationException { recordService.deleteRepresentation(cloudId, representationName, version); ObjectIdentity dataSetIdentity = new ObjectIdentityImpl(REPRESENTATION_CLASS_NAME, cloudId + "/" + representationName + "/" + version); mutableAclService.deleteAcl(dataSetIdentity, false); } RepresentationVersionResource(RecordService recordService, MutableAclService mutableAclService); @GetMapping(value = REPRESENTATION_VERSION, produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") @ResponseBody Representation getRepresentationVersion( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @DeleteMapping(value = REPRESENTATION_VERSION) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', delete)") @ResponseStatus(HttpStatus.NO_CONTENT) void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @PostMapping(value = REPRESENTATION_VERSION_PERSIST) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', write)") ResponseEntity<Void> persistRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @PostMapping(value = REPRESENTATION_VERSION_COPY) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") ResponseEntity<Void> copyRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); }
@Test public void shouldReturnTheExpectedCountStatement() { assertEquals(EXPECTED_COUNT_STATEMENT, CQLBuilder.getMatchCountStatementFromTargetTable(SOURCE_TABLE, primaryKeys)); }
public static String getMatchCountStatementFromTargetTable(String targetTableName, List<String> names) { String wherePart = getStringWherePart(names); StringBuilder selectStatementFromTargetTableBuilder = new StringBuilder(); selectStatementFromTargetTableBuilder.append("Select count(*) from ").append(targetTableName).append(" WHERE ").append(wherePart); return selectStatementFromTargetTableBuilder.toString(); }
CQLBuilder { public static String getMatchCountStatementFromTargetTable(String targetTableName, List<String> names) { String wherePart = getStringWherePart(names); StringBuilder selectStatementFromTargetTableBuilder = new StringBuilder(); selectStatementFromTargetTableBuilder.append("Select count(*) from ").append(targetTableName).append(" WHERE ").append(wherePart); return selectStatementFromTargetTableBuilder.toString(); } }
CQLBuilder { public static String getMatchCountStatementFromTargetTable(String targetTableName, List<String> names) { String wherePart = getStringWherePart(names); StringBuilder selectStatementFromTargetTableBuilder = new StringBuilder(); selectStatementFromTargetTableBuilder.append("Select count(*) from ").append(targetTableName).append(" WHERE ").append(wherePart); return selectStatementFromTargetTableBuilder.toString(); } }
CQLBuilder { public static String getMatchCountStatementFromTargetTable(String targetTableName, List<String> names) { String wherePart = getStringWherePart(names); StringBuilder selectStatementFromTargetTableBuilder = new StringBuilder(); selectStatementFromTargetTableBuilder.append("Select count(*) from ").append(targetTableName).append(" WHERE ").append(wherePart); return selectStatementFromTargetTableBuilder.toString(); } static String getMatchCountStatementFromTargetTable(String targetTableName, List<String> names); static String constructSelectPrimaryKeysFromSourceTable(String sourceTableName, List<String> primaryKeyNames); }
CQLBuilder { public static String getMatchCountStatementFromTargetTable(String targetTableName, List<String> names) { String wherePart = getStringWherePart(names); StringBuilder selectStatementFromTargetTableBuilder = new StringBuilder(); selectStatementFromTargetTableBuilder.append("Select count(*) from ").append(targetTableName).append(" WHERE ").append(wherePart); return selectStatementFromTargetTableBuilder.toString(); } static String getMatchCountStatementFromTargetTable(String targetTableName, List<String> names); static String constructSelectPrimaryKeysFromSourceTable(String sourceTableName, List<String> primaryKeyNames); }
@Test public void testPersistRepresentation() throws Exception { when(recordService.persistRepresentation(globalId, schema, version)).thenReturn( new Representation(representation)); mockMvc.perform(post(persistPath).contentType(MediaType.APPLICATION_FORM_URLENCODED)) .andExpect(status().isCreated()) .andExpect(header().string(HttpHeaders.LOCATION, URITools.getVersionUri(getBaseUri(), globalId, schema, version).toString())); verify(recordService, times(1)).persistRepresentation(globalId, schema, version); verifyNoMoreInteractions(recordService); }
@PostMapping(value = REPRESENTATION_VERSION_PERSIST) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', write)") public ResponseEntity<Void> persistRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version) throws RepresentationNotExistsException, CannotModifyPersistentRepresentationException, CannotPersistEmptyRepresentationException { Representation persistentRepresentation = recordService.persistRepresentation(cloudId, representationName, version); EnrichUriUtil.enrich(httpServletRequest, persistentRepresentation); return ResponseEntity.created(persistentRepresentation.getUri()).build(); }
RepresentationVersionResource { @PostMapping(value = REPRESENTATION_VERSION_PERSIST) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', write)") public ResponseEntity<Void> persistRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version) throws RepresentationNotExistsException, CannotModifyPersistentRepresentationException, CannotPersistEmptyRepresentationException { Representation persistentRepresentation = recordService.persistRepresentation(cloudId, representationName, version); EnrichUriUtil.enrich(httpServletRequest, persistentRepresentation); return ResponseEntity.created(persistentRepresentation.getUri()).build(); } }
RepresentationVersionResource { @PostMapping(value = REPRESENTATION_VERSION_PERSIST) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', write)") public ResponseEntity<Void> persistRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version) throws RepresentationNotExistsException, CannotModifyPersistentRepresentationException, CannotPersistEmptyRepresentationException { Representation persistentRepresentation = recordService.persistRepresentation(cloudId, representationName, version); EnrichUriUtil.enrich(httpServletRequest, persistentRepresentation); return ResponseEntity.created(persistentRepresentation.getUri()).build(); } RepresentationVersionResource(RecordService recordService, MutableAclService mutableAclService); }
RepresentationVersionResource { @PostMapping(value = REPRESENTATION_VERSION_PERSIST) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', write)") public ResponseEntity<Void> persistRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version) throws RepresentationNotExistsException, CannotModifyPersistentRepresentationException, CannotPersistEmptyRepresentationException { Representation persistentRepresentation = recordService.persistRepresentation(cloudId, representationName, version); EnrichUriUtil.enrich(httpServletRequest, persistentRepresentation); return ResponseEntity.created(persistentRepresentation.getUri()).build(); } RepresentationVersionResource(RecordService recordService, MutableAclService mutableAclService); @GetMapping(value = REPRESENTATION_VERSION, produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") @ResponseBody Representation getRepresentationVersion( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @DeleteMapping(value = REPRESENTATION_VERSION) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', delete)") @ResponseStatus(HttpStatus.NO_CONTENT) void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @PostMapping(value = REPRESENTATION_VERSION_PERSIST) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', write)") ResponseEntity<Void> persistRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @PostMapping(value = REPRESENTATION_VERSION_COPY) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") ResponseEntity<Void> copyRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); }
RepresentationVersionResource { @PostMapping(value = REPRESENTATION_VERSION_PERSIST) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', write)") public ResponseEntity<Void> persistRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version) throws RepresentationNotExistsException, CannotModifyPersistentRepresentationException, CannotPersistEmptyRepresentationException { Representation persistentRepresentation = recordService.persistRepresentation(cloudId, representationName, version); EnrichUriUtil.enrich(httpServletRequest, persistentRepresentation); return ResponseEntity.created(persistentRepresentation.getUri()).build(); } RepresentationVersionResource(RecordService recordService, MutableAclService mutableAclService); @GetMapping(value = REPRESENTATION_VERSION, produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") @ResponseBody Representation getRepresentationVersion( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @DeleteMapping(value = REPRESENTATION_VERSION) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', delete)") @ResponseStatus(HttpStatus.NO_CONTENT) void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @PostMapping(value = REPRESENTATION_VERSION_PERSIST) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', write)") ResponseEntity<Void> persistRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @PostMapping(value = REPRESENTATION_VERSION_COPY) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") ResponseEntity<Void> copyRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); }
@Test @Parameters(method = "persistErrors") public void testPersistRepresentationReturns40XIfExceptionOccur(Throwable exception, String errorCode, int statusCode) throws Exception { when(recordService.persistRepresentation(globalId, schema, version)).thenThrow(exception); ResultActions response = mockMvc.perform(post(persistPath).contentType(MediaType.APPLICATION_FORM_URLENCODED)) .andExpect(status().is(statusCode)); ErrorInfo errorInfo = responseContentAsErrorInfo(response); assertThat(errorInfo.getErrorCode(), is(errorCode)); verify(recordService, times(1)).persistRepresentation(globalId, schema, version); verifyNoMoreInteractions(recordService); }
@PostMapping(value = REPRESENTATION_VERSION_PERSIST) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', write)") public ResponseEntity<Void> persistRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version) throws RepresentationNotExistsException, CannotModifyPersistentRepresentationException, CannotPersistEmptyRepresentationException { Representation persistentRepresentation = recordService.persistRepresentation(cloudId, representationName, version); EnrichUriUtil.enrich(httpServletRequest, persistentRepresentation); return ResponseEntity.created(persistentRepresentation.getUri()).build(); }
RepresentationVersionResource { @PostMapping(value = REPRESENTATION_VERSION_PERSIST) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', write)") public ResponseEntity<Void> persistRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version) throws RepresentationNotExistsException, CannotModifyPersistentRepresentationException, CannotPersistEmptyRepresentationException { Representation persistentRepresentation = recordService.persistRepresentation(cloudId, representationName, version); EnrichUriUtil.enrich(httpServletRequest, persistentRepresentation); return ResponseEntity.created(persistentRepresentation.getUri()).build(); } }
RepresentationVersionResource { @PostMapping(value = REPRESENTATION_VERSION_PERSIST) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', write)") public ResponseEntity<Void> persistRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version) throws RepresentationNotExistsException, CannotModifyPersistentRepresentationException, CannotPersistEmptyRepresentationException { Representation persistentRepresentation = recordService.persistRepresentation(cloudId, representationName, version); EnrichUriUtil.enrich(httpServletRequest, persistentRepresentation); return ResponseEntity.created(persistentRepresentation.getUri()).build(); } RepresentationVersionResource(RecordService recordService, MutableAclService mutableAclService); }
RepresentationVersionResource { @PostMapping(value = REPRESENTATION_VERSION_PERSIST) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', write)") public ResponseEntity<Void> persistRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version) throws RepresentationNotExistsException, CannotModifyPersistentRepresentationException, CannotPersistEmptyRepresentationException { Representation persistentRepresentation = recordService.persistRepresentation(cloudId, representationName, version); EnrichUriUtil.enrich(httpServletRequest, persistentRepresentation); return ResponseEntity.created(persistentRepresentation.getUri()).build(); } RepresentationVersionResource(RecordService recordService, MutableAclService mutableAclService); @GetMapping(value = REPRESENTATION_VERSION, produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") @ResponseBody Representation getRepresentationVersion( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @DeleteMapping(value = REPRESENTATION_VERSION) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', delete)") @ResponseStatus(HttpStatus.NO_CONTENT) void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @PostMapping(value = REPRESENTATION_VERSION_PERSIST) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', write)") ResponseEntity<Void> persistRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @PostMapping(value = REPRESENTATION_VERSION_COPY) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") ResponseEntity<Void> copyRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); }
RepresentationVersionResource { @PostMapping(value = REPRESENTATION_VERSION_PERSIST) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', write)") public ResponseEntity<Void> persistRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version) throws RepresentationNotExistsException, CannotModifyPersistentRepresentationException, CannotPersistEmptyRepresentationException { Representation persistentRepresentation = recordService.persistRepresentation(cloudId, representationName, version); EnrichUriUtil.enrich(httpServletRequest, persistentRepresentation); return ResponseEntity.created(persistentRepresentation.getUri()).build(); } RepresentationVersionResource(RecordService recordService, MutableAclService mutableAclService); @GetMapping(value = REPRESENTATION_VERSION, produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") @ResponseBody Representation getRepresentationVersion( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @DeleteMapping(value = REPRESENTATION_VERSION) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', delete)") @ResponseStatus(HttpStatus.NO_CONTENT) void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @PostMapping(value = REPRESENTATION_VERSION_PERSIST) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', write)") ResponseEntity<Void> persistRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @PostMapping(value = REPRESENTATION_VERSION_COPY) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") ResponseEntity<Void> copyRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); }
@Test public void testCopyRepresentation() throws Exception { when(recordService.copyRepresentation(globalId, schema, version)) .thenReturn(new Representation(representation)); mockMvc.perform(post(copyPath).contentType(MediaType.APPLICATION_FORM_URLENCODED)) .andExpect(status().isCreated()) .andExpect(header().string(HttpHeaders.LOCATION, URITools.getVersionUri(getBaseUri(), globalId, schema, version).toString())); verify(recordService, times(1)).copyRepresentation(globalId, schema, version); verifyNoMoreInteractions(recordService); }
@PostMapping(value = REPRESENTATION_VERSION_COPY) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") public ResponseEntity<Void> copyRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version) throws RepresentationNotExistsException { Representation representationCopy = recordService.copyRepresentation(cloudId, representationName, version); EnrichUriUtil.enrich(httpServletRequest, representationCopy); String copiedReprOwner = SpringUserUtils.getUsername(); if (copiedReprOwner != null) { ObjectIdentity versionIdentity = new ObjectIdentityImpl(REPRESENTATION_CLASS_NAME, cloudId + "/" + representationName + "/" + representationCopy.getVersion()); MutableAcl versionAcl = mutableAclService.createAcl(versionIdentity); versionAcl.insertAce(0, BasePermission.READ, new PrincipalSid(copiedReprOwner), true); versionAcl.insertAce(1, BasePermission.WRITE, new PrincipalSid(copiedReprOwner), true); versionAcl.insertAce(2, BasePermission.DELETE, new PrincipalSid(copiedReprOwner), true); versionAcl.insertAce(3, BasePermission.ADMINISTRATION, new PrincipalSid(copiedReprOwner),true); mutableAclService.updateAcl(versionAcl); } return ResponseEntity.created(representationCopy.getUri()).build(); }
RepresentationVersionResource { @PostMapping(value = REPRESENTATION_VERSION_COPY) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") public ResponseEntity<Void> copyRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version) throws RepresentationNotExistsException { Representation representationCopy = recordService.copyRepresentation(cloudId, representationName, version); EnrichUriUtil.enrich(httpServletRequest, representationCopy); String copiedReprOwner = SpringUserUtils.getUsername(); if (copiedReprOwner != null) { ObjectIdentity versionIdentity = new ObjectIdentityImpl(REPRESENTATION_CLASS_NAME, cloudId + "/" + representationName + "/" + representationCopy.getVersion()); MutableAcl versionAcl = mutableAclService.createAcl(versionIdentity); versionAcl.insertAce(0, BasePermission.READ, new PrincipalSid(copiedReprOwner), true); versionAcl.insertAce(1, BasePermission.WRITE, new PrincipalSid(copiedReprOwner), true); versionAcl.insertAce(2, BasePermission.DELETE, new PrincipalSid(copiedReprOwner), true); versionAcl.insertAce(3, BasePermission.ADMINISTRATION, new PrincipalSid(copiedReprOwner),true); mutableAclService.updateAcl(versionAcl); } return ResponseEntity.created(representationCopy.getUri()).build(); } }
RepresentationVersionResource { @PostMapping(value = REPRESENTATION_VERSION_COPY) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") public ResponseEntity<Void> copyRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version) throws RepresentationNotExistsException { Representation representationCopy = recordService.copyRepresentation(cloudId, representationName, version); EnrichUriUtil.enrich(httpServletRequest, representationCopy); String copiedReprOwner = SpringUserUtils.getUsername(); if (copiedReprOwner != null) { ObjectIdentity versionIdentity = new ObjectIdentityImpl(REPRESENTATION_CLASS_NAME, cloudId + "/" + representationName + "/" + representationCopy.getVersion()); MutableAcl versionAcl = mutableAclService.createAcl(versionIdentity); versionAcl.insertAce(0, BasePermission.READ, new PrincipalSid(copiedReprOwner), true); versionAcl.insertAce(1, BasePermission.WRITE, new PrincipalSid(copiedReprOwner), true); versionAcl.insertAce(2, BasePermission.DELETE, new PrincipalSid(copiedReprOwner), true); versionAcl.insertAce(3, BasePermission.ADMINISTRATION, new PrincipalSid(copiedReprOwner),true); mutableAclService.updateAcl(versionAcl); } return ResponseEntity.created(representationCopy.getUri()).build(); } RepresentationVersionResource(RecordService recordService, MutableAclService mutableAclService); }
RepresentationVersionResource { @PostMapping(value = REPRESENTATION_VERSION_COPY) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") public ResponseEntity<Void> copyRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version) throws RepresentationNotExistsException { Representation representationCopy = recordService.copyRepresentation(cloudId, representationName, version); EnrichUriUtil.enrich(httpServletRequest, representationCopy); String copiedReprOwner = SpringUserUtils.getUsername(); if (copiedReprOwner != null) { ObjectIdentity versionIdentity = new ObjectIdentityImpl(REPRESENTATION_CLASS_NAME, cloudId + "/" + representationName + "/" + representationCopy.getVersion()); MutableAcl versionAcl = mutableAclService.createAcl(versionIdentity); versionAcl.insertAce(0, BasePermission.READ, new PrincipalSid(copiedReprOwner), true); versionAcl.insertAce(1, BasePermission.WRITE, new PrincipalSid(copiedReprOwner), true); versionAcl.insertAce(2, BasePermission.DELETE, new PrincipalSid(copiedReprOwner), true); versionAcl.insertAce(3, BasePermission.ADMINISTRATION, new PrincipalSid(copiedReprOwner),true); mutableAclService.updateAcl(versionAcl); } return ResponseEntity.created(representationCopy.getUri()).build(); } RepresentationVersionResource(RecordService recordService, MutableAclService mutableAclService); @GetMapping(value = REPRESENTATION_VERSION, produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") @ResponseBody Representation getRepresentationVersion( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @DeleteMapping(value = REPRESENTATION_VERSION) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', delete)") @ResponseStatus(HttpStatus.NO_CONTENT) void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @PostMapping(value = REPRESENTATION_VERSION_PERSIST) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', write)") ResponseEntity<Void> persistRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @PostMapping(value = REPRESENTATION_VERSION_COPY) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") ResponseEntity<Void> copyRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); }
RepresentationVersionResource { @PostMapping(value = REPRESENTATION_VERSION_COPY) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") public ResponseEntity<Void> copyRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version) throws RepresentationNotExistsException { Representation representationCopy = recordService.copyRepresentation(cloudId, representationName, version); EnrichUriUtil.enrich(httpServletRequest, representationCopy); String copiedReprOwner = SpringUserUtils.getUsername(); if (copiedReprOwner != null) { ObjectIdentity versionIdentity = new ObjectIdentityImpl(REPRESENTATION_CLASS_NAME, cloudId + "/" + representationName + "/" + representationCopy.getVersion()); MutableAcl versionAcl = mutableAclService.createAcl(versionIdentity); versionAcl.insertAce(0, BasePermission.READ, new PrincipalSid(copiedReprOwner), true); versionAcl.insertAce(1, BasePermission.WRITE, new PrincipalSid(copiedReprOwner), true); versionAcl.insertAce(2, BasePermission.DELETE, new PrincipalSid(copiedReprOwner), true); versionAcl.insertAce(3, BasePermission.ADMINISTRATION, new PrincipalSid(copiedReprOwner),true); mutableAclService.updateAcl(versionAcl); } return ResponseEntity.created(representationCopy.getUri()).build(); } RepresentationVersionResource(RecordService recordService, MutableAclService mutableAclService); @GetMapping(value = REPRESENTATION_VERSION, produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") @ResponseBody Representation getRepresentationVersion( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @DeleteMapping(value = REPRESENTATION_VERSION) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', delete)") @ResponseStatus(HttpStatus.NO_CONTENT) void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @PostMapping(value = REPRESENTATION_VERSION_PERSIST) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', write)") ResponseEntity<Void> persistRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @PostMapping(value = REPRESENTATION_VERSION_COPY) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") ResponseEntity<Void> copyRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); }
@Test @Parameters(method = "errors") public void testCopyRepresentationReturns404IfRepresentationOrRecordOrVersionDoesNotExists(Throwable exception, String errorCode, int statusCode) throws Exception { when(recordService.copyRepresentation(globalId, schema, version)).thenThrow(exception); ResultActions response = mockMvc.perform(post(copyPath).contentType(MediaType.APPLICATION_FORM_URLENCODED)) .andExpect(status().is(statusCode)); ErrorInfo errorInfo = responseContentAsErrorInfo(response); assertThat(errorInfo.getErrorCode(), is(errorCode)); verify(recordService, times(1)).copyRepresentation(globalId, schema, version); verifyNoMoreInteractions(recordService); }
@PostMapping(value = REPRESENTATION_VERSION_COPY) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") public ResponseEntity<Void> copyRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version) throws RepresentationNotExistsException { Representation representationCopy = recordService.copyRepresentation(cloudId, representationName, version); EnrichUriUtil.enrich(httpServletRequest, representationCopy); String copiedReprOwner = SpringUserUtils.getUsername(); if (copiedReprOwner != null) { ObjectIdentity versionIdentity = new ObjectIdentityImpl(REPRESENTATION_CLASS_NAME, cloudId + "/" + representationName + "/" + representationCopy.getVersion()); MutableAcl versionAcl = mutableAclService.createAcl(versionIdentity); versionAcl.insertAce(0, BasePermission.READ, new PrincipalSid(copiedReprOwner), true); versionAcl.insertAce(1, BasePermission.WRITE, new PrincipalSid(copiedReprOwner), true); versionAcl.insertAce(2, BasePermission.DELETE, new PrincipalSid(copiedReprOwner), true); versionAcl.insertAce(3, BasePermission.ADMINISTRATION, new PrincipalSid(copiedReprOwner),true); mutableAclService.updateAcl(versionAcl); } return ResponseEntity.created(representationCopy.getUri()).build(); }
RepresentationVersionResource { @PostMapping(value = REPRESENTATION_VERSION_COPY) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") public ResponseEntity<Void> copyRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version) throws RepresentationNotExistsException { Representation representationCopy = recordService.copyRepresentation(cloudId, representationName, version); EnrichUriUtil.enrich(httpServletRequest, representationCopy); String copiedReprOwner = SpringUserUtils.getUsername(); if (copiedReprOwner != null) { ObjectIdentity versionIdentity = new ObjectIdentityImpl(REPRESENTATION_CLASS_NAME, cloudId + "/" + representationName + "/" + representationCopy.getVersion()); MutableAcl versionAcl = mutableAclService.createAcl(versionIdentity); versionAcl.insertAce(0, BasePermission.READ, new PrincipalSid(copiedReprOwner), true); versionAcl.insertAce(1, BasePermission.WRITE, new PrincipalSid(copiedReprOwner), true); versionAcl.insertAce(2, BasePermission.DELETE, new PrincipalSid(copiedReprOwner), true); versionAcl.insertAce(3, BasePermission.ADMINISTRATION, new PrincipalSid(copiedReprOwner),true); mutableAclService.updateAcl(versionAcl); } return ResponseEntity.created(representationCopy.getUri()).build(); } }
RepresentationVersionResource { @PostMapping(value = REPRESENTATION_VERSION_COPY) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") public ResponseEntity<Void> copyRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version) throws RepresentationNotExistsException { Representation representationCopy = recordService.copyRepresentation(cloudId, representationName, version); EnrichUriUtil.enrich(httpServletRequest, representationCopy); String copiedReprOwner = SpringUserUtils.getUsername(); if (copiedReprOwner != null) { ObjectIdentity versionIdentity = new ObjectIdentityImpl(REPRESENTATION_CLASS_NAME, cloudId + "/" + representationName + "/" + representationCopy.getVersion()); MutableAcl versionAcl = mutableAclService.createAcl(versionIdentity); versionAcl.insertAce(0, BasePermission.READ, new PrincipalSid(copiedReprOwner), true); versionAcl.insertAce(1, BasePermission.WRITE, new PrincipalSid(copiedReprOwner), true); versionAcl.insertAce(2, BasePermission.DELETE, new PrincipalSid(copiedReprOwner), true); versionAcl.insertAce(3, BasePermission.ADMINISTRATION, new PrincipalSid(copiedReprOwner),true); mutableAclService.updateAcl(versionAcl); } return ResponseEntity.created(representationCopy.getUri()).build(); } RepresentationVersionResource(RecordService recordService, MutableAclService mutableAclService); }
RepresentationVersionResource { @PostMapping(value = REPRESENTATION_VERSION_COPY) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") public ResponseEntity<Void> copyRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version) throws RepresentationNotExistsException { Representation representationCopy = recordService.copyRepresentation(cloudId, representationName, version); EnrichUriUtil.enrich(httpServletRequest, representationCopy); String copiedReprOwner = SpringUserUtils.getUsername(); if (copiedReprOwner != null) { ObjectIdentity versionIdentity = new ObjectIdentityImpl(REPRESENTATION_CLASS_NAME, cloudId + "/" + representationName + "/" + representationCopy.getVersion()); MutableAcl versionAcl = mutableAclService.createAcl(versionIdentity); versionAcl.insertAce(0, BasePermission.READ, new PrincipalSid(copiedReprOwner), true); versionAcl.insertAce(1, BasePermission.WRITE, new PrincipalSid(copiedReprOwner), true); versionAcl.insertAce(2, BasePermission.DELETE, new PrincipalSid(copiedReprOwner), true); versionAcl.insertAce(3, BasePermission.ADMINISTRATION, new PrincipalSid(copiedReprOwner),true); mutableAclService.updateAcl(versionAcl); } return ResponseEntity.created(representationCopy.getUri()).build(); } RepresentationVersionResource(RecordService recordService, MutableAclService mutableAclService); @GetMapping(value = REPRESENTATION_VERSION, produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") @ResponseBody Representation getRepresentationVersion( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @DeleteMapping(value = REPRESENTATION_VERSION) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', delete)") @ResponseStatus(HttpStatus.NO_CONTENT) void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @PostMapping(value = REPRESENTATION_VERSION_PERSIST) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', write)") ResponseEntity<Void> persistRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @PostMapping(value = REPRESENTATION_VERSION_COPY) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") ResponseEntity<Void> copyRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); }
RepresentationVersionResource { @PostMapping(value = REPRESENTATION_VERSION_COPY) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") public ResponseEntity<Void> copyRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version) throws RepresentationNotExistsException { Representation representationCopy = recordService.copyRepresentation(cloudId, representationName, version); EnrichUriUtil.enrich(httpServletRequest, representationCopy); String copiedReprOwner = SpringUserUtils.getUsername(); if (copiedReprOwner != null) { ObjectIdentity versionIdentity = new ObjectIdentityImpl(REPRESENTATION_CLASS_NAME, cloudId + "/" + representationName + "/" + representationCopy.getVersion()); MutableAcl versionAcl = mutableAclService.createAcl(versionIdentity); versionAcl.insertAce(0, BasePermission.READ, new PrincipalSid(copiedReprOwner), true); versionAcl.insertAce(1, BasePermission.WRITE, new PrincipalSid(copiedReprOwner), true); versionAcl.insertAce(2, BasePermission.DELETE, new PrincipalSid(copiedReprOwner), true); versionAcl.insertAce(3, BasePermission.ADMINISTRATION, new PrincipalSid(copiedReprOwner),true); mutableAclService.updateAcl(versionAcl); } return ResponseEntity.created(representationCopy.getUri()).build(); } RepresentationVersionResource(RecordService recordService, MutableAclService mutableAclService); @GetMapping(value = REPRESENTATION_VERSION, produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") @ResponseBody Representation getRepresentationVersion( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @DeleteMapping(value = REPRESENTATION_VERSION) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', delete)") @ResponseStatus(HttpStatus.NO_CONTENT) void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @PostMapping(value = REPRESENTATION_VERSION_PERSIST) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', write)") ResponseEntity<Void> persistRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); @PostMapping(value = REPRESENTATION_VERSION_COPY) @PreAuthorize("hasPermission(#cloudId.concat('/').concat(#representationName).concat('/').concat(#version)," + " 'eu.europeana.cloud.common.model.Representation', read)") ResponseEntity<Void> copyRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String version); }
@Test @Parameters(method = "mimeTypes") public void getRecord(MediaType mediaType) throws Exception { String globalId = "global1"; Record record = new Record(globalId, Lists.newArrayList(new Representation(globalId, "DC", "1", null, null, "FBC", Lists.newArrayList(new File("dc.xml", "text/xml", "91162629d258a876ee994e9233b2ad87", "2013-10-21", 12345L, URI.create("http: + "/representations/DC/versions/1/files/dc.xml"))), null, false, new Date()))); Record expected = new Record(record); Representation expectedRepresentation = expected.getRepresentations().get(0); expectedRepresentation.setCloudId(null); expectedRepresentation.setAllVersionsUri(URI.create(getBaseUri() + "records/" + globalId + "/representations/DC/versions")); expectedRepresentation.setUri(URI.create(getBaseUri() + "records/" + globalId + "/representations/DC/versions/1")); when(recordService.getRecord(globalId)).thenReturn(record); ResultActions response = mockMvc.perform(get("/records/" + globalId).accept(mediaType)) .andExpect(status().isOk()) .andExpect(content().contentType(mediaType)); System.out.println("Response body:\n" + response.andReturn().getResponse().getContentAsString()); Record entity = responseContent(response, Record.class, mediaType); assertThat(entity, is(expected)); verify(recordService, times(1)).getRecord(globalId); verifyNoMoreInteractions(recordService); }
@GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody public Record getRecord( HttpServletRequest httpServletRequest, @PathVariable String cloudId) throws RecordNotExistsException { Record record = recordService.getRecord(cloudId); prepare(httpServletRequest, record); return record; }
RecordsResource { @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody public Record getRecord( HttpServletRequest httpServletRequest, @PathVariable String cloudId) throws RecordNotExistsException { Record record = recordService.getRecord(cloudId); prepare(httpServletRequest, record); return record; } }
RecordsResource { @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody public Record getRecord( HttpServletRequest httpServletRequest, @PathVariable String cloudId) throws RecordNotExistsException { Record record = recordService.getRecord(cloudId); prepare(httpServletRequest, record); return record; } RecordsResource(RecordService recordService); }
RecordsResource { @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody public Record getRecord( HttpServletRequest httpServletRequest, @PathVariable String cloudId) throws RecordNotExistsException { Record record = recordService.getRecord(cloudId); prepare(httpServletRequest, record); return record; } RecordsResource(RecordService recordService); @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody Record getRecord( HttpServletRequest httpServletRequest, @PathVariable String cloudId); @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") void deleteRecord( @PathVariable String cloudId); }
RecordsResource { @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody public Record getRecord( HttpServletRequest httpServletRequest, @PathVariable String cloudId) throws RecordNotExistsException { Record record = recordService.getRecord(cloudId); prepare(httpServletRequest, record); return record; } RecordsResource(RecordService recordService); @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody Record getRecord( HttpServletRequest httpServletRequest, @PathVariable String cloudId); @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") void deleteRecord( @PathVariable String cloudId); }
@Test public void getRecordReturns404IfRecordDoesNotExists() throws Exception { String globalId = "global1"; Throwable exception = new RecordNotExistsException(); when(recordService.getRecord(globalId)).thenThrow(exception); mockMvc.perform(get("/records/" + globalId).contentType(MediaType.APPLICATION_XML)) .andExpect(status().isNotFound()); verify(recordService, times(1)).getRecord(globalId); verifyNoMoreInteractions(recordService); }
@GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody public Record getRecord( HttpServletRequest httpServletRequest, @PathVariable String cloudId) throws RecordNotExistsException { Record record = recordService.getRecord(cloudId); prepare(httpServletRequest, record); return record; }
RecordsResource { @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody public Record getRecord( HttpServletRequest httpServletRequest, @PathVariable String cloudId) throws RecordNotExistsException { Record record = recordService.getRecord(cloudId); prepare(httpServletRequest, record); return record; } }
RecordsResource { @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody public Record getRecord( HttpServletRequest httpServletRequest, @PathVariable String cloudId) throws RecordNotExistsException { Record record = recordService.getRecord(cloudId); prepare(httpServletRequest, record); return record; } RecordsResource(RecordService recordService); }
RecordsResource { @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody public Record getRecord( HttpServletRequest httpServletRequest, @PathVariable String cloudId) throws RecordNotExistsException { Record record = recordService.getRecord(cloudId); prepare(httpServletRequest, record); return record; } RecordsResource(RecordService recordService); @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody Record getRecord( HttpServletRequest httpServletRequest, @PathVariable String cloudId); @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") void deleteRecord( @PathVariable String cloudId); }
RecordsResource { @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody public Record getRecord( HttpServletRequest httpServletRequest, @PathVariable String cloudId) throws RecordNotExistsException { Record record = recordService.getRecord(cloudId); prepare(httpServletRequest, record); return record; } RecordsResource(RecordService recordService); @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody Record getRecord( HttpServletRequest httpServletRequest, @PathVariable String cloudId); @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") void deleteRecord( @PathVariable String cloudId); }
@Test public void deleteRecord() throws Exception { String globalId = "global1"; mockMvc.perform(delete("/records/" + globalId)) .andExpect(status().isNoContent()); verify(recordService, times(1)).deleteRecord(globalId); verifyNoMoreInteractions(recordService); }
@DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") public void deleteRecord( @PathVariable String cloudId) throws RecordNotExistsException, RepresentationNotExistsException { recordService.deleteRecord(cloudId); }
RecordsResource { @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") public void deleteRecord( @PathVariable String cloudId) throws RecordNotExistsException, RepresentationNotExistsException { recordService.deleteRecord(cloudId); } }
RecordsResource { @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") public void deleteRecord( @PathVariable String cloudId) throws RecordNotExistsException, RepresentationNotExistsException { recordService.deleteRecord(cloudId); } RecordsResource(RecordService recordService); }
RecordsResource { @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") public void deleteRecord( @PathVariable String cloudId) throws RecordNotExistsException, RepresentationNotExistsException { recordService.deleteRecord(cloudId); } RecordsResource(RecordService recordService); @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody Record getRecord( HttpServletRequest httpServletRequest, @PathVariable String cloudId); @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") void deleteRecord( @PathVariable String cloudId); }
RecordsResource { @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") public void deleteRecord( @PathVariable String cloudId) throws RecordNotExistsException, RepresentationNotExistsException { recordService.deleteRecord(cloudId); } RecordsResource(RecordService recordService); @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody Record getRecord( HttpServletRequest httpServletRequest, @PathVariable String cloudId); @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") void deleteRecord( @PathVariable String cloudId); }
@Test public void deleteRecordReturns404IfRecordDoesNotExists() throws Exception { String globalId = "global1"; Throwable exception = new RecordNotExistsException(); Mockito.doThrow(exception).when(recordService).deleteRecord(globalId); mockMvc.perform(delete("/records/" + globalId).contentType(MediaType.APPLICATION_XML)) .andExpect(status().isNotFound()); verify(recordService, times(1)).deleteRecord(globalId); verifyNoMoreInteractions(recordService); }
@DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") public void deleteRecord( @PathVariable String cloudId) throws RecordNotExistsException, RepresentationNotExistsException { recordService.deleteRecord(cloudId); }
RecordsResource { @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") public void deleteRecord( @PathVariable String cloudId) throws RecordNotExistsException, RepresentationNotExistsException { recordService.deleteRecord(cloudId); } }
RecordsResource { @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") public void deleteRecord( @PathVariable String cloudId) throws RecordNotExistsException, RepresentationNotExistsException { recordService.deleteRecord(cloudId); } RecordsResource(RecordService recordService); }
RecordsResource { @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") public void deleteRecord( @PathVariable String cloudId) throws RecordNotExistsException, RepresentationNotExistsException { recordService.deleteRecord(cloudId); } RecordsResource(RecordService recordService); @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody Record getRecord( HttpServletRequest httpServletRequest, @PathVariable String cloudId); @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") void deleteRecord( @PathVariable String cloudId); }
RecordsResource { @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") public void deleteRecord( @PathVariable String cloudId) throws RecordNotExistsException, RepresentationNotExistsException { recordService.deleteRecord(cloudId); } RecordsResource(RecordService recordService); @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody Record getRecord( HttpServletRequest httpServletRequest, @PathVariable String cloudId); @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") void deleteRecord( @PathVariable String cloudId); }
@Test public void deleteRecordReturns404IfRecordHasNoRepresentations() throws Exception { String globalId = "global1"; Throwable exception = new RepresentationNotExistsException(); Mockito.doThrow(exception).when(recordService).deleteRecord(globalId); mockMvc.perform(delete("/records/" + globalId).contentType(MediaType.APPLICATION_XML)) .andExpect(status().isNotFound()); verify(recordService, times(1)).deleteRecord(globalId); verifyNoMoreInteractions(recordService); }
@DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") public void deleteRecord( @PathVariable String cloudId) throws RecordNotExistsException, RepresentationNotExistsException { recordService.deleteRecord(cloudId); }
RecordsResource { @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") public void deleteRecord( @PathVariable String cloudId) throws RecordNotExistsException, RepresentationNotExistsException { recordService.deleteRecord(cloudId); } }
RecordsResource { @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") public void deleteRecord( @PathVariable String cloudId) throws RecordNotExistsException, RepresentationNotExistsException { recordService.deleteRecord(cloudId); } RecordsResource(RecordService recordService); }
RecordsResource { @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") public void deleteRecord( @PathVariable String cloudId) throws RecordNotExistsException, RepresentationNotExistsException { recordService.deleteRecord(cloudId); } RecordsResource(RecordService recordService); @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody Record getRecord( HttpServletRequest httpServletRequest, @PathVariable String cloudId); @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") void deleteRecord( @PathVariable String cloudId); }
RecordsResource { @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") public void deleteRecord( @PathVariable String cloudId) throws RecordNotExistsException, RepresentationNotExistsException { recordService.deleteRecord(cloudId); } RecordsResource(RecordService recordService); @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody Record getRecord( HttpServletRequest httpServletRequest, @PathVariable String cloudId); @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") void deleteRecord( @PathVariable String cloudId); }
@Test public void shouldCreateDataset() throws Exception { Mockito.doReturn(new DataProvider()).when(uisHandler) .getProvider("provId"); String datasetId = "datasetId"; String description = "dataset description"; ResultActions createResponse = mockMvc.perform(post(dataSetsWebTarget, "provId").contentType(MediaType.APPLICATION_FORM_URLENCODED) .param(F_DATASET, datasetId).param(F_DESCRIPTION, description) ).andExpect(status().isCreated()); String uriFromResponse = createResponse.andReturn().getResponse().getHeader(HttpHeaders.LOCATION); assertEquals("http: List<DataSet> dataSetsForPrivider = dataSetService.getDataSets( "provId", null, 10000).getResults(); assertEquals("Expected single dataset in service", 1, dataSetsForPrivider.size()); DataSet ds = dataSetsForPrivider.get(0); assertEquals(datasetId, ds.getId()); assertEquals(description, ds.getDescription()); }
@GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody public ResultSlice<DataSet> getDataSets( @PathVariable String providerId, @RequestParam(required = false) String startFrom) { return dataSetService.getDataSets(providerId, startFrom, numberOfElementsOnPage); }
DataSetsResource { @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody public ResultSlice<DataSet> getDataSets( @PathVariable String providerId, @RequestParam(required = false) String startFrom) { return dataSetService.getDataSets(providerId, startFrom, numberOfElementsOnPage); } }
DataSetsResource { @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody public ResultSlice<DataSet> getDataSets( @PathVariable String providerId, @RequestParam(required = false) String startFrom) { return dataSetService.getDataSets(providerId, startFrom, numberOfElementsOnPage); } DataSetsResource(DataSetService dataSetService, MutableAclService mutableAclService); }
DataSetsResource { @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody public ResultSlice<DataSet> getDataSets( @PathVariable String providerId, @RequestParam(required = false) String startFrom) { return dataSetService.getDataSets(providerId, startFrom, numberOfElementsOnPage); } DataSetsResource(DataSetService dataSetService, MutableAclService mutableAclService); @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody ResultSlice<DataSet> getDataSets( @PathVariable String providerId, @RequestParam(required = false) String startFrom); @PreAuthorize("isAuthenticated()") @PostMapping ResponseEntity<Void> createDataSet( HttpServletRequest httpServletRequest, @PathVariable String providerId, @RequestParam String dataSetId, @RequestParam(required = false) String description); }
DataSetsResource { @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody public ResultSlice<DataSet> getDataSets( @PathVariable String providerId, @RequestParam(required = false) String startFrom) { return dataSetService.getDataSets(providerId, startFrom, numberOfElementsOnPage); } DataSetsResource(DataSetService dataSetService, MutableAclService mutableAclService); @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody ResultSlice<DataSet> getDataSets( @PathVariable String providerId, @RequestParam(required = false) String startFrom); @PreAuthorize("isAuthenticated()") @PostMapping ResponseEntity<Void> createDataSet( HttpServletRequest httpServletRequest, @PathVariable String providerId, @RequestParam String dataSetId, @RequestParam(required = false) String description); }
@Test public void shouldSuccessfullyMigrateData() { MigrationExecutor migrator = new MigrationExecutor(EmbeddedCassandra.KEYSPACE, contactPoint, EmbeddedCassandra.PORT, cassandraUsername, cassandraPassword, scriptsLocations); migrator.migrate(); validateMigration(); List<String> cloudIds = getCloudIds(session.execute("SELECT * FROM data_set_assignments_by_data_set;").all()); assertThat(cloudIds.size(), is(2)); }
public void migrate() { CassandraMigration cm = new CassandraMigration(); cm.getConfigs().setScriptsLocations(scriptsLocations); cm.setKeyspace(keyspace); cm.migrate(); }
MigrationExecutor { public void migrate() { CassandraMigration cm = new CassandraMigration(); cm.getConfigs().setScriptsLocations(scriptsLocations); cm.setKeyspace(keyspace); cm.migrate(); } }
MigrationExecutor { public void migrate() { CassandraMigration cm = new CassandraMigration(); cm.getConfigs().setScriptsLocations(scriptsLocations); cm.setKeyspace(keyspace); cm.migrate(); } MigrationExecutor(String cassandraKeyspace, String cassandraContactPoint, int cassandraPort, String cassandraUsername, String cassandraPassword, String[] scriptsLocations); }
MigrationExecutor { public void migrate() { CassandraMigration cm = new CassandraMigration(); cm.getConfigs().setScriptsLocations(scriptsLocations); cm.setKeyspace(keyspace); cm.migrate(); } MigrationExecutor(String cassandraKeyspace, String cassandraContactPoint, int cassandraPort, String cassandraUsername, String cassandraPassword, String[] scriptsLocations); void migrate(); }
MigrationExecutor { public void migrate() { CassandraMigration cm = new CassandraMigration(); cm.getConfigs().setScriptsLocations(scriptsLocations); cm.setKeyspace(keyspace); cm.migrate(); } MigrationExecutor(String cassandraKeyspace, String cassandraContactPoint, int cassandraPort, String cassandraUsername, String cassandraPassword, String[] scriptsLocations); void migrate(); }
@Test public void shouldNotCreateTwoDatasetsWithSameId() throws Exception { Mockito.doReturn(new DataProvider()).when(uisHandler) .getProvider("provId"); String dataSetId = "dataset"; dataSetService.createDataSet("provId", dataSetId, ""); ResultActions createResponse = mockMvc.perform(post(dataSetsWebTarget, "provId") .contentType(MediaType.APPLICATION_FORM_URLENCODED) .param(F_DATASET, dataSetId)).andExpect(status().isConflict()); ErrorInfo errorInfo = responseContentAsErrorInfo(createResponse); assertEquals(McsErrorCode.DATASET_ALREADY_EXISTS.toString(), errorInfo.getErrorCode()); }
@PreAuthorize("isAuthenticated()") @PostMapping public ResponseEntity<Void> createDataSet( HttpServletRequest httpServletRequest, @PathVariable String providerId, @RequestParam String dataSetId, @RequestParam(required = false) String description) throws ProviderNotExistsException, DataSetAlreadyExistsException { DataSet dataSet = dataSetService.createDataSet(providerId, dataSetId, description); EnrichUriUtil.enrich(httpServletRequest, dataSet); String creatorName = SpringUserUtils.getUsername(); if (creatorName != null) { ObjectIdentity dataSetIdentity = new ObjectIdentityImpl(DATASET_CLASS_NAME, dataSetId + "/" + providerId); MutableAcl datasetAcl = mutableAclService.createAcl(dataSetIdentity); datasetAcl.insertAce(0, BasePermission.READ, new PrincipalSid(creatorName), true); datasetAcl.insertAce(1, BasePermission.WRITE, new PrincipalSid(creatorName), true); datasetAcl.insertAce(2, BasePermission.DELETE, new PrincipalSid(creatorName), true); datasetAcl.insertAce(3, BasePermission.ADMINISTRATION, new PrincipalSid(creatorName), true); mutableAclService.updateAcl(datasetAcl); } return ResponseEntity.created(dataSet.getUri()).build(); }
DataSetsResource { @PreAuthorize("isAuthenticated()") @PostMapping public ResponseEntity<Void> createDataSet( HttpServletRequest httpServletRequest, @PathVariable String providerId, @RequestParam String dataSetId, @RequestParam(required = false) String description) throws ProviderNotExistsException, DataSetAlreadyExistsException { DataSet dataSet = dataSetService.createDataSet(providerId, dataSetId, description); EnrichUriUtil.enrich(httpServletRequest, dataSet); String creatorName = SpringUserUtils.getUsername(); if (creatorName != null) { ObjectIdentity dataSetIdentity = new ObjectIdentityImpl(DATASET_CLASS_NAME, dataSetId + "/" + providerId); MutableAcl datasetAcl = mutableAclService.createAcl(dataSetIdentity); datasetAcl.insertAce(0, BasePermission.READ, new PrincipalSid(creatorName), true); datasetAcl.insertAce(1, BasePermission.WRITE, new PrincipalSid(creatorName), true); datasetAcl.insertAce(2, BasePermission.DELETE, new PrincipalSid(creatorName), true); datasetAcl.insertAce(3, BasePermission.ADMINISTRATION, new PrincipalSid(creatorName), true); mutableAclService.updateAcl(datasetAcl); } return ResponseEntity.created(dataSet.getUri()).build(); } }
DataSetsResource { @PreAuthorize("isAuthenticated()") @PostMapping public ResponseEntity<Void> createDataSet( HttpServletRequest httpServletRequest, @PathVariable String providerId, @RequestParam String dataSetId, @RequestParam(required = false) String description) throws ProviderNotExistsException, DataSetAlreadyExistsException { DataSet dataSet = dataSetService.createDataSet(providerId, dataSetId, description); EnrichUriUtil.enrich(httpServletRequest, dataSet); String creatorName = SpringUserUtils.getUsername(); if (creatorName != null) { ObjectIdentity dataSetIdentity = new ObjectIdentityImpl(DATASET_CLASS_NAME, dataSetId + "/" + providerId); MutableAcl datasetAcl = mutableAclService.createAcl(dataSetIdentity); datasetAcl.insertAce(0, BasePermission.READ, new PrincipalSid(creatorName), true); datasetAcl.insertAce(1, BasePermission.WRITE, new PrincipalSid(creatorName), true); datasetAcl.insertAce(2, BasePermission.DELETE, new PrincipalSid(creatorName), true); datasetAcl.insertAce(3, BasePermission.ADMINISTRATION, new PrincipalSid(creatorName), true); mutableAclService.updateAcl(datasetAcl); } return ResponseEntity.created(dataSet.getUri()).build(); } DataSetsResource(DataSetService dataSetService, MutableAclService mutableAclService); }
DataSetsResource { @PreAuthorize("isAuthenticated()") @PostMapping public ResponseEntity<Void> createDataSet( HttpServletRequest httpServletRequest, @PathVariable String providerId, @RequestParam String dataSetId, @RequestParam(required = false) String description) throws ProviderNotExistsException, DataSetAlreadyExistsException { DataSet dataSet = dataSetService.createDataSet(providerId, dataSetId, description); EnrichUriUtil.enrich(httpServletRequest, dataSet); String creatorName = SpringUserUtils.getUsername(); if (creatorName != null) { ObjectIdentity dataSetIdentity = new ObjectIdentityImpl(DATASET_CLASS_NAME, dataSetId + "/" + providerId); MutableAcl datasetAcl = mutableAclService.createAcl(dataSetIdentity); datasetAcl.insertAce(0, BasePermission.READ, new PrincipalSid(creatorName), true); datasetAcl.insertAce(1, BasePermission.WRITE, new PrincipalSid(creatorName), true); datasetAcl.insertAce(2, BasePermission.DELETE, new PrincipalSid(creatorName), true); datasetAcl.insertAce(3, BasePermission.ADMINISTRATION, new PrincipalSid(creatorName), true); mutableAclService.updateAcl(datasetAcl); } return ResponseEntity.created(dataSet.getUri()).build(); } DataSetsResource(DataSetService dataSetService, MutableAclService mutableAclService); @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody ResultSlice<DataSet> getDataSets( @PathVariable String providerId, @RequestParam(required = false) String startFrom); @PreAuthorize("isAuthenticated()") @PostMapping ResponseEntity<Void> createDataSet( HttpServletRequest httpServletRequest, @PathVariable String providerId, @RequestParam String dataSetId, @RequestParam(required = false) String description); }
DataSetsResource { @PreAuthorize("isAuthenticated()") @PostMapping public ResponseEntity<Void> createDataSet( HttpServletRequest httpServletRequest, @PathVariable String providerId, @RequestParam String dataSetId, @RequestParam(required = false) String description) throws ProviderNotExistsException, DataSetAlreadyExistsException { DataSet dataSet = dataSetService.createDataSet(providerId, dataSetId, description); EnrichUriUtil.enrich(httpServletRequest, dataSet); String creatorName = SpringUserUtils.getUsername(); if (creatorName != null) { ObjectIdentity dataSetIdentity = new ObjectIdentityImpl(DATASET_CLASS_NAME, dataSetId + "/" + providerId); MutableAcl datasetAcl = mutableAclService.createAcl(dataSetIdentity); datasetAcl.insertAce(0, BasePermission.READ, new PrincipalSid(creatorName), true); datasetAcl.insertAce(1, BasePermission.WRITE, new PrincipalSid(creatorName), true); datasetAcl.insertAce(2, BasePermission.DELETE, new PrincipalSid(creatorName), true); datasetAcl.insertAce(3, BasePermission.ADMINISTRATION, new PrincipalSid(creatorName), true); mutableAclService.updateAcl(datasetAcl); } return ResponseEntity.created(dataSet.getUri()).build(); } DataSetsResource(DataSetService dataSetService, MutableAclService mutableAclService); @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody ResultSlice<DataSet> getDataSets( @PathVariable String providerId, @RequestParam(required = false) String startFrom); @PreAuthorize("isAuthenticated()") @PostMapping ResponseEntity<Void> createDataSet( HttpServletRequest httpServletRequest, @PathVariable String providerId, @RequestParam String dataSetId, @RequestParam(required = false) String description); }
@Test @Parameters(method = "mimeTypes") public void getRepresentationByRevisionResponse(MediaType mediaType) throws Exception { RepresentationRevisionResponse representationRevisionResponse = new RepresentationRevisionResponse(representationResponse); ArrayList<File> files = new ArrayList<>(1); files.add(new File("1.xml", "text/xml", "91162629d258a876ee994e9233b2ad87", "2013-01-01", 12345L, URI.create("http: + "/representations/" + schema + "/versions/" + version + "/files/1.xml"))); representationRevisionResponse.setFiles(files); Representation representation = new Representation(representationRevisionResponse.getCloudId(), representationRevisionResponse.getRepresentationName(), representationRevisionResponse.getVersion(), null, null, representationRevisionResponse.getRevisionProviderId(), representationRevisionResponse.getFiles(), new ArrayList<Revision>(), false, representationRevisionResponse.getRevisionTimestamp()); List<RepresentationRevisionResponse> expectedResponse = new ArrayList<>(); expectedResponse.add(representationRevisionResponse); doReturn(expectedResponse).when(recordService).getRepresentationRevisions(globalId, schema, revisionProviderId, revisionName, null); when(recordService.getRepresentation(globalId, representationResponse.getRepresentationName(), representationResponse.getVersion())).thenReturn(representation); ResultActions response = mockMvc.perform(get(URITools.getRepresentationRevisionsPath(globalId, schema, revisionName)) .queryParam(ParamConstants.F_REVISION_PROVIDER_ID, revisionProviderId).accept(mediaType)) .andExpect(status().isOk()) .andExpect(content().contentType(mediaType)); List<Representation> entity = responseContentAsRepresentationList(response, mediaType); assertThat(entity.size(), is(1)); assertThat(entity.get(0), is(representation)); verify(recordService, times(1)).getRepresentationRevisions(globalId, schema, revisionProviderId, revisionName, null); verify(recordService, times(1)).getRepresentation(globalId, schema, representationRevisionResponse.getVersion()); verifyNoMoreInteractions(recordService); }
@GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody public RepresentationsListWrapper getRepresentationRevisions( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String revisionName, @RequestParam String revisionProviderId, @RequestParam(required = false) String revisionTimestamp) throws RepresentationNotExistsException { Date revisionDate = null; if (revisionTimestamp != null) { DateTime utc = new DateTime(revisionTimestamp, DateTimeZone.UTC); revisionDate = utc.toDate(); } List<RepresentationRevisionResponse> info = recordService.getRepresentationRevisions(cloudId, representationName, revisionProviderId, revisionName, revisionDate); List<Representation> representations = new ArrayList<>(); if (info != null) { for (RepresentationRevisionResponse representationRevisionsResource : info) { Representation representation; representation = recordService.getRepresentation( representationRevisionsResource.getCloudId(), representationRevisionsResource.getRepresentationName(), representationRevisionsResource.getVersion()); EnrichUriUtil.enrich(httpServletRequest, representation); if (userHasAccessTo(representation)) { representations.add(representation); } } } else { throw new RepresentationNotExistsException("No representation was found"); } return new RepresentationsListWrapper(representations); }
RepresentationRevisionsResource { @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody public RepresentationsListWrapper getRepresentationRevisions( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String revisionName, @RequestParam String revisionProviderId, @RequestParam(required = false) String revisionTimestamp) throws RepresentationNotExistsException { Date revisionDate = null; if (revisionTimestamp != null) { DateTime utc = new DateTime(revisionTimestamp, DateTimeZone.UTC); revisionDate = utc.toDate(); } List<RepresentationRevisionResponse> info = recordService.getRepresentationRevisions(cloudId, representationName, revisionProviderId, revisionName, revisionDate); List<Representation> representations = new ArrayList<>(); if (info != null) { for (RepresentationRevisionResponse representationRevisionsResource : info) { Representation representation; representation = recordService.getRepresentation( representationRevisionsResource.getCloudId(), representationRevisionsResource.getRepresentationName(), representationRevisionsResource.getVersion()); EnrichUriUtil.enrich(httpServletRequest, representation); if (userHasAccessTo(representation)) { representations.add(representation); } } } else { throw new RepresentationNotExistsException("No representation was found"); } return new RepresentationsListWrapper(representations); } }
RepresentationRevisionsResource { @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody public RepresentationsListWrapper getRepresentationRevisions( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String revisionName, @RequestParam String revisionProviderId, @RequestParam(required = false) String revisionTimestamp) throws RepresentationNotExistsException { Date revisionDate = null; if (revisionTimestamp != null) { DateTime utc = new DateTime(revisionTimestamp, DateTimeZone.UTC); revisionDate = utc.toDate(); } List<RepresentationRevisionResponse> info = recordService.getRepresentationRevisions(cloudId, representationName, revisionProviderId, revisionName, revisionDate); List<Representation> representations = new ArrayList<>(); if (info != null) { for (RepresentationRevisionResponse representationRevisionsResource : info) { Representation representation; representation = recordService.getRepresentation( representationRevisionsResource.getCloudId(), representationRevisionsResource.getRepresentationName(), representationRevisionsResource.getVersion()); EnrichUriUtil.enrich(httpServletRequest, representation); if (userHasAccessTo(representation)) { representations.add(representation); } } } else { throw new RepresentationNotExistsException("No representation was found"); } return new RepresentationsListWrapper(representations); } RepresentationRevisionsResource(RecordService recordService, PermissionEvaluator permissionEvaluator); }
RepresentationRevisionsResource { @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody public RepresentationsListWrapper getRepresentationRevisions( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String revisionName, @RequestParam String revisionProviderId, @RequestParam(required = false) String revisionTimestamp) throws RepresentationNotExistsException { Date revisionDate = null; if (revisionTimestamp != null) { DateTime utc = new DateTime(revisionTimestamp, DateTimeZone.UTC); revisionDate = utc.toDate(); } List<RepresentationRevisionResponse> info = recordService.getRepresentationRevisions(cloudId, representationName, revisionProviderId, revisionName, revisionDate); List<Representation> representations = new ArrayList<>(); if (info != null) { for (RepresentationRevisionResponse representationRevisionsResource : info) { Representation representation; representation = recordService.getRepresentation( representationRevisionsResource.getCloudId(), representationRevisionsResource.getRepresentationName(), representationRevisionsResource.getVersion()); EnrichUriUtil.enrich(httpServletRequest, representation); if (userHasAccessTo(representation)) { representations.add(representation); } } } else { throw new RepresentationNotExistsException("No representation was found"); } return new RepresentationsListWrapper(representations); } RepresentationRevisionsResource(RecordService recordService, PermissionEvaluator permissionEvaluator); @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody RepresentationsListWrapper getRepresentationRevisions( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String revisionName, @RequestParam String revisionProviderId, @RequestParam(required = false) String revisionTimestamp); }
RepresentationRevisionsResource { @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody public RepresentationsListWrapper getRepresentationRevisions( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String revisionName, @RequestParam String revisionProviderId, @RequestParam(required = false) String revisionTimestamp) throws RepresentationNotExistsException { Date revisionDate = null; if (revisionTimestamp != null) { DateTime utc = new DateTime(revisionTimestamp, DateTimeZone.UTC); revisionDate = utc.toDate(); } List<RepresentationRevisionResponse> info = recordService.getRepresentationRevisions(cloudId, representationName, revisionProviderId, revisionName, revisionDate); List<Representation> representations = new ArrayList<>(); if (info != null) { for (RepresentationRevisionResponse representationRevisionsResource : info) { Representation representation; representation = recordService.getRepresentation( representationRevisionsResource.getCloudId(), representationRevisionsResource.getRepresentationName(), representationRevisionsResource.getVersion()); EnrichUriUtil.enrich(httpServletRequest, representation); if (userHasAccessTo(representation)) { representations.add(representation); } } } else { throw new RepresentationNotExistsException("No representation was found"); } return new RepresentationsListWrapper(representations); } RepresentationRevisionsResource(RecordService recordService, PermissionEvaluator permissionEvaluator); @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody RepresentationsListWrapper getRepresentationRevisions( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String revisionName, @RequestParam String revisionProviderId, @RequestParam(required = false) String revisionTimestamp); }
@Test public void getRepresentationByRevisionsThrowExceptionWhenReturnsEmptyObjectIfRevisionDoesNotExists() throws Exception { List<RepresentationRevisionResponse> expectedResponse = new ArrayList<>(); expectedResponse.add(new RepresentationRevisionResponse()); doReturn(expectedResponse).when(recordService).getRepresentationRevisions(globalId, schema, revisionProviderId, revisionName, null); doThrow(RepresentationNotExistsException.class).when(recordService).getRepresentation(anyString(), anyString(), anyString()); mockMvc.perform(get(URITools.getRepresentationRevisionsPath(globalId, schema, revisionName)) .queryParam(ParamConstants.F_REVISION_PROVIDER_ID, revisionProviderId) .accept(MediaType.APPLICATION_XML)) .andExpect(status().isNotFound()); verify(recordService, times(1)).getRepresentationRevisions(globalId, schema, revisionProviderId, revisionName, null); verify(recordService, times(1)).getRepresentation(anyString(), anyString(), anyString()); }
@GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody public RepresentationsListWrapper getRepresentationRevisions( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String revisionName, @RequestParam String revisionProviderId, @RequestParam(required = false) String revisionTimestamp) throws RepresentationNotExistsException { Date revisionDate = null; if (revisionTimestamp != null) { DateTime utc = new DateTime(revisionTimestamp, DateTimeZone.UTC); revisionDate = utc.toDate(); } List<RepresentationRevisionResponse> info = recordService.getRepresentationRevisions(cloudId, representationName, revisionProviderId, revisionName, revisionDate); List<Representation> representations = new ArrayList<>(); if (info != null) { for (RepresentationRevisionResponse representationRevisionsResource : info) { Representation representation; representation = recordService.getRepresentation( representationRevisionsResource.getCloudId(), representationRevisionsResource.getRepresentationName(), representationRevisionsResource.getVersion()); EnrichUriUtil.enrich(httpServletRequest, representation); if (userHasAccessTo(representation)) { representations.add(representation); } } } else { throw new RepresentationNotExistsException("No representation was found"); } return new RepresentationsListWrapper(representations); }
RepresentationRevisionsResource { @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody public RepresentationsListWrapper getRepresentationRevisions( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String revisionName, @RequestParam String revisionProviderId, @RequestParam(required = false) String revisionTimestamp) throws RepresentationNotExistsException { Date revisionDate = null; if (revisionTimestamp != null) { DateTime utc = new DateTime(revisionTimestamp, DateTimeZone.UTC); revisionDate = utc.toDate(); } List<RepresentationRevisionResponse> info = recordService.getRepresentationRevisions(cloudId, representationName, revisionProviderId, revisionName, revisionDate); List<Representation> representations = new ArrayList<>(); if (info != null) { for (RepresentationRevisionResponse representationRevisionsResource : info) { Representation representation; representation = recordService.getRepresentation( representationRevisionsResource.getCloudId(), representationRevisionsResource.getRepresentationName(), representationRevisionsResource.getVersion()); EnrichUriUtil.enrich(httpServletRequest, representation); if (userHasAccessTo(representation)) { representations.add(representation); } } } else { throw new RepresentationNotExistsException("No representation was found"); } return new RepresentationsListWrapper(representations); } }
RepresentationRevisionsResource { @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody public RepresentationsListWrapper getRepresentationRevisions( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String revisionName, @RequestParam String revisionProviderId, @RequestParam(required = false) String revisionTimestamp) throws RepresentationNotExistsException { Date revisionDate = null; if (revisionTimestamp != null) { DateTime utc = new DateTime(revisionTimestamp, DateTimeZone.UTC); revisionDate = utc.toDate(); } List<RepresentationRevisionResponse> info = recordService.getRepresentationRevisions(cloudId, representationName, revisionProviderId, revisionName, revisionDate); List<Representation> representations = new ArrayList<>(); if (info != null) { for (RepresentationRevisionResponse representationRevisionsResource : info) { Representation representation; representation = recordService.getRepresentation( representationRevisionsResource.getCloudId(), representationRevisionsResource.getRepresentationName(), representationRevisionsResource.getVersion()); EnrichUriUtil.enrich(httpServletRequest, representation); if (userHasAccessTo(representation)) { representations.add(representation); } } } else { throw new RepresentationNotExistsException("No representation was found"); } return new RepresentationsListWrapper(representations); } RepresentationRevisionsResource(RecordService recordService, PermissionEvaluator permissionEvaluator); }
RepresentationRevisionsResource { @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody public RepresentationsListWrapper getRepresentationRevisions( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String revisionName, @RequestParam String revisionProviderId, @RequestParam(required = false) String revisionTimestamp) throws RepresentationNotExistsException { Date revisionDate = null; if (revisionTimestamp != null) { DateTime utc = new DateTime(revisionTimestamp, DateTimeZone.UTC); revisionDate = utc.toDate(); } List<RepresentationRevisionResponse> info = recordService.getRepresentationRevisions(cloudId, representationName, revisionProviderId, revisionName, revisionDate); List<Representation> representations = new ArrayList<>(); if (info != null) { for (RepresentationRevisionResponse representationRevisionsResource : info) { Representation representation; representation = recordService.getRepresentation( representationRevisionsResource.getCloudId(), representationRevisionsResource.getRepresentationName(), representationRevisionsResource.getVersion()); EnrichUriUtil.enrich(httpServletRequest, representation); if (userHasAccessTo(representation)) { representations.add(representation); } } } else { throw new RepresentationNotExistsException("No representation was found"); } return new RepresentationsListWrapper(representations); } RepresentationRevisionsResource(RecordService recordService, PermissionEvaluator permissionEvaluator); @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody RepresentationsListWrapper getRepresentationRevisions( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String revisionName, @RequestParam String revisionProviderId, @RequestParam(required = false) String revisionTimestamp); }
RepresentationRevisionsResource { @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody public RepresentationsListWrapper getRepresentationRevisions( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String revisionName, @RequestParam String revisionProviderId, @RequestParam(required = false) String revisionTimestamp) throws RepresentationNotExistsException { Date revisionDate = null; if (revisionTimestamp != null) { DateTime utc = new DateTime(revisionTimestamp, DateTimeZone.UTC); revisionDate = utc.toDate(); } List<RepresentationRevisionResponse> info = recordService.getRepresentationRevisions(cloudId, representationName, revisionProviderId, revisionName, revisionDate); List<Representation> representations = new ArrayList<>(); if (info != null) { for (RepresentationRevisionResponse representationRevisionsResource : info) { Representation representation; representation = recordService.getRepresentation( representationRevisionsResource.getCloudId(), representationRevisionsResource.getRepresentationName(), representationRevisionsResource.getVersion()); EnrichUriUtil.enrich(httpServletRequest, representation); if (userHasAccessTo(representation)) { representations.add(representation); } } } else { throw new RepresentationNotExistsException("No representation was found"); } return new RepresentationsListWrapper(representations); } RepresentationRevisionsResource(RecordService recordService, PermissionEvaluator permissionEvaluator); @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody RepresentationsListWrapper getRepresentationRevisions( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String revisionName, @RequestParam String revisionProviderId, @RequestParam(required = false) String revisionTimestamp); }
@Test public void getRepresentationByRevisionsThrowExceptionWhenReturnsRepresentationRevisionResponseIsNull() throws Exception { when(recordService.getRepresentationRevisions(globalId, schema, revisionProviderId, revisionName, null)).thenReturn(null); mockMvc.perform(get(URITools.getRepresentationRevisionsPath(globalId, schema, revisionName)) .queryParam(ParamConstants.F_REVISION_PROVIDER_ID, revisionProviderId) .accept(MediaType.APPLICATION_XML)) .andExpect(status().isNotFound()); verify(recordService, times(1)).getRepresentationRevisions(globalId, schema, revisionProviderId, revisionName, null); }
@GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody public RepresentationsListWrapper getRepresentationRevisions( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String revisionName, @RequestParam String revisionProviderId, @RequestParam(required = false) String revisionTimestamp) throws RepresentationNotExistsException { Date revisionDate = null; if (revisionTimestamp != null) { DateTime utc = new DateTime(revisionTimestamp, DateTimeZone.UTC); revisionDate = utc.toDate(); } List<RepresentationRevisionResponse> info = recordService.getRepresentationRevisions(cloudId, representationName, revisionProviderId, revisionName, revisionDate); List<Representation> representations = new ArrayList<>(); if (info != null) { for (RepresentationRevisionResponse representationRevisionsResource : info) { Representation representation; representation = recordService.getRepresentation( representationRevisionsResource.getCloudId(), representationRevisionsResource.getRepresentationName(), representationRevisionsResource.getVersion()); EnrichUriUtil.enrich(httpServletRequest, representation); if (userHasAccessTo(representation)) { representations.add(representation); } } } else { throw new RepresentationNotExistsException("No representation was found"); } return new RepresentationsListWrapper(representations); }
RepresentationRevisionsResource { @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody public RepresentationsListWrapper getRepresentationRevisions( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String revisionName, @RequestParam String revisionProviderId, @RequestParam(required = false) String revisionTimestamp) throws RepresentationNotExistsException { Date revisionDate = null; if (revisionTimestamp != null) { DateTime utc = new DateTime(revisionTimestamp, DateTimeZone.UTC); revisionDate = utc.toDate(); } List<RepresentationRevisionResponse> info = recordService.getRepresentationRevisions(cloudId, representationName, revisionProviderId, revisionName, revisionDate); List<Representation> representations = new ArrayList<>(); if (info != null) { for (RepresentationRevisionResponse representationRevisionsResource : info) { Representation representation; representation = recordService.getRepresentation( representationRevisionsResource.getCloudId(), representationRevisionsResource.getRepresentationName(), representationRevisionsResource.getVersion()); EnrichUriUtil.enrich(httpServletRequest, representation); if (userHasAccessTo(representation)) { representations.add(representation); } } } else { throw new RepresentationNotExistsException("No representation was found"); } return new RepresentationsListWrapper(representations); } }
RepresentationRevisionsResource { @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody public RepresentationsListWrapper getRepresentationRevisions( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String revisionName, @RequestParam String revisionProviderId, @RequestParam(required = false) String revisionTimestamp) throws RepresentationNotExistsException { Date revisionDate = null; if (revisionTimestamp != null) { DateTime utc = new DateTime(revisionTimestamp, DateTimeZone.UTC); revisionDate = utc.toDate(); } List<RepresentationRevisionResponse> info = recordService.getRepresentationRevisions(cloudId, representationName, revisionProviderId, revisionName, revisionDate); List<Representation> representations = new ArrayList<>(); if (info != null) { for (RepresentationRevisionResponse representationRevisionsResource : info) { Representation representation; representation = recordService.getRepresentation( representationRevisionsResource.getCloudId(), representationRevisionsResource.getRepresentationName(), representationRevisionsResource.getVersion()); EnrichUriUtil.enrich(httpServletRequest, representation); if (userHasAccessTo(representation)) { representations.add(representation); } } } else { throw new RepresentationNotExistsException("No representation was found"); } return new RepresentationsListWrapper(representations); } RepresentationRevisionsResource(RecordService recordService, PermissionEvaluator permissionEvaluator); }
RepresentationRevisionsResource { @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody public RepresentationsListWrapper getRepresentationRevisions( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String revisionName, @RequestParam String revisionProviderId, @RequestParam(required = false) String revisionTimestamp) throws RepresentationNotExistsException { Date revisionDate = null; if (revisionTimestamp != null) { DateTime utc = new DateTime(revisionTimestamp, DateTimeZone.UTC); revisionDate = utc.toDate(); } List<RepresentationRevisionResponse> info = recordService.getRepresentationRevisions(cloudId, representationName, revisionProviderId, revisionName, revisionDate); List<Representation> representations = new ArrayList<>(); if (info != null) { for (RepresentationRevisionResponse representationRevisionsResource : info) { Representation representation; representation = recordService.getRepresentation( representationRevisionsResource.getCloudId(), representationRevisionsResource.getRepresentationName(), representationRevisionsResource.getVersion()); EnrichUriUtil.enrich(httpServletRequest, representation); if (userHasAccessTo(representation)) { representations.add(representation); } } } else { throw new RepresentationNotExistsException("No representation was found"); } return new RepresentationsListWrapper(representations); } RepresentationRevisionsResource(RecordService recordService, PermissionEvaluator permissionEvaluator); @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody RepresentationsListWrapper getRepresentationRevisions( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String revisionName, @RequestParam String revisionProviderId, @RequestParam(required = false) String revisionTimestamp); }
RepresentationRevisionsResource { @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody public RepresentationsListWrapper getRepresentationRevisions( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String revisionName, @RequestParam String revisionProviderId, @RequestParam(required = false) String revisionTimestamp) throws RepresentationNotExistsException { Date revisionDate = null; if (revisionTimestamp != null) { DateTime utc = new DateTime(revisionTimestamp, DateTimeZone.UTC); revisionDate = utc.toDate(); } List<RepresentationRevisionResponse> info = recordService.getRepresentationRevisions(cloudId, representationName, revisionProviderId, revisionName, revisionDate); List<Representation> representations = new ArrayList<>(); if (info != null) { for (RepresentationRevisionResponse representationRevisionsResource : info) { Representation representation; representation = recordService.getRepresentation( representationRevisionsResource.getCloudId(), representationRevisionsResource.getRepresentationName(), representationRevisionsResource.getVersion()); EnrichUriUtil.enrich(httpServletRequest, representation); if (userHasAccessTo(representation)) { representations.add(representation); } } } else { throw new RepresentationNotExistsException("No representation was found"); } return new RepresentationsListWrapper(representations); } RepresentationRevisionsResource(RecordService recordService, PermissionEvaluator permissionEvaluator); @GetMapping(produces = {MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody RepresentationsListWrapper getRepresentationRevisions( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @PathVariable String revisionName, @RequestParam String revisionProviderId, @RequestParam(required = false) String revisionTimestamp); }
@Test @Parameters(method = "mimeTypes") public void getRepresentation(MediaType mediaType) throws Exception { Representation expected = new Representation(representation); expected.setUri(URITools.getVersionUri(getBaseUri(), globalId, schema, version)); expected.setAllVersionsUri(URITools.getAllVersionsUri(getBaseUri(), globalId, schema)); ArrayList<File> files = new ArrayList<>(1); files.add(new File("1.xml", "text/xml", "91162629d258a876ee994e9233b2ad87", "2013-01-01", 12345L, URI.create("http: + "/representations/" + schema + "/versions/" + version + "/files/1.xml"))); expected.setFiles(files); when(recordService.getRepresentation(globalId, schema)).thenReturn(new Representation(representation)); ResultActions response = mockMvc.perform(get(URITools.getRepresentationPath(globalId, schema)).accept(mediaType)) .andExpect(status().isOk()) .andExpect(content().contentType(mediaType)); Representation entity = responseContent(response,Representation.class, mediaType); assertThat(entity, is(expected)); verify(recordService, times(1)).getRepresentation(globalId, schema); verifyNoMoreInteractions(recordService); }
@GetMapping(produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }) @PostAuthorize("hasPermission" + "( " + " (#cloudId).concat('/').concat(#representationName).concat('/').concat(returnObject.version) ," + " 'eu.europeana.cloud.common.model.Representation', read" + ")") @ResponseBody public Representation getRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName) throws RepresentationNotExistsException { Representation info = recordService.getRepresentation(cloudId, representationName); prepare(httpServletRequest, info); return info; }
RepresentationResource { @GetMapping(produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }) @PostAuthorize("hasPermission" + "( " + " (#cloudId).concat('/').concat(#representationName).concat('/').concat(returnObject.version) ," + " 'eu.europeana.cloud.common.model.Representation', read" + ")") @ResponseBody public Representation getRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName) throws RepresentationNotExistsException { Representation info = recordService.getRepresentation(cloudId, representationName); prepare(httpServletRequest, info); return info; } }
RepresentationResource { @GetMapping(produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }) @PostAuthorize("hasPermission" + "( " + " (#cloudId).concat('/').concat(#representationName).concat('/').concat(returnObject.version) ," + " 'eu.europeana.cloud.common.model.Representation', read" + ")") @ResponseBody public Representation getRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName) throws RepresentationNotExistsException { Representation info = recordService.getRepresentation(cloudId, representationName); prepare(httpServletRequest, info); return info; } RepresentationResource(RecordService recordService, MutableAclService mutableAclService); }
RepresentationResource { @GetMapping(produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }) @PostAuthorize("hasPermission" + "( " + " (#cloudId).concat('/').concat(#representationName).concat('/').concat(returnObject.version) ," + " 'eu.europeana.cloud.common.model.Representation', read" + ")") @ResponseBody public Representation getRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName) throws RepresentationNotExistsException { Representation info = recordService.getRepresentation(cloudId, representationName); prepare(httpServletRequest, info); return info; } RepresentationResource(RecordService recordService, MutableAclService mutableAclService); @GetMapping(produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }) @PostAuthorize("hasPermission" + "( " + " (#cloudId).concat('/').concat(#representationName).concat('/').concat(returnObject.version) ," + " 'eu.europeana.cloud.common.model.Representation', read" + ")") @ResponseBody Representation getRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName); @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName); @PostMapping(consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE}) @PreAuthorize("isAuthenticated()") ResponseEntity<Void> createRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @RequestParam String providerId); }
RepresentationResource { @GetMapping(produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }) @PostAuthorize("hasPermission" + "( " + " (#cloudId).concat('/').concat(#representationName).concat('/').concat(returnObject.version) ," + " 'eu.europeana.cloud.common.model.Representation', read" + ")") @ResponseBody public Representation getRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName) throws RepresentationNotExistsException { Representation info = recordService.getRepresentation(cloudId, representationName); prepare(httpServletRequest, info); return info; } RepresentationResource(RecordService recordService, MutableAclService mutableAclService); @GetMapping(produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }) @PostAuthorize("hasPermission" + "( " + " (#cloudId).concat('/').concat(#representationName).concat('/').concat(returnObject.version) ," + " 'eu.europeana.cloud.common.model.Representation', read" + ")") @ResponseBody Representation getRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName); @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName); @PostMapping(consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE}) @PreAuthorize("isAuthenticated()") ResponseEntity<Void> createRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @RequestParam String providerId); }
@Test @Parameters(method = "representationErrors") public void getRepresentationReturns404IfRepresentationOrRecordDoesNotExists(Throwable exception, String errorCode) throws Exception { when(recordService.getRepresentation(globalId, schema)).thenThrow(exception); ResultActions response = mockMvc.perform(get(URITools.getRepresentationPath(globalId, schema)) .accept(MediaType.APPLICATION_XML)) .andExpect(status().isNotFound()); ErrorInfo errorInfo = responseContent(response,ErrorInfo.class,MediaType.APPLICATION_XML); assertThat(errorInfo.getErrorCode(), is(errorCode)); verify(recordService, times(1)).getRepresentation(globalId, schema); verifyNoMoreInteractions(recordService); }
@GetMapping(produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }) @PostAuthorize("hasPermission" + "( " + " (#cloudId).concat('/').concat(#representationName).concat('/').concat(returnObject.version) ," + " 'eu.europeana.cloud.common.model.Representation', read" + ")") @ResponseBody public Representation getRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName) throws RepresentationNotExistsException { Representation info = recordService.getRepresentation(cloudId, representationName); prepare(httpServletRequest, info); return info; }
RepresentationResource { @GetMapping(produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }) @PostAuthorize("hasPermission" + "( " + " (#cloudId).concat('/').concat(#representationName).concat('/').concat(returnObject.version) ," + " 'eu.europeana.cloud.common.model.Representation', read" + ")") @ResponseBody public Representation getRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName) throws RepresentationNotExistsException { Representation info = recordService.getRepresentation(cloudId, representationName); prepare(httpServletRequest, info); return info; } }
RepresentationResource { @GetMapping(produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }) @PostAuthorize("hasPermission" + "( " + " (#cloudId).concat('/').concat(#representationName).concat('/').concat(returnObject.version) ," + " 'eu.europeana.cloud.common.model.Representation', read" + ")") @ResponseBody public Representation getRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName) throws RepresentationNotExistsException { Representation info = recordService.getRepresentation(cloudId, representationName); prepare(httpServletRequest, info); return info; } RepresentationResource(RecordService recordService, MutableAclService mutableAclService); }
RepresentationResource { @GetMapping(produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }) @PostAuthorize("hasPermission" + "( " + " (#cloudId).concat('/').concat(#representationName).concat('/').concat(returnObject.version) ," + " 'eu.europeana.cloud.common.model.Representation', read" + ")") @ResponseBody public Representation getRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName) throws RepresentationNotExistsException { Representation info = recordService.getRepresentation(cloudId, representationName); prepare(httpServletRequest, info); return info; } RepresentationResource(RecordService recordService, MutableAclService mutableAclService); @GetMapping(produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }) @PostAuthorize("hasPermission" + "( " + " (#cloudId).concat('/').concat(#representationName).concat('/').concat(returnObject.version) ," + " 'eu.europeana.cloud.common.model.Representation', read" + ")") @ResponseBody Representation getRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName); @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName); @PostMapping(consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE}) @PreAuthorize("isAuthenticated()") ResponseEntity<Void> createRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @RequestParam String providerId); }
RepresentationResource { @GetMapping(produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }) @PostAuthorize("hasPermission" + "( " + " (#cloudId).concat('/').concat(#representationName).concat('/').concat(returnObject.version) ," + " 'eu.europeana.cloud.common.model.Representation', read" + ")") @ResponseBody public Representation getRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName) throws RepresentationNotExistsException { Representation info = recordService.getRepresentation(cloudId, representationName); prepare(httpServletRequest, info); return info; } RepresentationResource(RecordService recordService, MutableAclService mutableAclService); @GetMapping(produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }) @PostAuthorize("hasPermission" + "( " + " (#cloudId).concat('/').concat(#representationName).concat('/').concat(returnObject.version) ," + " 'eu.europeana.cloud.common.model.Representation', read" + ")") @ResponseBody Representation getRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName); @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName); @PostMapping(consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE}) @PreAuthorize("isAuthenticated()") ResponseEntity<Void> createRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @RequestParam String providerId); }
@Test public void deleteRecord() throws Exception { mockMvc.perform(delete(URITools.getRepresentationPath(globalId, schema))) .andExpect(status().isNoContent()); verify(recordService, times(1)).deleteRepresentation(globalId, schema); verifyNoMoreInteractions(recordService); }
@DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") public void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName) throws RepresentationNotExistsException { recordService.deleteRepresentation(cloudId, representationName); }
RepresentationResource { @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") public void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName) throws RepresentationNotExistsException { recordService.deleteRepresentation(cloudId, representationName); } }
RepresentationResource { @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") public void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName) throws RepresentationNotExistsException { recordService.deleteRepresentation(cloudId, representationName); } RepresentationResource(RecordService recordService, MutableAclService mutableAclService); }
RepresentationResource { @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") public void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName) throws RepresentationNotExistsException { recordService.deleteRepresentation(cloudId, representationName); } RepresentationResource(RecordService recordService, MutableAclService mutableAclService); @GetMapping(produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }) @PostAuthorize("hasPermission" + "( " + " (#cloudId).concat('/').concat(#representationName).concat('/').concat(returnObject.version) ," + " 'eu.europeana.cloud.common.model.Representation', read" + ")") @ResponseBody Representation getRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName); @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName); @PostMapping(consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE}) @PreAuthorize("isAuthenticated()") ResponseEntity<Void> createRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @RequestParam String providerId); }
RepresentationResource { @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") public void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName) throws RepresentationNotExistsException { recordService.deleteRepresentation(cloudId, representationName); } RepresentationResource(RecordService recordService, MutableAclService mutableAclService); @GetMapping(produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }) @PostAuthorize("hasPermission" + "( " + " (#cloudId).concat('/').concat(#representationName).concat('/').concat(returnObject.version) ," + " 'eu.europeana.cloud.common.model.Representation', read" + ")") @ResponseBody Representation getRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName); @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName); @PostMapping(consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE}) @PreAuthorize("isAuthenticated()") ResponseEntity<Void> createRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @RequestParam String providerId); }
@Test @Parameters(method = "representationErrors") public void deleteRepresentationReturns404IfRecordOrRepresentationDoesNotExists(Throwable exception, String errorCode) throws Exception { Mockito.doThrow(exception).when(recordService).deleteRepresentation(globalId, schema); ResultActions response = mockMvc.perform(delete(URITools.getRepresentationPath(globalId, schema))) .andExpect(status().isNotFound()); ErrorInfo errorInfo = responseContentAsErrorInfo(response); assertThat(errorInfo.getErrorCode(), is(errorCode)); verify(recordService, times(1)).deleteRepresentation(globalId, schema); verifyNoMoreInteractions(recordService); }
@DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") public void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName) throws RepresentationNotExistsException { recordService.deleteRepresentation(cloudId, representationName); }
RepresentationResource { @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") public void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName) throws RepresentationNotExistsException { recordService.deleteRepresentation(cloudId, representationName); } }
RepresentationResource { @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") public void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName) throws RepresentationNotExistsException { recordService.deleteRepresentation(cloudId, representationName); } RepresentationResource(RecordService recordService, MutableAclService mutableAclService); }
RepresentationResource { @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") public void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName) throws RepresentationNotExistsException { recordService.deleteRepresentation(cloudId, representationName); } RepresentationResource(RecordService recordService, MutableAclService mutableAclService); @GetMapping(produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }) @PostAuthorize("hasPermission" + "( " + " (#cloudId).concat('/').concat(#representationName).concat('/').concat(returnObject.version) ," + " 'eu.europeana.cloud.common.model.Representation', read" + ")") @ResponseBody Representation getRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName); @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName); @PostMapping(consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE}) @PreAuthorize("isAuthenticated()") ResponseEntity<Void> createRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @RequestParam String providerId); }
RepresentationResource { @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") public void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName) throws RepresentationNotExistsException { recordService.deleteRepresentation(cloudId, representationName); } RepresentationResource(RecordService recordService, MutableAclService mutableAclService); @GetMapping(produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }) @PostAuthorize("hasPermission" + "( " + " (#cloudId).concat('/').concat(#representationName).concat('/').concat(returnObject.version) ," + " 'eu.europeana.cloud.common.model.Representation', read" + ")") @ResponseBody Representation getRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName); @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName); @PostMapping(consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE}) @PreAuthorize("isAuthenticated()") ResponseEntity<Void> createRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @RequestParam String providerId); }
@Test public void createRepresentation() throws Exception { when(recordService.createRepresentation(globalId, schema, providerID)).thenReturn( new Representation(representation)); mockMvc.perform(post(URITools.getRepresentationPath(globalId, schema)) .contentType(MediaType.APPLICATION_FORM_URLENCODED) .param(ParamConstants.F_PROVIDER, providerID)) .andExpect(status().isCreated()) .andExpect(header().string(HttpHeaders.LOCATION, URITools.getVersionUri(getBaseUri(), globalId, schema, version).toString())); verify(recordService, times(1)).createRepresentation(globalId, schema, providerID); verifyNoMoreInteractions(recordService); }
@PostMapping(consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE}) @PreAuthorize("isAuthenticated()") public ResponseEntity<Void> createRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @RequestParam String providerId) throws RecordNotExistsException, ProviderNotExistsException { Representation version = recordService.createRepresentation(cloudId, representationName, providerId); EnrichUriUtil.enrich(httpServletRequest, version); String creatorName = SpringUserUtils.getUsername(); if (creatorName != null) { ObjectIdentity versionIdentity = new ObjectIdentityImpl(REPRESENTATION_CLASS_NAME, cloudId + "/" + representationName + "/" + version.getVersion()); MutableAcl versionAcl = mutableAclService .createAcl(versionIdentity); versionAcl.insertAce(0, BasePermission.READ, new PrincipalSid(creatorName), true); versionAcl.insertAce(1, BasePermission.WRITE, new PrincipalSid(creatorName), true); versionAcl.insertAce(2, BasePermission.DELETE, new PrincipalSid(creatorName), true); versionAcl.insertAce(3, BasePermission.ADMINISTRATION, new PrincipalSid(creatorName), true); mutableAclService.updateAcl(versionAcl); } return ResponseEntity.created(version.getUri()).build(); }
RepresentationResource { @PostMapping(consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE}) @PreAuthorize("isAuthenticated()") public ResponseEntity<Void> createRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @RequestParam String providerId) throws RecordNotExistsException, ProviderNotExistsException { Representation version = recordService.createRepresentation(cloudId, representationName, providerId); EnrichUriUtil.enrich(httpServletRequest, version); String creatorName = SpringUserUtils.getUsername(); if (creatorName != null) { ObjectIdentity versionIdentity = new ObjectIdentityImpl(REPRESENTATION_CLASS_NAME, cloudId + "/" + representationName + "/" + version.getVersion()); MutableAcl versionAcl = mutableAclService .createAcl(versionIdentity); versionAcl.insertAce(0, BasePermission.READ, new PrincipalSid(creatorName), true); versionAcl.insertAce(1, BasePermission.WRITE, new PrincipalSid(creatorName), true); versionAcl.insertAce(2, BasePermission.DELETE, new PrincipalSid(creatorName), true); versionAcl.insertAce(3, BasePermission.ADMINISTRATION, new PrincipalSid(creatorName), true); mutableAclService.updateAcl(versionAcl); } return ResponseEntity.created(version.getUri()).build(); } }
RepresentationResource { @PostMapping(consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE}) @PreAuthorize("isAuthenticated()") public ResponseEntity<Void> createRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @RequestParam String providerId) throws RecordNotExistsException, ProviderNotExistsException { Representation version = recordService.createRepresentation(cloudId, representationName, providerId); EnrichUriUtil.enrich(httpServletRequest, version); String creatorName = SpringUserUtils.getUsername(); if (creatorName != null) { ObjectIdentity versionIdentity = new ObjectIdentityImpl(REPRESENTATION_CLASS_NAME, cloudId + "/" + representationName + "/" + version.getVersion()); MutableAcl versionAcl = mutableAclService .createAcl(versionIdentity); versionAcl.insertAce(0, BasePermission.READ, new PrincipalSid(creatorName), true); versionAcl.insertAce(1, BasePermission.WRITE, new PrincipalSid(creatorName), true); versionAcl.insertAce(2, BasePermission.DELETE, new PrincipalSid(creatorName), true); versionAcl.insertAce(3, BasePermission.ADMINISTRATION, new PrincipalSid(creatorName), true); mutableAclService.updateAcl(versionAcl); } return ResponseEntity.created(version.getUri()).build(); } RepresentationResource(RecordService recordService, MutableAclService mutableAclService); }
RepresentationResource { @PostMapping(consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE}) @PreAuthorize("isAuthenticated()") public ResponseEntity<Void> createRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @RequestParam String providerId) throws RecordNotExistsException, ProviderNotExistsException { Representation version = recordService.createRepresentation(cloudId, representationName, providerId); EnrichUriUtil.enrich(httpServletRequest, version); String creatorName = SpringUserUtils.getUsername(); if (creatorName != null) { ObjectIdentity versionIdentity = new ObjectIdentityImpl(REPRESENTATION_CLASS_NAME, cloudId + "/" + representationName + "/" + version.getVersion()); MutableAcl versionAcl = mutableAclService .createAcl(versionIdentity); versionAcl.insertAce(0, BasePermission.READ, new PrincipalSid(creatorName), true); versionAcl.insertAce(1, BasePermission.WRITE, new PrincipalSid(creatorName), true); versionAcl.insertAce(2, BasePermission.DELETE, new PrincipalSid(creatorName), true); versionAcl.insertAce(3, BasePermission.ADMINISTRATION, new PrincipalSid(creatorName), true); mutableAclService.updateAcl(versionAcl); } return ResponseEntity.created(version.getUri()).build(); } RepresentationResource(RecordService recordService, MutableAclService mutableAclService); @GetMapping(produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }) @PostAuthorize("hasPermission" + "( " + " (#cloudId).concat('/').concat(#representationName).concat('/').concat(returnObject.version) ," + " 'eu.europeana.cloud.common.model.Representation', read" + ")") @ResponseBody Representation getRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName); @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName); @PostMapping(consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE}) @PreAuthorize("isAuthenticated()") ResponseEntity<Void> createRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @RequestParam String providerId); }
RepresentationResource { @PostMapping(consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE}) @PreAuthorize("isAuthenticated()") public ResponseEntity<Void> createRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @RequestParam String providerId) throws RecordNotExistsException, ProviderNotExistsException { Representation version = recordService.createRepresentation(cloudId, representationName, providerId); EnrichUriUtil.enrich(httpServletRequest, version); String creatorName = SpringUserUtils.getUsername(); if (creatorName != null) { ObjectIdentity versionIdentity = new ObjectIdentityImpl(REPRESENTATION_CLASS_NAME, cloudId + "/" + representationName + "/" + version.getVersion()); MutableAcl versionAcl = mutableAclService .createAcl(versionIdentity); versionAcl.insertAce(0, BasePermission.READ, new PrincipalSid(creatorName), true); versionAcl.insertAce(1, BasePermission.WRITE, new PrincipalSid(creatorName), true); versionAcl.insertAce(2, BasePermission.DELETE, new PrincipalSid(creatorName), true); versionAcl.insertAce(3, BasePermission.ADMINISTRATION, new PrincipalSid(creatorName), true); mutableAclService.updateAcl(versionAcl); } return ResponseEntity.created(version.getUri()).build(); } RepresentationResource(RecordService recordService, MutableAclService mutableAclService); @GetMapping(produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }) @PostAuthorize("hasPermission" + "( " + " (#cloudId).concat('/').concat(#representationName).concat('/').concat(returnObject.version) ," + " 'eu.europeana.cloud.common.model.Representation', read" + ")") @ResponseBody Representation getRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName); @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName); @PostMapping(consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE}) @PreAuthorize("isAuthenticated()") ResponseEntity<Void> createRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @RequestParam String providerId); }
@Test @Parameters(method = "recordErrors") public void createRepresentationReturns404IfRecordOrRepresentationDoesNotExists(Throwable exception, String errorCode) throws Exception { Mockito.doThrow(exception).when(recordService).createRepresentation(globalId, schema, providerID); ResultActions response = mockMvc.perform(post(URITools.getRepresentationPath(globalId, schema)) .contentType(MediaType.APPLICATION_FORM_URLENCODED) .param(ParamConstants.F_PROVIDER, providerID)) .andExpect(status().isNotFound()); ErrorInfo errorInfo = responseContentAsErrorInfo(response); assertThat(errorInfo.getErrorCode(), is(errorCode)); verify(recordService, times(1)).createRepresentation(globalId, schema, providerID); verifyNoMoreInteractions(recordService); }
@PostMapping(consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE}) @PreAuthorize("isAuthenticated()") public ResponseEntity<Void> createRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @RequestParam String providerId) throws RecordNotExistsException, ProviderNotExistsException { Representation version = recordService.createRepresentation(cloudId, representationName, providerId); EnrichUriUtil.enrich(httpServletRequest, version); String creatorName = SpringUserUtils.getUsername(); if (creatorName != null) { ObjectIdentity versionIdentity = new ObjectIdentityImpl(REPRESENTATION_CLASS_NAME, cloudId + "/" + representationName + "/" + version.getVersion()); MutableAcl versionAcl = mutableAclService .createAcl(versionIdentity); versionAcl.insertAce(0, BasePermission.READ, new PrincipalSid(creatorName), true); versionAcl.insertAce(1, BasePermission.WRITE, new PrincipalSid(creatorName), true); versionAcl.insertAce(2, BasePermission.DELETE, new PrincipalSid(creatorName), true); versionAcl.insertAce(3, BasePermission.ADMINISTRATION, new PrincipalSid(creatorName), true); mutableAclService.updateAcl(versionAcl); } return ResponseEntity.created(version.getUri()).build(); }
RepresentationResource { @PostMapping(consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE}) @PreAuthorize("isAuthenticated()") public ResponseEntity<Void> createRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @RequestParam String providerId) throws RecordNotExistsException, ProviderNotExistsException { Representation version = recordService.createRepresentation(cloudId, representationName, providerId); EnrichUriUtil.enrich(httpServletRequest, version); String creatorName = SpringUserUtils.getUsername(); if (creatorName != null) { ObjectIdentity versionIdentity = new ObjectIdentityImpl(REPRESENTATION_CLASS_NAME, cloudId + "/" + representationName + "/" + version.getVersion()); MutableAcl versionAcl = mutableAclService .createAcl(versionIdentity); versionAcl.insertAce(0, BasePermission.READ, new PrincipalSid(creatorName), true); versionAcl.insertAce(1, BasePermission.WRITE, new PrincipalSid(creatorName), true); versionAcl.insertAce(2, BasePermission.DELETE, new PrincipalSid(creatorName), true); versionAcl.insertAce(3, BasePermission.ADMINISTRATION, new PrincipalSid(creatorName), true); mutableAclService.updateAcl(versionAcl); } return ResponseEntity.created(version.getUri()).build(); } }
RepresentationResource { @PostMapping(consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE}) @PreAuthorize("isAuthenticated()") public ResponseEntity<Void> createRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @RequestParam String providerId) throws RecordNotExistsException, ProviderNotExistsException { Representation version = recordService.createRepresentation(cloudId, representationName, providerId); EnrichUriUtil.enrich(httpServletRequest, version); String creatorName = SpringUserUtils.getUsername(); if (creatorName != null) { ObjectIdentity versionIdentity = new ObjectIdentityImpl(REPRESENTATION_CLASS_NAME, cloudId + "/" + representationName + "/" + version.getVersion()); MutableAcl versionAcl = mutableAclService .createAcl(versionIdentity); versionAcl.insertAce(0, BasePermission.READ, new PrincipalSid(creatorName), true); versionAcl.insertAce(1, BasePermission.WRITE, new PrincipalSid(creatorName), true); versionAcl.insertAce(2, BasePermission.DELETE, new PrincipalSid(creatorName), true); versionAcl.insertAce(3, BasePermission.ADMINISTRATION, new PrincipalSid(creatorName), true); mutableAclService.updateAcl(versionAcl); } return ResponseEntity.created(version.getUri()).build(); } RepresentationResource(RecordService recordService, MutableAclService mutableAclService); }
RepresentationResource { @PostMapping(consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE}) @PreAuthorize("isAuthenticated()") public ResponseEntity<Void> createRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @RequestParam String providerId) throws RecordNotExistsException, ProviderNotExistsException { Representation version = recordService.createRepresentation(cloudId, representationName, providerId); EnrichUriUtil.enrich(httpServletRequest, version); String creatorName = SpringUserUtils.getUsername(); if (creatorName != null) { ObjectIdentity versionIdentity = new ObjectIdentityImpl(REPRESENTATION_CLASS_NAME, cloudId + "/" + representationName + "/" + version.getVersion()); MutableAcl versionAcl = mutableAclService .createAcl(versionIdentity); versionAcl.insertAce(0, BasePermission.READ, new PrincipalSid(creatorName), true); versionAcl.insertAce(1, BasePermission.WRITE, new PrincipalSid(creatorName), true); versionAcl.insertAce(2, BasePermission.DELETE, new PrincipalSid(creatorName), true); versionAcl.insertAce(3, BasePermission.ADMINISTRATION, new PrincipalSid(creatorName), true); mutableAclService.updateAcl(versionAcl); } return ResponseEntity.created(version.getUri()).build(); } RepresentationResource(RecordService recordService, MutableAclService mutableAclService); @GetMapping(produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }) @PostAuthorize("hasPermission" + "( " + " (#cloudId).concat('/').concat(#representationName).concat('/').concat(returnObject.version) ," + " 'eu.europeana.cloud.common.model.Representation', read" + ")") @ResponseBody Representation getRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName); @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName); @PostMapping(consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE}) @PreAuthorize("isAuthenticated()") ResponseEntity<Void> createRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @RequestParam String providerId); }
RepresentationResource { @PostMapping(consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE}) @PreAuthorize("isAuthenticated()") public ResponseEntity<Void> createRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @RequestParam String providerId) throws RecordNotExistsException, ProviderNotExistsException { Representation version = recordService.createRepresentation(cloudId, representationName, providerId); EnrichUriUtil.enrich(httpServletRequest, version); String creatorName = SpringUserUtils.getUsername(); if (creatorName != null) { ObjectIdentity versionIdentity = new ObjectIdentityImpl(REPRESENTATION_CLASS_NAME, cloudId + "/" + representationName + "/" + version.getVersion()); MutableAcl versionAcl = mutableAclService .createAcl(versionIdentity); versionAcl.insertAce(0, BasePermission.READ, new PrincipalSid(creatorName), true); versionAcl.insertAce(1, BasePermission.WRITE, new PrincipalSid(creatorName), true); versionAcl.insertAce(2, BasePermission.DELETE, new PrincipalSid(creatorName), true); versionAcl.insertAce(3, BasePermission.ADMINISTRATION, new PrincipalSid(creatorName), true); mutableAclService.updateAcl(versionAcl); } return ResponseEntity.created(version.getUri()).build(); } RepresentationResource(RecordService recordService, MutableAclService mutableAclService); @GetMapping(produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }) @PostAuthorize("hasPermission" + "( " + " (#cloudId).concat('/').concat(#representationName).concat('/').concat(returnObject.version) ," + " 'eu.europeana.cloud.common.model.Representation', read" + ")") @ResponseBody Representation getRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName); @DeleteMapping @ResponseStatus(HttpStatus.NO_CONTENT) @PreAuthorize("hasRole('ROLE_ADMIN')") void deleteRepresentation( @PathVariable String cloudId, @PathVariable String representationName); @PostMapping(consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE}) @PreAuthorize("isAuthenticated()") ResponseEntity<Void> createRepresentation( HttpServletRequest httpServletRequest, @PathVariable String cloudId, @PathVariable String representationName, @RequestParam String providerId); }
@Test public void shouldThrowExceptionOnTwiceDataMigrations() { MigrationExecutor migrator = new MigrationExecutor(EmbeddedCassandra.KEYSPACE, contactPoint, EmbeddedCassandra.PORT, cassandraUsername, cassandraPassword, scriptsLocations); migrator.migrate(); migrator.migrate(); List<String> cloudIds = getCloudIds(session.execute("SELECT * FROM data_set_assignments_by_data_set;").all()); assertThat(cloudIds.size(), is(2)); }
public void migrate() { CassandraMigration cm = new CassandraMigration(); cm.getConfigs().setScriptsLocations(scriptsLocations); cm.setKeyspace(keyspace); cm.migrate(); }
MigrationExecutor { public void migrate() { CassandraMigration cm = new CassandraMigration(); cm.getConfigs().setScriptsLocations(scriptsLocations); cm.setKeyspace(keyspace); cm.migrate(); } }
MigrationExecutor { public void migrate() { CassandraMigration cm = new CassandraMigration(); cm.getConfigs().setScriptsLocations(scriptsLocations); cm.setKeyspace(keyspace); cm.migrate(); } MigrationExecutor(String cassandraKeyspace, String cassandraContactPoint, int cassandraPort, String cassandraUsername, String cassandraPassword, String[] scriptsLocations); }
MigrationExecutor { public void migrate() { CassandraMigration cm = new CassandraMigration(); cm.getConfigs().setScriptsLocations(scriptsLocations); cm.setKeyspace(keyspace); cm.migrate(); } MigrationExecutor(String cassandraKeyspace, String cassandraContactPoint, int cassandraPort, String cassandraUsername, String cassandraPassword, String[] scriptsLocations); void migrate(); }
MigrationExecutor { public void migrate() { CassandraMigration cm = new CassandraMigration(); cm.getConfigs().setScriptsLocations(scriptsLocations); cm.setKeyspace(keyspace); cm.migrate(); } MigrationExecutor(String cassandraKeyspace, String cassandraContactPoint, int cassandraPort, String cassandraUsername, String cassandraPassword, String[] scriptsLocations); void migrate(); }
@Test public void shouldReadAndReturnTaskIdsForCSVFile() throws IOException { List<RevisionInformation> taskIds = csvReader.getRevisionsInformation(Paths.get("src/test/resources/revisions.csv").toString()); assertNotNull(taskIds); assertEquals(8, taskIds.size()); }
@Override public List<RevisionInformation> getRevisionsInformation(String filePath) throws IOException { List<RevisionInformation> revisionInformationList = new ArrayList<>(); try (BufferedReader br = new BufferedReader(new FileReader(filePath))) { String line = ""; br.readLine(); while ((line = br.readLine()) != null) { String[] lines = line.split(LINE_SEPARATOR); RevisionInformation revisionInformation = new RevisionInformation(lines[0], lines[1], lines[2], lines[3], lines[4], lines[5]); revisionInformationList.add(revisionInformation); } } return revisionInformationList; }
CSVReader implements RevisionsReader { @Override public List<RevisionInformation> getRevisionsInformation(String filePath) throws IOException { List<RevisionInformation> revisionInformationList = new ArrayList<>(); try (BufferedReader br = new BufferedReader(new FileReader(filePath))) { String line = ""; br.readLine(); while ((line = br.readLine()) != null) { String[] lines = line.split(LINE_SEPARATOR); RevisionInformation revisionInformation = new RevisionInformation(lines[0], lines[1], lines[2], lines[3], lines[4], lines[5]); revisionInformationList.add(revisionInformation); } } return revisionInformationList; } }
CSVReader implements RevisionsReader { @Override public List<RevisionInformation> getRevisionsInformation(String filePath) throws IOException { List<RevisionInformation> revisionInformationList = new ArrayList<>(); try (BufferedReader br = new BufferedReader(new FileReader(filePath))) { String line = ""; br.readLine(); while ((line = br.readLine()) != null) { String[] lines = line.split(LINE_SEPARATOR); RevisionInformation revisionInformation = new RevisionInformation(lines[0], lines[1], lines[2], lines[3], lines[4], lines[5]); revisionInformationList.add(revisionInformation); } } return revisionInformationList; } }
CSVReader implements RevisionsReader { @Override public List<RevisionInformation> getRevisionsInformation(String filePath) throws IOException { List<RevisionInformation> revisionInformationList = new ArrayList<>(); try (BufferedReader br = new BufferedReader(new FileReader(filePath))) { String line = ""; br.readLine(); while ((line = br.readLine()) != null) { String[] lines = line.split(LINE_SEPARATOR); RevisionInformation revisionInformation = new RevisionInformation(lines[0], lines[1], lines[2], lines[3], lines[4], lines[5]); revisionInformationList.add(revisionInformation); } } return revisionInformationList; } @Override List<RevisionInformation> getRevisionsInformation(String filePath); }
CSVReader implements RevisionsReader { @Override public List<RevisionInformation> getRevisionsInformation(String filePath) throws IOException { List<RevisionInformation> revisionInformationList = new ArrayList<>(); try (BufferedReader br = new BufferedReader(new FileReader(filePath))) { String line = ""; br.readLine(); while ((line = br.readLine()) != null) { String[] lines = line.split(LINE_SEPARATOR); RevisionInformation revisionInformation = new RevisionInformation(lines[0], lines[1], lines[2], lines[3], lines[4], lines[5]); revisionInformationList.add(revisionInformation); } } return revisionInformationList; } @Override List<RevisionInformation> getRevisionsInformation(String filePath); }
@Test @Parameters(method = "mimeTypes") public void getRepresentations(MediaType mediaType) throws Exception { Record expected = new Record(record); Representation expectedRepresentation = expected.getRepresentations().get(0); expectedRepresentation.setUri(URITools.getVersionUri(getBaseUri(), globalId, schema, version)); expectedRepresentation.setAllVersionsUri(URITools.getAllVersionsUri(getBaseUri(), globalId, schema)); expectedRepresentation.setFiles(new ArrayList<File>()); when(recordService.getRecord(globalId)).thenReturn(new Record(record)); ResultActions response = mockMvc.perform(get(URITools.getRepresentationsPath(globalId).toString()).accept(mediaType)) .andExpect(status().isOk()) .andExpect(content().contentType(mediaType)); List<Representation> entity = responseContentAsRepresentationList(response, mediaType); assertThat(entity, is(expected.getRepresentations())); verify(recordService, times(1)).getRecord(globalId); verifyNoMoreInteractions(recordService); }
@GetMapping(produces = {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @ResponseBody public RepresentationsListWrapper getRepresentations( HttpServletRequest httpServletRequest, @PathVariable String cloudId) throws RecordNotExistsException { List<Representation> representationInfos = recordService.getRecord(cloudId).getRepresentations(); prepare(httpServletRequest, representationInfos); return new RepresentationsListWrapper(representationInfos); }
RepresentationsResource { @GetMapping(produces = {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @ResponseBody public RepresentationsListWrapper getRepresentations( HttpServletRequest httpServletRequest, @PathVariable String cloudId) throws RecordNotExistsException { List<Representation> representationInfos = recordService.getRecord(cloudId).getRepresentations(); prepare(httpServletRequest, representationInfos); return new RepresentationsListWrapper(representationInfos); } }
RepresentationsResource { @GetMapping(produces = {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @ResponseBody public RepresentationsListWrapper getRepresentations( HttpServletRequest httpServletRequest, @PathVariable String cloudId) throws RecordNotExistsException { List<Representation> representationInfos = recordService.getRecord(cloudId).getRepresentations(); prepare(httpServletRequest, representationInfos); return new RepresentationsListWrapper(representationInfos); } RepresentationsResource(RecordService recordService); }
RepresentationsResource { @GetMapping(produces = {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @ResponseBody public RepresentationsListWrapper getRepresentations( HttpServletRequest httpServletRequest, @PathVariable String cloudId) throws RecordNotExistsException { List<Representation> representationInfos = recordService.getRecord(cloudId).getRepresentations(); prepare(httpServletRequest, representationInfos); return new RepresentationsListWrapper(representationInfos); } RepresentationsResource(RecordService recordService); @GetMapping(produces = {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @ResponseBody RepresentationsListWrapper getRepresentations( HttpServletRequest httpServletRequest, @PathVariable String cloudId); }
RepresentationsResource { @GetMapping(produces = {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @ResponseBody public RepresentationsListWrapper getRepresentations( HttpServletRequest httpServletRequest, @PathVariable String cloudId) throws RecordNotExistsException { List<Representation> representationInfos = recordService.getRecord(cloudId).getRepresentations(); prepare(httpServletRequest, representationInfos); return new RepresentationsListWrapper(representationInfos); } RepresentationsResource(RecordService recordService); @GetMapping(produces = {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @ResponseBody RepresentationsListWrapper getRepresentations( HttpServletRequest httpServletRequest, @PathVariable String cloudId); }
@Test @Parameters({ "example_metadata.xml, application/xml", "example_jpg2000.jp2, image/jp2" }) public void shouldProperlyGuessMimeType_Xml(String fileName, String expectedMimeType) throws IOException { URL resource = Resources.getResource(fileName); byte[] expected = Resources.toByteArray(resource); BufferedInputStream inputStream = new BufferedInputStream(new FileInputStream( resource.getFile())); String mimeType = detectMediaType(inputStream).toString(); assertThat(mimeType,is(expectedMimeType)); byte[] actual = readFully(inputStream, expected.length); assertThat(actual,is(expected)); }
public static MediaType detectMediaType(InputStream inputStream) throws IOException { if (!inputStream.markSupported()) { throw new UnsupportedOperationException("InputStream marking support is required!"); } return new AutoDetectParser().getDetector().detect(inputStream, new Metadata()); }
ContentStreamDetector { public static MediaType detectMediaType(InputStream inputStream) throws IOException { if (!inputStream.markSupported()) { throw new UnsupportedOperationException("InputStream marking support is required!"); } return new AutoDetectParser().getDetector().detect(inputStream, new Metadata()); } }
ContentStreamDetector { public static MediaType detectMediaType(InputStream inputStream) throws IOException { if (!inputStream.markSupported()) { throw new UnsupportedOperationException("InputStream marking support is required!"); } return new AutoDetectParser().getDetector().detect(inputStream, new Metadata()); } private ContentStreamDetector(); }
ContentStreamDetector { public static MediaType detectMediaType(InputStream inputStream) throws IOException { if (!inputStream.markSupported()) { throw new UnsupportedOperationException("InputStream marking support is required!"); } return new AutoDetectParser().getDetector().detect(inputStream, new Metadata()); } private ContentStreamDetector(); static MediaType detectMediaType(InputStream inputStream); }
ContentStreamDetector { public static MediaType detectMediaType(InputStream inputStream) throws IOException { if (!inputStream.markSupported()) { throw new UnsupportedOperationException("InputStream marking support is required!"); } return new AutoDetectParser().getDetector().detect(inputStream, new Metadata()); } private ContentStreamDetector(); static MediaType detectMediaType(InputStream inputStream); }
@Test @Parameters({ "example_metadata.xml, DATA_BASE, application/xml", "example_jpg2000.jp2, OBJECT_STORAGE, image/jp2" }) public void shouldDetectStorage(String fileName, String expectedDecision, String mediaType) throws IOException { URL resource = Resources.getResource(fileName); byte[] expected = Resources.toByteArray(resource); PreBufferedInputStream inputStream = new PreBufferedInputStream( new FileInputStream(resource.getFile()), 512 * 1024); StorageSelector instance = new StorageSelector(inputStream, mediaType); Storage decision = instance.selectStorage(); assertThat(decision.toString(), is(expectedDecision)); byte[] actual = readFully(inputStream, expected.length); assertThat(actual, is(expected)); }
public Storage selectStorage() { return decide(assertUserMediaType(), getAvailable()); }
StorageSelector { public Storage selectStorage() { return decide(assertUserMediaType(), getAvailable()); } }
StorageSelector { public Storage selectStorage() { return decide(assertUserMediaType(), getAvailable()); } StorageSelector(final PreBufferedInputStream inputStream, final String userMediaType); }
StorageSelector { public Storage selectStorage() { return decide(assertUserMediaType(), getAvailable()); } StorageSelector(final PreBufferedInputStream inputStream, final String userMediaType); Storage selectStorage(); }
StorageSelector { public Storage selectStorage() { return decide(assertUserMediaType(), getAvailable()); } StorageSelector(final PreBufferedInputStream inputStream, final String userMediaType); Storage selectStorage(); }
@Test(expected = BadRequestException.class) @Parameters({ "example_metadata.xml, image/jp2", "example_jpg2000.jp2, application/xml" }) public void shouldThrowBadRequestOnDifferentMimeTypeProvidedByUser(String fileName, String mediaType) throws IOException { URL resource = Resources.getResource(fileName); byte[] expected = Resources.toByteArray(resource); PreBufferedInputStream inputStream = new PreBufferedInputStream( new FileInputStream(resource.getFile()), 512 * 1024); StorageSelector instance = new StorageSelector(inputStream, mediaType); Storage decision = instance.selectStorage(); }
public Storage selectStorage() { return decide(assertUserMediaType(), getAvailable()); }
StorageSelector { public Storage selectStorage() { return decide(assertUserMediaType(), getAvailable()); } }
StorageSelector { public Storage selectStorage() { return decide(assertUserMediaType(), getAvailable()); } StorageSelector(final PreBufferedInputStream inputStream, final String userMediaType); }
StorageSelector { public Storage selectStorage() { return decide(assertUserMediaType(), getAvailable()); } StorageSelector(final PreBufferedInputStream inputStream, final String userMediaType); Storage selectStorage(); }
StorageSelector { public Storage selectStorage() { return decide(assertUserMediaType(), getAvailable()); } StorageSelector(final PreBufferedInputStream inputStream, final String userMediaType); Storage selectStorage(); }
@Test @Parameters({ "10, 20", "20, 10", "10, 10000", "10000, 20", "10000, 3000", "10000, 4000", "10, 20", "20, 10" }) public void shouldProperlyCheckAvailableForByteArrayInputStream(int size, int bufferSize) throws IOException { byte[] expected = Helper.generateRandom(size); ByteArrayInputStream inputStream = new ByteArrayInputStream(expected); PreBufferedInputStream instance = new PreBufferedInputStream(inputStream, bufferSize); int available = instance.available(); assertThat(available, is(size)); assertUnchangedStream(expected, instance); }
@Override public synchronized int available() throws IOException { ensureIsNotClosed(); int inBufferAvailable = bufferFill - position; int avail = super.available(); return inBufferAvailable > (Integer.MAX_VALUE - avail) ? Integer.MAX_VALUE : inBufferAvailable + avail; }
PreBufferedInputStream extends BufferedInputStream { @Override public synchronized int available() throws IOException { ensureIsNotClosed(); int inBufferAvailable = bufferFill - position; int avail = super.available(); return inBufferAvailable > (Integer.MAX_VALUE - avail) ? Integer.MAX_VALUE : inBufferAvailable + avail; } }
PreBufferedInputStream extends BufferedInputStream { @Override public synchronized int available() throws IOException { ensureIsNotClosed(); int inBufferAvailable = bufferFill - position; int avail = super.available(); return inBufferAvailable > (Integer.MAX_VALUE - avail) ? Integer.MAX_VALUE : inBufferAvailable + avail; } PreBufferedInputStream(InputStream stream, int bufferSize); }
PreBufferedInputStream extends BufferedInputStream { @Override public synchronized int available() throws IOException { ensureIsNotClosed(); int inBufferAvailable = bufferFill - position; int avail = super.available(); return inBufferAvailable > (Integer.MAX_VALUE - avail) ? Integer.MAX_VALUE : inBufferAvailable + avail; } PreBufferedInputStream(InputStream stream, int bufferSize); static PreBufferedInputStream wrap(final byte[] data, final int preloadChunkSize); int getBufferSize(); @Override synchronized int read(); @Override synchronized int read(final byte[] b, final int offset, final int length); @Override synchronized int available(); @Override boolean markSupported(); @Override synchronized void mark(int readLimit); @Override synchronized void reset(); @Override synchronized void close(); @Override synchronized long skip(final long length); }
PreBufferedInputStream extends BufferedInputStream { @Override public synchronized int available() throws IOException { ensureIsNotClosed(); int inBufferAvailable = bufferFill - position; int avail = super.available(); return inBufferAvailable > (Integer.MAX_VALUE - avail) ? Integer.MAX_VALUE : inBufferAvailable + avail; } PreBufferedInputStream(InputStream stream, int bufferSize); static PreBufferedInputStream wrap(final byte[] data, final int preloadChunkSize); int getBufferSize(); @Override synchronized int read(); @Override synchronized int read(final byte[] b, final int offset, final int length); @Override synchronized int available(); @Override boolean markSupported(); @Override synchronized void mark(int readLimit); @Override synchronized void reset(); @Override synchronized void close(); @Override synchronized long skip(final long length); }
@Test @Parameters({ "10, example_metadata.xml", "200, example_metadata.xml", "2000, example_metadata.xml", "3000, example_metadata.xml", "10, example_jpg2000.jp2", "2000, example_jpg2000.jp2", "3000, example_jpg2000.jp2" }) public void shouldProperlyCheckAvailableForFile(final int bufferSize, final String fileName) throws IOException { URL resourceUri = Resources.getResource(fileName); final byte[] expected = Resources.toByteArray(resourceUri); FileInputStream inputStream = new FileInputStream( resourceUri.getFile()); PreBufferedInputStream instance = new PreBufferedInputStream(inputStream, bufferSize); int available = instance.available(); assertThat(available,is((expected.length))); assertThat(available,is(((int) new File(resourceUri.getFile()).length()))); assertUnchangedStream(expected, instance); }
@Override public synchronized int available() throws IOException { ensureIsNotClosed(); int inBufferAvailable = bufferFill - position; int avail = super.available(); return inBufferAvailable > (Integer.MAX_VALUE - avail) ? Integer.MAX_VALUE : inBufferAvailable + avail; }
PreBufferedInputStream extends BufferedInputStream { @Override public synchronized int available() throws IOException { ensureIsNotClosed(); int inBufferAvailable = bufferFill - position; int avail = super.available(); return inBufferAvailable > (Integer.MAX_VALUE - avail) ? Integer.MAX_VALUE : inBufferAvailable + avail; } }
PreBufferedInputStream extends BufferedInputStream { @Override public synchronized int available() throws IOException { ensureIsNotClosed(); int inBufferAvailable = bufferFill - position; int avail = super.available(); return inBufferAvailable > (Integer.MAX_VALUE - avail) ? Integer.MAX_VALUE : inBufferAvailable + avail; } PreBufferedInputStream(InputStream stream, int bufferSize); }
PreBufferedInputStream extends BufferedInputStream { @Override public synchronized int available() throws IOException { ensureIsNotClosed(); int inBufferAvailable = bufferFill - position; int avail = super.available(); return inBufferAvailable > (Integer.MAX_VALUE - avail) ? Integer.MAX_VALUE : inBufferAvailable + avail; } PreBufferedInputStream(InputStream stream, int bufferSize); static PreBufferedInputStream wrap(final byte[] data, final int preloadChunkSize); int getBufferSize(); @Override synchronized int read(); @Override synchronized int read(final byte[] b, final int offset, final int length); @Override synchronized int available(); @Override boolean markSupported(); @Override synchronized void mark(int readLimit); @Override synchronized void reset(); @Override synchronized void close(); @Override synchronized long skip(final long length); }
PreBufferedInputStream extends BufferedInputStream { @Override public synchronized int available() throws IOException { ensureIsNotClosed(); int inBufferAvailable = bufferFill - position; int avail = super.available(); return inBufferAvailable > (Integer.MAX_VALUE - avail) ? Integer.MAX_VALUE : inBufferAvailable + avail; } PreBufferedInputStream(InputStream stream, int bufferSize); static PreBufferedInputStream wrap(final byte[] data, final int preloadChunkSize); int getBufferSize(); @Override synchronized int read(); @Override synchronized int read(final byte[] b, final int offset, final int length); @Override synchronized int available(); @Override boolean markSupported(); @Override synchronized void mark(int readLimit); @Override synchronized void reset(); @Override synchronized void close(); @Override synchronized long skip(final long length); }
@Test @Parameters({ "10, 20", "200, 10", "100, 10000", "100, 200", "200, 100" }) public void shouldReadStreamPerByte(int size, int bufferSize) throws IOException { byte[] randomByes = Helper.generateSeq(size); ByteArrayInputStream inputStream = new ByteArrayInputStream(randomByes); PreBufferedInputStream instance = new PreBufferedInputStream(inputStream, bufferSize); int[] actual = new int[randomByes.length]; for (int i = 0; i < actual.length; i++) { actual[i] = instance.read(); } int[] randomIntegers = new int[actual.length]; for (int i = 0; i < randomIntegers.length; i++) { randomIntegers[i] = randomByes[i] & 0xff; } assertThat(actual, is(randomIntegers)); }
@Override public synchronized int read() throws IOException { ensureIsNotClosed(); if (position < bufferFill) { return buffer[position++] & 0xff; } return super.read(); }
PreBufferedInputStream extends BufferedInputStream { @Override public synchronized int read() throws IOException { ensureIsNotClosed(); if (position < bufferFill) { return buffer[position++] & 0xff; } return super.read(); } }
PreBufferedInputStream extends BufferedInputStream { @Override public synchronized int read() throws IOException { ensureIsNotClosed(); if (position < bufferFill) { return buffer[position++] & 0xff; } return super.read(); } PreBufferedInputStream(InputStream stream, int bufferSize); }
PreBufferedInputStream extends BufferedInputStream { @Override public synchronized int read() throws IOException { ensureIsNotClosed(); if (position < bufferFill) { return buffer[position++] & 0xff; } return super.read(); } PreBufferedInputStream(InputStream stream, int bufferSize); static PreBufferedInputStream wrap(final byte[] data, final int preloadChunkSize); int getBufferSize(); @Override synchronized int read(); @Override synchronized int read(final byte[] b, final int offset, final int length); @Override synchronized int available(); @Override boolean markSupported(); @Override synchronized void mark(int readLimit); @Override synchronized void reset(); @Override synchronized void close(); @Override synchronized long skip(final long length); }
PreBufferedInputStream extends BufferedInputStream { @Override public synchronized int read() throws IOException { ensureIsNotClosed(); if (position < bufferFill) { return buffer[position++] & 0xff; } return super.read(); } PreBufferedInputStream(InputStream stream, int bufferSize); static PreBufferedInputStream wrap(final byte[] data, final int preloadChunkSize); int getBufferSize(); @Override synchronized int read(); @Override synchronized int read(final byte[] b, final int offset, final int length); @Override synchronized int available(); @Override boolean markSupported(); @Override synchronized void mark(int readLimit); @Override synchronized void reset(); @Override synchronized void close(); @Override synchronized long skip(final long length); }
@Test public void shouldCloseClosedStream() throws IOException { PreBufferedInputStream instance = new PreBufferedInputStream(new NullInputStream(1), 1); instance.close(); instance.close(); }
@Override public synchronized void close() throws IOException { if (in == null && buffer == null) { return; } buffer = null; in.close(); in = null; }
PreBufferedInputStream extends BufferedInputStream { @Override public synchronized void close() throws IOException { if (in == null && buffer == null) { return; } buffer = null; in.close(); in = null; } }
PreBufferedInputStream extends BufferedInputStream { @Override public synchronized void close() throws IOException { if (in == null && buffer == null) { return; } buffer = null; in.close(); in = null; } PreBufferedInputStream(InputStream stream, int bufferSize); }
PreBufferedInputStream extends BufferedInputStream { @Override public synchronized void close() throws IOException { if (in == null && buffer == null) { return; } buffer = null; in.close(); in = null; } PreBufferedInputStream(InputStream stream, int bufferSize); static PreBufferedInputStream wrap(final byte[] data, final int preloadChunkSize); int getBufferSize(); @Override synchronized int read(); @Override synchronized int read(final byte[] b, final int offset, final int length); @Override synchronized int available(); @Override boolean markSupported(); @Override synchronized void mark(int readLimit); @Override synchronized void reset(); @Override synchronized void close(); @Override synchronized long skip(final long length); }
PreBufferedInputStream extends BufferedInputStream { @Override public synchronized void close() throws IOException { if (in == null && buffer == null) { return; } buffer = null; in.close(); in = null; } PreBufferedInputStream(InputStream stream, int bufferSize); static PreBufferedInputStream wrap(final byte[] data, final int preloadChunkSize); int getBufferSize(); @Override synchronized int read(); @Override synchronized int read(final byte[] b, final int offset, final int length); @Override synchronized int available(); @Override boolean markSupported(); @Override synchronized void mark(int readLimit); @Override synchronized void reset(); @Override synchronized void close(); @Override synchronized long skip(final long length); }
@Test public void shouldCreateDataSet() throws Exception { makeUISProviderSuccess(); String dsName = "ds"; String description = "description of data set"; DataSet ds = cassandraDataSetService.createDataSet(PROVIDER_ID, dsName, description); assertThat(ds.getId(), is(dsName)); assertThat(ds.getDescription(), is(description)); assertThat(ds.getProviderId(), is(PROVIDER_ID)); }
@Override public DataSet createDataSet(String providerId, String dataSetId, String description) throws ProviderNotExistsException, DataSetAlreadyExistsException { Date now = new Date(); if (uis.getProvider(providerId) == null) { throw new ProviderNotExistsException(); } DataSet ds = dataSetDAO.getDataSet(providerId, dataSetId); if (ds != null) { throw new DataSetAlreadyExistsException("Data set with provided name already exists"); } return dataSetDAO .createDataSet(providerId, dataSetId, description, now); }
CassandraDataSetService implements DataSetService { @Override public DataSet createDataSet(String providerId, String dataSetId, String description) throws ProviderNotExistsException, DataSetAlreadyExistsException { Date now = new Date(); if (uis.getProvider(providerId) == null) { throw new ProviderNotExistsException(); } DataSet ds = dataSetDAO.getDataSet(providerId, dataSetId); if (ds != null) { throw new DataSetAlreadyExistsException("Data set with provided name already exists"); } return dataSetDAO .createDataSet(providerId, dataSetId, description, now); } }
CassandraDataSetService implements DataSetService { @Override public DataSet createDataSet(String providerId, String dataSetId, String description) throws ProviderNotExistsException, DataSetAlreadyExistsException { Date now = new Date(); if (uis.getProvider(providerId) == null) { throw new ProviderNotExistsException(); } DataSet ds = dataSetDAO.getDataSet(providerId, dataSetId); if (ds != null) { throw new DataSetAlreadyExistsException("Data set with provided name already exists"); } return dataSetDAO .createDataSet(providerId, dataSetId, description, now); } }
CassandraDataSetService implements DataSetService { @Override public DataSet createDataSet(String providerId, String dataSetId, String description) throws ProviderNotExistsException, DataSetAlreadyExistsException { Date now = new Date(); if (uis.getProvider(providerId) == null) { throw new ProviderNotExistsException(); } DataSet ds = dataSetDAO.getDataSet(providerId, dataSetId); if (ds != null) { throw new DataSetAlreadyExistsException("Data set with provided name already exists"); } return dataSetDAO .createDataSet(providerId, dataSetId, description, now); } @Override ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit); @Override void addAssignment(String providerId, String dataSetId, String recordId, String schema, String version); @Override void removeAssignment(String providerId, String dataSetId, String recordId, String schema, String versionId); @Override DataSet createDataSet(String providerId, String dataSetId, String description); @Override DataSet updateDataSet(String providerId, String dataSetId, String description); @Override ResultSlice<DataSet> getDataSets(String providerId, String thresholdDatasetId, int limit); @Override ResultSlice<CloudTagsResponse> getDataSetsRevisions(String providerId, String dataSetId, String revisionProviderId, String revisionName, Date revisionTimestamp, String representationName, String startFrom, int limit); @Override void addDataSetsRevisions(String providerId, String dataSetId, Revision revision, String representationName, String cloudId); @Override ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationPublished(String dataSetId, String providerId, String representationName, Date dateFrom, String startFrom, int numberOfElementsPerPage); @Override void updateAllRevisionDatasetsEntries(String globalId, String schema, String version, Revision revision); @Override void deleteDataSet(String providerId, String dataSetId); @Override Set<String> getAllDataSetRepresentationsNames(String providerId, String dataSetId); @Override void updateProviderDatasetRepresentation(String globalId, String schema, String version, Revision revision); @Override String getLatestVersionForGivenRevision(String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); @Override void addLatestRevisionForGivenVersionInDataset(DataSet dataSet, Representation representation, Revision revision); @Override ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage); @Override void deleteRevision(String cloudId, String representationName, String version, String revisionName, String revisionProviderId, Date revisionTimestamp); }
CassandraDataSetService implements DataSetService { @Override public DataSet createDataSet(String providerId, String dataSetId, String description) throws ProviderNotExistsException, DataSetAlreadyExistsException { Date now = new Date(); if (uis.getProvider(providerId) == null) { throw new ProviderNotExistsException(); } DataSet ds = dataSetDAO.getDataSet(providerId, dataSetId); if (ds != null) { throw new DataSetAlreadyExistsException("Data set with provided name already exists"); } return dataSetDAO .createDataSet(providerId, dataSetId, description, now); } @Override ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit); @Override void addAssignment(String providerId, String dataSetId, String recordId, String schema, String version); @Override void removeAssignment(String providerId, String dataSetId, String recordId, String schema, String versionId); @Override DataSet createDataSet(String providerId, String dataSetId, String description); @Override DataSet updateDataSet(String providerId, String dataSetId, String description); @Override ResultSlice<DataSet> getDataSets(String providerId, String thresholdDatasetId, int limit); @Override ResultSlice<CloudTagsResponse> getDataSetsRevisions(String providerId, String dataSetId, String revisionProviderId, String revisionName, Date revisionTimestamp, String representationName, String startFrom, int limit); @Override void addDataSetsRevisions(String providerId, String dataSetId, Revision revision, String representationName, String cloudId); @Override ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationPublished(String dataSetId, String providerId, String representationName, Date dateFrom, String startFrom, int numberOfElementsPerPage); @Override void updateAllRevisionDatasetsEntries(String globalId, String schema, String version, Revision revision); @Override void deleteDataSet(String providerId, String dataSetId); @Override Set<String> getAllDataSetRepresentationsNames(String providerId, String dataSetId); @Override void updateProviderDatasetRepresentation(String globalId, String schema, String version, Revision revision); @Override String getLatestVersionForGivenRevision(String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); @Override void addLatestRevisionForGivenVersionInDataset(DataSet dataSet, Representation representation, Revision revision); @Override ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage); @Override void deleteRevision(String cloudId, String representationName, String version, String revisionName, String revisionProviderId, Date revisionTimestamp); }
@Test(expected = DataSetNotExistsException.class) public void shouldNotAssignToNotExistingDataSet() throws Exception { makeUISProviderSuccess(); Representation r = insertDummyPersistentRepresentation("cloud-id", "schema", PROVIDER_ID); cassandraDataSetService.addAssignment(PROVIDER_ID, "not-existing", r.getCloudId(), r.getRepresentationName(), r.getVersion()); }
@Override public void addAssignment(String providerId, String dataSetId, String recordId, String schema, String version) throws DataSetNotExistsException, RepresentationNotExistsException { checkIfDatasetExists(dataSetId, providerId); Representation rep = getRepresentationIfExist(recordId, schema, version); if (!isAssignmentExists(providerId, dataSetId, recordId, schema, rep.getVersion())) { dataSetDAO.addAssignment(providerId, dataSetId, recordId, schema, rep.getVersion()); DataProvider dataProvider = uis.getProvider(providerId); dataSetDAO.addDataSetsRepresentationName(providerId, dataSetId, schema); Map<String, Revision> latestRevisions = new HashMap<>(); for (Revision revision : rep.getRevisions()) { String revisionKey = revision.getRevisionName() + "_" + revision.getRevisionProviderId(); Revision currentRevision = latestRevisions.get(revisionKey); if (currentRevision == null || revision.getCreationTimeStamp().getTime() > currentRevision.getCreationTimeStamp().getTime()) { latestRevisions.put(revisionKey, revision); } dataSetDAO.addDataSetsRevision(providerId, dataSetId, revision, schema, recordId); dataSetDAO.insertProviderDatasetRepresentationInfo(dataSetId, providerId, recordId, rep.getVersion(), schema, RevisionUtils.getRevisionKey(revision), revision.getCreationTimeStamp(), revision.isAcceptance(), revision.isPublished(), revision.isDeleted()); dataSetDAO.addLatestRevisionForDatasetAssignment(dataSetDAO.getDataSet(providerId, dataSetId), rep, revision); } updateLatestProviderDatasetRevisions(providerId, dataSetId, recordId, schema, version, latestRevisions); } }
CassandraDataSetService implements DataSetService { @Override public void addAssignment(String providerId, String dataSetId, String recordId, String schema, String version) throws DataSetNotExistsException, RepresentationNotExistsException { checkIfDatasetExists(dataSetId, providerId); Representation rep = getRepresentationIfExist(recordId, schema, version); if (!isAssignmentExists(providerId, dataSetId, recordId, schema, rep.getVersion())) { dataSetDAO.addAssignment(providerId, dataSetId, recordId, schema, rep.getVersion()); DataProvider dataProvider = uis.getProvider(providerId); dataSetDAO.addDataSetsRepresentationName(providerId, dataSetId, schema); Map<String, Revision> latestRevisions = new HashMap<>(); for (Revision revision : rep.getRevisions()) { String revisionKey = revision.getRevisionName() + "_" + revision.getRevisionProviderId(); Revision currentRevision = latestRevisions.get(revisionKey); if (currentRevision == null || revision.getCreationTimeStamp().getTime() > currentRevision.getCreationTimeStamp().getTime()) { latestRevisions.put(revisionKey, revision); } dataSetDAO.addDataSetsRevision(providerId, dataSetId, revision, schema, recordId); dataSetDAO.insertProviderDatasetRepresentationInfo(dataSetId, providerId, recordId, rep.getVersion(), schema, RevisionUtils.getRevisionKey(revision), revision.getCreationTimeStamp(), revision.isAcceptance(), revision.isPublished(), revision.isDeleted()); dataSetDAO.addLatestRevisionForDatasetAssignment(dataSetDAO.getDataSet(providerId, dataSetId), rep, revision); } updateLatestProviderDatasetRevisions(providerId, dataSetId, recordId, schema, version, latestRevisions); } } }
CassandraDataSetService implements DataSetService { @Override public void addAssignment(String providerId, String dataSetId, String recordId, String schema, String version) throws DataSetNotExistsException, RepresentationNotExistsException { checkIfDatasetExists(dataSetId, providerId); Representation rep = getRepresentationIfExist(recordId, schema, version); if (!isAssignmentExists(providerId, dataSetId, recordId, schema, rep.getVersion())) { dataSetDAO.addAssignment(providerId, dataSetId, recordId, schema, rep.getVersion()); DataProvider dataProvider = uis.getProvider(providerId); dataSetDAO.addDataSetsRepresentationName(providerId, dataSetId, schema); Map<String, Revision> latestRevisions = new HashMap<>(); for (Revision revision : rep.getRevisions()) { String revisionKey = revision.getRevisionName() + "_" + revision.getRevisionProviderId(); Revision currentRevision = latestRevisions.get(revisionKey); if (currentRevision == null || revision.getCreationTimeStamp().getTime() > currentRevision.getCreationTimeStamp().getTime()) { latestRevisions.put(revisionKey, revision); } dataSetDAO.addDataSetsRevision(providerId, dataSetId, revision, schema, recordId); dataSetDAO.insertProviderDatasetRepresentationInfo(dataSetId, providerId, recordId, rep.getVersion(), schema, RevisionUtils.getRevisionKey(revision), revision.getCreationTimeStamp(), revision.isAcceptance(), revision.isPublished(), revision.isDeleted()); dataSetDAO.addLatestRevisionForDatasetAssignment(dataSetDAO.getDataSet(providerId, dataSetId), rep, revision); } updateLatestProviderDatasetRevisions(providerId, dataSetId, recordId, schema, version, latestRevisions); } } }
CassandraDataSetService implements DataSetService { @Override public void addAssignment(String providerId, String dataSetId, String recordId, String schema, String version) throws DataSetNotExistsException, RepresentationNotExistsException { checkIfDatasetExists(dataSetId, providerId); Representation rep = getRepresentationIfExist(recordId, schema, version); if (!isAssignmentExists(providerId, dataSetId, recordId, schema, rep.getVersion())) { dataSetDAO.addAssignment(providerId, dataSetId, recordId, schema, rep.getVersion()); DataProvider dataProvider = uis.getProvider(providerId); dataSetDAO.addDataSetsRepresentationName(providerId, dataSetId, schema); Map<String, Revision> latestRevisions = new HashMap<>(); for (Revision revision : rep.getRevisions()) { String revisionKey = revision.getRevisionName() + "_" + revision.getRevisionProviderId(); Revision currentRevision = latestRevisions.get(revisionKey); if (currentRevision == null || revision.getCreationTimeStamp().getTime() > currentRevision.getCreationTimeStamp().getTime()) { latestRevisions.put(revisionKey, revision); } dataSetDAO.addDataSetsRevision(providerId, dataSetId, revision, schema, recordId); dataSetDAO.insertProviderDatasetRepresentationInfo(dataSetId, providerId, recordId, rep.getVersion(), schema, RevisionUtils.getRevisionKey(revision), revision.getCreationTimeStamp(), revision.isAcceptance(), revision.isPublished(), revision.isDeleted()); dataSetDAO.addLatestRevisionForDatasetAssignment(dataSetDAO.getDataSet(providerId, dataSetId), rep, revision); } updateLatestProviderDatasetRevisions(providerId, dataSetId, recordId, schema, version, latestRevisions); } } @Override ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit); @Override void addAssignment(String providerId, String dataSetId, String recordId, String schema, String version); @Override void removeAssignment(String providerId, String dataSetId, String recordId, String schema, String versionId); @Override DataSet createDataSet(String providerId, String dataSetId, String description); @Override DataSet updateDataSet(String providerId, String dataSetId, String description); @Override ResultSlice<DataSet> getDataSets(String providerId, String thresholdDatasetId, int limit); @Override ResultSlice<CloudTagsResponse> getDataSetsRevisions(String providerId, String dataSetId, String revisionProviderId, String revisionName, Date revisionTimestamp, String representationName, String startFrom, int limit); @Override void addDataSetsRevisions(String providerId, String dataSetId, Revision revision, String representationName, String cloudId); @Override ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationPublished(String dataSetId, String providerId, String representationName, Date dateFrom, String startFrom, int numberOfElementsPerPage); @Override void updateAllRevisionDatasetsEntries(String globalId, String schema, String version, Revision revision); @Override void deleteDataSet(String providerId, String dataSetId); @Override Set<String> getAllDataSetRepresentationsNames(String providerId, String dataSetId); @Override void updateProviderDatasetRepresentation(String globalId, String schema, String version, Revision revision); @Override String getLatestVersionForGivenRevision(String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); @Override void addLatestRevisionForGivenVersionInDataset(DataSet dataSet, Representation representation, Revision revision); @Override ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage); @Override void deleteRevision(String cloudId, String representationName, String version, String revisionName, String revisionProviderId, Date revisionTimestamp); }
CassandraDataSetService implements DataSetService { @Override public void addAssignment(String providerId, String dataSetId, String recordId, String schema, String version) throws DataSetNotExistsException, RepresentationNotExistsException { checkIfDatasetExists(dataSetId, providerId); Representation rep = getRepresentationIfExist(recordId, schema, version); if (!isAssignmentExists(providerId, dataSetId, recordId, schema, rep.getVersion())) { dataSetDAO.addAssignment(providerId, dataSetId, recordId, schema, rep.getVersion()); DataProvider dataProvider = uis.getProvider(providerId); dataSetDAO.addDataSetsRepresentationName(providerId, dataSetId, schema); Map<String, Revision> latestRevisions = new HashMap<>(); for (Revision revision : rep.getRevisions()) { String revisionKey = revision.getRevisionName() + "_" + revision.getRevisionProviderId(); Revision currentRevision = latestRevisions.get(revisionKey); if (currentRevision == null || revision.getCreationTimeStamp().getTime() > currentRevision.getCreationTimeStamp().getTime()) { latestRevisions.put(revisionKey, revision); } dataSetDAO.addDataSetsRevision(providerId, dataSetId, revision, schema, recordId); dataSetDAO.insertProviderDatasetRepresentationInfo(dataSetId, providerId, recordId, rep.getVersion(), schema, RevisionUtils.getRevisionKey(revision), revision.getCreationTimeStamp(), revision.isAcceptance(), revision.isPublished(), revision.isDeleted()); dataSetDAO.addLatestRevisionForDatasetAssignment(dataSetDAO.getDataSet(providerId, dataSetId), rep, revision); } updateLatestProviderDatasetRevisions(providerId, dataSetId, recordId, schema, version, latestRevisions); } } @Override ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit); @Override void addAssignment(String providerId, String dataSetId, String recordId, String schema, String version); @Override void removeAssignment(String providerId, String dataSetId, String recordId, String schema, String versionId); @Override DataSet createDataSet(String providerId, String dataSetId, String description); @Override DataSet updateDataSet(String providerId, String dataSetId, String description); @Override ResultSlice<DataSet> getDataSets(String providerId, String thresholdDatasetId, int limit); @Override ResultSlice<CloudTagsResponse> getDataSetsRevisions(String providerId, String dataSetId, String revisionProviderId, String revisionName, Date revisionTimestamp, String representationName, String startFrom, int limit); @Override void addDataSetsRevisions(String providerId, String dataSetId, Revision revision, String representationName, String cloudId); @Override ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationPublished(String dataSetId, String providerId, String representationName, Date dateFrom, String startFrom, int numberOfElementsPerPage); @Override void updateAllRevisionDatasetsEntries(String globalId, String schema, String version, Revision revision); @Override void deleteDataSet(String providerId, String dataSetId); @Override Set<String> getAllDataSetRepresentationsNames(String providerId, String dataSetId); @Override void updateProviderDatasetRepresentation(String globalId, String schema, String version, Revision revision); @Override String getLatestVersionForGivenRevision(String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); @Override void addLatestRevisionForGivenVersionInDataset(DataSet dataSet, Representation representation, Revision revision); @Override ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage); @Override void deleteRevision(String cloudId, String representationName, String version, String revisionName, String revisionProviderId, Date revisionTimestamp); }
@Test public void shouldSuccessfullyMigrateDataInUIS() { final String[] scriptsLocations1 = new String[]{"migrations/service/uis", "testMigrations/uis"}; MigrationExecutor migrator = new MigrationExecutor(EmbeddedCassandra.KEYSPACE, contactPoint, EmbeddedCassandra.PORT, cassandraUsername, cassandraPassword, scriptsLocations1); migrator.migrate(); List<Row> rows = session.execute("SELECT * FROM provider_record_id;").all(); assertEquals(rows.size(), 1); Row row = rows.get(0); assertTheMigratedTableValues(row); }
public void migrate() { CassandraMigration cm = new CassandraMigration(); cm.getConfigs().setScriptsLocations(scriptsLocations); cm.setKeyspace(keyspace); cm.migrate(); }
MigrationExecutor { public void migrate() { CassandraMigration cm = new CassandraMigration(); cm.getConfigs().setScriptsLocations(scriptsLocations); cm.setKeyspace(keyspace); cm.migrate(); } }
MigrationExecutor { public void migrate() { CassandraMigration cm = new CassandraMigration(); cm.getConfigs().setScriptsLocations(scriptsLocations); cm.setKeyspace(keyspace); cm.migrate(); } MigrationExecutor(String cassandraKeyspace, String cassandraContactPoint, int cassandraPort, String cassandraUsername, String cassandraPassword, String[] scriptsLocations); }
MigrationExecutor { public void migrate() { CassandraMigration cm = new CassandraMigration(); cm.getConfigs().setScriptsLocations(scriptsLocations); cm.setKeyspace(keyspace); cm.migrate(); } MigrationExecutor(String cassandraKeyspace, String cassandraContactPoint, int cassandraPort, String cassandraUsername, String cassandraPassword, String[] scriptsLocations); void migrate(); }
MigrationExecutor { public void migrate() { CassandraMigration cm = new CassandraMigration(); cm.getConfigs().setScriptsLocations(scriptsLocations); cm.setKeyspace(keyspace); cm.migrate(); } MigrationExecutor(String cassandraKeyspace, String cassandraContactPoint, int cassandraPort, String cassandraUsername, String cassandraPassword, String[] scriptsLocations); void migrate(); }
@Test(expected = DataSetNotExistsException.class) public void shouldThrowExceptionWhenDeletingNotExistingDataSet() throws Exception { cassandraDataSetService.deleteDataSet("xxx", "xxx"); }
@Override public void deleteDataSet(String providerId, String dataSetId) throws DataSetNotExistsException { checkIfDatasetExists(dataSetId, providerId); String nextToken = null; int maxSize = 10000; List<Properties> representations = dataSetDAO.listDataSet(providerId, dataSetId, null, maxSize); for (Properties representation : representations) { removeAssignment(providerId, dataSetId, representation.getProperty("cloudId"), representation.getProperty("schema"), representation.getProperty("versionId")); } while (representations.size() == maxSize + 1) { nextToken = representations.get(maxSize).getProperty("nextSlice"); representations = dataSetDAO.listDataSet(providerId, dataSetId, nextToken, maxSize); for (Properties representation : representations) { removeAssignment(providerId, dataSetId, representation.getProperty("cloudId"), representation.getProperty("schema"), representation.getProperty("versionId")); } } dataSetDAO.deleteDataSet(providerId, dataSetId); }
CassandraDataSetService implements DataSetService { @Override public void deleteDataSet(String providerId, String dataSetId) throws DataSetNotExistsException { checkIfDatasetExists(dataSetId, providerId); String nextToken = null; int maxSize = 10000; List<Properties> representations = dataSetDAO.listDataSet(providerId, dataSetId, null, maxSize); for (Properties representation : representations) { removeAssignment(providerId, dataSetId, representation.getProperty("cloudId"), representation.getProperty("schema"), representation.getProperty("versionId")); } while (representations.size() == maxSize + 1) { nextToken = representations.get(maxSize).getProperty("nextSlice"); representations = dataSetDAO.listDataSet(providerId, dataSetId, nextToken, maxSize); for (Properties representation : representations) { removeAssignment(providerId, dataSetId, representation.getProperty("cloudId"), representation.getProperty("schema"), representation.getProperty("versionId")); } } dataSetDAO.deleteDataSet(providerId, dataSetId); } }
CassandraDataSetService implements DataSetService { @Override public void deleteDataSet(String providerId, String dataSetId) throws DataSetNotExistsException { checkIfDatasetExists(dataSetId, providerId); String nextToken = null; int maxSize = 10000; List<Properties> representations = dataSetDAO.listDataSet(providerId, dataSetId, null, maxSize); for (Properties representation : representations) { removeAssignment(providerId, dataSetId, representation.getProperty("cloudId"), representation.getProperty("schema"), representation.getProperty("versionId")); } while (representations.size() == maxSize + 1) { nextToken = representations.get(maxSize).getProperty("nextSlice"); representations = dataSetDAO.listDataSet(providerId, dataSetId, nextToken, maxSize); for (Properties representation : representations) { removeAssignment(providerId, dataSetId, representation.getProperty("cloudId"), representation.getProperty("schema"), representation.getProperty("versionId")); } } dataSetDAO.deleteDataSet(providerId, dataSetId); } }
CassandraDataSetService implements DataSetService { @Override public void deleteDataSet(String providerId, String dataSetId) throws DataSetNotExistsException { checkIfDatasetExists(dataSetId, providerId); String nextToken = null; int maxSize = 10000; List<Properties> representations = dataSetDAO.listDataSet(providerId, dataSetId, null, maxSize); for (Properties representation : representations) { removeAssignment(providerId, dataSetId, representation.getProperty("cloudId"), representation.getProperty("schema"), representation.getProperty("versionId")); } while (representations.size() == maxSize + 1) { nextToken = representations.get(maxSize).getProperty("nextSlice"); representations = dataSetDAO.listDataSet(providerId, dataSetId, nextToken, maxSize); for (Properties representation : representations) { removeAssignment(providerId, dataSetId, representation.getProperty("cloudId"), representation.getProperty("schema"), representation.getProperty("versionId")); } } dataSetDAO.deleteDataSet(providerId, dataSetId); } @Override ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit); @Override void addAssignment(String providerId, String dataSetId, String recordId, String schema, String version); @Override void removeAssignment(String providerId, String dataSetId, String recordId, String schema, String versionId); @Override DataSet createDataSet(String providerId, String dataSetId, String description); @Override DataSet updateDataSet(String providerId, String dataSetId, String description); @Override ResultSlice<DataSet> getDataSets(String providerId, String thresholdDatasetId, int limit); @Override ResultSlice<CloudTagsResponse> getDataSetsRevisions(String providerId, String dataSetId, String revisionProviderId, String revisionName, Date revisionTimestamp, String representationName, String startFrom, int limit); @Override void addDataSetsRevisions(String providerId, String dataSetId, Revision revision, String representationName, String cloudId); @Override ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationPublished(String dataSetId, String providerId, String representationName, Date dateFrom, String startFrom, int numberOfElementsPerPage); @Override void updateAllRevisionDatasetsEntries(String globalId, String schema, String version, Revision revision); @Override void deleteDataSet(String providerId, String dataSetId); @Override Set<String> getAllDataSetRepresentationsNames(String providerId, String dataSetId); @Override void updateProviderDatasetRepresentation(String globalId, String schema, String version, Revision revision); @Override String getLatestVersionForGivenRevision(String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); @Override void addLatestRevisionForGivenVersionInDataset(DataSet dataSet, Representation representation, Revision revision); @Override ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage); @Override void deleteRevision(String cloudId, String representationName, String version, String revisionName, String revisionProviderId, Date revisionTimestamp); }
CassandraDataSetService implements DataSetService { @Override public void deleteDataSet(String providerId, String dataSetId) throws DataSetNotExistsException { checkIfDatasetExists(dataSetId, providerId); String nextToken = null; int maxSize = 10000; List<Properties> representations = dataSetDAO.listDataSet(providerId, dataSetId, null, maxSize); for (Properties representation : representations) { removeAssignment(providerId, dataSetId, representation.getProperty("cloudId"), representation.getProperty("schema"), representation.getProperty("versionId")); } while (representations.size() == maxSize + 1) { nextToken = representations.get(maxSize).getProperty("nextSlice"); representations = dataSetDAO.listDataSet(providerId, dataSetId, nextToken, maxSize); for (Properties representation : representations) { removeAssignment(providerId, dataSetId, representation.getProperty("cloudId"), representation.getProperty("schema"), representation.getProperty("versionId")); } } dataSetDAO.deleteDataSet(providerId, dataSetId); } @Override ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit); @Override void addAssignment(String providerId, String dataSetId, String recordId, String schema, String version); @Override void removeAssignment(String providerId, String dataSetId, String recordId, String schema, String versionId); @Override DataSet createDataSet(String providerId, String dataSetId, String description); @Override DataSet updateDataSet(String providerId, String dataSetId, String description); @Override ResultSlice<DataSet> getDataSets(String providerId, String thresholdDatasetId, int limit); @Override ResultSlice<CloudTagsResponse> getDataSetsRevisions(String providerId, String dataSetId, String revisionProviderId, String revisionName, Date revisionTimestamp, String representationName, String startFrom, int limit); @Override void addDataSetsRevisions(String providerId, String dataSetId, Revision revision, String representationName, String cloudId); @Override ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationPublished(String dataSetId, String providerId, String representationName, Date dateFrom, String startFrom, int numberOfElementsPerPage); @Override void updateAllRevisionDatasetsEntries(String globalId, String schema, String version, Revision revision); @Override void deleteDataSet(String providerId, String dataSetId); @Override Set<String> getAllDataSetRepresentationsNames(String providerId, String dataSetId); @Override void updateProviderDatasetRepresentation(String globalId, String schema, String version, Revision revision); @Override String getLatestVersionForGivenRevision(String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); @Override void addLatestRevisionForGivenVersionInDataset(DataSet dataSet, Representation representation, Revision revision); @Override ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage); @Override void deleteRevision(String cloudId, String representationName, String version, String revisionName, String revisionProviderId, Date revisionTimestamp); }
@Test(expected = ProviderNotExistsException.class) public void shouldThrowExceptionWhenCreatingDatasetForNotExistingProvider() throws Exception { makeUISProviderFailure(); cassandraDataSetService.createDataSet("not-existing-provider", "ds", "description"); }
@Override public DataSet createDataSet(String providerId, String dataSetId, String description) throws ProviderNotExistsException, DataSetAlreadyExistsException { Date now = new Date(); if (uis.getProvider(providerId) == null) { throw new ProviderNotExistsException(); } DataSet ds = dataSetDAO.getDataSet(providerId, dataSetId); if (ds != null) { throw new DataSetAlreadyExistsException("Data set with provided name already exists"); } return dataSetDAO .createDataSet(providerId, dataSetId, description, now); }
CassandraDataSetService implements DataSetService { @Override public DataSet createDataSet(String providerId, String dataSetId, String description) throws ProviderNotExistsException, DataSetAlreadyExistsException { Date now = new Date(); if (uis.getProvider(providerId) == null) { throw new ProviderNotExistsException(); } DataSet ds = dataSetDAO.getDataSet(providerId, dataSetId); if (ds != null) { throw new DataSetAlreadyExistsException("Data set with provided name already exists"); } return dataSetDAO .createDataSet(providerId, dataSetId, description, now); } }
CassandraDataSetService implements DataSetService { @Override public DataSet createDataSet(String providerId, String dataSetId, String description) throws ProviderNotExistsException, DataSetAlreadyExistsException { Date now = new Date(); if (uis.getProvider(providerId) == null) { throw new ProviderNotExistsException(); } DataSet ds = dataSetDAO.getDataSet(providerId, dataSetId); if (ds != null) { throw new DataSetAlreadyExistsException("Data set with provided name already exists"); } return dataSetDAO .createDataSet(providerId, dataSetId, description, now); } }
CassandraDataSetService implements DataSetService { @Override public DataSet createDataSet(String providerId, String dataSetId, String description) throws ProviderNotExistsException, DataSetAlreadyExistsException { Date now = new Date(); if (uis.getProvider(providerId) == null) { throw new ProviderNotExistsException(); } DataSet ds = dataSetDAO.getDataSet(providerId, dataSetId); if (ds != null) { throw new DataSetAlreadyExistsException("Data set with provided name already exists"); } return dataSetDAO .createDataSet(providerId, dataSetId, description, now); } @Override ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit); @Override void addAssignment(String providerId, String dataSetId, String recordId, String schema, String version); @Override void removeAssignment(String providerId, String dataSetId, String recordId, String schema, String versionId); @Override DataSet createDataSet(String providerId, String dataSetId, String description); @Override DataSet updateDataSet(String providerId, String dataSetId, String description); @Override ResultSlice<DataSet> getDataSets(String providerId, String thresholdDatasetId, int limit); @Override ResultSlice<CloudTagsResponse> getDataSetsRevisions(String providerId, String dataSetId, String revisionProviderId, String revisionName, Date revisionTimestamp, String representationName, String startFrom, int limit); @Override void addDataSetsRevisions(String providerId, String dataSetId, Revision revision, String representationName, String cloudId); @Override ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationPublished(String dataSetId, String providerId, String representationName, Date dateFrom, String startFrom, int numberOfElementsPerPage); @Override void updateAllRevisionDatasetsEntries(String globalId, String schema, String version, Revision revision); @Override void deleteDataSet(String providerId, String dataSetId); @Override Set<String> getAllDataSetRepresentationsNames(String providerId, String dataSetId); @Override void updateProviderDatasetRepresentation(String globalId, String schema, String version, Revision revision); @Override String getLatestVersionForGivenRevision(String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); @Override void addLatestRevisionForGivenVersionInDataset(DataSet dataSet, Representation representation, Revision revision); @Override ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage); @Override void deleteRevision(String cloudId, String representationName, String version, String revisionName, String revisionProviderId, Date revisionTimestamp); }
CassandraDataSetService implements DataSetService { @Override public DataSet createDataSet(String providerId, String dataSetId, String description) throws ProviderNotExistsException, DataSetAlreadyExistsException { Date now = new Date(); if (uis.getProvider(providerId) == null) { throw new ProviderNotExistsException(); } DataSet ds = dataSetDAO.getDataSet(providerId, dataSetId); if (ds != null) { throw new DataSetAlreadyExistsException("Data set with provided name already exists"); } return dataSetDAO .createDataSet(providerId, dataSetId, description, now); } @Override ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit); @Override void addAssignment(String providerId, String dataSetId, String recordId, String schema, String version); @Override void removeAssignment(String providerId, String dataSetId, String recordId, String schema, String versionId); @Override DataSet createDataSet(String providerId, String dataSetId, String description); @Override DataSet updateDataSet(String providerId, String dataSetId, String description); @Override ResultSlice<DataSet> getDataSets(String providerId, String thresholdDatasetId, int limit); @Override ResultSlice<CloudTagsResponse> getDataSetsRevisions(String providerId, String dataSetId, String revisionProviderId, String revisionName, Date revisionTimestamp, String representationName, String startFrom, int limit); @Override void addDataSetsRevisions(String providerId, String dataSetId, Revision revision, String representationName, String cloudId); @Override ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationPublished(String dataSetId, String providerId, String representationName, Date dateFrom, String startFrom, int numberOfElementsPerPage); @Override void updateAllRevisionDatasetsEntries(String globalId, String schema, String version, Revision revision); @Override void deleteDataSet(String providerId, String dataSetId); @Override Set<String> getAllDataSetRepresentationsNames(String providerId, String dataSetId); @Override void updateProviderDatasetRepresentation(String globalId, String schema, String version, Revision revision); @Override String getLatestVersionForGivenRevision(String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); @Override void addLatestRevisionForGivenVersionInDataset(DataSet dataSet, Representation representation, Revision revision); @Override ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage); @Override void deleteRevision(String cloudId, String representationName, String version, String revisionName, String revisionProviderId, Date revisionTimestamp); }
@Test(expected = DataSetAlreadyExistsException.class) public void shouldNotCreateTwoDatasetsWithSameNameForProvider() throws Exception { String dsName = "ds"; makeUISProviderSuccess(); cassandraDataSetService .createDataSet(PROVIDER_ID, dsName, "description"); cassandraDataSetService.createDataSet(PROVIDER_ID, dsName, "description of another"); }
@Override public DataSet createDataSet(String providerId, String dataSetId, String description) throws ProviderNotExistsException, DataSetAlreadyExistsException { Date now = new Date(); if (uis.getProvider(providerId) == null) { throw new ProviderNotExistsException(); } DataSet ds = dataSetDAO.getDataSet(providerId, dataSetId); if (ds != null) { throw new DataSetAlreadyExistsException("Data set with provided name already exists"); } return dataSetDAO .createDataSet(providerId, dataSetId, description, now); }
CassandraDataSetService implements DataSetService { @Override public DataSet createDataSet(String providerId, String dataSetId, String description) throws ProviderNotExistsException, DataSetAlreadyExistsException { Date now = new Date(); if (uis.getProvider(providerId) == null) { throw new ProviderNotExistsException(); } DataSet ds = dataSetDAO.getDataSet(providerId, dataSetId); if (ds != null) { throw new DataSetAlreadyExistsException("Data set with provided name already exists"); } return dataSetDAO .createDataSet(providerId, dataSetId, description, now); } }
CassandraDataSetService implements DataSetService { @Override public DataSet createDataSet(String providerId, String dataSetId, String description) throws ProviderNotExistsException, DataSetAlreadyExistsException { Date now = new Date(); if (uis.getProvider(providerId) == null) { throw new ProviderNotExistsException(); } DataSet ds = dataSetDAO.getDataSet(providerId, dataSetId); if (ds != null) { throw new DataSetAlreadyExistsException("Data set with provided name already exists"); } return dataSetDAO .createDataSet(providerId, dataSetId, description, now); } }
CassandraDataSetService implements DataSetService { @Override public DataSet createDataSet(String providerId, String dataSetId, String description) throws ProviderNotExistsException, DataSetAlreadyExistsException { Date now = new Date(); if (uis.getProvider(providerId) == null) { throw new ProviderNotExistsException(); } DataSet ds = dataSetDAO.getDataSet(providerId, dataSetId); if (ds != null) { throw new DataSetAlreadyExistsException("Data set with provided name already exists"); } return dataSetDAO .createDataSet(providerId, dataSetId, description, now); } @Override ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit); @Override void addAssignment(String providerId, String dataSetId, String recordId, String schema, String version); @Override void removeAssignment(String providerId, String dataSetId, String recordId, String schema, String versionId); @Override DataSet createDataSet(String providerId, String dataSetId, String description); @Override DataSet updateDataSet(String providerId, String dataSetId, String description); @Override ResultSlice<DataSet> getDataSets(String providerId, String thresholdDatasetId, int limit); @Override ResultSlice<CloudTagsResponse> getDataSetsRevisions(String providerId, String dataSetId, String revisionProviderId, String revisionName, Date revisionTimestamp, String representationName, String startFrom, int limit); @Override void addDataSetsRevisions(String providerId, String dataSetId, Revision revision, String representationName, String cloudId); @Override ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationPublished(String dataSetId, String providerId, String representationName, Date dateFrom, String startFrom, int numberOfElementsPerPage); @Override void updateAllRevisionDatasetsEntries(String globalId, String schema, String version, Revision revision); @Override void deleteDataSet(String providerId, String dataSetId); @Override Set<String> getAllDataSetRepresentationsNames(String providerId, String dataSetId); @Override void updateProviderDatasetRepresentation(String globalId, String schema, String version, Revision revision); @Override String getLatestVersionForGivenRevision(String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); @Override void addLatestRevisionForGivenVersionInDataset(DataSet dataSet, Representation representation, Revision revision); @Override ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage); @Override void deleteRevision(String cloudId, String representationName, String version, String revisionName, String revisionProviderId, Date revisionTimestamp); }
CassandraDataSetService implements DataSetService { @Override public DataSet createDataSet(String providerId, String dataSetId, String description) throws ProviderNotExistsException, DataSetAlreadyExistsException { Date now = new Date(); if (uis.getProvider(providerId) == null) { throw new ProviderNotExistsException(); } DataSet ds = dataSetDAO.getDataSet(providerId, dataSetId); if (ds != null) { throw new DataSetAlreadyExistsException("Data set with provided name already exists"); } return dataSetDAO .createDataSet(providerId, dataSetId, description, now); } @Override ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit); @Override void addAssignment(String providerId, String dataSetId, String recordId, String schema, String version); @Override void removeAssignment(String providerId, String dataSetId, String recordId, String schema, String versionId); @Override DataSet createDataSet(String providerId, String dataSetId, String description); @Override DataSet updateDataSet(String providerId, String dataSetId, String description); @Override ResultSlice<DataSet> getDataSets(String providerId, String thresholdDatasetId, int limit); @Override ResultSlice<CloudTagsResponse> getDataSetsRevisions(String providerId, String dataSetId, String revisionProviderId, String revisionName, Date revisionTimestamp, String representationName, String startFrom, int limit); @Override void addDataSetsRevisions(String providerId, String dataSetId, Revision revision, String representationName, String cloudId); @Override ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationPublished(String dataSetId, String providerId, String representationName, Date dateFrom, String startFrom, int numberOfElementsPerPage); @Override void updateAllRevisionDatasetsEntries(String globalId, String schema, String version, Revision revision); @Override void deleteDataSet(String providerId, String dataSetId); @Override Set<String> getAllDataSetRepresentationsNames(String providerId, String dataSetId); @Override void updateProviderDatasetRepresentation(String globalId, String schema, String version, Revision revision); @Override String getLatestVersionForGivenRevision(String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); @Override void addLatestRevisionForGivenVersionInDataset(DataSet dataSet, Representation representation, Revision revision); @Override ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage); @Override void deleteRevision(String cloudId, String representationName, String version, String revisionName, String revisionProviderId, Date revisionTimestamp); }
@Test(expected = DataSetNotExistsException.class) public void shouldThrowExceptionWhenRequestingCloudIdsForNonExistingDataSet() throws Exception { makeUISProviderExistsSuccess(); cassandraDataSetService.getDataSetCloudIdsByRepresentationPublished("non-existent-ds", "provider", "representation", new Date(), null, 1); }
@Override public ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationPublished(String dataSetId, String providerId, String representationName, Date dateFrom, String startFrom, int numberOfElementsPerPage) throws ProviderNotExistsException, DataSetNotExistsException { validateRequest(dataSetId, providerId); List<Properties> list = dataSetDAO.getDataSetCloudIdsByRepresentationPublished(providerId, dataSetId, representationName, dateFrom, startFrom, numberOfElementsPerPage); String nextToken = null; if (list.size() == numberOfElementsPerPage + 1) { nextToken = list.get(numberOfElementsPerPage).getProperty("nextSlice"); list.remove(numberOfElementsPerPage); } return new ResultSlice<>(nextToken, prepareResponseList(list)); }
CassandraDataSetService implements DataSetService { @Override public ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationPublished(String dataSetId, String providerId, String representationName, Date dateFrom, String startFrom, int numberOfElementsPerPage) throws ProviderNotExistsException, DataSetNotExistsException { validateRequest(dataSetId, providerId); List<Properties> list = dataSetDAO.getDataSetCloudIdsByRepresentationPublished(providerId, dataSetId, representationName, dateFrom, startFrom, numberOfElementsPerPage); String nextToken = null; if (list.size() == numberOfElementsPerPage + 1) { nextToken = list.get(numberOfElementsPerPage).getProperty("nextSlice"); list.remove(numberOfElementsPerPage); } return new ResultSlice<>(nextToken, prepareResponseList(list)); } }
CassandraDataSetService implements DataSetService { @Override public ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationPublished(String dataSetId, String providerId, String representationName, Date dateFrom, String startFrom, int numberOfElementsPerPage) throws ProviderNotExistsException, DataSetNotExistsException { validateRequest(dataSetId, providerId); List<Properties> list = dataSetDAO.getDataSetCloudIdsByRepresentationPublished(providerId, dataSetId, representationName, dateFrom, startFrom, numberOfElementsPerPage); String nextToken = null; if (list.size() == numberOfElementsPerPage + 1) { nextToken = list.get(numberOfElementsPerPage).getProperty("nextSlice"); list.remove(numberOfElementsPerPage); } return new ResultSlice<>(nextToken, prepareResponseList(list)); } }
CassandraDataSetService implements DataSetService { @Override public ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationPublished(String dataSetId, String providerId, String representationName, Date dateFrom, String startFrom, int numberOfElementsPerPage) throws ProviderNotExistsException, DataSetNotExistsException { validateRequest(dataSetId, providerId); List<Properties> list = dataSetDAO.getDataSetCloudIdsByRepresentationPublished(providerId, dataSetId, representationName, dateFrom, startFrom, numberOfElementsPerPage); String nextToken = null; if (list.size() == numberOfElementsPerPage + 1) { nextToken = list.get(numberOfElementsPerPage).getProperty("nextSlice"); list.remove(numberOfElementsPerPage); } return new ResultSlice<>(nextToken, prepareResponseList(list)); } @Override ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit); @Override void addAssignment(String providerId, String dataSetId, String recordId, String schema, String version); @Override void removeAssignment(String providerId, String dataSetId, String recordId, String schema, String versionId); @Override DataSet createDataSet(String providerId, String dataSetId, String description); @Override DataSet updateDataSet(String providerId, String dataSetId, String description); @Override ResultSlice<DataSet> getDataSets(String providerId, String thresholdDatasetId, int limit); @Override ResultSlice<CloudTagsResponse> getDataSetsRevisions(String providerId, String dataSetId, String revisionProviderId, String revisionName, Date revisionTimestamp, String representationName, String startFrom, int limit); @Override void addDataSetsRevisions(String providerId, String dataSetId, Revision revision, String representationName, String cloudId); @Override ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationPublished(String dataSetId, String providerId, String representationName, Date dateFrom, String startFrom, int numberOfElementsPerPage); @Override void updateAllRevisionDatasetsEntries(String globalId, String schema, String version, Revision revision); @Override void deleteDataSet(String providerId, String dataSetId); @Override Set<String> getAllDataSetRepresentationsNames(String providerId, String dataSetId); @Override void updateProviderDatasetRepresentation(String globalId, String schema, String version, Revision revision); @Override String getLatestVersionForGivenRevision(String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); @Override void addLatestRevisionForGivenVersionInDataset(DataSet dataSet, Representation representation, Revision revision); @Override ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage); @Override void deleteRevision(String cloudId, String representationName, String version, String revisionName, String revisionProviderId, Date revisionTimestamp); }
CassandraDataSetService implements DataSetService { @Override public ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationPublished(String dataSetId, String providerId, String representationName, Date dateFrom, String startFrom, int numberOfElementsPerPage) throws ProviderNotExistsException, DataSetNotExistsException { validateRequest(dataSetId, providerId); List<Properties> list = dataSetDAO.getDataSetCloudIdsByRepresentationPublished(providerId, dataSetId, representationName, dateFrom, startFrom, numberOfElementsPerPage); String nextToken = null; if (list.size() == numberOfElementsPerPage + 1) { nextToken = list.get(numberOfElementsPerPage).getProperty("nextSlice"); list.remove(numberOfElementsPerPage); } return new ResultSlice<>(nextToken, prepareResponseList(list)); } @Override ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit); @Override void addAssignment(String providerId, String dataSetId, String recordId, String schema, String version); @Override void removeAssignment(String providerId, String dataSetId, String recordId, String schema, String versionId); @Override DataSet createDataSet(String providerId, String dataSetId, String description); @Override DataSet updateDataSet(String providerId, String dataSetId, String description); @Override ResultSlice<DataSet> getDataSets(String providerId, String thresholdDatasetId, int limit); @Override ResultSlice<CloudTagsResponse> getDataSetsRevisions(String providerId, String dataSetId, String revisionProviderId, String revisionName, Date revisionTimestamp, String representationName, String startFrom, int limit); @Override void addDataSetsRevisions(String providerId, String dataSetId, Revision revision, String representationName, String cloudId); @Override ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationPublished(String dataSetId, String providerId, String representationName, Date dateFrom, String startFrom, int numberOfElementsPerPage); @Override void updateAllRevisionDatasetsEntries(String globalId, String schema, String version, Revision revision); @Override void deleteDataSet(String providerId, String dataSetId); @Override Set<String> getAllDataSetRepresentationsNames(String providerId, String dataSetId); @Override void updateProviderDatasetRepresentation(String globalId, String schema, String version, Revision revision); @Override String getLatestVersionForGivenRevision(String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); @Override void addLatestRevisionForGivenVersionInDataset(DataSet dataSet, Representation representation, Revision revision); @Override ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage); @Override void deleteRevision(String cloudId, String representationName, String version, String revisionName, String revisionProviderId, Date revisionTimestamp); }
@Test(expected = ProviderNotExistsException.class) public void shouldThrowExceptionWhenRequestingCloudIdsForNonExistingProvider() throws Exception { makeUISProviderExistsFailure(); cassandraDataSetService.getDataSetCloudIdsByRepresentationPublished("ds", "non-existent-provider", "representation", new Date(), null, 1); }
@Override public ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationPublished(String dataSetId, String providerId, String representationName, Date dateFrom, String startFrom, int numberOfElementsPerPage) throws ProviderNotExistsException, DataSetNotExistsException { validateRequest(dataSetId, providerId); List<Properties> list = dataSetDAO.getDataSetCloudIdsByRepresentationPublished(providerId, dataSetId, representationName, dateFrom, startFrom, numberOfElementsPerPage); String nextToken = null; if (list.size() == numberOfElementsPerPage + 1) { nextToken = list.get(numberOfElementsPerPage).getProperty("nextSlice"); list.remove(numberOfElementsPerPage); } return new ResultSlice<>(nextToken, prepareResponseList(list)); }
CassandraDataSetService implements DataSetService { @Override public ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationPublished(String dataSetId, String providerId, String representationName, Date dateFrom, String startFrom, int numberOfElementsPerPage) throws ProviderNotExistsException, DataSetNotExistsException { validateRequest(dataSetId, providerId); List<Properties> list = dataSetDAO.getDataSetCloudIdsByRepresentationPublished(providerId, dataSetId, representationName, dateFrom, startFrom, numberOfElementsPerPage); String nextToken = null; if (list.size() == numberOfElementsPerPage + 1) { nextToken = list.get(numberOfElementsPerPage).getProperty("nextSlice"); list.remove(numberOfElementsPerPage); } return new ResultSlice<>(nextToken, prepareResponseList(list)); } }
CassandraDataSetService implements DataSetService { @Override public ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationPublished(String dataSetId, String providerId, String representationName, Date dateFrom, String startFrom, int numberOfElementsPerPage) throws ProviderNotExistsException, DataSetNotExistsException { validateRequest(dataSetId, providerId); List<Properties> list = dataSetDAO.getDataSetCloudIdsByRepresentationPublished(providerId, dataSetId, representationName, dateFrom, startFrom, numberOfElementsPerPage); String nextToken = null; if (list.size() == numberOfElementsPerPage + 1) { nextToken = list.get(numberOfElementsPerPage).getProperty("nextSlice"); list.remove(numberOfElementsPerPage); } return new ResultSlice<>(nextToken, prepareResponseList(list)); } }
CassandraDataSetService implements DataSetService { @Override public ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationPublished(String dataSetId, String providerId, String representationName, Date dateFrom, String startFrom, int numberOfElementsPerPage) throws ProviderNotExistsException, DataSetNotExistsException { validateRequest(dataSetId, providerId); List<Properties> list = dataSetDAO.getDataSetCloudIdsByRepresentationPublished(providerId, dataSetId, representationName, dateFrom, startFrom, numberOfElementsPerPage); String nextToken = null; if (list.size() == numberOfElementsPerPage + 1) { nextToken = list.get(numberOfElementsPerPage).getProperty("nextSlice"); list.remove(numberOfElementsPerPage); } return new ResultSlice<>(nextToken, prepareResponseList(list)); } @Override ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit); @Override void addAssignment(String providerId, String dataSetId, String recordId, String schema, String version); @Override void removeAssignment(String providerId, String dataSetId, String recordId, String schema, String versionId); @Override DataSet createDataSet(String providerId, String dataSetId, String description); @Override DataSet updateDataSet(String providerId, String dataSetId, String description); @Override ResultSlice<DataSet> getDataSets(String providerId, String thresholdDatasetId, int limit); @Override ResultSlice<CloudTagsResponse> getDataSetsRevisions(String providerId, String dataSetId, String revisionProviderId, String revisionName, Date revisionTimestamp, String representationName, String startFrom, int limit); @Override void addDataSetsRevisions(String providerId, String dataSetId, Revision revision, String representationName, String cloudId); @Override ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationPublished(String dataSetId, String providerId, String representationName, Date dateFrom, String startFrom, int numberOfElementsPerPage); @Override void updateAllRevisionDatasetsEntries(String globalId, String schema, String version, Revision revision); @Override void deleteDataSet(String providerId, String dataSetId); @Override Set<String> getAllDataSetRepresentationsNames(String providerId, String dataSetId); @Override void updateProviderDatasetRepresentation(String globalId, String schema, String version, Revision revision); @Override String getLatestVersionForGivenRevision(String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); @Override void addLatestRevisionForGivenVersionInDataset(DataSet dataSet, Representation representation, Revision revision); @Override ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage); @Override void deleteRevision(String cloudId, String representationName, String version, String revisionName, String revisionProviderId, Date revisionTimestamp); }
CassandraDataSetService implements DataSetService { @Override public ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationPublished(String dataSetId, String providerId, String representationName, Date dateFrom, String startFrom, int numberOfElementsPerPage) throws ProviderNotExistsException, DataSetNotExistsException { validateRequest(dataSetId, providerId); List<Properties> list = dataSetDAO.getDataSetCloudIdsByRepresentationPublished(providerId, dataSetId, representationName, dateFrom, startFrom, numberOfElementsPerPage); String nextToken = null; if (list.size() == numberOfElementsPerPage + 1) { nextToken = list.get(numberOfElementsPerPage).getProperty("nextSlice"); list.remove(numberOfElementsPerPage); } return new ResultSlice<>(nextToken, prepareResponseList(list)); } @Override ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit); @Override void addAssignment(String providerId, String dataSetId, String recordId, String schema, String version); @Override void removeAssignment(String providerId, String dataSetId, String recordId, String schema, String versionId); @Override DataSet createDataSet(String providerId, String dataSetId, String description); @Override DataSet updateDataSet(String providerId, String dataSetId, String description); @Override ResultSlice<DataSet> getDataSets(String providerId, String thresholdDatasetId, int limit); @Override ResultSlice<CloudTagsResponse> getDataSetsRevisions(String providerId, String dataSetId, String revisionProviderId, String revisionName, Date revisionTimestamp, String representationName, String startFrom, int limit); @Override void addDataSetsRevisions(String providerId, String dataSetId, Revision revision, String representationName, String cloudId); @Override ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationPublished(String dataSetId, String providerId, String representationName, Date dateFrom, String startFrom, int numberOfElementsPerPage); @Override void updateAllRevisionDatasetsEntries(String globalId, String schema, String version, Revision revision); @Override void deleteDataSet(String providerId, String dataSetId); @Override Set<String> getAllDataSetRepresentationsNames(String providerId, String dataSetId); @Override void updateProviderDatasetRepresentation(String globalId, String schema, String version, Revision revision); @Override String getLatestVersionForGivenRevision(String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); @Override void addLatestRevisionForGivenVersionInDataset(DataSet dataSet, Representation representation, Revision revision); @Override ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage); @Override void deleteRevision(String cloudId, String representationName, String version, String revisionName, String revisionProviderId, Date revisionTimestamp); }
@Test public void shouldReturnTheLatestCloudIdsAndTimeStampInsideRevisionDataSet() throws Exception { int size = 10; prepareTestForTheLatestCloudIdAndTimeStampInsideDataSet(size); ResultSlice<CloudIdAndTimestampResponse> cloudIdsAndTimestampResponseResultSlice = cassandraDataSetService.getLatestDataSetCloudIdByRepresentationAndRevision(DATA_SET_NAME, PROVIDER_ID, REVISION, PROVIDER_ID, REPRESENTATION, null, true, 100); List<CloudIdAndTimestampResponse> cloudIdsAndTimestampResponse = cloudIdsAndTimestampResponseResultSlice.getResults(); assertFalse(cloudIdsAndTimestampResponse.isEmpty()); assertEquals(cloudIdsAndTimestampResponse.size(), size); }
@Override public ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage) throws ProviderNotExistsException, DataSetNotExistsException { validateRequest(dataSetId, providerId); List<CloudIdAndTimestampResponse> list = dataSetDAO.getLatestDataSetCloudIdByRepresentationAndRevision(providerId, dataSetId, revisionName, revisionProvider, representationName, startFrom, isDeleted, numberOfElementsPerPage); String nextToken = null; if (list.size() == numberOfElementsPerPage + 1) { nextToken = list.get(numberOfElementsPerPage).getCloudId(); list.remove(numberOfElementsPerPage); } return new ResultSlice<>(nextToken, list); }
CassandraDataSetService implements DataSetService { @Override public ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage) throws ProviderNotExistsException, DataSetNotExistsException { validateRequest(dataSetId, providerId); List<CloudIdAndTimestampResponse> list = dataSetDAO.getLatestDataSetCloudIdByRepresentationAndRevision(providerId, dataSetId, revisionName, revisionProvider, representationName, startFrom, isDeleted, numberOfElementsPerPage); String nextToken = null; if (list.size() == numberOfElementsPerPage + 1) { nextToken = list.get(numberOfElementsPerPage).getCloudId(); list.remove(numberOfElementsPerPage); } return new ResultSlice<>(nextToken, list); } }
CassandraDataSetService implements DataSetService { @Override public ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage) throws ProviderNotExistsException, DataSetNotExistsException { validateRequest(dataSetId, providerId); List<CloudIdAndTimestampResponse> list = dataSetDAO.getLatestDataSetCloudIdByRepresentationAndRevision(providerId, dataSetId, revisionName, revisionProvider, representationName, startFrom, isDeleted, numberOfElementsPerPage); String nextToken = null; if (list.size() == numberOfElementsPerPage + 1) { nextToken = list.get(numberOfElementsPerPage).getCloudId(); list.remove(numberOfElementsPerPage); } return new ResultSlice<>(nextToken, list); } }
CassandraDataSetService implements DataSetService { @Override public ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage) throws ProviderNotExistsException, DataSetNotExistsException { validateRequest(dataSetId, providerId); List<CloudIdAndTimestampResponse> list = dataSetDAO.getLatestDataSetCloudIdByRepresentationAndRevision(providerId, dataSetId, revisionName, revisionProvider, representationName, startFrom, isDeleted, numberOfElementsPerPage); String nextToken = null; if (list.size() == numberOfElementsPerPage + 1) { nextToken = list.get(numberOfElementsPerPage).getCloudId(); list.remove(numberOfElementsPerPage); } return new ResultSlice<>(nextToken, list); } @Override ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit); @Override void addAssignment(String providerId, String dataSetId, String recordId, String schema, String version); @Override void removeAssignment(String providerId, String dataSetId, String recordId, String schema, String versionId); @Override DataSet createDataSet(String providerId, String dataSetId, String description); @Override DataSet updateDataSet(String providerId, String dataSetId, String description); @Override ResultSlice<DataSet> getDataSets(String providerId, String thresholdDatasetId, int limit); @Override ResultSlice<CloudTagsResponse> getDataSetsRevisions(String providerId, String dataSetId, String revisionProviderId, String revisionName, Date revisionTimestamp, String representationName, String startFrom, int limit); @Override void addDataSetsRevisions(String providerId, String dataSetId, Revision revision, String representationName, String cloudId); @Override ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationPublished(String dataSetId, String providerId, String representationName, Date dateFrom, String startFrom, int numberOfElementsPerPage); @Override void updateAllRevisionDatasetsEntries(String globalId, String schema, String version, Revision revision); @Override void deleteDataSet(String providerId, String dataSetId); @Override Set<String> getAllDataSetRepresentationsNames(String providerId, String dataSetId); @Override void updateProviderDatasetRepresentation(String globalId, String schema, String version, Revision revision); @Override String getLatestVersionForGivenRevision(String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); @Override void addLatestRevisionForGivenVersionInDataset(DataSet dataSet, Representation representation, Revision revision); @Override ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage); @Override void deleteRevision(String cloudId, String representationName, String version, String revisionName, String revisionProviderId, Date revisionTimestamp); }
CassandraDataSetService implements DataSetService { @Override public ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage) throws ProviderNotExistsException, DataSetNotExistsException { validateRequest(dataSetId, providerId); List<CloudIdAndTimestampResponse> list = dataSetDAO.getLatestDataSetCloudIdByRepresentationAndRevision(providerId, dataSetId, revisionName, revisionProvider, representationName, startFrom, isDeleted, numberOfElementsPerPage); String nextToken = null; if (list.size() == numberOfElementsPerPage + 1) { nextToken = list.get(numberOfElementsPerPage).getCloudId(); list.remove(numberOfElementsPerPage); } return new ResultSlice<>(nextToken, list); } @Override ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit); @Override void addAssignment(String providerId, String dataSetId, String recordId, String schema, String version); @Override void removeAssignment(String providerId, String dataSetId, String recordId, String schema, String versionId); @Override DataSet createDataSet(String providerId, String dataSetId, String description); @Override DataSet updateDataSet(String providerId, String dataSetId, String description); @Override ResultSlice<DataSet> getDataSets(String providerId, String thresholdDatasetId, int limit); @Override ResultSlice<CloudTagsResponse> getDataSetsRevisions(String providerId, String dataSetId, String revisionProviderId, String revisionName, Date revisionTimestamp, String representationName, String startFrom, int limit); @Override void addDataSetsRevisions(String providerId, String dataSetId, Revision revision, String representationName, String cloudId); @Override ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationPublished(String dataSetId, String providerId, String representationName, Date dateFrom, String startFrom, int numberOfElementsPerPage); @Override void updateAllRevisionDatasetsEntries(String globalId, String schema, String version, Revision revision); @Override void deleteDataSet(String providerId, String dataSetId); @Override Set<String> getAllDataSetRepresentationsNames(String providerId, String dataSetId); @Override void updateProviderDatasetRepresentation(String globalId, String schema, String version, Revision revision); @Override String getLatestVersionForGivenRevision(String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); @Override void addLatestRevisionForGivenVersionInDataset(DataSet dataSet, Representation representation, Revision revision); @Override ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage); @Override void deleteRevision(String cloudId, String representationName, String version, String revisionName, String revisionProviderId, Date revisionTimestamp); }
@Test public void shouldReturnTheLatestCloudIdsAndTimeStampInsideRevisionDataSetWhenIsMarkedDeleted() throws Exception { int size = 10; prepareTestForTheLatestCloudIdAndTimeStampInsideDataSet(size); ResultSlice<CloudIdAndTimestampResponse> cloudIdsAndTimestampResponseResultSlice = cassandraDataSetService.getLatestDataSetCloudIdByRepresentationAndRevision(DATA_SET_NAME, PROVIDER_ID, REVISION, PROVIDER_ID, REPRESENTATION, null, false, 100); List<CloudIdAndTimestampResponse> cloudIdsAndTimestampResponse = cloudIdsAndTimestampResponseResultSlice.getResults(); assertTrue(cloudIdsAndTimestampResponse.isEmpty()); cloudIdsAndTimestampResponseResultSlice = cassandraDataSetService.getLatestDataSetCloudIdByRepresentationAndRevision(DATA_SET_NAME, PROVIDER_ID, REVISION, PROVIDER_ID, REPRESENTATION, null, true, 100); cloudIdsAndTimestampResponse = cloudIdsAndTimestampResponseResultSlice.getResults(); assertFalse(cloudIdsAndTimestampResponse.isEmpty()); assertEquals(cloudIdsAndTimestampResponse.size(), size); }
@Override public ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage) throws ProviderNotExistsException, DataSetNotExistsException { validateRequest(dataSetId, providerId); List<CloudIdAndTimestampResponse> list = dataSetDAO.getLatestDataSetCloudIdByRepresentationAndRevision(providerId, dataSetId, revisionName, revisionProvider, representationName, startFrom, isDeleted, numberOfElementsPerPage); String nextToken = null; if (list.size() == numberOfElementsPerPage + 1) { nextToken = list.get(numberOfElementsPerPage).getCloudId(); list.remove(numberOfElementsPerPage); } return new ResultSlice<>(nextToken, list); }
CassandraDataSetService implements DataSetService { @Override public ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage) throws ProviderNotExistsException, DataSetNotExistsException { validateRequest(dataSetId, providerId); List<CloudIdAndTimestampResponse> list = dataSetDAO.getLatestDataSetCloudIdByRepresentationAndRevision(providerId, dataSetId, revisionName, revisionProvider, representationName, startFrom, isDeleted, numberOfElementsPerPage); String nextToken = null; if (list.size() == numberOfElementsPerPage + 1) { nextToken = list.get(numberOfElementsPerPage).getCloudId(); list.remove(numberOfElementsPerPage); } return new ResultSlice<>(nextToken, list); } }
CassandraDataSetService implements DataSetService { @Override public ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage) throws ProviderNotExistsException, DataSetNotExistsException { validateRequest(dataSetId, providerId); List<CloudIdAndTimestampResponse> list = dataSetDAO.getLatestDataSetCloudIdByRepresentationAndRevision(providerId, dataSetId, revisionName, revisionProvider, representationName, startFrom, isDeleted, numberOfElementsPerPage); String nextToken = null; if (list.size() == numberOfElementsPerPage + 1) { nextToken = list.get(numberOfElementsPerPage).getCloudId(); list.remove(numberOfElementsPerPage); } return new ResultSlice<>(nextToken, list); } }
CassandraDataSetService implements DataSetService { @Override public ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage) throws ProviderNotExistsException, DataSetNotExistsException { validateRequest(dataSetId, providerId); List<CloudIdAndTimestampResponse> list = dataSetDAO.getLatestDataSetCloudIdByRepresentationAndRevision(providerId, dataSetId, revisionName, revisionProvider, representationName, startFrom, isDeleted, numberOfElementsPerPage); String nextToken = null; if (list.size() == numberOfElementsPerPage + 1) { nextToken = list.get(numberOfElementsPerPage).getCloudId(); list.remove(numberOfElementsPerPage); } return new ResultSlice<>(nextToken, list); } @Override ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit); @Override void addAssignment(String providerId, String dataSetId, String recordId, String schema, String version); @Override void removeAssignment(String providerId, String dataSetId, String recordId, String schema, String versionId); @Override DataSet createDataSet(String providerId, String dataSetId, String description); @Override DataSet updateDataSet(String providerId, String dataSetId, String description); @Override ResultSlice<DataSet> getDataSets(String providerId, String thresholdDatasetId, int limit); @Override ResultSlice<CloudTagsResponse> getDataSetsRevisions(String providerId, String dataSetId, String revisionProviderId, String revisionName, Date revisionTimestamp, String representationName, String startFrom, int limit); @Override void addDataSetsRevisions(String providerId, String dataSetId, Revision revision, String representationName, String cloudId); @Override ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationPublished(String dataSetId, String providerId, String representationName, Date dateFrom, String startFrom, int numberOfElementsPerPage); @Override void updateAllRevisionDatasetsEntries(String globalId, String schema, String version, Revision revision); @Override void deleteDataSet(String providerId, String dataSetId); @Override Set<String> getAllDataSetRepresentationsNames(String providerId, String dataSetId); @Override void updateProviderDatasetRepresentation(String globalId, String schema, String version, Revision revision); @Override String getLatestVersionForGivenRevision(String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); @Override void addLatestRevisionForGivenVersionInDataset(DataSet dataSet, Representation representation, Revision revision); @Override ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage); @Override void deleteRevision(String cloudId, String representationName, String version, String revisionName, String revisionProviderId, Date revisionTimestamp); }
CassandraDataSetService implements DataSetService { @Override public ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage) throws ProviderNotExistsException, DataSetNotExistsException { validateRequest(dataSetId, providerId); List<CloudIdAndTimestampResponse> list = dataSetDAO.getLatestDataSetCloudIdByRepresentationAndRevision(providerId, dataSetId, revisionName, revisionProvider, representationName, startFrom, isDeleted, numberOfElementsPerPage); String nextToken = null; if (list.size() == numberOfElementsPerPage + 1) { nextToken = list.get(numberOfElementsPerPage).getCloudId(); list.remove(numberOfElementsPerPage); } return new ResultSlice<>(nextToken, list); } @Override ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit); @Override void addAssignment(String providerId, String dataSetId, String recordId, String schema, String version); @Override void removeAssignment(String providerId, String dataSetId, String recordId, String schema, String versionId); @Override DataSet createDataSet(String providerId, String dataSetId, String description); @Override DataSet updateDataSet(String providerId, String dataSetId, String description); @Override ResultSlice<DataSet> getDataSets(String providerId, String thresholdDatasetId, int limit); @Override ResultSlice<CloudTagsResponse> getDataSetsRevisions(String providerId, String dataSetId, String revisionProviderId, String revisionName, Date revisionTimestamp, String representationName, String startFrom, int limit); @Override void addDataSetsRevisions(String providerId, String dataSetId, Revision revision, String representationName, String cloudId); @Override ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationPublished(String dataSetId, String providerId, String representationName, Date dateFrom, String startFrom, int numberOfElementsPerPage); @Override void updateAllRevisionDatasetsEntries(String globalId, String schema, String version, Revision revision); @Override void deleteDataSet(String providerId, String dataSetId); @Override Set<String> getAllDataSetRepresentationsNames(String providerId, String dataSetId); @Override void updateProviderDatasetRepresentation(String globalId, String schema, String version, Revision revision); @Override String getLatestVersionForGivenRevision(String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); @Override void addLatestRevisionForGivenVersionInDataset(DataSet dataSet, Representation representation, Revision revision); @Override ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage); @Override void deleteRevision(String cloudId, String representationName, String version, String revisionName, String revisionProviderId, Date revisionTimestamp); }
@Test public void shouldReturnTheLatestCloudIdsAndTimeStampInsideRevisionDataSetBatchByBatch() throws Exception { int size = 10; prepareTestForTheLatestCloudIdAndTimeStampInsideDataSet(size); ResultSlice<CloudIdAndTimestampResponse> cloudIdsAndTimestampResponseResultSlice = cassandraDataSetService.getLatestDataSetCloudIdByRepresentationAndRevision(DATA_SET_NAME, PROVIDER_ID, REVISION, PROVIDER_ID, REPRESENTATION, null, true, 1); List<CloudIdAndTimestampResponse> cloudIdsAndTimestampResponse = cloudIdsAndTimestampResponseResultSlice.getResults(); assertFalse(cloudIdsAndTimestampResponse.isEmpty()); assertEquals(cloudIdsAndTimestampResponse.size(), 1); String cloudId = cloudIdsAndTimestampResponse.get(0).getCloudId(); cloudIdsAndTimestampResponseResultSlice = cassandraDataSetService.getLatestDataSetCloudIdByRepresentationAndRevision(DATA_SET_NAME, PROVIDER_ID, REVISION, PROVIDER_ID, REPRESENTATION, cloudId, true, 1); cloudIdsAndTimestampResponse = cloudIdsAndTimestampResponseResultSlice.getResults(); int batchCounter = 1; while (!cloudIdsAndTimestampResponse.isEmpty()) { batchCounter++; cloudId = cloudIdsAndTimestampResponse.get(0).getCloudId(); cloudIdsAndTimestampResponseResultSlice = cassandraDataSetService.getLatestDataSetCloudIdByRepresentationAndRevision(DATA_SET_NAME, PROVIDER_ID, REVISION, PROVIDER_ID, REPRESENTATION, cloudId, true, 1); cloudIdsAndTimestampResponse = cloudIdsAndTimestampResponseResultSlice.getResults(); } assertEquals(batchCounter, size); }
@Override public ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage) throws ProviderNotExistsException, DataSetNotExistsException { validateRequest(dataSetId, providerId); List<CloudIdAndTimestampResponse> list = dataSetDAO.getLatestDataSetCloudIdByRepresentationAndRevision(providerId, dataSetId, revisionName, revisionProvider, representationName, startFrom, isDeleted, numberOfElementsPerPage); String nextToken = null; if (list.size() == numberOfElementsPerPage + 1) { nextToken = list.get(numberOfElementsPerPage).getCloudId(); list.remove(numberOfElementsPerPage); } return new ResultSlice<>(nextToken, list); }
CassandraDataSetService implements DataSetService { @Override public ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage) throws ProviderNotExistsException, DataSetNotExistsException { validateRequest(dataSetId, providerId); List<CloudIdAndTimestampResponse> list = dataSetDAO.getLatestDataSetCloudIdByRepresentationAndRevision(providerId, dataSetId, revisionName, revisionProvider, representationName, startFrom, isDeleted, numberOfElementsPerPage); String nextToken = null; if (list.size() == numberOfElementsPerPage + 1) { nextToken = list.get(numberOfElementsPerPage).getCloudId(); list.remove(numberOfElementsPerPage); } return new ResultSlice<>(nextToken, list); } }
CassandraDataSetService implements DataSetService { @Override public ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage) throws ProviderNotExistsException, DataSetNotExistsException { validateRequest(dataSetId, providerId); List<CloudIdAndTimestampResponse> list = dataSetDAO.getLatestDataSetCloudIdByRepresentationAndRevision(providerId, dataSetId, revisionName, revisionProvider, representationName, startFrom, isDeleted, numberOfElementsPerPage); String nextToken = null; if (list.size() == numberOfElementsPerPage + 1) { nextToken = list.get(numberOfElementsPerPage).getCloudId(); list.remove(numberOfElementsPerPage); } return new ResultSlice<>(nextToken, list); } }
CassandraDataSetService implements DataSetService { @Override public ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage) throws ProviderNotExistsException, DataSetNotExistsException { validateRequest(dataSetId, providerId); List<CloudIdAndTimestampResponse> list = dataSetDAO.getLatestDataSetCloudIdByRepresentationAndRevision(providerId, dataSetId, revisionName, revisionProvider, representationName, startFrom, isDeleted, numberOfElementsPerPage); String nextToken = null; if (list.size() == numberOfElementsPerPage + 1) { nextToken = list.get(numberOfElementsPerPage).getCloudId(); list.remove(numberOfElementsPerPage); } return new ResultSlice<>(nextToken, list); } @Override ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit); @Override void addAssignment(String providerId, String dataSetId, String recordId, String schema, String version); @Override void removeAssignment(String providerId, String dataSetId, String recordId, String schema, String versionId); @Override DataSet createDataSet(String providerId, String dataSetId, String description); @Override DataSet updateDataSet(String providerId, String dataSetId, String description); @Override ResultSlice<DataSet> getDataSets(String providerId, String thresholdDatasetId, int limit); @Override ResultSlice<CloudTagsResponse> getDataSetsRevisions(String providerId, String dataSetId, String revisionProviderId, String revisionName, Date revisionTimestamp, String representationName, String startFrom, int limit); @Override void addDataSetsRevisions(String providerId, String dataSetId, Revision revision, String representationName, String cloudId); @Override ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationPublished(String dataSetId, String providerId, String representationName, Date dateFrom, String startFrom, int numberOfElementsPerPage); @Override void updateAllRevisionDatasetsEntries(String globalId, String schema, String version, Revision revision); @Override void deleteDataSet(String providerId, String dataSetId); @Override Set<String> getAllDataSetRepresentationsNames(String providerId, String dataSetId); @Override void updateProviderDatasetRepresentation(String globalId, String schema, String version, Revision revision); @Override String getLatestVersionForGivenRevision(String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); @Override void addLatestRevisionForGivenVersionInDataset(DataSet dataSet, Representation representation, Revision revision); @Override ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage); @Override void deleteRevision(String cloudId, String representationName, String version, String revisionName, String revisionProviderId, Date revisionTimestamp); }
CassandraDataSetService implements DataSetService { @Override public ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage) throws ProviderNotExistsException, DataSetNotExistsException { validateRequest(dataSetId, providerId); List<CloudIdAndTimestampResponse> list = dataSetDAO.getLatestDataSetCloudIdByRepresentationAndRevision(providerId, dataSetId, revisionName, revisionProvider, representationName, startFrom, isDeleted, numberOfElementsPerPage); String nextToken = null; if (list.size() == numberOfElementsPerPage + 1) { nextToken = list.get(numberOfElementsPerPage).getCloudId(); list.remove(numberOfElementsPerPage); } return new ResultSlice<>(nextToken, list); } @Override ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit); @Override void addAssignment(String providerId, String dataSetId, String recordId, String schema, String version); @Override void removeAssignment(String providerId, String dataSetId, String recordId, String schema, String versionId); @Override DataSet createDataSet(String providerId, String dataSetId, String description); @Override DataSet updateDataSet(String providerId, String dataSetId, String description); @Override ResultSlice<DataSet> getDataSets(String providerId, String thresholdDatasetId, int limit); @Override ResultSlice<CloudTagsResponse> getDataSetsRevisions(String providerId, String dataSetId, String revisionProviderId, String revisionName, Date revisionTimestamp, String representationName, String startFrom, int limit); @Override void addDataSetsRevisions(String providerId, String dataSetId, Revision revision, String representationName, String cloudId); @Override ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationPublished(String dataSetId, String providerId, String representationName, Date dateFrom, String startFrom, int numberOfElementsPerPage); @Override void updateAllRevisionDatasetsEntries(String globalId, String schema, String version, Revision revision); @Override void deleteDataSet(String providerId, String dataSetId); @Override Set<String> getAllDataSetRepresentationsNames(String providerId, String dataSetId); @Override void updateProviderDatasetRepresentation(String globalId, String schema, String version, Revision revision); @Override String getLatestVersionForGivenRevision(String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); @Override void addLatestRevisionForGivenVersionInDataset(DataSet dataSet, Representation representation, Revision revision); @Override ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage); @Override void deleteRevision(String cloudId, String representationName, String version, String revisionName, String revisionProviderId, Date revisionTimestamp); }
@Test(expected = DataSetNotExistsException.class) public void shouldThrowDataSetNotExistedException() throws Exception { int size = 10; prepareTestForTheLatestCloudIdAndTimeStampInsideDataSet(size); cassandraDataSetService.getLatestDataSetCloudIdByRepresentationAndRevision("Non_Existed_Dataset", PROVIDER_ID, REVISION, PROVIDER_ID, REPRESENTATION, null, null, 1); }
@Override public ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage) throws ProviderNotExistsException, DataSetNotExistsException { validateRequest(dataSetId, providerId); List<CloudIdAndTimestampResponse> list = dataSetDAO.getLatestDataSetCloudIdByRepresentationAndRevision(providerId, dataSetId, revisionName, revisionProvider, representationName, startFrom, isDeleted, numberOfElementsPerPage); String nextToken = null; if (list.size() == numberOfElementsPerPage + 1) { nextToken = list.get(numberOfElementsPerPage).getCloudId(); list.remove(numberOfElementsPerPage); } return new ResultSlice<>(nextToken, list); }
CassandraDataSetService implements DataSetService { @Override public ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage) throws ProviderNotExistsException, DataSetNotExistsException { validateRequest(dataSetId, providerId); List<CloudIdAndTimestampResponse> list = dataSetDAO.getLatestDataSetCloudIdByRepresentationAndRevision(providerId, dataSetId, revisionName, revisionProvider, representationName, startFrom, isDeleted, numberOfElementsPerPage); String nextToken = null; if (list.size() == numberOfElementsPerPage + 1) { nextToken = list.get(numberOfElementsPerPage).getCloudId(); list.remove(numberOfElementsPerPage); } return new ResultSlice<>(nextToken, list); } }
CassandraDataSetService implements DataSetService { @Override public ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage) throws ProviderNotExistsException, DataSetNotExistsException { validateRequest(dataSetId, providerId); List<CloudIdAndTimestampResponse> list = dataSetDAO.getLatestDataSetCloudIdByRepresentationAndRevision(providerId, dataSetId, revisionName, revisionProvider, representationName, startFrom, isDeleted, numberOfElementsPerPage); String nextToken = null; if (list.size() == numberOfElementsPerPage + 1) { nextToken = list.get(numberOfElementsPerPage).getCloudId(); list.remove(numberOfElementsPerPage); } return new ResultSlice<>(nextToken, list); } }
CassandraDataSetService implements DataSetService { @Override public ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage) throws ProviderNotExistsException, DataSetNotExistsException { validateRequest(dataSetId, providerId); List<CloudIdAndTimestampResponse> list = dataSetDAO.getLatestDataSetCloudIdByRepresentationAndRevision(providerId, dataSetId, revisionName, revisionProvider, representationName, startFrom, isDeleted, numberOfElementsPerPage); String nextToken = null; if (list.size() == numberOfElementsPerPage + 1) { nextToken = list.get(numberOfElementsPerPage).getCloudId(); list.remove(numberOfElementsPerPage); } return new ResultSlice<>(nextToken, list); } @Override ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit); @Override void addAssignment(String providerId, String dataSetId, String recordId, String schema, String version); @Override void removeAssignment(String providerId, String dataSetId, String recordId, String schema, String versionId); @Override DataSet createDataSet(String providerId, String dataSetId, String description); @Override DataSet updateDataSet(String providerId, String dataSetId, String description); @Override ResultSlice<DataSet> getDataSets(String providerId, String thresholdDatasetId, int limit); @Override ResultSlice<CloudTagsResponse> getDataSetsRevisions(String providerId, String dataSetId, String revisionProviderId, String revisionName, Date revisionTimestamp, String representationName, String startFrom, int limit); @Override void addDataSetsRevisions(String providerId, String dataSetId, Revision revision, String representationName, String cloudId); @Override ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationPublished(String dataSetId, String providerId, String representationName, Date dateFrom, String startFrom, int numberOfElementsPerPage); @Override void updateAllRevisionDatasetsEntries(String globalId, String schema, String version, Revision revision); @Override void deleteDataSet(String providerId, String dataSetId); @Override Set<String> getAllDataSetRepresentationsNames(String providerId, String dataSetId); @Override void updateProviderDatasetRepresentation(String globalId, String schema, String version, Revision revision); @Override String getLatestVersionForGivenRevision(String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); @Override void addLatestRevisionForGivenVersionInDataset(DataSet dataSet, Representation representation, Revision revision); @Override ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage); @Override void deleteRevision(String cloudId, String representationName, String version, String revisionName, String revisionProviderId, Date revisionTimestamp); }
CassandraDataSetService implements DataSetService { @Override public ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage) throws ProviderNotExistsException, DataSetNotExistsException { validateRequest(dataSetId, providerId); List<CloudIdAndTimestampResponse> list = dataSetDAO.getLatestDataSetCloudIdByRepresentationAndRevision(providerId, dataSetId, revisionName, revisionProvider, representationName, startFrom, isDeleted, numberOfElementsPerPage); String nextToken = null; if (list.size() == numberOfElementsPerPage + 1) { nextToken = list.get(numberOfElementsPerPage).getCloudId(); list.remove(numberOfElementsPerPage); } return new ResultSlice<>(nextToken, list); } @Override ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit); @Override void addAssignment(String providerId, String dataSetId, String recordId, String schema, String version); @Override void removeAssignment(String providerId, String dataSetId, String recordId, String schema, String versionId); @Override DataSet createDataSet(String providerId, String dataSetId, String description); @Override DataSet updateDataSet(String providerId, String dataSetId, String description); @Override ResultSlice<DataSet> getDataSets(String providerId, String thresholdDatasetId, int limit); @Override ResultSlice<CloudTagsResponse> getDataSetsRevisions(String providerId, String dataSetId, String revisionProviderId, String revisionName, Date revisionTimestamp, String representationName, String startFrom, int limit); @Override void addDataSetsRevisions(String providerId, String dataSetId, Revision revision, String representationName, String cloudId); @Override ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationPublished(String dataSetId, String providerId, String representationName, Date dateFrom, String startFrom, int numberOfElementsPerPage); @Override void updateAllRevisionDatasetsEntries(String globalId, String schema, String version, Revision revision); @Override void deleteDataSet(String providerId, String dataSetId); @Override Set<String> getAllDataSetRepresentationsNames(String providerId, String dataSetId); @Override void updateProviderDatasetRepresentation(String globalId, String schema, String version, Revision revision); @Override String getLatestVersionForGivenRevision(String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); @Override void addLatestRevisionForGivenVersionInDataset(DataSet dataSet, Representation representation, Revision revision); @Override ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage); @Override void deleteRevision(String cloudId, String representationName, String version, String revisionName, String revisionProviderId, Date revisionTimestamp); }
@Test(expected = RepresentationNotExistsException.class) public void shouldThrowRepresentationNotExistsException() throws Exception { makeUISProviderSuccess(); makeUISSuccess(); makeDatasetExists(); Date date = new Date(); String cloudId = "2EEN23VWNXOW7LGLM6SKTDOZUBUOTKEWZ3IULSYEWEMERHISS6XA"; cassandraDataSetService.deleteRevision(cloudId, REPRESENTATION, "3d6381c0-a3cf-11e9-960f-fa163e8d4ae3", REVISION, PROVIDER_ID, date); }
@Override public void deleteRevision(String cloudId, String representationName, String version, String revisionName, String revisionProviderId, Date revisionTimestamp) throws RepresentationNotExistsException { checkIfRepresentationExists(representationName, version, cloudId); Revision revision = new Revision(revisionName, revisionProviderId); revision.setCreationTimeStamp(revisionTimestamp); Collection<CompoundDataSetId> compoundDataSetIds = dataSetDAO.getDataSetAssignmentsByRepresentationVersion(cloudId, representationName, version); for (CompoundDataSetId compoundDataSetId : compoundDataSetIds) { dataSetDAO.removeDataSetsRevision(compoundDataSetId.getDataSetProviderId(), compoundDataSetId.getDataSetId(), revision, representationName, cloudId); dataSetDAO.deleteProviderDatasetRepresentationInfo(compoundDataSetId.getDataSetId(), compoundDataSetId.getDataSetProviderId(), cloudId, representationName, revisionTimestamp); } recordDAO.deleteRepresentationRevision(cloudId, representationName, version, revisionProviderId, revisionName, revisionTimestamp); recordDAO.removeRevisionFromRepresentationVersion(cloudId, representationName, version,revision); }
CassandraDataSetService implements DataSetService { @Override public void deleteRevision(String cloudId, String representationName, String version, String revisionName, String revisionProviderId, Date revisionTimestamp) throws RepresentationNotExistsException { checkIfRepresentationExists(representationName, version, cloudId); Revision revision = new Revision(revisionName, revisionProviderId); revision.setCreationTimeStamp(revisionTimestamp); Collection<CompoundDataSetId> compoundDataSetIds = dataSetDAO.getDataSetAssignmentsByRepresentationVersion(cloudId, representationName, version); for (CompoundDataSetId compoundDataSetId : compoundDataSetIds) { dataSetDAO.removeDataSetsRevision(compoundDataSetId.getDataSetProviderId(), compoundDataSetId.getDataSetId(), revision, representationName, cloudId); dataSetDAO.deleteProviderDatasetRepresentationInfo(compoundDataSetId.getDataSetId(), compoundDataSetId.getDataSetProviderId(), cloudId, representationName, revisionTimestamp); } recordDAO.deleteRepresentationRevision(cloudId, representationName, version, revisionProviderId, revisionName, revisionTimestamp); recordDAO.removeRevisionFromRepresentationVersion(cloudId, representationName, version,revision); } }
CassandraDataSetService implements DataSetService { @Override public void deleteRevision(String cloudId, String representationName, String version, String revisionName, String revisionProviderId, Date revisionTimestamp) throws RepresentationNotExistsException { checkIfRepresentationExists(representationName, version, cloudId); Revision revision = new Revision(revisionName, revisionProviderId); revision.setCreationTimeStamp(revisionTimestamp); Collection<CompoundDataSetId> compoundDataSetIds = dataSetDAO.getDataSetAssignmentsByRepresentationVersion(cloudId, representationName, version); for (CompoundDataSetId compoundDataSetId : compoundDataSetIds) { dataSetDAO.removeDataSetsRevision(compoundDataSetId.getDataSetProviderId(), compoundDataSetId.getDataSetId(), revision, representationName, cloudId); dataSetDAO.deleteProviderDatasetRepresentationInfo(compoundDataSetId.getDataSetId(), compoundDataSetId.getDataSetProviderId(), cloudId, representationName, revisionTimestamp); } recordDAO.deleteRepresentationRevision(cloudId, representationName, version, revisionProviderId, revisionName, revisionTimestamp); recordDAO.removeRevisionFromRepresentationVersion(cloudId, representationName, version,revision); } }
CassandraDataSetService implements DataSetService { @Override public void deleteRevision(String cloudId, String representationName, String version, String revisionName, String revisionProviderId, Date revisionTimestamp) throws RepresentationNotExistsException { checkIfRepresentationExists(representationName, version, cloudId); Revision revision = new Revision(revisionName, revisionProviderId); revision.setCreationTimeStamp(revisionTimestamp); Collection<CompoundDataSetId> compoundDataSetIds = dataSetDAO.getDataSetAssignmentsByRepresentationVersion(cloudId, representationName, version); for (CompoundDataSetId compoundDataSetId : compoundDataSetIds) { dataSetDAO.removeDataSetsRevision(compoundDataSetId.getDataSetProviderId(), compoundDataSetId.getDataSetId(), revision, representationName, cloudId); dataSetDAO.deleteProviderDatasetRepresentationInfo(compoundDataSetId.getDataSetId(), compoundDataSetId.getDataSetProviderId(), cloudId, representationName, revisionTimestamp); } recordDAO.deleteRepresentationRevision(cloudId, representationName, version, revisionProviderId, revisionName, revisionTimestamp); recordDAO.removeRevisionFromRepresentationVersion(cloudId, representationName, version,revision); } @Override ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit); @Override void addAssignment(String providerId, String dataSetId, String recordId, String schema, String version); @Override void removeAssignment(String providerId, String dataSetId, String recordId, String schema, String versionId); @Override DataSet createDataSet(String providerId, String dataSetId, String description); @Override DataSet updateDataSet(String providerId, String dataSetId, String description); @Override ResultSlice<DataSet> getDataSets(String providerId, String thresholdDatasetId, int limit); @Override ResultSlice<CloudTagsResponse> getDataSetsRevisions(String providerId, String dataSetId, String revisionProviderId, String revisionName, Date revisionTimestamp, String representationName, String startFrom, int limit); @Override void addDataSetsRevisions(String providerId, String dataSetId, Revision revision, String representationName, String cloudId); @Override ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationPublished(String dataSetId, String providerId, String representationName, Date dateFrom, String startFrom, int numberOfElementsPerPage); @Override void updateAllRevisionDatasetsEntries(String globalId, String schema, String version, Revision revision); @Override void deleteDataSet(String providerId, String dataSetId); @Override Set<String> getAllDataSetRepresentationsNames(String providerId, String dataSetId); @Override void updateProviderDatasetRepresentation(String globalId, String schema, String version, Revision revision); @Override String getLatestVersionForGivenRevision(String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); @Override void addLatestRevisionForGivenVersionInDataset(DataSet dataSet, Representation representation, Revision revision); @Override ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage); @Override void deleteRevision(String cloudId, String representationName, String version, String revisionName, String revisionProviderId, Date revisionTimestamp); }
CassandraDataSetService implements DataSetService { @Override public void deleteRevision(String cloudId, String representationName, String version, String revisionName, String revisionProviderId, Date revisionTimestamp) throws RepresentationNotExistsException { checkIfRepresentationExists(representationName, version, cloudId); Revision revision = new Revision(revisionName, revisionProviderId); revision.setCreationTimeStamp(revisionTimestamp); Collection<CompoundDataSetId> compoundDataSetIds = dataSetDAO.getDataSetAssignmentsByRepresentationVersion(cloudId, representationName, version); for (CompoundDataSetId compoundDataSetId : compoundDataSetIds) { dataSetDAO.removeDataSetsRevision(compoundDataSetId.getDataSetProviderId(), compoundDataSetId.getDataSetId(), revision, representationName, cloudId); dataSetDAO.deleteProviderDatasetRepresentationInfo(compoundDataSetId.getDataSetId(), compoundDataSetId.getDataSetProviderId(), cloudId, representationName, revisionTimestamp); } recordDAO.deleteRepresentationRevision(cloudId, representationName, version, revisionProviderId, revisionName, revisionTimestamp); recordDAO.removeRevisionFromRepresentationVersion(cloudId, representationName, version,revision); } @Override ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit); @Override void addAssignment(String providerId, String dataSetId, String recordId, String schema, String version); @Override void removeAssignment(String providerId, String dataSetId, String recordId, String schema, String versionId); @Override DataSet createDataSet(String providerId, String dataSetId, String description); @Override DataSet updateDataSet(String providerId, String dataSetId, String description); @Override ResultSlice<DataSet> getDataSets(String providerId, String thresholdDatasetId, int limit); @Override ResultSlice<CloudTagsResponse> getDataSetsRevisions(String providerId, String dataSetId, String revisionProviderId, String revisionName, Date revisionTimestamp, String representationName, String startFrom, int limit); @Override void addDataSetsRevisions(String providerId, String dataSetId, Revision revision, String representationName, String cloudId); @Override ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationPublished(String dataSetId, String providerId, String representationName, Date dateFrom, String startFrom, int numberOfElementsPerPage); @Override void updateAllRevisionDatasetsEntries(String globalId, String schema, String version, Revision revision); @Override void deleteDataSet(String providerId, String dataSetId); @Override Set<String> getAllDataSetRepresentationsNames(String providerId, String dataSetId); @Override void updateProviderDatasetRepresentation(String globalId, String schema, String version, Revision revision); @Override String getLatestVersionForGivenRevision(String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); @Override void addLatestRevisionForGivenVersionInDataset(DataSet dataSet, Representation representation, Revision revision); @Override ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision(String dataSetId, String providerId, String revisionName, String revisionProvider, String representationName, String startFrom, Boolean isDeleted, int numberOfElementsPerPage); @Override void deleteRevision(String cloudId, String representationName, String version, String revisionName, String revisionProviderId, Date revisionTimestamp); }
@Test public void shouldSuccessfullyMigrateDataInDPS() { final String[] scriptsLocations1 = new String[]{"migrations/service/dps", "testMigrations/dps"}; MigrationExecutor migrator = new MigrationExecutor(EmbeddedCassandra.KEYSPACE, contactPoint, EmbeddedCassandra.PORT, cassandraUsername, cassandraPassword, scriptsLocations1); migrator.migrate(); validateDPSMigration(); }
public void migrate() { CassandraMigration cm = new CassandraMigration(); cm.getConfigs().setScriptsLocations(scriptsLocations); cm.setKeyspace(keyspace); cm.migrate(); }
MigrationExecutor { public void migrate() { CassandraMigration cm = new CassandraMigration(); cm.getConfigs().setScriptsLocations(scriptsLocations); cm.setKeyspace(keyspace); cm.migrate(); } }
MigrationExecutor { public void migrate() { CassandraMigration cm = new CassandraMigration(); cm.getConfigs().setScriptsLocations(scriptsLocations); cm.setKeyspace(keyspace); cm.migrate(); } MigrationExecutor(String cassandraKeyspace, String cassandraContactPoint, int cassandraPort, String cassandraUsername, String cassandraPassword, String[] scriptsLocations); }
MigrationExecutor { public void migrate() { CassandraMigration cm = new CassandraMigration(); cm.getConfigs().setScriptsLocations(scriptsLocations); cm.setKeyspace(keyspace); cm.migrate(); } MigrationExecutor(String cassandraKeyspace, String cassandraContactPoint, int cassandraPort, String cassandraUsername, String cassandraPassword, String[] scriptsLocations); void migrate(); }
MigrationExecutor { public void migrate() { CassandraMigration cm = new CassandraMigration(); cm.getConfigs().setScriptsLocations(scriptsLocations); cm.setKeyspace(keyspace); cm.migrate(); } MigrationExecutor(String cassandraKeyspace, String cassandraContactPoint, int cassandraPort, String cassandraUsername, String cassandraPassword, String[] scriptsLocations); void migrate(); }
@Test(expected = ContentDaoNotFoundException.class) public void shouldThrowExceptionOnNonExistingDAO() throws FileNotExistsException { final DynamicContentDAO instance = new DynamicContentDAO(prepareDAOMap( mock(SwiftContentDAO.class) )); instance.deleteContent("exampleFileName",Storage.DATA_BASE); }
public void deleteContent(String fileName, Storage stored) throws FileNotExistsException { getContentDAO(stored).deleteContent(fileName); }
DynamicContentDAO { public void deleteContent(String fileName, Storage stored) throws FileNotExistsException { getContentDAO(stored).deleteContent(fileName); } }
DynamicContentDAO { public void deleteContent(String fileName, Storage stored) throws FileNotExistsException { getContentDAO(stored).deleteContent(fileName); } @Autowired DynamicContentDAO(Map<Storage,ContentDAO> contentDAOs); }
DynamicContentDAO { public void deleteContent(String fileName, Storage stored) throws FileNotExistsException { getContentDAO(stored).deleteContent(fileName); } @Autowired DynamicContentDAO(Map<Storage,ContentDAO> contentDAOs); void copyContent(String sourceObjectId, String trgObjectId, Storage stored); void deleteContent(String fileName, Storage stored); void getContent(String fileName, long start, long end, OutputStream os, Storage stored); PutResult putContent(String fileName, InputStream data, Storage stored); }
DynamicContentDAO { public void deleteContent(String fileName, Storage stored) throws FileNotExistsException { getContentDAO(stored).deleteContent(fileName); } @Autowired DynamicContentDAO(Map<Storage,ContentDAO> contentDAOs); void copyContent(String sourceObjectId, String trgObjectId, Storage stored); void deleteContent(String fileName, Storage stored); void getContent(String fileName, long start, long end, OutputStream os, Storage stored); PutResult putContent(String fileName, InputStream data, Storage stored); }
@Test public void shouldProperlySelectDataBaseDeleteContent() throws FileNotExistsException { SwiftContentDAO daoMock = mock(SwiftContentDAO.class); final DynamicContentDAO instance = new DynamicContentDAO(prepareDAOMap(daoMock)); instance.deleteContent("exampleFileName",Storage.OBJECT_STORAGE); verify(daoMock).deleteContent(anyString()); }
public void deleteContent(String fileName, Storage stored) throws FileNotExistsException { getContentDAO(stored).deleteContent(fileName); }
DynamicContentDAO { public void deleteContent(String fileName, Storage stored) throws FileNotExistsException { getContentDAO(stored).deleteContent(fileName); } }
DynamicContentDAO { public void deleteContent(String fileName, Storage stored) throws FileNotExistsException { getContentDAO(stored).deleteContent(fileName); } @Autowired DynamicContentDAO(Map<Storage,ContentDAO> contentDAOs); }
DynamicContentDAO { public void deleteContent(String fileName, Storage stored) throws FileNotExistsException { getContentDAO(stored).deleteContent(fileName); } @Autowired DynamicContentDAO(Map<Storage,ContentDAO> contentDAOs); void copyContent(String sourceObjectId, String trgObjectId, Storage stored); void deleteContent(String fileName, Storage stored); void getContent(String fileName, long start, long end, OutputStream os, Storage stored); PutResult putContent(String fileName, InputStream data, Storage stored); }
DynamicContentDAO { public void deleteContent(String fileName, Storage stored) throws FileNotExistsException { getContentDAO(stored).deleteContent(fileName); } @Autowired DynamicContentDAO(Map<Storage,ContentDAO> contentDAOs); void copyContent(String sourceObjectId, String trgObjectId, Storage stored); void deleteContent(String fileName, Storage stored); void getContent(String fileName, long start, long end, OutputStream os, Storage stored); PutResult putContent(String fileName, InputStream data, Storage stored); }
@Test(expected = RecordNotExistsException.class) public void shouldThrowExpWhileCreatingRepresentationIfNoRecordInUis() throws Exception { makeUISThrowRecordNotExist(); mockUISProvider1Success(); cassandraRecordService.createRepresentation("globalId", "dc", PROVIDER_1_ID); }
@Override public Representation createRepresentation(String cloudId, String representationName, String providerId) throws ProviderNotExistsException, RecordNotExistsException { Date now = new Date(); DataProvider dataProvider; if ((dataProvider = uis.getProvider(providerId)) == null) { throw new ProviderNotExistsException(String.format("Provider %s does not exist.", providerId)); } if (uis.existsCloudId(cloudId)) { Representation rep = recordDAO.createRepresentation(cloudId, representationName, providerId, now); return rep; } else { throw new RecordNotExistsException(cloudId); } }
CassandraRecordService implements RecordService { @Override public Representation createRepresentation(String cloudId, String representationName, String providerId) throws ProviderNotExistsException, RecordNotExistsException { Date now = new Date(); DataProvider dataProvider; if ((dataProvider = uis.getProvider(providerId)) == null) { throw new ProviderNotExistsException(String.format("Provider %s does not exist.", providerId)); } if (uis.existsCloudId(cloudId)) { Representation rep = recordDAO.createRepresentation(cloudId, representationName, providerId, now); return rep; } else { throw new RecordNotExistsException(cloudId); } } }
CassandraRecordService implements RecordService { @Override public Representation createRepresentation(String cloudId, String representationName, String providerId) throws ProviderNotExistsException, RecordNotExistsException { Date now = new Date(); DataProvider dataProvider; if ((dataProvider = uis.getProvider(providerId)) == null) { throw new ProviderNotExistsException(String.format("Provider %s does not exist.", providerId)); } if (uis.existsCloudId(cloudId)) { Representation rep = recordDAO.createRepresentation(cloudId, representationName, providerId, now); return rep; } else { throw new RecordNotExistsException(cloudId); } } }
CassandraRecordService implements RecordService { @Override public Representation createRepresentation(String cloudId, String representationName, String providerId) throws ProviderNotExistsException, RecordNotExistsException { Date now = new Date(); DataProvider dataProvider; if ((dataProvider = uis.getProvider(providerId)) == null) { throw new ProviderNotExistsException(String.format("Provider %s does not exist.", providerId)); } if (uis.existsCloudId(cloudId)) { Representation rep = recordDAO.createRepresentation(cloudId, representationName, providerId, now); return rep; } else { throw new RecordNotExistsException(cloudId); } } @Override Record getRecord(String cloudId); @Override void deleteRecord(String cloudId); @Override void deleteRepresentation(String globalId, String schema); @Override Representation createRepresentation(String cloudId, String representationName, String providerId); @Override Representation getRepresentation(String globalId, String schema); @Override Representation getRepresentation(String globalId, String schema, String version); @Override void deleteRepresentation(String globalId, String schema, String version); @Override Representation persistRepresentation(String globalId, String schema, String version); @Override List<Representation> listRepresentationVersions(String globalId, String schema); @Override boolean putContent(String globalId, String schema, String version, File file, InputStream content); @Override Consumer<OutputStream> getContent(String globalId, String schema, String version, String fileName, long rangeStart, long rangeEnd); @Override String getContent(String globalId, String schema, String version, String fileName, OutputStream os); @Override void deleteContent(String globalId, String schema, String version, String fileName); @Override Representation copyRepresentation(String globalId, String schema, String version); @Override File getFile(String globalId, String schema, String version, String fileName); @Override void addRevision(String globalId, String schema, String version, Revision revision); @Override List<RepresentationRevisionResponse> getRepresentationRevisions(String globalId, String schema, String revisionProviderId, String revisionName, Date revisionTimestamp); @Override void insertRepresentationRevision(String globalId, String schema, String revisionProviderId, String revisionName, String versionId, Date revisionTimestamp); @Override Revision getRevision(String globalId, String schema, String version, String revisionKey); }
CassandraRecordService implements RecordService { @Override public Representation createRepresentation(String cloudId, String representationName, String providerId) throws ProviderNotExistsException, RecordNotExistsException { Date now = new Date(); DataProvider dataProvider; if ((dataProvider = uis.getProvider(providerId)) == null) { throw new ProviderNotExistsException(String.format("Provider %s does not exist.", providerId)); } if (uis.existsCloudId(cloudId)) { Representation rep = recordDAO.createRepresentation(cloudId, representationName, providerId, now); return rep; } else { throw new RecordNotExistsException(cloudId); } } @Override Record getRecord(String cloudId); @Override void deleteRecord(String cloudId); @Override void deleteRepresentation(String globalId, String schema); @Override Representation createRepresentation(String cloudId, String representationName, String providerId); @Override Representation getRepresentation(String globalId, String schema); @Override Representation getRepresentation(String globalId, String schema, String version); @Override void deleteRepresentation(String globalId, String schema, String version); @Override Representation persistRepresentation(String globalId, String schema, String version); @Override List<Representation> listRepresentationVersions(String globalId, String schema); @Override boolean putContent(String globalId, String schema, String version, File file, InputStream content); @Override Consumer<OutputStream> getContent(String globalId, String schema, String version, String fileName, long rangeStart, long rangeEnd); @Override String getContent(String globalId, String schema, String version, String fileName, OutputStream os); @Override void deleteContent(String globalId, String schema, String version, String fileName); @Override Representation copyRepresentation(String globalId, String schema, String version); @Override File getFile(String globalId, String schema, String version, String fileName); @Override void addRevision(String globalId, String schema, String version, Revision revision); @Override List<RepresentationRevisionResponse> getRepresentationRevisions(String globalId, String schema, String revisionProviderId, String revisionName, Date revisionTimestamp); @Override void insertRepresentationRevision(String globalId, String schema, String revisionProviderId, String revisionName, String versionId, Date revisionTimestamp); @Override Revision getRevision(String globalId, String schema, String version, String revisionKey); }
@Test(expected = SystemException.class) public void shouldThrowSystemExpWhileCreatingRepresentationIfUisFails() throws Exception { mockUISProvider1Success(); makeUISThrowSystemException(); cassandraRecordService.createRepresentation("globalId", "dc", PROVIDER_1_ID); }
@Override public Representation createRepresentation(String cloudId, String representationName, String providerId) throws ProviderNotExistsException, RecordNotExistsException { Date now = new Date(); DataProvider dataProvider; if ((dataProvider = uis.getProvider(providerId)) == null) { throw new ProviderNotExistsException(String.format("Provider %s does not exist.", providerId)); } if (uis.existsCloudId(cloudId)) { Representation rep = recordDAO.createRepresentation(cloudId, representationName, providerId, now); return rep; } else { throw new RecordNotExistsException(cloudId); } }
CassandraRecordService implements RecordService { @Override public Representation createRepresentation(String cloudId, String representationName, String providerId) throws ProviderNotExistsException, RecordNotExistsException { Date now = new Date(); DataProvider dataProvider; if ((dataProvider = uis.getProvider(providerId)) == null) { throw new ProviderNotExistsException(String.format("Provider %s does not exist.", providerId)); } if (uis.existsCloudId(cloudId)) { Representation rep = recordDAO.createRepresentation(cloudId, representationName, providerId, now); return rep; } else { throw new RecordNotExistsException(cloudId); } } }
CassandraRecordService implements RecordService { @Override public Representation createRepresentation(String cloudId, String representationName, String providerId) throws ProviderNotExistsException, RecordNotExistsException { Date now = new Date(); DataProvider dataProvider; if ((dataProvider = uis.getProvider(providerId)) == null) { throw new ProviderNotExistsException(String.format("Provider %s does not exist.", providerId)); } if (uis.existsCloudId(cloudId)) { Representation rep = recordDAO.createRepresentation(cloudId, representationName, providerId, now); return rep; } else { throw new RecordNotExistsException(cloudId); } } }
CassandraRecordService implements RecordService { @Override public Representation createRepresentation(String cloudId, String representationName, String providerId) throws ProviderNotExistsException, RecordNotExistsException { Date now = new Date(); DataProvider dataProvider; if ((dataProvider = uis.getProvider(providerId)) == null) { throw new ProviderNotExistsException(String.format("Provider %s does not exist.", providerId)); } if (uis.existsCloudId(cloudId)) { Representation rep = recordDAO.createRepresentation(cloudId, representationName, providerId, now); return rep; } else { throw new RecordNotExistsException(cloudId); } } @Override Record getRecord(String cloudId); @Override void deleteRecord(String cloudId); @Override void deleteRepresentation(String globalId, String schema); @Override Representation createRepresentation(String cloudId, String representationName, String providerId); @Override Representation getRepresentation(String globalId, String schema); @Override Representation getRepresentation(String globalId, String schema, String version); @Override void deleteRepresentation(String globalId, String schema, String version); @Override Representation persistRepresentation(String globalId, String schema, String version); @Override List<Representation> listRepresentationVersions(String globalId, String schema); @Override boolean putContent(String globalId, String schema, String version, File file, InputStream content); @Override Consumer<OutputStream> getContent(String globalId, String schema, String version, String fileName, long rangeStart, long rangeEnd); @Override String getContent(String globalId, String schema, String version, String fileName, OutputStream os); @Override void deleteContent(String globalId, String schema, String version, String fileName); @Override Representation copyRepresentation(String globalId, String schema, String version); @Override File getFile(String globalId, String schema, String version, String fileName); @Override void addRevision(String globalId, String schema, String version, Revision revision); @Override List<RepresentationRevisionResponse> getRepresentationRevisions(String globalId, String schema, String revisionProviderId, String revisionName, Date revisionTimestamp); @Override void insertRepresentationRevision(String globalId, String schema, String revisionProviderId, String revisionName, String versionId, Date revisionTimestamp); @Override Revision getRevision(String globalId, String schema, String version, String revisionKey); }
CassandraRecordService implements RecordService { @Override public Representation createRepresentation(String cloudId, String representationName, String providerId) throws ProviderNotExistsException, RecordNotExistsException { Date now = new Date(); DataProvider dataProvider; if ((dataProvider = uis.getProvider(providerId)) == null) { throw new ProviderNotExistsException(String.format("Provider %s does not exist.", providerId)); } if (uis.existsCloudId(cloudId)) { Representation rep = recordDAO.createRepresentation(cloudId, representationName, providerId, now); return rep; } else { throw new RecordNotExistsException(cloudId); } } @Override Record getRecord(String cloudId); @Override void deleteRecord(String cloudId); @Override void deleteRepresentation(String globalId, String schema); @Override Representation createRepresentation(String cloudId, String representationName, String providerId); @Override Representation getRepresentation(String globalId, String schema); @Override Representation getRepresentation(String globalId, String schema, String version); @Override void deleteRepresentation(String globalId, String schema, String version); @Override Representation persistRepresentation(String globalId, String schema, String version); @Override List<Representation> listRepresentationVersions(String globalId, String schema); @Override boolean putContent(String globalId, String schema, String version, File file, InputStream content); @Override Consumer<OutputStream> getContent(String globalId, String schema, String version, String fileName, long rangeStart, long rangeEnd); @Override String getContent(String globalId, String schema, String version, String fileName, OutputStream os); @Override void deleteContent(String globalId, String schema, String version, String fileName); @Override Representation copyRepresentation(String globalId, String schema, String version); @Override File getFile(String globalId, String schema, String version, String fileName); @Override void addRevision(String globalId, String schema, String version, Revision revision); @Override List<RepresentationRevisionResponse> getRepresentationRevisions(String globalId, String schema, String revisionProviderId, String revisionName, Date revisionTimestamp); @Override void insertRepresentationRevision(String globalId, String schema, String revisionProviderId, String revisionName, String versionId, Date revisionTimestamp); @Override Revision getRevision(String globalId, String schema, String version, String revisionKey); }
@Test(expected = RecordNotExistsException.class) public void shouldThrowExpWhileGettingRecordIfNoRecordInUis() throws Exception { makeUISThrowRecordNotExist(); cassandraRecordService.getRecord("globalId"); }
@Override public Record getRecord(String cloudId) throws RecordNotExistsException { Record record = null; if (uis.existsCloudId(cloudId)) { record = recordDAO.getRecord(cloudId); if (record.getRepresentations().isEmpty()) { throw new RecordNotExistsException(cloudId); } } else { throw new RecordNotExistsException(cloudId); } return record; }
CassandraRecordService implements RecordService { @Override public Record getRecord(String cloudId) throws RecordNotExistsException { Record record = null; if (uis.existsCloudId(cloudId)) { record = recordDAO.getRecord(cloudId); if (record.getRepresentations().isEmpty()) { throw new RecordNotExistsException(cloudId); } } else { throw new RecordNotExistsException(cloudId); } return record; } }
CassandraRecordService implements RecordService { @Override public Record getRecord(String cloudId) throws RecordNotExistsException { Record record = null; if (uis.existsCloudId(cloudId)) { record = recordDAO.getRecord(cloudId); if (record.getRepresentations().isEmpty()) { throw new RecordNotExistsException(cloudId); } } else { throw new RecordNotExistsException(cloudId); } return record; } }
CassandraRecordService implements RecordService { @Override public Record getRecord(String cloudId) throws RecordNotExistsException { Record record = null; if (uis.existsCloudId(cloudId)) { record = recordDAO.getRecord(cloudId); if (record.getRepresentations().isEmpty()) { throw new RecordNotExistsException(cloudId); } } else { throw new RecordNotExistsException(cloudId); } return record; } @Override Record getRecord(String cloudId); @Override void deleteRecord(String cloudId); @Override void deleteRepresentation(String globalId, String schema); @Override Representation createRepresentation(String cloudId, String representationName, String providerId); @Override Representation getRepresentation(String globalId, String schema); @Override Representation getRepresentation(String globalId, String schema, String version); @Override void deleteRepresentation(String globalId, String schema, String version); @Override Representation persistRepresentation(String globalId, String schema, String version); @Override List<Representation> listRepresentationVersions(String globalId, String schema); @Override boolean putContent(String globalId, String schema, String version, File file, InputStream content); @Override Consumer<OutputStream> getContent(String globalId, String schema, String version, String fileName, long rangeStart, long rangeEnd); @Override String getContent(String globalId, String schema, String version, String fileName, OutputStream os); @Override void deleteContent(String globalId, String schema, String version, String fileName); @Override Representation copyRepresentation(String globalId, String schema, String version); @Override File getFile(String globalId, String schema, String version, String fileName); @Override void addRevision(String globalId, String schema, String version, Revision revision); @Override List<RepresentationRevisionResponse> getRepresentationRevisions(String globalId, String schema, String revisionProviderId, String revisionName, Date revisionTimestamp); @Override void insertRepresentationRevision(String globalId, String schema, String revisionProviderId, String revisionName, String versionId, Date revisionTimestamp); @Override Revision getRevision(String globalId, String schema, String version, String revisionKey); }
CassandraRecordService implements RecordService { @Override public Record getRecord(String cloudId) throws RecordNotExistsException { Record record = null; if (uis.existsCloudId(cloudId)) { record = recordDAO.getRecord(cloudId); if (record.getRepresentations().isEmpty()) { throw new RecordNotExistsException(cloudId); } } else { throw new RecordNotExistsException(cloudId); } return record; } @Override Record getRecord(String cloudId); @Override void deleteRecord(String cloudId); @Override void deleteRepresentation(String globalId, String schema); @Override Representation createRepresentation(String cloudId, String representationName, String providerId); @Override Representation getRepresentation(String globalId, String schema); @Override Representation getRepresentation(String globalId, String schema, String version); @Override void deleteRepresentation(String globalId, String schema, String version); @Override Representation persistRepresentation(String globalId, String schema, String version); @Override List<Representation> listRepresentationVersions(String globalId, String schema); @Override boolean putContent(String globalId, String schema, String version, File file, InputStream content); @Override Consumer<OutputStream> getContent(String globalId, String schema, String version, String fileName, long rangeStart, long rangeEnd); @Override String getContent(String globalId, String schema, String version, String fileName, OutputStream os); @Override void deleteContent(String globalId, String schema, String version, String fileName); @Override Representation copyRepresentation(String globalId, String schema, String version); @Override File getFile(String globalId, String schema, String version, String fileName); @Override void addRevision(String globalId, String schema, String version, Revision revision); @Override List<RepresentationRevisionResponse> getRepresentationRevisions(String globalId, String schema, String revisionProviderId, String revisionName, Date revisionTimestamp); @Override void insertRepresentationRevision(String globalId, String schema, String revisionProviderId, String revisionName, String versionId, Date revisionTimestamp); @Override Revision getRevision(String globalId, String schema, String version, String revisionKey); }
@Test(expected = SystemException.class) public void shouldThrowSystemExpWhileGettingRecordIfUisFails() throws Exception { makeUISThrowSystemException(); cassandraRecordService.getRecord("globalId"); }
@Override public Record getRecord(String cloudId) throws RecordNotExistsException { Record record = null; if (uis.existsCloudId(cloudId)) { record = recordDAO.getRecord(cloudId); if (record.getRepresentations().isEmpty()) { throw new RecordNotExistsException(cloudId); } } else { throw new RecordNotExistsException(cloudId); } return record; }
CassandraRecordService implements RecordService { @Override public Record getRecord(String cloudId) throws RecordNotExistsException { Record record = null; if (uis.existsCloudId(cloudId)) { record = recordDAO.getRecord(cloudId); if (record.getRepresentations().isEmpty()) { throw new RecordNotExistsException(cloudId); } } else { throw new RecordNotExistsException(cloudId); } return record; } }
CassandraRecordService implements RecordService { @Override public Record getRecord(String cloudId) throws RecordNotExistsException { Record record = null; if (uis.existsCloudId(cloudId)) { record = recordDAO.getRecord(cloudId); if (record.getRepresentations().isEmpty()) { throw new RecordNotExistsException(cloudId); } } else { throw new RecordNotExistsException(cloudId); } return record; } }
CassandraRecordService implements RecordService { @Override public Record getRecord(String cloudId) throws RecordNotExistsException { Record record = null; if (uis.existsCloudId(cloudId)) { record = recordDAO.getRecord(cloudId); if (record.getRepresentations().isEmpty()) { throw new RecordNotExistsException(cloudId); } } else { throw new RecordNotExistsException(cloudId); } return record; } @Override Record getRecord(String cloudId); @Override void deleteRecord(String cloudId); @Override void deleteRepresentation(String globalId, String schema); @Override Representation createRepresentation(String cloudId, String representationName, String providerId); @Override Representation getRepresentation(String globalId, String schema); @Override Representation getRepresentation(String globalId, String schema, String version); @Override void deleteRepresentation(String globalId, String schema, String version); @Override Representation persistRepresentation(String globalId, String schema, String version); @Override List<Representation> listRepresentationVersions(String globalId, String schema); @Override boolean putContent(String globalId, String schema, String version, File file, InputStream content); @Override Consumer<OutputStream> getContent(String globalId, String schema, String version, String fileName, long rangeStart, long rangeEnd); @Override String getContent(String globalId, String schema, String version, String fileName, OutputStream os); @Override void deleteContent(String globalId, String schema, String version, String fileName); @Override Representation copyRepresentation(String globalId, String schema, String version); @Override File getFile(String globalId, String schema, String version, String fileName); @Override void addRevision(String globalId, String schema, String version, Revision revision); @Override List<RepresentationRevisionResponse> getRepresentationRevisions(String globalId, String schema, String revisionProviderId, String revisionName, Date revisionTimestamp); @Override void insertRepresentationRevision(String globalId, String schema, String revisionProviderId, String revisionName, String versionId, Date revisionTimestamp); @Override Revision getRevision(String globalId, String schema, String version, String revisionKey); }
CassandraRecordService implements RecordService { @Override public Record getRecord(String cloudId) throws RecordNotExistsException { Record record = null; if (uis.existsCloudId(cloudId)) { record = recordDAO.getRecord(cloudId); if (record.getRepresentations().isEmpty()) { throw new RecordNotExistsException(cloudId); } } else { throw new RecordNotExistsException(cloudId); } return record; } @Override Record getRecord(String cloudId); @Override void deleteRecord(String cloudId); @Override void deleteRepresentation(String globalId, String schema); @Override Representation createRepresentation(String cloudId, String representationName, String providerId); @Override Representation getRepresentation(String globalId, String schema); @Override Representation getRepresentation(String globalId, String schema, String version); @Override void deleteRepresentation(String globalId, String schema, String version); @Override Representation persistRepresentation(String globalId, String schema, String version); @Override List<Representation> listRepresentationVersions(String globalId, String schema); @Override boolean putContent(String globalId, String schema, String version, File file, InputStream content); @Override Consumer<OutputStream> getContent(String globalId, String schema, String version, String fileName, long rangeStart, long rangeEnd); @Override String getContent(String globalId, String schema, String version, String fileName, OutputStream os); @Override void deleteContent(String globalId, String schema, String version, String fileName); @Override Representation copyRepresentation(String globalId, String schema, String version); @Override File getFile(String globalId, String schema, String version, String fileName); @Override void addRevision(String globalId, String schema, String version, Revision revision); @Override List<RepresentationRevisionResponse> getRepresentationRevisions(String globalId, String schema, String revisionProviderId, String revisionName, Date revisionTimestamp); @Override void insertRepresentationRevision(String globalId, String schema, String revisionProviderId, String revisionName, String versionId, Date revisionTimestamp); @Override Revision getRevision(String globalId, String schema, String version, String revisionKey); }
@Test(expected = RecordNotExistsException.class) public void shouldThrowExpWhileDeletingRecordIfNoRecordInUis() throws Exception { makeUISThrowRecordNotExist(); cassandraRecordService.deleteRecord("globalId"); }
@Override public void deleteRecord(String cloudId) throws RecordNotExistsException, RepresentationNotExistsException { if (uis.existsCloudId(cloudId)) { List<Representation> allRecordRepresentationsInAllVersions = recordDAO.listRepresentationVersions(cloudId); if (allRecordRepresentationsInAllVersions.isEmpty()) { throw new RepresentationNotExistsException(String.format( "No representation found for given cloudId %s", cloudId)); } sortByProviderId(allRecordRepresentationsInAllVersions); String dPId = null; for (Representation repVersion : allRecordRepresentationsInAllVersions) { removeFilesFromRepresentationVersion(cloudId, repVersion); removeRepresentationAssignmentFromDataSets(cloudId, repVersion); deleteRepresentationRevision(cloudId, repVersion); recordDAO.deleteRepresentation(cloudId, repVersion.getRepresentationName(), repVersion.getVersion()); } } else { throw new RecordNotExistsException(cloudId); } }
CassandraRecordService implements RecordService { @Override public void deleteRecord(String cloudId) throws RecordNotExistsException, RepresentationNotExistsException { if (uis.existsCloudId(cloudId)) { List<Representation> allRecordRepresentationsInAllVersions = recordDAO.listRepresentationVersions(cloudId); if (allRecordRepresentationsInAllVersions.isEmpty()) { throw new RepresentationNotExistsException(String.format( "No representation found for given cloudId %s", cloudId)); } sortByProviderId(allRecordRepresentationsInAllVersions); String dPId = null; for (Representation repVersion : allRecordRepresentationsInAllVersions) { removeFilesFromRepresentationVersion(cloudId, repVersion); removeRepresentationAssignmentFromDataSets(cloudId, repVersion); deleteRepresentationRevision(cloudId, repVersion); recordDAO.deleteRepresentation(cloudId, repVersion.getRepresentationName(), repVersion.getVersion()); } } else { throw new RecordNotExistsException(cloudId); } } }
CassandraRecordService implements RecordService { @Override public void deleteRecord(String cloudId) throws RecordNotExistsException, RepresentationNotExistsException { if (uis.existsCloudId(cloudId)) { List<Representation> allRecordRepresentationsInAllVersions = recordDAO.listRepresentationVersions(cloudId); if (allRecordRepresentationsInAllVersions.isEmpty()) { throw new RepresentationNotExistsException(String.format( "No representation found for given cloudId %s", cloudId)); } sortByProviderId(allRecordRepresentationsInAllVersions); String dPId = null; for (Representation repVersion : allRecordRepresentationsInAllVersions) { removeFilesFromRepresentationVersion(cloudId, repVersion); removeRepresentationAssignmentFromDataSets(cloudId, repVersion); deleteRepresentationRevision(cloudId, repVersion); recordDAO.deleteRepresentation(cloudId, repVersion.getRepresentationName(), repVersion.getVersion()); } } else { throw new RecordNotExistsException(cloudId); } } }
CassandraRecordService implements RecordService { @Override public void deleteRecord(String cloudId) throws RecordNotExistsException, RepresentationNotExistsException { if (uis.existsCloudId(cloudId)) { List<Representation> allRecordRepresentationsInAllVersions = recordDAO.listRepresentationVersions(cloudId); if (allRecordRepresentationsInAllVersions.isEmpty()) { throw new RepresentationNotExistsException(String.format( "No representation found for given cloudId %s", cloudId)); } sortByProviderId(allRecordRepresentationsInAllVersions); String dPId = null; for (Representation repVersion : allRecordRepresentationsInAllVersions) { removeFilesFromRepresentationVersion(cloudId, repVersion); removeRepresentationAssignmentFromDataSets(cloudId, repVersion); deleteRepresentationRevision(cloudId, repVersion); recordDAO.deleteRepresentation(cloudId, repVersion.getRepresentationName(), repVersion.getVersion()); } } else { throw new RecordNotExistsException(cloudId); } } @Override Record getRecord(String cloudId); @Override void deleteRecord(String cloudId); @Override void deleteRepresentation(String globalId, String schema); @Override Representation createRepresentation(String cloudId, String representationName, String providerId); @Override Representation getRepresentation(String globalId, String schema); @Override Representation getRepresentation(String globalId, String schema, String version); @Override void deleteRepresentation(String globalId, String schema, String version); @Override Representation persistRepresentation(String globalId, String schema, String version); @Override List<Representation> listRepresentationVersions(String globalId, String schema); @Override boolean putContent(String globalId, String schema, String version, File file, InputStream content); @Override Consumer<OutputStream> getContent(String globalId, String schema, String version, String fileName, long rangeStart, long rangeEnd); @Override String getContent(String globalId, String schema, String version, String fileName, OutputStream os); @Override void deleteContent(String globalId, String schema, String version, String fileName); @Override Representation copyRepresentation(String globalId, String schema, String version); @Override File getFile(String globalId, String schema, String version, String fileName); @Override void addRevision(String globalId, String schema, String version, Revision revision); @Override List<RepresentationRevisionResponse> getRepresentationRevisions(String globalId, String schema, String revisionProviderId, String revisionName, Date revisionTimestamp); @Override void insertRepresentationRevision(String globalId, String schema, String revisionProviderId, String revisionName, String versionId, Date revisionTimestamp); @Override Revision getRevision(String globalId, String schema, String version, String revisionKey); }
CassandraRecordService implements RecordService { @Override public void deleteRecord(String cloudId) throws RecordNotExistsException, RepresentationNotExistsException { if (uis.existsCloudId(cloudId)) { List<Representation> allRecordRepresentationsInAllVersions = recordDAO.listRepresentationVersions(cloudId); if (allRecordRepresentationsInAllVersions.isEmpty()) { throw new RepresentationNotExistsException(String.format( "No representation found for given cloudId %s", cloudId)); } sortByProviderId(allRecordRepresentationsInAllVersions); String dPId = null; for (Representation repVersion : allRecordRepresentationsInAllVersions) { removeFilesFromRepresentationVersion(cloudId, repVersion); removeRepresentationAssignmentFromDataSets(cloudId, repVersion); deleteRepresentationRevision(cloudId, repVersion); recordDAO.deleteRepresentation(cloudId, repVersion.getRepresentationName(), repVersion.getVersion()); } } else { throw new RecordNotExistsException(cloudId); } } @Override Record getRecord(String cloudId); @Override void deleteRecord(String cloudId); @Override void deleteRepresentation(String globalId, String schema); @Override Representation createRepresentation(String cloudId, String representationName, String providerId); @Override Representation getRepresentation(String globalId, String schema); @Override Representation getRepresentation(String globalId, String schema, String version); @Override void deleteRepresentation(String globalId, String schema, String version); @Override Representation persistRepresentation(String globalId, String schema, String version); @Override List<Representation> listRepresentationVersions(String globalId, String schema); @Override boolean putContent(String globalId, String schema, String version, File file, InputStream content); @Override Consumer<OutputStream> getContent(String globalId, String schema, String version, String fileName, long rangeStart, long rangeEnd); @Override String getContent(String globalId, String schema, String version, String fileName, OutputStream os); @Override void deleteContent(String globalId, String schema, String version, String fileName); @Override Representation copyRepresentation(String globalId, String schema, String version); @Override File getFile(String globalId, String schema, String version, String fileName); @Override void addRevision(String globalId, String schema, String version, Revision revision); @Override List<RepresentationRevisionResponse> getRepresentationRevisions(String globalId, String schema, String revisionProviderId, String revisionName, Date revisionTimestamp); @Override void insertRepresentationRevision(String globalId, String schema, String revisionProviderId, String revisionName, String versionId, Date revisionTimestamp); @Override Revision getRevision(String globalId, String schema, String version, String revisionKey); }
@Test(expected = SystemException.class) public void shouldThrowSystemExpWhileDeletingRecordIfUisFails() throws Exception { makeUISThrowSystemException(); cassandraRecordService.deleteRecord("globalId"); }
@Override public void deleteRecord(String cloudId) throws RecordNotExistsException, RepresentationNotExistsException { if (uis.existsCloudId(cloudId)) { List<Representation> allRecordRepresentationsInAllVersions = recordDAO.listRepresentationVersions(cloudId); if (allRecordRepresentationsInAllVersions.isEmpty()) { throw new RepresentationNotExistsException(String.format( "No representation found for given cloudId %s", cloudId)); } sortByProviderId(allRecordRepresentationsInAllVersions); String dPId = null; for (Representation repVersion : allRecordRepresentationsInAllVersions) { removeFilesFromRepresentationVersion(cloudId, repVersion); removeRepresentationAssignmentFromDataSets(cloudId, repVersion); deleteRepresentationRevision(cloudId, repVersion); recordDAO.deleteRepresentation(cloudId, repVersion.getRepresentationName(), repVersion.getVersion()); } } else { throw new RecordNotExistsException(cloudId); } }
CassandraRecordService implements RecordService { @Override public void deleteRecord(String cloudId) throws RecordNotExistsException, RepresentationNotExistsException { if (uis.existsCloudId(cloudId)) { List<Representation> allRecordRepresentationsInAllVersions = recordDAO.listRepresentationVersions(cloudId); if (allRecordRepresentationsInAllVersions.isEmpty()) { throw new RepresentationNotExistsException(String.format( "No representation found for given cloudId %s", cloudId)); } sortByProviderId(allRecordRepresentationsInAllVersions); String dPId = null; for (Representation repVersion : allRecordRepresentationsInAllVersions) { removeFilesFromRepresentationVersion(cloudId, repVersion); removeRepresentationAssignmentFromDataSets(cloudId, repVersion); deleteRepresentationRevision(cloudId, repVersion); recordDAO.deleteRepresentation(cloudId, repVersion.getRepresentationName(), repVersion.getVersion()); } } else { throw new RecordNotExistsException(cloudId); } } }
CassandraRecordService implements RecordService { @Override public void deleteRecord(String cloudId) throws RecordNotExistsException, RepresentationNotExistsException { if (uis.existsCloudId(cloudId)) { List<Representation> allRecordRepresentationsInAllVersions = recordDAO.listRepresentationVersions(cloudId); if (allRecordRepresentationsInAllVersions.isEmpty()) { throw new RepresentationNotExistsException(String.format( "No representation found for given cloudId %s", cloudId)); } sortByProviderId(allRecordRepresentationsInAllVersions); String dPId = null; for (Representation repVersion : allRecordRepresentationsInAllVersions) { removeFilesFromRepresentationVersion(cloudId, repVersion); removeRepresentationAssignmentFromDataSets(cloudId, repVersion); deleteRepresentationRevision(cloudId, repVersion); recordDAO.deleteRepresentation(cloudId, repVersion.getRepresentationName(), repVersion.getVersion()); } } else { throw new RecordNotExistsException(cloudId); } } }
CassandraRecordService implements RecordService { @Override public void deleteRecord(String cloudId) throws RecordNotExistsException, RepresentationNotExistsException { if (uis.existsCloudId(cloudId)) { List<Representation> allRecordRepresentationsInAllVersions = recordDAO.listRepresentationVersions(cloudId); if (allRecordRepresentationsInAllVersions.isEmpty()) { throw new RepresentationNotExistsException(String.format( "No representation found for given cloudId %s", cloudId)); } sortByProviderId(allRecordRepresentationsInAllVersions); String dPId = null; for (Representation repVersion : allRecordRepresentationsInAllVersions) { removeFilesFromRepresentationVersion(cloudId, repVersion); removeRepresentationAssignmentFromDataSets(cloudId, repVersion); deleteRepresentationRevision(cloudId, repVersion); recordDAO.deleteRepresentation(cloudId, repVersion.getRepresentationName(), repVersion.getVersion()); } } else { throw new RecordNotExistsException(cloudId); } } @Override Record getRecord(String cloudId); @Override void deleteRecord(String cloudId); @Override void deleteRepresentation(String globalId, String schema); @Override Representation createRepresentation(String cloudId, String representationName, String providerId); @Override Representation getRepresentation(String globalId, String schema); @Override Representation getRepresentation(String globalId, String schema, String version); @Override void deleteRepresentation(String globalId, String schema, String version); @Override Representation persistRepresentation(String globalId, String schema, String version); @Override List<Representation> listRepresentationVersions(String globalId, String schema); @Override boolean putContent(String globalId, String schema, String version, File file, InputStream content); @Override Consumer<OutputStream> getContent(String globalId, String schema, String version, String fileName, long rangeStart, long rangeEnd); @Override String getContent(String globalId, String schema, String version, String fileName, OutputStream os); @Override void deleteContent(String globalId, String schema, String version, String fileName); @Override Representation copyRepresentation(String globalId, String schema, String version); @Override File getFile(String globalId, String schema, String version, String fileName); @Override void addRevision(String globalId, String schema, String version, Revision revision); @Override List<RepresentationRevisionResponse> getRepresentationRevisions(String globalId, String schema, String revisionProviderId, String revisionName, Date revisionTimestamp); @Override void insertRepresentationRevision(String globalId, String schema, String revisionProviderId, String revisionName, String versionId, Date revisionTimestamp); @Override Revision getRevision(String globalId, String schema, String version, String revisionKey); }
CassandraRecordService implements RecordService { @Override public void deleteRecord(String cloudId) throws RecordNotExistsException, RepresentationNotExistsException { if (uis.existsCloudId(cloudId)) { List<Representation> allRecordRepresentationsInAllVersions = recordDAO.listRepresentationVersions(cloudId); if (allRecordRepresentationsInAllVersions.isEmpty()) { throw new RepresentationNotExistsException(String.format( "No representation found for given cloudId %s", cloudId)); } sortByProviderId(allRecordRepresentationsInAllVersions); String dPId = null; for (Representation repVersion : allRecordRepresentationsInAllVersions) { removeFilesFromRepresentationVersion(cloudId, repVersion); removeRepresentationAssignmentFromDataSets(cloudId, repVersion); deleteRepresentationRevision(cloudId, repVersion); recordDAO.deleteRepresentation(cloudId, repVersion.getRepresentationName(), repVersion.getVersion()); } } else { throw new RecordNotExistsException(cloudId); } } @Override Record getRecord(String cloudId); @Override void deleteRecord(String cloudId); @Override void deleteRepresentation(String globalId, String schema); @Override Representation createRepresentation(String cloudId, String representationName, String providerId); @Override Representation getRepresentation(String globalId, String schema); @Override Representation getRepresentation(String globalId, String schema, String version); @Override void deleteRepresentation(String globalId, String schema, String version); @Override Representation persistRepresentation(String globalId, String schema, String version); @Override List<Representation> listRepresentationVersions(String globalId, String schema); @Override boolean putContent(String globalId, String schema, String version, File file, InputStream content); @Override Consumer<OutputStream> getContent(String globalId, String schema, String version, String fileName, long rangeStart, long rangeEnd); @Override String getContent(String globalId, String schema, String version, String fileName, OutputStream os); @Override void deleteContent(String globalId, String schema, String version, String fileName); @Override Representation copyRepresentation(String globalId, String schema, String version); @Override File getFile(String globalId, String schema, String version, String fileName); @Override void addRevision(String globalId, String schema, String version, Revision revision); @Override List<RepresentationRevisionResponse> getRepresentationRevisions(String globalId, String schema, String revisionProviderId, String revisionName, Date revisionTimestamp); @Override void insertRepresentationRevision(String globalId, String schema, String revisionProviderId, String revisionName, String versionId, Date revisionTimestamp); @Override Revision getRevision(String globalId, String schema, String version, String revisionKey); }
@Test(expected = RepresentationNotExistsException.class) public void shouldThrowRepresentationNotFoundExpWhenNoSuchRepresentation() throws Exception { makeUISSuccess(); cassandraRecordService.getRepresentation("globalId", "not_existing_schema"); }
@Override public Representation getRepresentation(String globalId, String schema) throws RepresentationNotExistsException { Representation rep = recordDAO.getLatestPersistentRepresentation(globalId, schema); if (rep == null) { throw new RepresentationNotExistsException(); } else { return rep; } }
CassandraRecordService implements RecordService { @Override public Representation getRepresentation(String globalId, String schema) throws RepresentationNotExistsException { Representation rep = recordDAO.getLatestPersistentRepresentation(globalId, schema); if (rep == null) { throw new RepresentationNotExistsException(); } else { return rep; } } }
CassandraRecordService implements RecordService { @Override public Representation getRepresentation(String globalId, String schema) throws RepresentationNotExistsException { Representation rep = recordDAO.getLatestPersistentRepresentation(globalId, schema); if (rep == null) { throw new RepresentationNotExistsException(); } else { return rep; } } }
CassandraRecordService implements RecordService { @Override public Representation getRepresentation(String globalId, String schema) throws RepresentationNotExistsException { Representation rep = recordDAO.getLatestPersistentRepresentation(globalId, schema); if (rep == null) { throw new RepresentationNotExistsException(); } else { return rep; } } @Override Record getRecord(String cloudId); @Override void deleteRecord(String cloudId); @Override void deleteRepresentation(String globalId, String schema); @Override Representation createRepresentation(String cloudId, String representationName, String providerId); @Override Representation getRepresentation(String globalId, String schema); @Override Representation getRepresentation(String globalId, String schema, String version); @Override void deleteRepresentation(String globalId, String schema, String version); @Override Representation persistRepresentation(String globalId, String schema, String version); @Override List<Representation> listRepresentationVersions(String globalId, String schema); @Override boolean putContent(String globalId, String schema, String version, File file, InputStream content); @Override Consumer<OutputStream> getContent(String globalId, String schema, String version, String fileName, long rangeStart, long rangeEnd); @Override String getContent(String globalId, String schema, String version, String fileName, OutputStream os); @Override void deleteContent(String globalId, String schema, String version, String fileName); @Override Representation copyRepresentation(String globalId, String schema, String version); @Override File getFile(String globalId, String schema, String version, String fileName); @Override void addRevision(String globalId, String schema, String version, Revision revision); @Override List<RepresentationRevisionResponse> getRepresentationRevisions(String globalId, String schema, String revisionProviderId, String revisionName, Date revisionTimestamp); @Override void insertRepresentationRevision(String globalId, String schema, String revisionProviderId, String revisionName, String versionId, Date revisionTimestamp); @Override Revision getRevision(String globalId, String schema, String version, String revisionKey); }
CassandraRecordService implements RecordService { @Override public Representation getRepresentation(String globalId, String schema) throws RepresentationNotExistsException { Representation rep = recordDAO.getLatestPersistentRepresentation(globalId, schema); if (rep == null) { throw new RepresentationNotExistsException(); } else { return rep; } } @Override Record getRecord(String cloudId); @Override void deleteRecord(String cloudId); @Override void deleteRepresentation(String globalId, String schema); @Override Representation createRepresentation(String cloudId, String representationName, String providerId); @Override Representation getRepresentation(String globalId, String schema); @Override Representation getRepresentation(String globalId, String schema, String version); @Override void deleteRepresentation(String globalId, String schema, String version); @Override Representation persistRepresentation(String globalId, String schema, String version); @Override List<Representation> listRepresentationVersions(String globalId, String schema); @Override boolean putContent(String globalId, String schema, String version, File file, InputStream content); @Override Consumer<OutputStream> getContent(String globalId, String schema, String version, String fileName, long rangeStart, long rangeEnd); @Override String getContent(String globalId, String schema, String version, String fileName, OutputStream os); @Override void deleteContent(String globalId, String schema, String version, String fileName); @Override Representation copyRepresentation(String globalId, String schema, String version); @Override File getFile(String globalId, String schema, String version, String fileName); @Override void addRevision(String globalId, String schema, String version, Revision revision); @Override List<RepresentationRevisionResponse> getRepresentationRevisions(String globalId, String schema, String revisionProviderId, String revisionName, Date revisionTimestamp); @Override void insertRepresentationRevision(String globalId, String schema, String revisionProviderId, String revisionName, String versionId, Date revisionTimestamp); @Override Revision getRevision(String globalId, String schema, String version, String revisionKey); }
@Test(expected = ProviderNotExistsException.class) public void shouldNotCreateRepresentationForNotExistingProvider() throws Exception { makeUISFailure(); makeUISProviderFailure(); cassandraRecordService.createRepresentation("globalId", "dc", "not-existing"); }
@Override public Representation createRepresentation(String cloudId, String representationName, String providerId) throws ProviderNotExistsException, RecordNotExistsException { Date now = new Date(); DataProvider dataProvider; if ((dataProvider = uis.getProvider(providerId)) == null) { throw new ProviderNotExistsException(String.format("Provider %s does not exist.", providerId)); } if (uis.existsCloudId(cloudId)) { Representation rep = recordDAO.createRepresentation(cloudId, representationName, providerId, now); return rep; } else { throw new RecordNotExistsException(cloudId); } }
CassandraRecordService implements RecordService { @Override public Representation createRepresentation(String cloudId, String representationName, String providerId) throws ProviderNotExistsException, RecordNotExistsException { Date now = new Date(); DataProvider dataProvider; if ((dataProvider = uis.getProvider(providerId)) == null) { throw new ProviderNotExistsException(String.format("Provider %s does not exist.", providerId)); } if (uis.existsCloudId(cloudId)) { Representation rep = recordDAO.createRepresentation(cloudId, representationName, providerId, now); return rep; } else { throw new RecordNotExistsException(cloudId); } } }
CassandraRecordService implements RecordService { @Override public Representation createRepresentation(String cloudId, String representationName, String providerId) throws ProviderNotExistsException, RecordNotExistsException { Date now = new Date(); DataProvider dataProvider; if ((dataProvider = uis.getProvider(providerId)) == null) { throw new ProviderNotExistsException(String.format("Provider %s does not exist.", providerId)); } if (uis.existsCloudId(cloudId)) { Representation rep = recordDAO.createRepresentation(cloudId, representationName, providerId, now); return rep; } else { throw new RecordNotExistsException(cloudId); } } }
CassandraRecordService implements RecordService { @Override public Representation createRepresentation(String cloudId, String representationName, String providerId) throws ProviderNotExistsException, RecordNotExistsException { Date now = new Date(); DataProvider dataProvider; if ((dataProvider = uis.getProvider(providerId)) == null) { throw new ProviderNotExistsException(String.format("Provider %s does not exist.", providerId)); } if (uis.existsCloudId(cloudId)) { Representation rep = recordDAO.createRepresentation(cloudId, representationName, providerId, now); return rep; } else { throw new RecordNotExistsException(cloudId); } } @Override Record getRecord(String cloudId); @Override void deleteRecord(String cloudId); @Override void deleteRepresentation(String globalId, String schema); @Override Representation createRepresentation(String cloudId, String representationName, String providerId); @Override Representation getRepresentation(String globalId, String schema); @Override Representation getRepresentation(String globalId, String schema, String version); @Override void deleteRepresentation(String globalId, String schema, String version); @Override Representation persistRepresentation(String globalId, String schema, String version); @Override List<Representation> listRepresentationVersions(String globalId, String schema); @Override boolean putContent(String globalId, String schema, String version, File file, InputStream content); @Override Consumer<OutputStream> getContent(String globalId, String schema, String version, String fileName, long rangeStart, long rangeEnd); @Override String getContent(String globalId, String schema, String version, String fileName, OutputStream os); @Override void deleteContent(String globalId, String schema, String version, String fileName); @Override Representation copyRepresentation(String globalId, String schema, String version); @Override File getFile(String globalId, String schema, String version, String fileName); @Override void addRevision(String globalId, String schema, String version, Revision revision); @Override List<RepresentationRevisionResponse> getRepresentationRevisions(String globalId, String schema, String revisionProviderId, String revisionName, Date revisionTimestamp); @Override void insertRepresentationRevision(String globalId, String schema, String revisionProviderId, String revisionName, String versionId, Date revisionTimestamp); @Override Revision getRevision(String globalId, String schema, String version, String revisionKey); }
CassandraRecordService implements RecordService { @Override public Representation createRepresentation(String cloudId, String representationName, String providerId) throws ProviderNotExistsException, RecordNotExistsException { Date now = new Date(); DataProvider dataProvider; if ((dataProvider = uis.getProvider(providerId)) == null) { throw new ProviderNotExistsException(String.format("Provider %s does not exist.", providerId)); } if (uis.existsCloudId(cloudId)) { Representation rep = recordDAO.createRepresentation(cloudId, representationName, providerId, now); return rep; } else { throw new RecordNotExistsException(cloudId); } } @Override Record getRecord(String cloudId); @Override void deleteRecord(String cloudId); @Override void deleteRepresentation(String globalId, String schema); @Override Representation createRepresentation(String cloudId, String representationName, String providerId); @Override Representation getRepresentation(String globalId, String schema); @Override Representation getRepresentation(String globalId, String schema, String version); @Override void deleteRepresentation(String globalId, String schema, String version); @Override Representation persistRepresentation(String globalId, String schema, String version); @Override List<Representation> listRepresentationVersions(String globalId, String schema); @Override boolean putContent(String globalId, String schema, String version, File file, InputStream content); @Override Consumer<OutputStream> getContent(String globalId, String schema, String version, String fileName, long rangeStart, long rangeEnd); @Override String getContent(String globalId, String schema, String version, String fileName, OutputStream os); @Override void deleteContent(String globalId, String schema, String version, String fileName); @Override Representation copyRepresentation(String globalId, String schema, String version); @Override File getFile(String globalId, String schema, String version, String fileName); @Override void addRevision(String globalId, String schema, String version, Revision revision); @Override List<RepresentationRevisionResponse> getRepresentationRevisions(String globalId, String schema, String revisionProviderId, String revisionName, Date revisionTimestamp); @Override void insertRepresentationRevision(String globalId, String schema, String revisionProviderId, String revisionName, String versionId, Date revisionTimestamp); @Override Revision getRevision(String globalId, String schema, String version, String revisionKey); }
@Test public void shouldRetrunNullString() { final String fileName = ""; final String output = migrator.nameConversion(fileName); assertEquals(null, output); }
@Override public String nameConversion(final String s) { return s.contains("|") ? s.replace("|", "_") : null; }
CustomFileNameMigrator extends SwiftMigrator { @Override public String nameConversion(final String s) { return s.contains("|") ? s.replace("|", "_") : null; } }
CustomFileNameMigrator extends SwiftMigrator { @Override public String nameConversion(final String s) { return s.contains("|") ? s.replace("|", "_") : null; } }
CustomFileNameMigrator extends SwiftMigrator { @Override public String nameConversion(final String s) { return s.contains("|") ? s.replace("|", "_") : null; } @Override String nameConversion(final String s); }
CustomFileNameMigrator extends SwiftMigrator { @Override public String nameConversion(final String s) { return s.contains("|") ? s.replace("|", "_") : null; } @Override String nameConversion(final String s); }
@Test(expected = RepresentationNotExistsException.class) public void shouldThrowExcWhenDeletingRecordHasNoRepresentations() throws Exception { makeUISSuccess(); mockUISProvider1Success(); cassandraRecordService.deleteRecord("globalId"); }
@Override public void deleteRecord(String cloudId) throws RecordNotExistsException, RepresentationNotExistsException { if (uis.existsCloudId(cloudId)) { List<Representation> allRecordRepresentationsInAllVersions = recordDAO.listRepresentationVersions(cloudId); if (allRecordRepresentationsInAllVersions.isEmpty()) { throw new RepresentationNotExistsException(String.format( "No representation found for given cloudId %s", cloudId)); } sortByProviderId(allRecordRepresentationsInAllVersions); String dPId = null; for (Representation repVersion : allRecordRepresentationsInAllVersions) { removeFilesFromRepresentationVersion(cloudId, repVersion); removeRepresentationAssignmentFromDataSets(cloudId, repVersion); deleteRepresentationRevision(cloudId, repVersion); recordDAO.deleteRepresentation(cloudId, repVersion.getRepresentationName(), repVersion.getVersion()); } } else { throw new RecordNotExistsException(cloudId); } }
CassandraRecordService implements RecordService { @Override public void deleteRecord(String cloudId) throws RecordNotExistsException, RepresentationNotExistsException { if (uis.existsCloudId(cloudId)) { List<Representation> allRecordRepresentationsInAllVersions = recordDAO.listRepresentationVersions(cloudId); if (allRecordRepresentationsInAllVersions.isEmpty()) { throw new RepresentationNotExistsException(String.format( "No representation found for given cloudId %s", cloudId)); } sortByProviderId(allRecordRepresentationsInAllVersions); String dPId = null; for (Representation repVersion : allRecordRepresentationsInAllVersions) { removeFilesFromRepresentationVersion(cloudId, repVersion); removeRepresentationAssignmentFromDataSets(cloudId, repVersion); deleteRepresentationRevision(cloudId, repVersion); recordDAO.deleteRepresentation(cloudId, repVersion.getRepresentationName(), repVersion.getVersion()); } } else { throw new RecordNotExistsException(cloudId); } } }
CassandraRecordService implements RecordService { @Override public void deleteRecord(String cloudId) throws RecordNotExistsException, RepresentationNotExistsException { if (uis.existsCloudId(cloudId)) { List<Representation> allRecordRepresentationsInAllVersions = recordDAO.listRepresentationVersions(cloudId); if (allRecordRepresentationsInAllVersions.isEmpty()) { throw new RepresentationNotExistsException(String.format( "No representation found for given cloudId %s", cloudId)); } sortByProviderId(allRecordRepresentationsInAllVersions); String dPId = null; for (Representation repVersion : allRecordRepresentationsInAllVersions) { removeFilesFromRepresentationVersion(cloudId, repVersion); removeRepresentationAssignmentFromDataSets(cloudId, repVersion); deleteRepresentationRevision(cloudId, repVersion); recordDAO.deleteRepresentation(cloudId, repVersion.getRepresentationName(), repVersion.getVersion()); } } else { throw new RecordNotExistsException(cloudId); } } }
CassandraRecordService implements RecordService { @Override public void deleteRecord(String cloudId) throws RecordNotExistsException, RepresentationNotExistsException { if (uis.existsCloudId(cloudId)) { List<Representation> allRecordRepresentationsInAllVersions = recordDAO.listRepresentationVersions(cloudId); if (allRecordRepresentationsInAllVersions.isEmpty()) { throw new RepresentationNotExistsException(String.format( "No representation found for given cloudId %s", cloudId)); } sortByProviderId(allRecordRepresentationsInAllVersions); String dPId = null; for (Representation repVersion : allRecordRepresentationsInAllVersions) { removeFilesFromRepresentationVersion(cloudId, repVersion); removeRepresentationAssignmentFromDataSets(cloudId, repVersion); deleteRepresentationRevision(cloudId, repVersion); recordDAO.deleteRepresentation(cloudId, repVersion.getRepresentationName(), repVersion.getVersion()); } } else { throw new RecordNotExistsException(cloudId); } } @Override Record getRecord(String cloudId); @Override void deleteRecord(String cloudId); @Override void deleteRepresentation(String globalId, String schema); @Override Representation createRepresentation(String cloudId, String representationName, String providerId); @Override Representation getRepresentation(String globalId, String schema); @Override Representation getRepresentation(String globalId, String schema, String version); @Override void deleteRepresentation(String globalId, String schema, String version); @Override Representation persistRepresentation(String globalId, String schema, String version); @Override List<Representation> listRepresentationVersions(String globalId, String schema); @Override boolean putContent(String globalId, String schema, String version, File file, InputStream content); @Override Consumer<OutputStream> getContent(String globalId, String schema, String version, String fileName, long rangeStart, long rangeEnd); @Override String getContent(String globalId, String schema, String version, String fileName, OutputStream os); @Override void deleteContent(String globalId, String schema, String version, String fileName); @Override Representation copyRepresentation(String globalId, String schema, String version); @Override File getFile(String globalId, String schema, String version, String fileName); @Override void addRevision(String globalId, String schema, String version, Revision revision); @Override List<RepresentationRevisionResponse> getRepresentationRevisions(String globalId, String schema, String revisionProviderId, String revisionName, Date revisionTimestamp); @Override void insertRepresentationRevision(String globalId, String schema, String revisionProviderId, String revisionName, String versionId, Date revisionTimestamp); @Override Revision getRevision(String globalId, String schema, String version, String revisionKey); }
CassandraRecordService implements RecordService { @Override public void deleteRecord(String cloudId) throws RecordNotExistsException, RepresentationNotExistsException { if (uis.existsCloudId(cloudId)) { List<Representation> allRecordRepresentationsInAllVersions = recordDAO.listRepresentationVersions(cloudId); if (allRecordRepresentationsInAllVersions.isEmpty()) { throw new RepresentationNotExistsException(String.format( "No representation found for given cloudId %s", cloudId)); } sortByProviderId(allRecordRepresentationsInAllVersions); String dPId = null; for (Representation repVersion : allRecordRepresentationsInAllVersions) { removeFilesFromRepresentationVersion(cloudId, repVersion); removeRepresentationAssignmentFromDataSets(cloudId, repVersion); deleteRepresentationRevision(cloudId, repVersion); recordDAO.deleteRepresentation(cloudId, repVersion.getRepresentationName(), repVersion.getVersion()); } } else { throw new RecordNotExistsException(cloudId); } } @Override Record getRecord(String cloudId); @Override void deleteRecord(String cloudId); @Override void deleteRepresentation(String globalId, String schema); @Override Representation createRepresentation(String cloudId, String representationName, String providerId); @Override Representation getRepresentation(String globalId, String schema); @Override Representation getRepresentation(String globalId, String schema, String version); @Override void deleteRepresentation(String globalId, String schema, String version); @Override Representation persistRepresentation(String globalId, String schema, String version); @Override List<Representation> listRepresentationVersions(String globalId, String schema); @Override boolean putContent(String globalId, String schema, String version, File file, InputStream content); @Override Consumer<OutputStream> getContent(String globalId, String schema, String version, String fileName, long rangeStart, long rangeEnd); @Override String getContent(String globalId, String schema, String version, String fileName, OutputStream os); @Override void deleteContent(String globalId, String schema, String version, String fileName); @Override Representation copyRepresentation(String globalId, String schema, String version); @Override File getFile(String globalId, String schema, String version, String fileName); @Override void addRevision(String globalId, String schema, String version, Revision revision); @Override List<RepresentationRevisionResponse> getRepresentationRevisions(String globalId, String schema, String revisionProviderId, String revisionName, Date revisionTimestamp); @Override void insertRepresentationRevision(String globalId, String schema, String revisionProviderId, String revisionName, String versionId, Date revisionTimestamp); @Override Revision getRevision(String globalId, String schema, String version, String revisionKey); }
@Test public void shouldDeletePersistentRepresentation() throws Exception { makeUISSuccess(); mockUISProvider1Success(); Representation r = insertDummyPersistentRepresentation("globalId", "dc", PROVIDER_1_ID); cassandraRecordService.deleteRepresentation(r.getCloudId(), r.getRepresentationName(), r.getVersion()); }
@Override public void deleteRepresentation(String globalId, String schema) throws RepresentationNotExistsException { List<Representation> listRepresentations = recordDAO.listRepresentationVersions(globalId, schema); sortByProviderId(listRepresentations); String dPId = null; for (Representation rep : listRepresentations) { removeFilesFromRepresentationVersion(globalId, rep); removeRepresentationAssignmentFromDataSets(globalId, rep); deleteRepresentationRevision(globalId, rep); } recordDAO.deleteRepresentation(globalId, schema); }
CassandraRecordService implements RecordService { @Override public void deleteRepresentation(String globalId, String schema) throws RepresentationNotExistsException { List<Representation> listRepresentations = recordDAO.listRepresentationVersions(globalId, schema); sortByProviderId(listRepresentations); String dPId = null; for (Representation rep : listRepresentations) { removeFilesFromRepresentationVersion(globalId, rep); removeRepresentationAssignmentFromDataSets(globalId, rep); deleteRepresentationRevision(globalId, rep); } recordDAO.deleteRepresentation(globalId, schema); } }
CassandraRecordService implements RecordService { @Override public void deleteRepresentation(String globalId, String schema) throws RepresentationNotExistsException { List<Representation> listRepresentations = recordDAO.listRepresentationVersions(globalId, schema); sortByProviderId(listRepresentations); String dPId = null; for (Representation rep : listRepresentations) { removeFilesFromRepresentationVersion(globalId, rep); removeRepresentationAssignmentFromDataSets(globalId, rep); deleteRepresentationRevision(globalId, rep); } recordDAO.deleteRepresentation(globalId, schema); } }
CassandraRecordService implements RecordService { @Override public void deleteRepresentation(String globalId, String schema) throws RepresentationNotExistsException { List<Representation> listRepresentations = recordDAO.listRepresentationVersions(globalId, schema); sortByProviderId(listRepresentations); String dPId = null; for (Representation rep : listRepresentations) { removeFilesFromRepresentationVersion(globalId, rep); removeRepresentationAssignmentFromDataSets(globalId, rep); deleteRepresentationRevision(globalId, rep); } recordDAO.deleteRepresentation(globalId, schema); } @Override Record getRecord(String cloudId); @Override void deleteRecord(String cloudId); @Override void deleteRepresentation(String globalId, String schema); @Override Representation createRepresentation(String cloudId, String representationName, String providerId); @Override Representation getRepresentation(String globalId, String schema); @Override Representation getRepresentation(String globalId, String schema, String version); @Override void deleteRepresentation(String globalId, String schema, String version); @Override Representation persistRepresentation(String globalId, String schema, String version); @Override List<Representation> listRepresentationVersions(String globalId, String schema); @Override boolean putContent(String globalId, String schema, String version, File file, InputStream content); @Override Consumer<OutputStream> getContent(String globalId, String schema, String version, String fileName, long rangeStart, long rangeEnd); @Override String getContent(String globalId, String schema, String version, String fileName, OutputStream os); @Override void deleteContent(String globalId, String schema, String version, String fileName); @Override Representation copyRepresentation(String globalId, String schema, String version); @Override File getFile(String globalId, String schema, String version, String fileName); @Override void addRevision(String globalId, String schema, String version, Revision revision); @Override List<RepresentationRevisionResponse> getRepresentationRevisions(String globalId, String schema, String revisionProviderId, String revisionName, Date revisionTimestamp); @Override void insertRepresentationRevision(String globalId, String schema, String revisionProviderId, String revisionName, String versionId, Date revisionTimestamp); @Override Revision getRevision(String globalId, String schema, String version, String revisionKey); }
CassandraRecordService implements RecordService { @Override public void deleteRepresentation(String globalId, String schema) throws RepresentationNotExistsException { List<Representation> listRepresentations = recordDAO.listRepresentationVersions(globalId, schema); sortByProviderId(listRepresentations); String dPId = null; for (Representation rep : listRepresentations) { removeFilesFromRepresentationVersion(globalId, rep); removeRepresentationAssignmentFromDataSets(globalId, rep); deleteRepresentationRevision(globalId, rep); } recordDAO.deleteRepresentation(globalId, schema); } @Override Record getRecord(String cloudId); @Override void deleteRecord(String cloudId); @Override void deleteRepresentation(String globalId, String schema); @Override Representation createRepresentation(String cloudId, String representationName, String providerId); @Override Representation getRepresentation(String globalId, String schema); @Override Representation getRepresentation(String globalId, String schema, String version); @Override void deleteRepresentation(String globalId, String schema, String version); @Override Representation persistRepresentation(String globalId, String schema, String version); @Override List<Representation> listRepresentationVersions(String globalId, String schema); @Override boolean putContent(String globalId, String schema, String version, File file, InputStream content); @Override Consumer<OutputStream> getContent(String globalId, String schema, String version, String fileName, long rangeStart, long rangeEnd); @Override String getContent(String globalId, String schema, String version, String fileName, OutputStream os); @Override void deleteContent(String globalId, String schema, String version, String fileName); @Override Representation copyRepresentation(String globalId, String schema, String version); @Override File getFile(String globalId, String schema, String version, String fileName); @Override void addRevision(String globalId, String schema, String version, Revision revision); @Override List<RepresentationRevisionResponse> getRepresentationRevisions(String globalId, String schema, String revisionProviderId, String revisionName, Date revisionTimestamp); @Override void insertRepresentationRevision(String globalId, String schema, String revisionProviderId, String revisionName, String versionId, Date revisionTimestamp); @Override Revision getRevision(String globalId, String schema, String version, String revisionKey); }
@Test(expected = CannotModifyPersistentRepresentationException.class) public void shouldNotAddFileToPersistentRepresentation() throws Exception { makeUISSuccess(); mockUISProvider1Success(); Representation r = insertDummyPersistentRepresentation("globalId", "dc", PROVIDER_1_ID); byte[] dummyContent = {1, 2, 3}; File f = new File("content.xml", "application/xml", null, null, 0, null, OBJECT_STORAGE); cassandraRecordService.putContent(r.getCloudId(), r.getRepresentationName(), r.getVersion(), f, new ByteArrayInputStream(dummyContent)); }
@Override public boolean putContent(String globalId, String schema, String version, File file, InputStream content) throws CannotModifyPersistentRepresentationException, RepresentationNotExistsException { DateTime now = new DateTime(); Representation representation = getRepresentation(globalId, schema, version); if (representation.isPersistent()) { throw new CannotModifyPersistentRepresentationException(); } boolean isCreate = true; for (File f : representation.getFiles()) { if (f.getFileName().equals(file.getFileName())) { isCreate = false; break; } } String keyForFile = FileUtils.generateKeyForFile(globalId, schema, version, file.getFileName()); PutResult result; try { result = contentDAO.putContent(keyForFile, content, file.getFileStorage()); } catch (IOException ex) { throw new SystemException(ex); } file.setMd5(result.getMd5()); DateTimeFormatter fmt = ISODateTimeFormat.dateTime(); file.setDate(fmt.print(now)); file.setContentLength(result.getContentLength()); recordDAO.addOrReplaceFileInRepresentation(globalId, schema, version, file); for (Revision revision : representation.getRevisions()) { recordDAO.addOrReplaceFileInRepresentationRevision(globalId, schema, version, revision.getRevisionProviderId(), revision.getRevisionName(), revision.getCreationTimeStamp(), file); } return isCreate; }
CassandraRecordService implements RecordService { @Override public boolean putContent(String globalId, String schema, String version, File file, InputStream content) throws CannotModifyPersistentRepresentationException, RepresentationNotExistsException { DateTime now = new DateTime(); Representation representation = getRepresentation(globalId, schema, version); if (representation.isPersistent()) { throw new CannotModifyPersistentRepresentationException(); } boolean isCreate = true; for (File f : representation.getFiles()) { if (f.getFileName().equals(file.getFileName())) { isCreate = false; break; } } String keyForFile = FileUtils.generateKeyForFile(globalId, schema, version, file.getFileName()); PutResult result; try { result = contentDAO.putContent(keyForFile, content, file.getFileStorage()); } catch (IOException ex) { throw new SystemException(ex); } file.setMd5(result.getMd5()); DateTimeFormatter fmt = ISODateTimeFormat.dateTime(); file.setDate(fmt.print(now)); file.setContentLength(result.getContentLength()); recordDAO.addOrReplaceFileInRepresentation(globalId, schema, version, file); for (Revision revision : representation.getRevisions()) { recordDAO.addOrReplaceFileInRepresentationRevision(globalId, schema, version, revision.getRevisionProviderId(), revision.getRevisionName(), revision.getCreationTimeStamp(), file); } return isCreate; } }
CassandraRecordService implements RecordService { @Override public boolean putContent(String globalId, String schema, String version, File file, InputStream content) throws CannotModifyPersistentRepresentationException, RepresentationNotExistsException { DateTime now = new DateTime(); Representation representation = getRepresentation(globalId, schema, version); if (representation.isPersistent()) { throw new CannotModifyPersistentRepresentationException(); } boolean isCreate = true; for (File f : representation.getFiles()) { if (f.getFileName().equals(file.getFileName())) { isCreate = false; break; } } String keyForFile = FileUtils.generateKeyForFile(globalId, schema, version, file.getFileName()); PutResult result; try { result = contentDAO.putContent(keyForFile, content, file.getFileStorage()); } catch (IOException ex) { throw new SystemException(ex); } file.setMd5(result.getMd5()); DateTimeFormatter fmt = ISODateTimeFormat.dateTime(); file.setDate(fmt.print(now)); file.setContentLength(result.getContentLength()); recordDAO.addOrReplaceFileInRepresentation(globalId, schema, version, file); for (Revision revision : representation.getRevisions()) { recordDAO.addOrReplaceFileInRepresentationRevision(globalId, schema, version, revision.getRevisionProviderId(), revision.getRevisionName(), revision.getCreationTimeStamp(), file); } return isCreate; } }
CassandraRecordService implements RecordService { @Override public boolean putContent(String globalId, String schema, String version, File file, InputStream content) throws CannotModifyPersistentRepresentationException, RepresentationNotExistsException { DateTime now = new DateTime(); Representation representation = getRepresentation(globalId, schema, version); if (representation.isPersistent()) { throw new CannotModifyPersistentRepresentationException(); } boolean isCreate = true; for (File f : representation.getFiles()) { if (f.getFileName().equals(file.getFileName())) { isCreate = false; break; } } String keyForFile = FileUtils.generateKeyForFile(globalId, schema, version, file.getFileName()); PutResult result; try { result = contentDAO.putContent(keyForFile, content, file.getFileStorage()); } catch (IOException ex) { throw new SystemException(ex); } file.setMd5(result.getMd5()); DateTimeFormatter fmt = ISODateTimeFormat.dateTime(); file.setDate(fmt.print(now)); file.setContentLength(result.getContentLength()); recordDAO.addOrReplaceFileInRepresentation(globalId, schema, version, file); for (Revision revision : representation.getRevisions()) { recordDAO.addOrReplaceFileInRepresentationRevision(globalId, schema, version, revision.getRevisionProviderId(), revision.getRevisionName(), revision.getCreationTimeStamp(), file); } return isCreate; } @Override Record getRecord(String cloudId); @Override void deleteRecord(String cloudId); @Override void deleteRepresentation(String globalId, String schema); @Override Representation createRepresentation(String cloudId, String representationName, String providerId); @Override Representation getRepresentation(String globalId, String schema); @Override Representation getRepresentation(String globalId, String schema, String version); @Override void deleteRepresentation(String globalId, String schema, String version); @Override Representation persistRepresentation(String globalId, String schema, String version); @Override List<Representation> listRepresentationVersions(String globalId, String schema); @Override boolean putContent(String globalId, String schema, String version, File file, InputStream content); @Override Consumer<OutputStream> getContent(String globalId, String schema, String version, String fileName, long rangeStart, long rangeEnd); @Override String getContent(String globalId, String schema, String version, String fileName, OutputStream os); @Override void deleteContent(String globalId, String schema, String version, String fileName); @Override Representation copyRepresentation(String globalId, String schema, String version); @Override File getFile(String globalId, String schema, String version, String fileName); @Override void addRevision(String globalId, String schema, String version, Revision revision); @Override List<RepresentationRevisionResponse> getRepresentationRevisions(String globalId, String schema, String revisionProviderId, String revisionName, Date revisionTimestamp); @Override void insertRepresentationRevision(String globalId, String schema, String revisionProviderId, String revisionName, String versionId, Date revisionTimestamp); @Override Revision getRevision(String globalId, String schema, String version, String revisionKey); }
CassandraRecordService implements RecordService { @Override public boolean putContent(String globalId, String schema, String version, File file, InputStream content) throws CannotModifyPersistentRepresentationException, RepresentationNotExistsException { DateTime now = new DateTime(); Representation representation = getRepresentation(globalId, schema, version); if (representation.isPersistent()) { throw new CannotModifyPersistentRepresentationException(); } boolean isCreate = true; for (File f : representation.getFiles()) { if (f.getFileName().equals(file.getFileName())) { isCreate = false; break; } } String keyForFile = FileUtils.generateKeyForFile(globalId, schema, version, file.getFileName()); PutResult result; try { result = contentDAO.putContent(keyForFile, content, file.getFileStorage()); } catch (IOException ex) { throw new SystemException(ex); } file.setMd5(result.getMd5()); DateTimeFormatter fmt = ISODateTimeFormat.dateTime(); file.setDate(fmt.print(now)); file.setContentLength(result.getContentLength()); recordDAO.addOrReplaceFileInRepresentation(globalId, schema, version, file); for (Revision revision : representation.getRevisions()) { recordDAO.addOrReplaceFileInRepresentationRevision(globalId, schema, version, revision.getRevisionProviderId(), revision.getRevisionName(), revision.getCreationTimeStamp(), file); } return isCreate; } @Override Record getRecord(String cloudId); @Override void deleteRecord(String cloudId); @Override void deleteRepresentation(String globalId, String schema); @Override Representation createRepresentation(String cloudId, String representationName, String providerId); @Override Representation getRepresentation(String globalId, String schema); @Override Representation getRepresentation(String globalId, String schema, String version); @Override void deleteRepresentation(String globalId, String schema, String version); @Override Representation persistRepresentation(String globalId, String schema, String version); @Override List<Representation> listRepresentationVersions(String globalId, String schema); @Override boolean putContent(String globalId, String schema, String version, File file, InputStream content); @Override Consumer<OutputStream> getContent(String globalId, String schema, String version, String fileName, long rangeStart, long rangeEnd); @Override String getContent(String globalId, String schema, String version, String fileName, OutputStream os); @Override void deleteContent(String globalId, String schema, String version, String fileName); @Override Representation copyRepresentation(String globalId, String schema, String version); @Override File getFile(String globalId, String schema, String version, String fileName); @Override void addRevision(String globalId, String schema, String version, Revision revision); @Override List<RepresentationRevisionResponse> getRepresentationRevisions(String globalId, String schema, String revisionProviderId, String revisionName, Date revisionTimestamp); @Override void insertRepresentationRevision(String globalId, String schema, String revisionProviderId, String revisionName, String versionId, Date revisionTimestamp); @Override Revision getRevision(String globalId, String schema, String version, String revisionKey); }
@Test(expected = CannotModifyPersistentRepresentationException.class) public void shouldNotRemoveFileFromPersistentRepresentation() throws Exception { makeUISSuccess(); mockUISProvider1Success(); Representation r = insertDummyPersistentRepresentation("globalId", "dc", PROVIDER_1_ID); File f = r.getFiles().get(0); cassandraRecordService.deleteContent(r.getCloudId(), r.getRepresentationName(), r.getVersion(), f.getFileName()); }
@Override public void deleteContent(String globalId, String schema, String version, String fileName) throws FileNotExistsException, CannotModifyPersistentRepresentationException, RepresentationNotExistsException { Representation representation = getRepresentation(globalId, schema, version); if (representation.isPersistent()) { throw new CannotModifyPersistentRepresentationException(); } recordDAO.removeFileFromRepresentation(globalId, schema, version, fileName); recordDAO.removeFileFromRepresentationRevisionsTable(representation, fileName); File file = findFileInRepresentation(representation, fileName); contentDAO.deleteContent(FileUtils.generateKeyForFile(globalId, schema, version, fileName), file.getFileStorage()); }
CassandraRecordService implements RecordService { @Override public void deleteContent(String globalId, String schema, String version, String fileName) throws FileNotExistsException, CannotModifyPersistentRepresentationException, RepresentationNotExistsException { Representation representation = getRepresentation(globalId, schema, version); if (representation.isPersistent()) { throw new CannotModifyPersistentRepresentationException(); } recordDAO.removeFileFromRepresentation(globalId, schema, version, fileName); recordDAO.removeFileFromRepresentationRevisionsTable(representation, fileName); File file = findFileInRepresentation(representation, fileName); contentDAO.deleteContent(FileUtils.generateKeyForFile(globalId, schema, version, fileName), file.getFileStorage()); } }
CassandraRecordService implements RecordService { @Override public void deleteContent(String globalId, String schema, String version, String fileName) throws FileNotExistsException, CannotModifyPersistentRepresentationException, RepresentationNotExistsException { Representation representation = getRepresentation(globalId, schema, version); if (representation.isPersistent()) { throw new CannotModifyPersistentRepresentationException(); } recordDAO.removeFileFromRepresentation(globalId, schema, version, fileName); recordDAO.removeFileFromRepresentationRevisionsTable(representation, fileName); File file = findFileInRepresentation(representation, fileName); contentDAO.deleteContent(FileUtils.generateKeyForFile(globalId, schema, version, fileName), file.getFileStorage()); } }
CassandraRecordService implements RecordService { @Override public void deleteContent(String globalId, String schema, String version, String fileName) throws FileNotExistsException, CannotModifyPersistentRepresentationException, RepresentationNotExistsException { Representation representation = getRepresentation(globalId, schema, version); if (representation.isPersistent()) { throw new CannotModifyPersistentRepresentationException(); } recordDAO.removeFileFromRepresentation(globalId, schema, version, fileName); recordDAO.removeFileFromRepresentationRevisionsTable(representation, fileName); File file = findFileInRepresentation(representation, fileName); contentDAO.deleteContent(FileUtils.generateKeyForFile(globalId, schema, version, fileName), file.getFileStorage()); } @Override Record getRecord(String cloudId); @Override void deleteRecord(String cloudId); @Override void deleteRepresentation(String globalId, String schema); @Override Representation createRepresentation(String cloudId, String representationName, String providerId); @Override Representation getRepresentation(String globalId, String schema); @Override Representation getRepresentation(String globalId, String schema, String version); @Override void deleteRepresentation(String globalId, String schema, String version); @Override Representation persistRepresentation(String globalId, String schema, String version); @Override List<Representation> listRepresentationVersions(String globalId, String schema); @Override boolean putContent(String globalId, String schema, String version, File file, InputStream content); @Override Consumer<OutputStream> getContent(String globalId, String schema, String version, String fileName, long rangeStart, long rangeEnd); @Override String getContent(String globalId, String schema, String version, String fileName, OutputStream os); @Override void deleteContent(String globalId, String schema, String version, String fileName); @Override Representation copyRepresentation(String globalId, String schema, String version); @Override File getFile(String globalId, String schema, String version, String fileName); @Override void addRevision(String globalId, String schema, String version, Revision revision); @Override List<RepresentationRevisionResponse> getRepresentationRevisions(String globalId, String schema, String revisionProviderId, String revisionName, Date revisionTimestamp); @Override void insertRepresentationRevision(String globalId, String schema, String revisionProviderId, String revisionName, String versionId, Date revisionTimestamp); @Override Revision getRevision(String globalId, String schema, String version, String revisionKey); }
CassandraRecordService implements RecordService { @Override public void deleteContent(String globalId, String schema, String version, String fileName) throws FileNotExistsException, CannotModifyPersistentRepresentationException, RepresentationNotExistsException { Representation representation = getRepresentation(globalId, schema, version); if (representation.isPersistent()) { throw new CannotModifyPersistentRepresentationException(); } recordDAO.removeFileFromRepresentation(globalId, schema, version, fileName); recordDAO.removeFileFromRepresentationRevisionsTable(representation, fileName); File file = findFileInRepresentation(representation, fileName); contentDAO.deleteContent(FileUtils.generateKeyForFile(globalId, schema, version, fileName), file.getFileStorage()); } @Override Record getRecord(String cloudId); @Override void deleteRecord(String cloudId); @Override void deleteRepresentation(String globalId, String schema); @Override Representation createRepresentation(String cloudId, String representationName, String providerId); @Override Representation getRepresentation(String globalId, String schema); @Override Representation getRepresentation(String globalId, String schema, String version); @Override void deleteRepresentation(String globalId, String schema, String version); @Override Representation persistRepresentation(String globalId, String schema, String version); @Override List<Representation> listRepresentationVersions(String globalId, String schema); @Override boolean putContent(String globalId, String schema, String version, File file, InputStream content); @Override Consumer<OutputStream> getContent(String globalId, String schema, String version, String fileName, long rangeStart, long rangeEnd); @Override String getContent(String globalId, String schema, String version, String fileName, OutputStream os); @Override void deleteContent(String globalId, String schema, String version, String fileName); @Override Representation copyRepresentation(String globalId, String schema, String version); @Override File getFile(String globalId, String schema, String version, String fileName); @Override void addRevision(String globalId, String schema, String version, Revision revision); @Override List<RepresentationRevisionResponse> getRepresentationRevisions(String globalId, String schema, String revisionProviderId, String revisionName, Date revisionTimestamp); @Override void insertRepresentationRevision(String globalId, String schema, String revisionProviderId, String revisionName, String versionId, Date revisionTimestamp); @Override Revision getRevision(String globalId, String schema, String version, String revisionKey); }
@Test public void addRevision() throws Exception { makeUISSuccess(); mockUISProvider1Success(); Representation r = cassandraRecordService.createRepresentation( "globalId", "edm", PROVIDER_1_ID); Revision revision = new Revision(REVISION_NAME, REVISION_PROVIDER); cassandraRecordService.addRevision(r.getCloudId(), r.getRepresentationName(), r.getVersion(), revision); r = cassandraRecordService.getRepresentation(r.getCloudId(), r.getRepresentationName(), r.getVersion()); assertNotNull(r.getRevisions()); assertFalse(r.getRevisions().isEmpty()); assertEquals(r.getRevisions().size(), 1); }
@Override public void addRevision(String globalId, String schema, String version, Revision revision) throws RevisionIsNotValidException { recordDAO.addOrReplaceRevisionInRepresentation(globalId, schema, version, revision); }
CassandraRecordService implements RecordService { @Override public void addRevision(String globalId, String schema, String version, Revision revision) throws RevisionIsNotValidException { recordDAO.addOrReplaceRevisionInRepresentation(globalId, schema, version, revision); } }
CassandraRecordService implements RecordService { @Override public void addRevision(String globalId, String schema, String version, Revision revision) throws RevisionIsNotValidException { recordDAO.addOrReplaceRevisionInRepresentation(globalId, schema, version, revision); } }
CassandraRecordService implements RecordService { @Override public void addRevision(String globalId, String schema, String version, Revision revision) throws RevisionIsNotValidException { recordDAO.addOrReplaceRevisionInRepresentation(globalId, schema, version, revision); } @Override Record getRecord(String cloudId); @Override void deleteRecord(String cloudId); @Override void deleteRepresentation(String globalId, String schema); @Override Representation createRepresentation(String cloudId, String representationName, String providerId); @Override Representation getRepresentation(String globalId, String schema); @Override Representation getRepresentation(String globalId, String schema, String version); @Override void deleteRepresentation(String globalId, String schema, String version); @Override Representation persistRepresentation(String globalId, String schema, String version); @Override List<Representation> listRepresentationVersions(String globalId, String schema); @Override boolean putContent(String globalId, String schema, String version, File file, InputStream content); @Override Consumer<OutputStream> getContent(String globalId, String schema, String version, String fileName, long rangeStart, long rangeEnd); @Override String getContent(String globalId, String schema, String version, String fileName, OutputStream os); @Override void deleteContent(String globalId, String schema, String version, String fileName); @Override Representation copyRepresentation(String globalId, String schema, String version); @Override File getFile(String globalId, String schema, String version, String fileName); @Override void addRevision(String globalId, String schema, String version, Revision revision); @Override List<RepresentationRevisionResponse> getRepresentationRevisions(String globalId, String schema, String revisionProviderId, String revisionName, Date revisionTimestamp); @Override void insertRepresentationRevision(String globalId, String schema, String revisionProviderId, String revisionName, String versionId, Date revisionTimestamp); @Override Revision getRevision(String globalId, String schema, String version, String revisionKey); }
CassandraRecordService implements RecordService { @Override public void addRevision(String globalId, String schema, String version, Revision revision) throws RevisionIsNotValidException { recordDAO.addOrReplaceRevisionInRepresentation(globalId, schema, version, revision); } @Override Record getRecord(String cloudId); @Override void deleteRecord(String cloudId); @Override void deleteRepresentation(String globalId, String schema); @Override Representation createRepresentation(String cloudId, String representationName, String providerId); @Override Representation getRepresentation(String globalId, String schema); @Override Representation getRepresentation(String globalId, String schema, String version); @Override void deleteRepresentation(String globalId, String schema, String version); @Override Representation persistRepresentation(String globalId, String schema, String version); @Override List<Representation> listRepresentationVersions(String globalId, String schema); @Override boolean putContent(String globalId, String schema, String version, File file, InputStream content); @Override Consumer<OutputStream> getContent(String globalId, String schema, String version, String fileName, long rangeStart, long rangeEnd); @Override String getContent(String globalId, String schema, String version, String fileName, OutputStream os); @Override void deleteContent(String globalId, String schema, String version, String fileName); @Override Representation copyRepresentation(String globalId, String schema, String version); @Override File getFile(String globalId, String schema, String version, String fileName); @Override void addRevision(String globalId, String schema, String version, Revision revision); @Override List<RepresentationRevisionResponse> getRepresentationRevisions(String globalId, String schema, String revisionProviderId, String revisionName, Date revisionTimestamp); @Override void insertRepresentationRevision(String globalId, String schema, String revisionProviderId, String revisionName, String versionId, Date revisionTimestamp); @Override Revision getRevision(String globalId, String schema, String version, String revisionKey); }
@Test public void getRevision() throws Exception { makeUISSuccess(); mockUISProvider1Success(); Representation r = cassandraRecordService.createRepresentation( "globalId", "edm", PROVIDER_1_ID); Revision revision = new Revision(REVISION_NAME, REVISION_PROVIDER, new Date(), true, false, true); cassandraRecordService.addRevision(r.getCloudId(), r.getRepresentationName(), r.getVersion(), revision); String revisionKey = RevisionUtils.getRevisionKey(revision); Revision storedRevision = cassandraRecordService.getRevision(r.getCloudId(), r.getRepresentationName(), r.getVersion(), revisionKey); assertNotNull(storedRevision); assertThat(storedRevision, is(revision)); }
@Override public Revision getRevision(String globalId, String schema, String version, String revisionKey) throws RevisionNotExistsException, RepresentationNotExistsException { Representation rep = getRepresentation(globalId, schema, version); for (Revision revision : rep.getRevisions()) { if (revision != null) { if (RevisionUtils.getRevisionKey(revision).equals(revisionKey)) { return revision; } } } throw new RevisionNotExistsException(); }
CassandraRecordService implements RecordService { @Override public Revision getRevision(String globalId, String schema, String version, String revisionKey) throws RevisionNotExistsException, RepresentationNotExistsException { Representation rep = getRepresentation(globalId, schema, version); for (Revision revision : rep.getRevisions()) { if (revision != null) { if (RevisionUtils.getRevisionKey(revision).equals(revisionKey)) { return revision; } } } throw new RevisionNotExistsException(); } }
CassandraRecordService implements RecordService { @Override public Revision getRevision(String globalId, String schema, String version, String revisionKey) throws RevisionNotExistsException, RepresentationNotExistsException { Representation rep = getRepresentation(globalId, schema, version); for (Revision revision : rep.getRevisions()) { if (revision != null) { if (RevisionUtils.getRevisionKey(revision).equals(revisionKey)) { return revision; } } } throw new RevisionNotExistsException(); } }
CassandraRecordService implements RecordService { @Override public Revision getRevision(String globalId, String schema, String version, String revisionKey) throws RevisionNotExistsException, RepresentationNotExistsException { Representation rep = getRepresentation(globalId, schema, version); for (Revision revision : rep.getRevisions()) { if (revision != null) { if (RevisionUtils.getRevisionKey(revision).equals(revisionKey)) { return revision; } } } throw new RevisionNotExistsException(); } @Override Record getRecord(String cloudId); @Override void deleteRecord(String cloudId); @Override void deleteRepresentation(String globalId, String schema); @Override Representation createRepresentation(String cloudId, String representationName, String providerId); @Override Representation getRepresentation(String globalId, String schema); @Override Representation getRepresentation(String globalId, String schema, String version); @Override void deleteRepresentation(String globalId, String schema, String version); @Override Representation persistRepresentation(String globalId, String schema, String version); @Override List<Representation> listRepresentationVersions(String globalId, String schema); @Override boolean putContent(String globalId, String schema, String version, File file, InputStream content); @Override Consumer<OutputStream> getContent(String globalId, String schema, String version, String fileName, long rangeStart, long rangeEnd); @Override String getContent(String globalId, String schema, String version, String fileName, OutputStream os); @Override void deleteContent(String globalId, String schema, String version, String fileName); @Override Representation copyRepresentation(String globalId, String schema, String version); @Override File getFile(String globalId, String schema, String version, String fileName); @Override void addRevision(String globalId, String schema, String version, Revision revision); @Override List<RepresentationRevisionResponse> getRepresentationRevisions(String globalId, String schema, String revisionProviderId, String revisionName, Date revisionTimestamp); @Override void insertRepresentationRevision(String globalId, String schema, String revisionProviderId, String revisionName, String versionId, Date revisionTimestamp); @Override Revision getRevision(String globalId, String schema, String version, String revisionKey); }
CassandraRecordService implements RecordService { @Override public Revision getRevision(String globalId, String schema, String version, String revisionKey) throws RevisionNotExistsException, RepresentationNotExistsException { Representation rep = getRepresentation(globalId, schema, version); for (Revision revision : rep.getRevisions()) { if (revision != null) { if (RevisionUtils.getRevisionKey(revision).equals(revisionKey)) { return revision; } } } throw new RevisionNotExistsException(); } @Override Record getRecord(String cloudId); @Override void deleteRecord(String cloudId); @Override void deleteRepresentation(String globalId, String schema); @Override Representation createRepresentation(String cloudId, String representationName, String providerId); @Override Representation getRepresentation(String globalId, String schema); @Override Representation getRepresentation(String globalId, String schema, String version); @Override void deleteRepresentation(String globalId, String schema, String version); @Override Representation persistRepresentation(String globalId, String schema, String version); @Override List<Representation> listRepresentationVersions(String globalId, String schema); @Override boolean putContent(String globalId, String schema, String version, File file, InputStream content); @Override Consumer<OutputStream> getContent(String globalId, String schema, String version, String fileName, long rangeStart, long rangeEnd); @Override String getContent(String globalId, String schema, String version, String fileName, OutputStream os); @Override void deleteContent(String globalId, String schema, String version, String fileName); @Override Representation copyRepresentation(String globalId, String schema, String version); @Override File getFile(String globalId, String schema, String version, String fileName); @Override void addRevision(String globalId, String schema, String version, Revision revision); @Override List<RepresentationRevisionResponse> getRepresentationRevisions(String globalId, String schema, String revisionProviderId, String revisionName, Date revisionTimestamp); @Override void insertRepresentationRevision(String globalId, String schema, String revisionProviderId, String revisionName, String versionId, Date revisionTimestamp); @Override Revision getRevision(String globalId, String schema, String version, String revisionKey); }
@Test(expected = RepresentationNotExistsException.class) public void getRevisionFromNonExistedRepresentation() throws Exception { makeUISSuccess(); mockUISProvider1Success(); String revisionKey = RevisionUtils.getRevisionKey(REVISION_PROVIDER, REVISION_NAME, new Date().getTime()); cassandraRecordService.getRevision("globalId", "not_existing_schema", "5573dbf0-5979-11e6-9061-1c6f653f9042", revisionKey); }
@Override public Revision getRevision(String globalId, String schema, String version, String revisionKey) throws RevisionNotExistsException, RepresentationNotExistsException { Representation rep = getRepresentation(globalId, schema, version); for (Revision revision : rep.getRevisions()) { if (revision != null) { if (RevisionUtils.getRevisionKey(revision).equals(revisionKey)) { return revision; } } } throw new RevisionNotExistsException(); }
CassandraRecordService implements RecordService { @Override public Revision getRevision(String globalId, String schema, String version, String revisionKey) throws RevisionNotExistsException, RepresentationNotExistsException { Representation rep = getRepresentation(globalId, schema, version); for (Revision revision : rep.getRevisions()) { if (revision != null) { if (RevisionUtils.getRevisionKey(revision).equals(revisionKey)) { return revision; } } } throw new RevisionNotExistsException(); } }
CassandraRecordService implements RecordService { @Override public Revision getRevision(String globalId, String schema, String version, String revisionKey) throws RevisionNotExistsException, RepresentationNotExistsException { Representation rep = getRepresentation(globalId, schema, version); for (Revision revision : rep.getRevisions()) { if (revision != null) { if (RevisionUtils.getRevisionKey(revision).equals(revisionKey)) { return revision; } } } throw new RevisionNotExistsException(); } }
CassandraRecordService implements RecordService { @Override public Revision getRevision(String globalId, String schema, String version, String revisionKey) throws RevisionNotExistsException, RepresentationNotExistsException { Representation rep = getRepresentation(globalId, schema, version); for (Revision revision : rep.getRevisions()) { if (revision != null) { if (RevisionUtils.getRevisionKey(revision).equals(revisionKey)) { return revision; } } } throw new RevisionNotExistsException(); } @Override Record getRecord(String cloudId); @Override void deleteRecord(String cloudId); @Override void deleteRepresentation(String globalId, String schema); @Override Representation createRepresentation(String cloudId, String representationName, String providerId); @Override Representation getRepresentation(String globalId, String schema); @Override Representation getRepresentation(String globalId, String schema, String version); @Override void deleteRepresentation(String globalId, String schema, String version); @Override Representation persistRepresentation(String globalId, String schema, String version); @Override List<Representation> listRepresentationVersions(String globalId, String schema); @Override boolean putContent(String globalId, String schema, String version, File file, InputStream content); @Override Consumer<OutputStream> getContent(String globalId, String schema, String version, String fileName, long rangeStart, long rangeEnd); @Override String getContent(String globalId, String schema, String version, String fileName, OutputStream os); @Override void deleteContent(String globalId, String schema, String version, String fileName); @Override Representation copyRepresentation(String globalId, String schema, String version); @Override File getFile(String globalId, String schema, String version, String fileName); @Override void addRevision(String globalId, String schema, String version, Revision revision); @Override List<RepresentationRevisionResponse> getRepresentationRevisions(String globalId, String schema, String revisionProviderId, String revisionName, Date revisionTimestamp); @Override void insertRepresentationRevision(String globalId, String schema, String revisionProviderId, String revisionName, String versionId, Date revisionTimestamp); @Override Revision getRevision(String globalId, String schema, String version, String revisionKey); }
CassandraRecordService implements RecordService { @Override public Revision getRevision(String globalId, String schema, String version, String revisionKey) throws RevisionNotExistsException, RepresentationNotExistsException { Representation rep = getRepresentation(globalId, schema, version); for (Revision revision : rep.getRevisions()) { if (revision != null) { if (RevisionUtils.getRevisionKey(revision).equals(revisionKey)) { return revision; } } } throw new RevisionNotExistsException(); } @Override Record getRecord(String cloudId); @Override void deleteRecord(String cloudId); @Override void deleteRepresentation(String globalId, String schema); @Override Representation createRepresentation(String cloudId, String representationName, String providerId); @Override Representation getRepresentation(String globalId, String schema); @Override Representation getRepresentation(String globalId, String schema, String version); @Override void deleteRepresentation(String globalId, String schema, String version); @Override Representation persistRepresentation(String globalId, String schema, String version); @Override List<Representation> listRepresentationVersions(String globalId, String schema); @Override boolean putContent(String globalId, String schema, String version, File file, InputStream content); @Override Consumer<OutputStream> getContent(String globalId, String schema, String version, String fileName, long rangeStart, long rangeEnd); @Override String getContent(String globalId, String schema, String version, String fileName, OutputStream os); @Override void deleteContent(String globalId, String schema, String version, String fileName); @Override Representation copyRepresentation(String globalId, String schema, String version); @Override File getFile(String globalId, String schema, String version, String fileName); @Override void addRevision(String globalId, String schema, String version, Revision revision); @Override List<RepresentationRevisionResponse> getRepresentationRevisions(String globalId, String schema, String revisionProviderId, String revisionName, Date revisionTimestamp); @Override void insertRepresentationRevision(String globalId, String schema, String revisionProviderId, String revisionName, String versionId, Date revisionTimestamp); @Override Revision getRevision(String globalId, String schema, String version, String revisionKey); }
@Test @Parameters(method = "listDatasetParams") public void shouldListDataSet(String threshold, int limit, String nextSlice, int fromIndex, int toIndex) throws Exception { ResultSlice<Representation> actual = dataSetService.listDataSet(providerId, dataSetId, threshold, limit); assertThat("Next slice should be equal '" + nextSlice + "' but was '" + actual.getNextSlice() + "'", actual.getNextSlice(), equalTo(nextSlice)); assertThat("Lists of representations are not equal", actual.getResults(), equalTo(representations.subList(fromIndex, toIndex))); }
@Override public ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit) throws DataSetNotExistsException { int treshold = 0; if (thresholdParam != null) { treshold = parseInteger(thresholdParam); } List<Representation> listOfAllStubs = dataSetDAO.listDataSet(providerId, dataSetId); if (listOfAllStubs.size() != 0 && treshold >= listOfAllStubs.size()) { throw new IllegalArgumentException("Illegal threshold param value: '" + thresholdParam + "'."); } int newOffset = -1; List<Representation> listOfStubs = listOfAllStubs; if (limit > 0) { listOfStubs = listOfAllStubs.subList(treshold, Math.min(treshold + limit, listOfAllStubs.size())); if (listOfAllStubs.size() > treshold + limit) { newOffset = treshold + limit; } } List<Representation> toReturn = new ArrayList<>(listOfStubs.size()); for (Representation stub : listOfStubs) { Representation realContent; try { realContent = recordDAO.getRepresentation(stub.getCloudId(), stub.getRepresentationName(), stub.getVersion()); } catch (RepresentationNotExistsException e) { continue; } toReturn.add(realContent); } return newOffset == -1 ? new ResultSlice<>(null, toReturn) : new ResultSlice<>(Integer.toString(newOffset), toReturn); }
InMemoryDataSetService implements DataSetService { @Override public ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit) throws DataSetNotExistsException { int treshold = 0; if (thresholdParam != null) { treshold = parseInteger(thresholdParam); } List<Representation> listOfAllStubs = dataSetDAO.listDataSet(providerId, dataSetId); if (listOfAllStubs.size() != 0 && treshold >= listOfAllStubs.size()) { throw new IllegalArgumentException("Illegal threshold param value: '" + thresholdParam + "'."); } int newOffset = -1; List<Representation> listOfStubs = listOfAllStubs; if (limit > 0) { listOfStubs = listOfAllStubs.subList(treshold, Math.min(treshold + limit, listOfAllStubs.size())); if (listOfAllStubs.size() > treshold + limit) { newOffset = treshold + limit; } } List<Representation> toReturn = new ArrayList<>(listOfStubs.size()); for (Representation stub : listOfStubs) { Representation realContent; try { realContent = recordDAO.getRepresentation(stub.getCloudId(), stub.getRepresentationName(), stub.getVersion()); } catch (RepresentationNotExistsException e) { continue; } toReturn.add(realContent); } return newOffset == -1 ? new ResultSlice<>(null, toReturn) : new ResultSlice<>(Integer.toString(newOffset), toReturn); } }
InMemoryDataSetService implements DataSetService { @Override public ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit) throws DataSetNotExistsException { int treshold = 0; if (thresholdParam != null) { treshold = parseInteger(thresholdParam); } List<Representation> listOfAllStubs = dataSetDAO.listDataSet(providerId, dataSetId); if (listOfAllStubs.size() != 0 && treshold >= listOfAllStubs.size()) { throw new IllegalArgumentException("Illegal threshold param value: '" + thresholdParam + "'."); } int newOffset = -1; List<Representation> listOfStubs = listOfAllStubs; if (limit > 0) { listOfStubs = listOfAllStubs.subList(treshold, Math.min(treshold + limit, listOfAllStubs.size())); if (listOfAllStubs.size() > treshold + limit) { newOffset = treshold + limit; } } List<Representation> toReturn = new ArrayList<>(listOfStubs.size()); for (Representation stub : listOfStubs) { Representation realContent; try { realContent = recordDAO.getRepresentation(stub.getCloudId(), stub.getRepresentationName(), stub.getVersion()); } catch (RepresentationNotExistsException e) { continue; } toReturn.add(realContent); } return newOffset == -1 ? new ResultSlice<>(null, toReturn) : new ResultSlice<>(Integer.toString(newOffset), toReturn); } InMemoryDataSetService(InMemoryDataSetDAO dataSetDAO, InMemoryRecordDAO recordDAO, UISClientHandler dataProviderDao); InMemoryDataSetService(); }
InMemoryDataSetService implements DataSetService { @Override public ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit) throws DataSetNotExistsException { int treshold = 0; if (thresholdParam != null) { treshold = parseInteger(thresholdParam); } List<Representation> listOfAllStubs = dataSetDAO.listDataSet(providerId, dataSetId); if (listOfAllStubs.size() != 0 && treshold >= listOfAllStubs.size()) { throw new IllegalArgumentException("Illegal threshold param value: '" + thresholdParam + "'."); } int newOffset = -1; List<Representation> listOfStubs = listOfAllStubs; if (limit > 0) { listOfStubs = listOfAllStubs.subList(treshold, Math.min(treshold + limit, listOfAllStubs.size())); if (listOfAllStubs.size() > treshold + limit) { newOffset = treshold + limit; } } List<Representation> toReturn = new ArrayList<>(listOfStubs.size()); for (Representation stub : listOfStubs) { Representation realContent; try { realContent = recordDAO.getRepresentation(stub.getCloudId(), stub.getRepresentationName(), stub.getVersion()); } catch (RepresentationNotExistsException e) { continue; } toReturn.add(realContent); } return newOffset == -1 ? new ResultSlice<>(null, toReturn) : new ResultSlice<>(Integer.toString(newOffset), toReturn); } InMemoryDataSetService(InMemoryDataSetDAO dataSetDAO, InMemoryRecordDAO recordDAO, UISClientHandler dataProviderDao); InMemoryDataSetService(); @Override ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit); @Override void addAssignment(String providerId, String dataSetId, String recordId, String schema, String version); @Override void removeAssignment(String providerId, String dataSetId, String recordId, String schema); @Override DataSet createDataSet(String providerId, String dataSetId, String description); @Override ResultSlice<DataSet> getDataSets(String providerId, String thresholdDatasetId, int limit); @Override void deleteDataSet(String providerId, String dataSetId); @Override DataSet updateDataSet(String providerId, String dataSetId, String description); }
InMemoryDataSetService implements DataSetService { @Override public ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit) throws DataSetNotExistsException { int treshold = 0; if (thresholdParam != null) { treshold = parseInteger(thresholdParam); } List<Representation> listOfAllStubs = dataSetDAO.listDataSet(providerId, dataSetId); if (listOfAllStubs.size() != 0 && treshold >= listOfAllStubs.size()) { throw new IllegalArgumentException("Illegal threshold param value: '" + thresholdParam + "'."); } int newOffset = -1; List<Representation> listOfStubs = listOfAllStubs; if (limit > 0) { listOfStubs = listOfAllStubs.subList(treshold, Math.min(treshold + limit, listOfAllStubs.size())); if (listOfAllStubs.size() > treshold + limit) { newOffset = treshold + limit; } } List<Representation> toReturn = new ArrayList<>(listOfStubs.size()); for (Representation stub : listOfStubs) { Representation realContent; try { realContent = recordDAO.getRepresentation(stub.getCloudId(), stub.getRepresentationName(), stub.getVersion()); } catch (RepresentationNotExistsException e) { continue; } toReturn.add(realContent); } return newOffset == -1 ? new ResultSlice<>(null, toReturn) : new ResultSlice<>(Integer.toString(newOffset), toReturn); } InMemoryDataSetService(InMemoryDataSetDAO dataSetDAO, InMemoryRecordDAO recordDAO, UISClientHandler dataProviderDao); InMemoryDataSetService(); @Override ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit); @Override void addAssignment(String providerId, String dataSetId, String recordId, String schema, String version); @Override void removeAssignment(String providerId, String dataSetId, String recordId, String schema); @Override DataSet createDataSet(String providerId, String dataSetId, String description); @Override ResultSlice<DataSet> getDataSets(String providerId, String thresholdDatasetId, int limit); @Override void deleteDataSet(String providerId, String dataSetId); @Override DataSet updateDataSet(String providerId, String dataSetId, String description); }
@Test public void shouldListEmptyDataSet() throws Exception { when(datasetDao.listDataSet(providerId, dataSetId)).thenReturn(new ArrayList<Representation>()); InMemoryRecordDAO recordDao = new InMemoryRecordListDAO(new ArrayList<Representation>()); dataSetService = new InMemoryDataSetService(datasetDao, recordDao, uisHandler); ResultSlice<Representation> actual = dataSetService.listDataSet(providerId, dataSetId, null, 100); assertThat("Next slice should be null, but was '" + actual.getNextSlice() + "'", actual.getNextSlice(), nullValue()); assertTrue("List of representations should be empty, but was: " + actual.getResults(), actual.getResults() .isEmpty()); }
@Override public ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit) throws DataSetNotExistsException { int treshold = 0; if (thresholdParam != null) { treshold = parseInteger(thresholdParam); } List<Representation> listOfAllStubs = dataSetDAO.listDataSet(providerId, dataSetId); if (listOfAllStubs.size() != 0 && treshold >= listOfAllStubs.size()) { throw new IllegalArgumentException("Illegal threshold param value: '" + thresholdParam + "'."); } int newOffset = -1; List<Representation> listOfStubs = listOfAllStubs; if (limit > 0) { listOfStubs = listOfAllStubs.subList(treshold, Math.min(treshold + limit, listOfAllStubs.size())); if (listOfAllStubs.size() > treshold + limit) { newOffset = treshold + limit; } } List<Representation> toReturn = new ArrayList<>(listOfStubs.size()); for (Representation stub : listOfStubs) { Representation realContent; try { realContent = recordDAO.getRepresentation(stub.getCloudId(), stub.getRepresentationName(), stub.getVersion()); } catch (RepresentationNotExistsException e) { continue; } toReturn.add(realContent); } return newOffset == -1 ? new ResultSlice<>(null, toReturn) : new ResultSlice<>(Integer.toString(newOffset), toReturn); }
InMemoryDataSetService implements DataSetService { @Override public ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit) throws DataSetNotExistsException { int treshold = 0; if (thresholdParam != null) { treshold = parseInteger(thresholdParam); } List<Representation> listOfAllStubs = dataSetDAO.listDataSet(providerId, dataSetId); if (listOfAllStubs.size() != 0 && treshold >= listOfAllStubs.size()) { throw new IllegalArgumentException("Illegal threshold param value: '" + thresholdParam + "'."); } int newOffset = -1; List<Representation> listOfStubs = listOfAllStubs; if (limit > 0) { listOfStubs = listOfAllStubs.subList(treshold, Math.min(treshold + limit, listOfAllStubs.size())); if (listOfAllStubs.size() > treshold + limit) { newOffset = treshold + limit; } } List<Representation> toReturn = new ArrayList<>(listOfStubs.size()); for (Representation stub : listOfStubs) { Representation realContent; try { realContent = recordDAO.getRepresentation(stub.getCloudId(), stub.getRepresentationName(), stub.getVersion()); } catch (RepresentationNotExistsException e) { continue; } toReturn.add(realContent); } return newOffset == -1 ? new ResultSlice<>(null, toReturn) : new ResultSlice<>(Integer.toString(newOffset), toReturn); } }
InMemoryDataSetService implements DataSetService { @Override public ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit) throws DataSetNotExistsException { int treshold = 0; if (thresholdParam != null) { treshold = parseInteger(thresholdParam); } List<Representation> listOfAllStubs = dataSetDAO.listDataSet(providerId, dataSetId); if (listOfAllStubs.size() != 0 && treshold >= listOfAllStubs.size()) { throw new IllegalArgumentException("Illegal threshold param value: '" + thresholdParam + "'."); } int newOffset = -1; List<Representation> listOfStubs = listOfAllStubs; if (limit > 0) { listOfStubs = listOfAllStubs.subList(treshold, Math.min(treshold + limit, listOfAllStubs.size())); if (listOfAllStubs.size() > treshold + limit) { newOffset = treshold + limit; } } List<Representation> toReturn = new ArrayList<>(listOfStubs.size()); for (Representation stub : listOfStubs) { Representation realContent; try { realContent = recordDAO.getRepresentation(stub.getCloudId(), stub.getRepresentationName(), stub.getVersion()); } catch (RepresentationNotExistsException e) { continue; } toReturn.add(realContent); } return newOffset == -1 ? new ResultSlice<>(null, toReturn) : new ResultSlice<>(Integer.toString(newOffset), toReturn); } InMemoryDataSetService(InMemoryDataSetDAO dataSetDAO, InMemoryRecordDAO recordDAO, UISClientHandler dataProviderDao); InMemoryDataSetService(); }
InMemoryDataSetService implements DataSetService { @Override public ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit) throws DataSetNotExistsException { int treshold = 0; if (thresholdParam != null) { treshold = parseInteger(thresholdParam); } List<Representation> listOfAllStubs = dataSetDAO.listDataSet(providerId, dataSetId); if (listOfAllStubs.size() != 0 && treshold >= listOfAllStubs.size()) { throw new IllegalArgumentException("Illegal threshold param value: '" + thresholdParam + "'."); } int newOffset = -1; List<Representation> listOfStubs = listOfAllStubs; if (limit > 0) { listOfStubs = listOfAllStubs.subList(treshold, Math.min(treshold + limit, listOfAllStubs.size())); if (listOfAllStubs.size() > treshold + limit) { newOffset = treshold + limit; } } List<Representation> toReturn = new ArrayList<>(listOfStubs.size()); for (Representation stub : listOfStubs) { Representation realContent; try { realContent = recordDAO.getRepresentation(stub.getCloudId(), stub.getRepresentationName(), stub.getVersion()); } catch (RepresentationNotExistsException e) { continue; } toReturn.add(realContent); } return newOffset == -1 ? new ResultSlice<>(null, toReturn) : new ResultSlice<>(Integer.toString(newOffset), toReturn); } InMemoryDataSetService(InMemoryDataSetDAO dataSetDAO, InMemoryRecordDAO recordDAO, UISClientHandler dataProviderDao); InMemoryDataSetService(); @Override ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit); @Override void addAssignment(String providerId, String dataSetId, String recordId, String schema, String version); @Override void removeAssignment(String providerId, String dataSetId, String recordId, String schema); @Override DataSet createDataSet(String providerId, String dataSetId, String description); @Override ResultSlice<DataSet> getDataSets(String providerId, String thresholdDatasetId, int limit); @Override void deleteDataSet(String providerId, String dataSetId); @Override DataSet updateDataSet(String providerId, String dataSetId, String description); }
InMemoryDataSetService implements DataSetService { @Override public ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit) throws DataSetNotExistsException { int treshold = 0; if (thresholdParam != null) { treshold = parseInteger(thresholdParam); } List<Representation> listOfAllStubs = dataSetDAO.listDataSet(providerId, dataSetId); if (listOfAllStubs.size() != 0 && treshold >= listOfAllStubs.size()) { throw new IllegalArgumentException("Illegal threshold param value: '" + thresholdParam + "'."); } int newOffset = -1; List<Representation> listOfStubs = listOfAllStubs; if (limit > 0) { listOfStubs = listOfAllStubs.subList(treshold, Math.min(treshold + limit, listOfAllStubs.size())); if (listOfAllStubs.size() > treshold + limit) { newOffset = treshold + limit; } } List<Representation> toReturn = new ArrayList<>(listOfStubs.size()); for (Representation stub : listOfStubs) { Representation realContent; try { realContent = recordDAO.getRepresentation(stub.getCloudId(), stub.getRepresentationName(), stub.getVersion()); } catch (RepresentationNotExistsException e) { continue; } toReturn.add(realContent); } return newOffset == -1 ? new ResultSlice<>(null, toReturn) : new ResultSlice<>(Integer.toString(newOffset), toReturn); } InMemoryDataSetService(InMemoryDataSetDAO dataSetDAO, InMemoryRecordDAO recordDAO, UISClientHandler dataProviderDao); InMemoryDataSetService(); @Override ResultSlice<Representation> listDataSet(String providerId, String dataSetId, String thresholdParam, int limit); @Override void addAssignment(String providerId, String dataSetId, String recordId, String schema, String version); @Override void removeAssignment(String providerId, String dataSetId, String recordId, String schema); @Override DataSet createDataSet(String providerId, String dataSetId, String description); @Override ResultSlice<DataSet> getDataSets(String providerId, String thresholdDatasetId, int limit); @Override void deleteDataSet(String providerId, String dataSetId); @Override DataSet updateDataSet(String providerId, String dataSetId, String description); }
@Test @Parameters(method = "searchRepresentatonsParams") public void shouldSearchRepresentations(String threshold, int limit, int fromIndex, int toIndex, String nextSlice) { List<Representation> representations = createRepresentations(5, PROVIDER_ID, SCHEMA); when(recordDAO.findRepresentations(PROVIDER_ID, SCHEMA)).thenReturn(representations); InMemoryRecordService recordService = new InMemoryRecordService(recordDAO, null, null, null); RepresentationSearchParams searchParams = RepresentationSearchParams.builder().setDataProvider(PROVIDER_ID) .setSchema(SCHEMA).build(); ResultSlice<Representation> actual = recordService.search(searchParams, threshold, limit); assertEquals("List of representations are not equal. ", representations.subList(fromIndex, toIndex), actual.getResults()); assertEquals("Next slice ", actual.getNextSlice(), nextSlice); }
public ResultSlice<Representation> search(RepresentationSearchParams searchParams, String thresholdParam, int limit) { int threshold = 0; if (thresholdParam != null) { threshold = parseInteger(thresholdParam); } String providerId = searchParams.getDataProvider(); String schema = searchParams.getSchema(); String dataSetId = searchParams.getDataSetId(); List<Representation> allRecords; if (providerId != null && dataSetId != null) { List<Representation> toReturn = new ArrayList<>(); try { List<Representation> representationStubs = dataSetDAO.listDataSet(providerId, dataSetId); for (Representation stub : representationStubs) { if (schema == null || schema.equals(stub.getRepresentationName())) { Representation realContent; try { realContent = recordDAO.getRepresentation(stub.getCloudId(), stub.getRepresentationName(), stub.getVersion()); toReturn.add(realContent); } catch (RepresentationNotExistsException ex) { } } } } catch (DataSetNotExistsException ex) { allRecords = Collections.emptyList(); } allRecords = toReturn; } else { allRecords = recordDAO.findRepresentations(providerId, schema); } if (allRecords.size() != 0 && threshold >= allRecords.size()) { throw new IllegalArgumentException("Illegal threshold param value: '" + thresholdParam + "'."); } return prepareResultSlice(limit, threshold, allRecords); }
InMemoryRecordService implements RecordService { public ResultSlice<Representation> search(RepresentationSearchParams searchParams, String thresholdParam, int limit) { int threshold = 0; if (thresholdParam != null) { threshold = parseInteger(thresholdParam); } String providerId = searchParams.getDataProvider(); String schema = searchParams.getSchema(); String dataSetId = searchParams.getDataSetId(); List<Representation> allRecords; if (providerId != null && dataSetId != null) { List<Representation> toReturn = new ArrayList<>(); try { List<Representation> representationStubs = dataSetDAO.listDataSet(providerId, dataSetId); for (Representation stub : representationStubs) { if (schema == null || schema.equals(stub.getRepresentationName())) { Representation realContent; try { realContent = recordDAO.getRepresentation(stub.getCloudId(), stub.getRepresentationName(), stub.getVersion()); toReturn.add(realContent); } catch (RepresentationNotExistsException ex) { } } } } catch (DataSetNotExistsException ex) { allRecords = Collections.emptyList(); } allRecords = toReturn; } else { allRecords = recordDAO.findRepresentations(providerId, schema); } if (allRecords.size() != 0 && threshold >= allRecords.size()) { throw new IllegalArgumentException("Illegal threshold param value: '" + thresholdParam + "'."); } return prepareResultSlice(limit, threshold, allRecords); } }
InMemoryRecordService implements RecordService { public ResultSlice<Representation> search(RepresentationSearchParams searchParams, String thresholdParam, int limit) { int threshold = 0; if (thresholdParam != null) { threshold = parseInteger(thresholdParam); } String providerId = searchParams.getDataProvider(); String schema = searchParams.getSchema(); String dataSetId = searchParams.getDataSetId(); List<Representation> allRecords; if (providerId != null && dataSetId != null) { List<Representation> toReturn = new ArrayList<>(); try { List<Representation> representationStubs = dataSetDAO.listDataSet(providerId, dataSetId); for (Representation stub : representationStubs) { if (schema == null || schema.equals(stub.getRepresentationName())) { Representation realContent; try { realContent = recordDAO.getRepresentation(stub.getCloudId(), stub.getRepresentationName(), stub.getVersion()); toReturn.add(realContent); } catch (RepresentationNotExistsException ex) { } } } } catch (DataSetNotExistsException ex) { allRecords = Collections.emptyList(); } allRecords = toReturn; } else { allRecords = recordDAO.findRepresentations(providerId, schema); } if (allRecords.size() != 0 && threshold >= allRecords.size()) { throw new IllegalArgumentException("Illegal threshold param value: '" + thresholdParam + "'."); } return prepareResultSlice(limit, threshold, allRecords); } InMemoryRecordService(); InMemoryRecordService(InMemoryRecordDAO recordDAO, InMemoryContentDAO contentDAO, InMemoryDataSetDAO dataSetDAO, UISClientHandler uisHandler); }
InMemoryRecordService implements RecordService { public ResultSlice<Representation> search(RepresentationSearchParams searchParams, String thresholdParam, int limit) { int threshold = 0; if (thresholdParam != null) { threshold = parseInteger(thresholdParam); } String providerId = searchParams.getDataProvider(); String schema = searchParams.getSchema(); String dataSetId = searchParams.getDataSetId(); List<Representation> allRecords; if (providerId != null && dataSetId != null) { List<Representation> toReturn = new ArrayList<>(); try { List<Representation> representationStubs = dataSetDAO.listDataSet(providerId, dataSetId); for (Representation stub : representationStubs) { if (schema == null || schema.equals(stub.getRepresentationName())) { Representation realContent; try { realContent = recordDAO.getRepresentation(stub.getCloudId(), stub.getRepresentationName(), stub.getVersion()); toReturn.add(realContent); } catch (RepresentationNotExistsException ex) { } } } } catch (DataSetNotExistsException ex) { allRecords = Collections.emptyList(); } allRecords = toReturn; } else { allRecords = recordDAO.findRepresentations(providerId, schema); } if (allRecords.size() != 0 && threshold >= allRecords.size()) { throw new IllegalArgumentException("Illegal threshold param value: '" + thresholdParam + "'."); } return prepareResultSlice(limit, threshold, allRecords); } InMemoryRecordService(); InMemoryRecordService(InMemoryRecordDAO recordDAO, InMemoryContentDAO contentDAO, InMemoryDataSetDAO dataSetDAO, UISClientHandler uisHandler); @Override Record getRecord(String globalId); @Override void deleteRecord(String globalId); @Override void deleteRepresentation(String globalId, String schema); @Override Representation createRepresentation(String globalId, String representationName, String providerId); @Override Representation getRepresentation(String globalId, String schema); @Override Representation getRepresentation(String globalId, String schema, String version); @Override void deleteRepresentation(String globalId, String schema, String version); @Override Representation persistRepresentation(String globalId, String schema, String version); @Override List<Representation> listRepresentationVersions(String globalId, String schema); @Override boolean putContent(String globalId, String schema, String version, File file, InputStream content); @Override void getContent(String globalId, String schema, String version, String fileName, long rangeStart, long rangeEnd, OutputStream os); @Override String getContent(String globalId, String schema, String version, String fileName, OutputStream os); @Override void deleteContent(String globalId, String schema, String version, String fileName); @Override Representation copyRepresentation(String globalId, String schema, String version); ResultSlice<Representation> search(RepresentationSearchParams searchParams, String thresholdParam, int limit); @Override File getFile(String globalId, String schema, String version, String fileName); }
InMemoryRecordService implements RecordService { public ResultSlice<Representation> search(RepresentationSearchParams searchParams, String thresholdParam, int limit) { int threshold = 0; if (thresholdParam != null) { threshold = parseInteger(thresholdParam); } String providerId = searchParams.getDataProvider(); String schema = searchParams.getSchema(); String dataSetId = searchParams.getDataSetId(); List<Representation> allRecords; if (providerId != null && dataSetId != null) { List<Representation> toReturn = new ArrayList<>(); try { List<Representation> representationStubs = dataSetDAO.listDataSet(providerId, dataSetId); for (Representation stub : representationStubs) { if (schema == null || schema.equals(stub.getRepresentationName())) { Representation realContent; try { realContent = recordDAO.getRepresentation(stub.getCloudId(), stub.getRepresentationName(), stub.getVersion()); toReturn.add(realContent); } catch (RepresentationNotExistsException ex) { } } } } catch (DataSetNotExistsException ex) { allRecords = Collections.emptyList(); } allRecords = toReturn; } else { allRecords = recordDAO.findRepresentations(providerId, schema); } if (allRecords.size() != 0 && threshold >= allRecords.size()) { throw new IllegalArgumentException("Illegal threshold param value: '" + thresholdParam + "'."); } return prepareResultSlice(limit, threshold, allRecords); } InMemoryRecordService(); InMemoryRecordService(InMemoryRecordDAO recordDAO, InMemoryContentDAO contentDAO, InMemoryDataSetDAO dataSetDAO, UISClientHandler uisHandler); @Override Record getRecord(String globalId); @Override void deleteRecord(String globalId); @Override void deleteRepresentation(String globalId, String schema); @Override Representation createRepresentation(String globalId, String representationName, String providerId); @Override Representation getRepresentation(String globalId, String schema); @Override Representation getRepresentation(String globalId, String schema, String version); @Override void deleteRepresentation(String globalId, String schema, String version); @Override Representation persistRepresentation(String globalId, String schema, String version); @Override List<Representation> listRepresentationVersions(String globalId, String schema); @Override boolean putContent(String globalId, String schema, String version, File file, InputStream content); @Override void getContent(String globalId, String schema, String version, String fileName, long rangeStart, long rangeEnd, OutputStream os); @Override String getContent(String globalId, String schema, String version, String fileName, OutputStream os); @Override void deleteContent(String globalId, String schema, String version, String fileName); @Override Representation copyRepresentation(String globalId, String schema, String version); ResultSlice<Representation> search(RepresentationSearchParams searchParams, String thresholdParam, int limit); @Override File getFile(String globalId, String schema, String version, String fileName); }
@Test public void shouldConvertFileProperly() { final String fileName = "test2|test1|tes2"; final String output = migrator.nameConversion(fileName); assertEquals("test2_test1_tes2", output); }
@Override public String nameConversion(final String s) { return s.contains("|") ? s.replace("|", "_") : null; }
CustomFileNameMigrator extends SwiftMigrator { @Override public String nameConversion(final String s) { return s.contains("|") ? s.replace("|", "_") : null; } }
CustomFileNameMigrator extends SwiftMigrator { @Override public String nameConversion(final String s) { return s.contains("|") ? s.replace("|", "_") : null; } }
CustomFileNameMigrator extends SwiftMigrator { @Override public String nameConversion(final String s) { return s.contains("|") ? s.replace("|", "_") : null; } @Override String nameConversion(final String s); }
CustomFileNameMigrator extends SwiftMigrator { @Override public String nameConversion(final String s) { return s.contains("|") ? s.replace("|", "_") : null; } @Override String nameConversion(final String s); }
@Betamax(tape = "dataSets_shouldRetrieveDataSetsFirstChunk") @Test public void shouldRetrieveDataSetsFirstChunk() throws MCSException { String providerId = "Provider002"; int resultSize = 100; String startFrom = "dataset000101"; DataSetServiceClient instance = new DataSetServiceClient(baseUrl); ResultSlice<DataSet> result = instance.getDataSetsForProviderChunk(providerId, null); assertNotNull(result.getResults()); assertEquals(result.getResults().size(), resultSize); assertEquals(result.getNextSlice(), startFrom); }
public ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } return prepareResultSliceResponse(target); }
DataSetServiceClient extends MCSClient { public ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } return prepareResultSliceResponse(target); } }
DataSetServiceClient extends MCSClient { public ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } return prepareResultSliceResponse(target); } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); }
DataSetServiceClient extends MCSClient { public ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } return prepareResultSliceResponse(target); } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
DataSetServiceClient extends MCSClient { public ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } return prepareResultSliceResponse(target); } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
@Betamax(tape = "dataSets_shouldRetrieveDataSetsSecondChunk") @Test public void shouldRetrieveDataSetsSecondChunk() throws MCSException { String providerId = "Provider002"; int resultSize = 100; String startFrom = "dataset000101"; DataSetServiceClient instance = new DataSetServiceClient(baseUrl); ResultSlice<DataSet> result = instance.getDataSetsForProviderChunk(providerId, startFrom); assertNotNull(result.getResults()); assertEquals(result.getResults().size(), resultSize); assertNull(result.getNextSlice()); }
public ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } return prepareResultSliceResponse(target); }
DataSetServiceClient extends MCSClient { public ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } return prepareResultSliceResponse(target); } }
DataSetServiceClient extends MCSClient { public ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } return prepareResultSliceResponse(target); } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); }
DataSetServiceClient extends MCSClient { public ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } return prepareResultSliceResponse(target); } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
DataSetServiceClient extends MCSClient { public ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } return prepareResultSliceResponse(target); } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
@Betamax(tape = "dataSets_shouldNotThrowProviderNotExistsForDataSetsChunk") @Test public void shouldNotThrowProviderNotExistsForDataSetsChunk() throws MCSException { String providerId = "notFoundProviderId"; String startFrom = null; DataSetServiceClient instance = new DataSetServiceClient(baseUrl); ResultSlice<DataSet> result = instance.getDataSetsForProviderChunk(providerId, startFrom); assertNotNull(result.getResults()); assertEquals(result.getResults().size(), 0); }
public ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } return prepareResultSliceResponse(target); }
DataSetServiceClient extends MCSClient { public ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } return prepareResultSliceResponse(target); } }
DataSetServiceClient extends MCSClient { public ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } return prepareResultSliceResponse(target); } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); }
DataSetServiceClient extends MCSClient { public ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } return prepareResultSliceResponse(target); } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
DataSetServiceClient extends MCSClient { public ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } return prepareResultSliceResponse(target); } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
@Betamax(tape = "dataSets_shouldReturnAllDataSets") @Test public void shouldReturnAllDataSets() throws MCSException { String providerId = "Provider002"; int resultSize = 200; DataSetServiceClient instance = new DataSetServiceClient(baseUrl); List<DataSet> result = instance.getDataSetsForProvider(providerId); assertNotNull(result); assertEquals(result.size(), resultSize); }
public List<DataSet> getDataSetsForProvider(String providerId) throws MCSException { List<DataSet> resultList = new ArrayList<>(); ResultSlice resultSlice; String startFrom = null; do { resultSlice = getDataSetsForProviderChunk(providerId, startFrom); if (resultSlice == null || resultSlice.getResults() == null) { throw new DriverException("Getting DataSet: result chunk obtained but is empty."); } resultList.addAll(resultSlice.getResults()); startFrom = resultSlice.getNextSlice(); } while (resultSlice.getNextSlice() != null); return resultList; }
DataSetServiceClient extends MCSClient { public List<DataSet> getDataSetsForProvider(String providerId) throws MCSException { List<DataSet> resultList = new ArrayList<>(); ResultSlice resultSlice; String startFrom = null; do { resultSlice = getDataSetsForProviderChunk(providerId, startFrom); if (resultSlice == null || resultSlice.getResults() == null) { throw new DriverException("Getting DataSet: result chunk obtained but is empty."); } resultList.addAll(resultSlice.getResults()); startFrom = resultSlice.getNextSlice(); } while (resultSlice.getNextSlice() != null); return resultList; } }
DataSetServiceClient extends MCSClient { public List<DataSet> getDataSetsForProvider(String providerId) throws MCSException { List<DataSet> resultList = new ArrayList<>(); ResultSlice resultSlice; String startFrom = null; do { resultSlice = getDataSetsForProviderChunk(providerId, startFrom); if (resultSlice == null || resultSlice.getResults() == null) { throw new DriverException("Getting DataSet: result chunk obtained but is empty."); } resultList.addAll(resultSlice.getResults()); startFrom = resultSlice.getNextSlice(); } while (resultSlice.getNextSlice() != null); return resultList; } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); }
DataSetServiceClient extends MCSClient { public List<DataSet> getDataSetsForProvider(String providerId) throws MCSException { List<DataSet> resultList = new ArrayList<>(); ResultSlice resultSlice; String startFrom = null; do { resultSlice = getDataSetsForProviderChunk(providerId, startFrom); if (resultSlice == null || resultSlice.getResults() == null) { throw new DriverException("Getting DataSet: result chunk obtained but is empty."); } resultList.addAll(resultSlice.getResults()); startFrom = resultSlice.getNextSlice(); } while (resultSlice.getNextSlice() != null); return resultList; } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
DataSetServiceClient extends MCSClient { public List<DataSet> getDataSetsForProvider(String providerId) throws MCSException { List<DataSet> resultList = new ArrayList<>(); ResultSlice resultSlice; String startFrom = null; do { resultSlice = getDataSetsForProviderChunk(providerId, startFrom); if (resultSlice == null || resultSlice.getResults() == null) { throw new DriverException("Getting DataSet: result chunk obtained but is empty."); } resultList.addAll(resultSlice.getResults()); startFrom = resultSlice.getNextSlice(); } while (resultSlice.getNextSlice() != null); return resultList; } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
@Betamax(tape = "dataSets_shouldNotThrowProviderNotExistsForDataSetsAll") @Test public void shouldNotThrowProviderNotExistsForDataSetsAll() throws MCSException { String providerId = "notFoundProviderId"; DataSetServiceClient instance = new DataSetServiceClient(baseUrl); List<DataSet> result = instance.getDataSetsForProvider(providerId); assertNotNull(result); assertEquals(result.size(), 0); }
public List<DataSet> getDataSetsForProvider(String providerId) throws MCSException { List<DataSet> resultList = new ArrayList<>(); ResultSlice resultSlice; String startFrom = null; do { resultSlice = getDataSetsForProviderChunk(providerId, startFrom); if (resultSlice == null || resultSlice.getResults() == null) { throw new DriverException("Getting DataSet: result chunk obtained but is empty."); } resultList.addAll(resultSlice.getResults()); startFrom = resultSlice.getNextSlice(); } while (resultSlice.getNextSlice() != null); return resultList; }
DataSetServiceClient extends MCSClient { public List<DataSet> getDataSetsForProvider(String providerId) throws MCSException { List<DataSet> resultList = new ArrayList<>(); ResultSlice resultSlice; String startFrom = null; do { resultSlice = getDataSetsForProviderChunk(providerId, startFrom); if (resultSlice == null || resultSlice.getResults() == null) { throw new DriverException("Getting DataSet: result chunk obtained but is empty."); } resultList.addAll(resultSlice.getResults()); startFrom = resultSlice.getNextSlice(); } while (resultSlice.getNextSlice() != null); return resultList; } }
DataSetServiceClient extends MCSClient { public List<DataSet> getDataSetsForProvider(String providerId) throws MCSException { List<DataSet> resultList = new ArrayList<>(); ResultSlice resultSlice; String startFrom = null; do { resultSlice = getDataSetsForProviderChunk(providerId, startFrom); if (resultSlice == null || resultSlice.getResults() == null) { throw new DriverException("Getting DataSet: result chunk obtained but is empty."); } resultList.addAll(resultSlice.getResults()); startFrom = resultSlice.getNextSlice(); } while (resultSlice.getNextSlice() != null); return resultList; } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); }
DataSetServiceClient extends MCSClient { public List<DataSet> getDataSetsForProvider(String providerId) throws MCSException { List<DataSet> resultList = new ArrayList<>(); ResultSlice resultSlice; String startFrom = null; do { resultSlice = getDataSetsForProviderChunk(providerId, startFrom); if (resultSlice == null || resultSlice.getResults() == null) { throw new DriverException("Getting DataSet: result chunk obtained but is empty."); } resultList.addAll(resultSlice.getResults()); startFrom = resultSlice.getNextSlice(); } while (resultSlice.getNextSlice() != null); return resultList; } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
DataSetServiceClient extends MCSClient { public List<DataSet> getDataSetsForProvider(String providerId) throws MCSException { List<DataSet> resultList = new ArrayList<>(); ResultSlice resultSlice; String startFrom = null; do { resultSlice = getDataSetsForProviderChunk(providerId, startFrom); if (resultSlice == null || resultSlice.getResults() == null) { throw new DriverException("Getting DataSet: result chunk obtained but is empty."); } resultList.addAll(resultSlice.getResults()); startFrom = resultSlice.getNextSlice(); } while (resultSlice.getNextSlice() != null); return resultList; } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
@Betamax(tape = "dataSets_shouldThrowDriverExceptionForGetDataSetsChunk") @Test(expected = DriverException.class) public void shouldThrowDriverExceptionForGetDataSetsChunk() throws MCSException { String providerId = "Provider001"; DataSetServiceClient instance = new DataSetServiceClient(baseUrl); instance.getDataSetsForProviderChunk(providerId, null); }
public ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } return prepareResultSliceResponse(target); }
DataSetServiceClient extends MCSClient { public ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } return prepareResultSliceResponse(target); } }
DataSetServiceClient extends MCSClient { public ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } return prepareResultSliceResponse(target); } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); }
DataSetServiceClient extends MCSClient { public ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } return prepareResultSliceResponse(target); } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
DataSetServiceClient extends MCSClient { public ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } return prepareResultSliceResponse(target); } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
@Betamax(tape = "dataSets_shouldThrowDriverExceptionForGetDataSets") @Test(expected = DriverException.class) public void shouldThrowDriverExceptionForGetDataSets() throws MCSException { String providerId = "Provider001"; DataSetServiceClient instance = new DataSetServiceClient(baseUrl); instance.getDataSetsForProviderChunk(providerId, null); }
public ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } return prepareResultSliceResponse(target); }
DataSetServiceClient extends MCSClient { public ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } return prepareResultSliceResponse(target); } }
DataSetServiceClient extends MCSClient { public ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } return prepareResultSliceResponse(target); } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); }
DataSetServiceClient extends MCSClient { public ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } return prepareResultSliceResponse(target); } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
DataSetServiceClient extends MCSClient { public ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } return prepareResultSliceResponse(target); } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
@Betamax(tape = "dataSets_shouldSuccessfullyCreateDataSet") @Test public void shouldSuccessfullyCreateDataSet() throws MCSException { String providerId = "Provider001"; String dataSetId = "dataset000008"; String description = "description01"; String expectedLocation = baseUrl + "/data-providers/" + providerId + "/data-sets/" + dataSetId; DataSetServiceClient instance = new DataSetServiceClient(baseUrl); URI result = instance.createDataSet(providerId, dataSetId, description); assertEquals(result.toString(), expectedLocation); }
public URI createDataSet(String providerId, String dataSetId, String description) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); Form form = new Form(); form.param(ParamConstants.F_DATASET, dataSetId); form.param(ParamConstants.F_DESCRIPTION, description); Response response = null; try { response = target .request() .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() == Status.CREATED.getStatusCode()) { return response.getLocation(); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } }
DataSetServiceClient extends MCSClient { public URI createDataSet(String providerId, String dataSetId, String description) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); Form form = new Form(); form.param(ParamConstants.F_DATASET, dataSetId); form.param(ParamConstants.F_DESCRIPTION, description); Response response = null; try { response = target .request() .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() == Status.CREATED.getStatusCode()) { return response.getLocation(); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } } }
DataSetServiceClient extends MCSClient { public URI createDataSet(String providerId, String dataSetId, String description) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); Form form = new Form(); form.param(ParamConstants.F_DATASET, dataSetId); form.param(ParamConstants.F_DESCRIPTION, description); Response response = null; try { response = target .request() .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() == Status.CREATED.getStatusCode()) { return response.getLocation(); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); }
DataSetServiceClient extends MCSClient { public URI createDataSet(String providerId, String dataSetId, String description) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); Form form = new Form(); form.param(ParamConstants.F_DATASET, dataSetId); form.param(ParamConstants.F_DESCRIPTION, description); Response response = null; try { response = target .request() .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() == Status.CREATED.getStatusCode()) { return response.getLocation(); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
DataSetServiceClient extends MCSClient { public URI createDataSet(String providerId, String dataSetId, String description) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); Form form = new Form(); form.param(ParamConstants.F_DATASET, dataSetId); form.param(ParamConstants.F_DESCRIPTION, description); Response response = null; try { response = target .request() .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() == Status.CREATED.getStatusCode()) { return response.getLocation(); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
@Betamax(tape = "dataSets_shouldThrowDataSetAlreadyExists") @Test(expected = DataSetAlreadyExistsException.class) public void shouldThrowDataSetAlreadyExists() throws MCSException { String providerId = "Provider001"; String dataSetId = "dataset000002"; String description = "description"; DataSetServiceClient instance = new DataSetServiceClient(baseUrl); instance.createDataSet(providerId, dataSetId, description); }
public URI createDataSet(String providerId, String dataSetId, String description) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); Form form = new Form(); form.param(ParamConstants.F_DATASET, dataSetId); form.param(ParamConstants.F_DESCRIPTION, description); Response response = null; try { response = target .request() .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() == Status.CREATED.getStatusCode()) { return response.getLocation(); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } }
DataSetServiceClient extends MCSClient { public URI createDataSet(String providerId, String dataSetId, String description) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); Form form = new Form(); form.param(ParamConstants.F_DATASET, dataSetId); form.param(ParamConstants.F_DESCRIPTION, description); Response response = null; try { response = target .request() .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() == Status.CREATED.getStatusCode()) { return response.getLocation(); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } } }
DataSetServiceClient extends MCSClient { public URI createDataSet(String providerId, String dataSetId, String description) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); Form form = new Form(); form.param(ParamConstants.F_DATASET, dataSetId); form.param(ParamConstants.F_DESCRIPTION, description); Response response = null; try { response = target .request() .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() == Status.CREATED.getStatusCode()) { return response.getLocation(); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); }
DataSetServiceClient extends MCSClient { public URI createDataSet(String providerId, String dataSetId, String description) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); Form form = new Form(); form.param(ParamConstants.F_DATASET, dataSetId); form.param(ParamConstants.F_DESCRIPTION, description); Response response = null; try { response = target .request() .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() == Status.CREATED.getStatusCode()) { return response.getLocation(); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
DataSetServiceClient extends MCSClient { public URI createDataSet(String providerId, String dataSetId, String description) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); Form form = new Form(); form.param(ParamConstants.F_DATASET, dataSetId); form.param(ParamConstants.F_DESCRIPTION, description); Response response = null; try { response = target .request() .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() == Status.CREATED.getStatusCode()) { return response.getLocation(); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
@Betamax(tape = "dataSets_shouldThrowProviderNotExists") @Test(expected = ProviderNotExistsException.class) public void shouldThrowProviderNotExists() throws MCSException { String providerId = "notFoundProviderId"; String dataSetId = "dataSetId"; String description = "description"; DataSetServiceClient instance = new DataSetServiceClient(baseUrl); instance.createDataSet(providerId, dataSetId, description); }
public URI createDataSet(String providerId, String dataSetId, String description) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); Form form = new Form(); form.param(ParamConstants.F_DATASET, dataSetId); form.param(ParamConstants.F_DESCRIPTION, description); Response response = null; try { response = target .request() .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() == Status.CREATED.getStatusCode()) { return response.getLocation(); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } }
DataSetServiceClient extends MCSClient { public URI createDataSet(String providerId, String dataSetId, String description) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); Form form = new Form(); form.param(ParamConstants.F_DATASET, dataSetId); form.param(ParamConstants.F_DESCRIPTION, description); Response response = null; try { response = target .request() .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() == Status.CREATED.getStatusCode()) { return response.getLocation(); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } } }
DataSetServiceClient extends MCSClient { public URI createDataSet(String providerId, String dataSetId, String description) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); Form form = new Form(); form.param(ParamConstants.F_DATASET, dataSetId); form.param(ParamConstants.F_DESCRIPTION, description); Response response = null; try { response = target .request() .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() == Status.CREATED.getStatusCode()) { return response.getLocation(); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); }
DataSetServiceClient extends MCSClient { public URI createDataSet(String providerId, String dataSetId, String description) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); Form form = new Form(); form.param(ParamConstants.F_DATASET, dataSetId); form.param(ParamConstants.F_DESCRIPTION, description); Response response = null; try { response = target .request() .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() == Status.CREATED.getStatusCode()) { return response.getLocation(); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
DataSetServiceClient extends MCSClient { public URI createDataSet(String providerId, String dataSetId, String description) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); Form form = new Form(); form.param(ParamConstants.F_DATASET, dataSetId); form.param(ParamConstants.F_DESCRIPTION, description); Response response = null; try { response = target .request() .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() == Status.CREATED.getStatusCode()) { return response.getLocation(); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
@Test public void shouldConvertFileProperly2() { final String fileName = "test2_test1|tes2"; final String output = migrator.nameConversion(fileName); assertEquals("test2_test1_tes2", output); }
@Override public String nameConversion(final String s) { return s.contains("|") ? s.replace("|", "_") : null; }
CustomFileNameMigrator extends SwiftMigrator { @Override public String nameConversion(final String s) { return s.contains("|") ? s.replace("|", "_") : null; } }
CustomFileNameMigrator extends SwiftMigrator { @Override public String nameConversion(final String s) { return s.contains("|") ? s.replace("|", "_") : null; } }
CustomFileNameMigrator extends SwiftMigrator { @Override public String nameConversion(final String s) { return s.contains("|") ? s.replace("|", "_") : null; } @Override String nameConversion(final String s); }
CustomFileNameMigrator extends SwiftMigrator { @Override public String nameConversion(final String s) { return s.contains("|") ? s.replace("|", "_") : null; } @Override String nameConversion(final String s); }
@Betamax(tape = "dataSets_shouldThrowDriverExceptionForCreateDataSet") @Test(expected = DriverException.class) public void shouldThrowDriverExceptionForCreateDataSet() throws MCSException { String providerId = "providerId"; String dataSetId = "dataSetId"; String description = "description"; DataSetServiceClient instance = new DataSetServiceClient(baseUrl); instance.createDataSet(providerId, dataSetId, description); }
public URI createDataSet(String providerId, String dataSetId, String description) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); Form form = new Form(); form.param(ParamConstants.F_DATASET, dataSetId); form.param(ParamConstants.F_DESCRIPTION, description); Response response = null; try { response = target .request() .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() == Status.CREATED.getStatusCode()) { return response.getLocation(); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } }
DataSetServiceClient extends MCSClient { public URI createDataSet(String providerId, String dataSetId, String description) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); Form form = new Form(); form.param(ParamConstants.F_DATASET, dataSetId); form.param(ParamConstants.F_DESCRIPTION, description); Response response = null; try { response = target .request() .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() == Status.CREATED.getStatusCode()) { return response.getLocation(); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } } }
DataSetServiceClient extends MCSClient { public URI createDataSet(String providerId, String dataSetId, String description) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); Form form = new Form(); form.param(ParamConstants.F_DATASET, dataSetId); form.param(ParamConstants.F_DESCRIPTION, description); Response response = null; try { response = target .request() .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() == Status.CREATED.getStatusCode()) { return response.getLocation(); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); }
DataSetServiceClient extends MCSClient { public URI createDataSet(String providerId, String dataSetId, String description) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); Form form = new Form(); form.param(ParamConstants.F_DATASET, dataSetId); form.param(ParamConstants.F_DESCRIPTION, description); Response response = null; try { response = target .request() .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() == Status.CREATED.getStatusCode()) { return response.getLocation(); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
DataSetServiceClient extends MCSClient { public URI createDataSet(String providerId, String dataSetId, String description) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SETS_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId); Form form = new Form(); form.param(ParamConstants.F_DATASET, dataSetId); form.param(ParamConstants.F_DESCRIPTION, description); Response response = null; try { response = target .request() .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() == Status.CREATED.getStatusCode()) { return response.getLocation(); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
@Betamax(tape = "dataSets_shouldRetrieveRepresentationsFirstChunk") @Test public void shouldRetrieveRepresentationsFirstChunk() throws MCSException { String providerId = "Provider001"; String dataSetId = "dataset000002"; int resultSize = 100; String startFrom = "G5DFUSCILJFVGQSEJYFHGY3IMVWWCMI="; DataSetServiceClient instance = new DataSetServiceClient(baseUrl); ResultSlice<Representation> result = instance.getDataSetRepresentationsChunk(providerId, dataSetId, null); assertNotNull(result.getResults()); assertEquals(result.getResults().size(), resultSize); assertEquals(result.getNextSlice(), startFrom); }
public ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } Response response = null; try { response = target.request().get(); if (response.getStatus() == Status.OK.getStatusCode()) { return response.readEntity(ResultSlice.class); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } }
DataSetServiceClient extends MCSClient { public ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } Response response = null; try { response = target.request().get(); if (response.getStatus() == Status.OK.getStatusCode()) { return response.readEntity(ResultSlice.class); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } } }
DataSetServiceClient extends MCSClient { public ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } Response response = null; try { response = target.request().get(); if (response.getStatus() == Status.OK.getStatusCode()) { return response.readEntity(ResultSlice.class); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); }
DataSetServiceClient extends MCSClient { public ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } Response response = null; try { response = target.request().get(); if (response.getStatus() == Status.OK.getStatusCode()) { return response.readEntity(ResultSlice.class); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
DataSetServiceClient extends MCSClient { public ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } Response response = null; try { response = target.request().get(); if (response.getStatus() == Status.OK.getStatusCode()) { return response.readEntity(ResultSlice.class); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
@Betamax(tape = "dataSets_shouldRetrieveRepresentationsSecondChunk") @Test public void shouldRetrieveRepresentationsSecondChunk() throws MCSException { String providerId = "Provider001"; String dataSetId = "dataset000002"; int resultSize = 100; String startFrom = "G5DFUSCILJFVGQSEJYFHGY3IMVWWCMI="; DataSetServiceClient instance = new DataSetServiceClient(baseUrl); ResultSlice<Representation> result = instance.getDataSetRepresentationsChunk(providerId, dataSetId, startFrom); assertNotNull(result.getResults()); assertEquals(result.getResults().size(), resultSize); assertNull(result.getNextSlice()); }
public ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } Response response = null; try { response = target.request().get(); if (response.getStatus() == Status.OK.getStatusCode()) { return response.readEntity(ResultSlice.class); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } }
DataSetServiceClient extends MCSClient { public ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } Response response = null; try { response = target.request().get(); if (response.getStatus() == Status.OK.getStatusCode()) { return response.readEntity(ResultSlice.class); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } } }
DataSetServiceClient extends MCSClient { public ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } Response response = null; try { response = target.request().get(); if (response.getStatus() == Status.OK.getStatusCode()) { return response.readEntity(ResultSlice.class); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); }
DataSetServiceClient extends MCSClient { public ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } Response response = null; try { response = target.request().get(); if (response.getStatus() == Status.OK.getStatusCode()) { return response.readEntity(ResultSlice.class); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
DataSetServiceClient extends MCSClient { public ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } Response response = null; try { response = target.request().get(); if (response.getStatus() == Status.OK.getStatusCode()) { return response.readEntity(ResultSlice.class); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
@Betamax(tape = "dataSets_shouldThrowDataSetNotExistsForRepresentationsChunk") @Test(expected = DataSetNotExistsException.class) public void shouldThrowDataSetNotExistsForRepresentationsChunk() throws MCSException { String providerId = "Provider001"; String dataSetId = "dataset000042"; String startFrom = "G5DFUSCILJFVGQSEJYFHGY3IMVWWCMI="; DataSetServiceClient instance = new DataSetServiceClient(baseUrl); instance.getDataSetRepresentationsChunk(providerId, dataSetId, startFrom); }
public ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } Response response = null; try { response = target.request().get(); if (response.getStatus() == Status.OK.getStatusCode()) { return response.readEntity(ResultSlice.class); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } }
DataSetServiceClient extends MCSClient { public ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } Response response = null; try { response = target.request().get(); if (response.getStatus() == Status.OK.getStatusCode()) { return response.readEntity(ResultSlice.class); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } } }
DataSetServiceClient extends MCSClient { public ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } Response response = null; try { response = target.request().get(); if (response.getStatus() == Status.OK.getStatusCode()) { return response.readEntity(ResultSlice.class); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); }
DataSetServiceClient extends MCSClient { public ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } Response response = null; try { response = target.request().get(); if (response.getStatus() == Status.OK.getStatusCode()) { return response.readEntity(ResultSlice.class); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
DataSetServiceClient extends MCSClient { public ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } Response response = null; try { response = target.request().get(); if (response.getStatus() == Status.OK.getStatusCode()) { return response.readEntity(ResultSlice.class); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
@Betamax(tape = "dataSets_shouldReturnAllRepresentations") @Test public void shouldReturnAllRepresentations() throws MCSException { String providerId = "Provider001"; String dataSetId = "dataset000002"; int resultSize = 200; DataSetServiceClient instance = new DataSetServiceClient(baseUrl); List<Representation> result = instance.getDataSetRepresentations(providerId, dataSetId); assertNotNull(result); assertEquals(result.size(), resultSize); }
public List<Representation> getDataSetRepresentations(String providerId, String dataSetId) throws MCSException { List<Representation> resultList = new ArrayList<>(); ResultSlice<Representation> resultSlice; String startFrom = null; do { resultSlice = getDataSetRepresentationsChunk(providerId, dataSetId, startFrom); if (resultSlice == null || resultSlice.getResults() == null) { throw new DriverException("Getting DataSet: result chunk obtained but is empty."); } resultList.addAll(resultSlice.getResults()); startFrom = resultSlice.getNextSlice(); } while (resultSlice.getNextSlice() != null); return resultList; }
DataSetServiceClient extends MCSClient { public List<Representation> getDataSetRepresentations(String providerId, String dataSetId) throws MCSException { List<Representation> resultList = new ArrayList<>(); ResultSlice<Representation> resultSlice; String startFrom = null; do { resultSlice = getDataSetRepresentationsChunk(providerId, dataSetId, startFrom); if (resultSlice == null || resultSlice.getResults() == null) { throw new DriverException("Getting DataSet: result chunk obtained but is empty."); } resultList.addAll(resultSlice.getResults()); startFrom = resultSlice.getNextSlice(); } while (resultSlice.getNextSlice() != null); return resultList; } }
DataSetServiceClient extends MCSClient { public List<Representation> getDataSetRepresentations(String providerId, String dataSetId) throws MCSException { List<Representation> resultList = new ArrayList<>(); ResultSlice<Representation> resultSlice; String startFrom = null; do { resultSlice = getDataSetRepresentationsChunk(providerId, dataSetId, startFrom); if (resultSlice == null || resultSlice.getResults() == null) { throw new DriverException("Getting DataSet: result chunk obtained but is empty."); } resultList.addAll(resultSlice.getResults()); startFrom = resultSlice.getNextSlice(); } while (resultSlice.getNextSlice() != null); return resultList; } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); }
DataSetServiceClient extends MCSClient { public List<Representation> getDataSetRepresentations(String providerId, String dataSetId) throws MCSException { List<Representation> resultList = new ArrayList<>(); ResultSlice<Representation> resultSlice; String startFrom = null; do { resultSlice = getDataSetRepresentationsChunk(providerId, dataSetId, startFrom); if (resultSlice == null || resultSlice.getResults() == null) { throw new DriverException("Getting DataSet: result chunk obtained but is empty."); } resultList.addAll(resultSlice.getResults()); startFrom = resultSlice.getNextSlice(); } while (resultSlice.getNextSlice() != null); return resultList; } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
DataSetServiceClient extends MCSClient { public List<Representation> getDataSetRepresentations(String providerId, String dataSetId) throws MCSException { List<Representation> resultList = new ArrayList<>(); ResultSlice<Representation> resultSlice; String startFrom = null; do { resultSlice = getDataSetRepresentationsChunk(providerId, dataSetId, startFrom); if (resultSlice == null || resultSlice.getResults() == null) { throw new DriverException("Getting DataSet: result chunk obtained but is empty."); } resultList.addAll(resultSlice.getResults()); startFrom = resultSlice.getNextSlice(); } while (resultSlice.getNextSlice() != null); return resultList; } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
@Betamax(tape = "dataSets_shouldThrowDataSetNotExistsForRepresentationsAll") @Test(expected = DataSetNotExistsException.class) public void shouldThrowDataSetNotExistsForRepresentationsAll() throws MCSException { String providerId = "Provider001"; String dataSetId = "dataset000042"; DataSetServiceClient instance = new DataSetServiceClient(baseUrl); instance.getDataSetRepresentations(providerId, dataSetId); }
public List<Representation> getDataSetRepresentations(String providerId, String dataSetId) throws MCSException { List<Representation> resultList = new ArrayList<>(); ResultSlice<Representation> resultSlice; String startFrom = null; do { resultSlice = getDataSetRepresentationsChunk(providerId, dataSetId, startFrom); if (resultSlice == null || resultSlice.getResults() == null) { throw new DriverException("Getting DataSet: result chunk obtained but is empty."); } resultList.addAll(resultSlice.getResults()); startFrom = resultSlice.getNextSlice(); } while (resultSlice.getNextSlice() != null); return resultList; }
DataSetServiceClient extends MCSClient { public List<Representation> getDataSetRepresentations(String providerId, String dataSetId) throws MCSException { List<Representation> resultList = new ArrayList<>(); ResultSlice<Representation> resultSlice; String startFrom = null; do { resultSlice = getDataSetRepresentationsChunk(providerId, dataSetId, startFrom); if (resultSlice == null || resultSlice.getResults() == null) { throw new DriverException("Getting DataSet: result chunk obtained but is empty."); } resultList.addAll(resultSlice.getResults()); startFrom = resultSlice.getNextSlice(); } while (resultSlice.getNextSlice() != null); return resultList; } }
DataSetServiceClient extends MCSClient { public List<Representation> getDataSetRepresentations(String providerId, String dataSetId) throws MCSException { List<Representation> resultList = new ArrayList<>(); ResultSlice<Representation> resultSlice; String startFrom = null; do { resultSlice = getDataSetRepresentationsChunk(providerId, dataSetId, startFrom); if (resultSlice == null || resultSlice.getResults() == null) { throw new DriverException("Getting DataSet: result chunk obtained but is empty."); } resultList.addAll(resultSlice.getResults()); startFrom = resultSlice.getNextSlice(); } while (resultSlice.getNextSlice() != null); return resultList; } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); }
DataSetServiceClient extends MCSClient { public List<Representation> getDataSetRepresentations(String providerId, String dataSetId) throws MCSException { List<Representation> resultList = new ArrayList<>(); ResultSlice<Representation> resultSlice; String startFrom = null; do { resultSlice = getDataSetRepresentationsChunk(providerId, dataSetId, startFrom); if (resultSlice == null || resultSlice.getResults() == null) { throw new DriverException("Getting DataSet: result chunk obtained but is empty."); } resultList.addAll(resultSlice.getResults()); startFrom = resultSlice.getNextSlice(); } while (resultSlice.getNextSlice() != null); return resultList; } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
DataSetServiceClient extends MCSClient { public List<Representation> getDataSetRepresentations(String providerId, String dataSetId) throws MCSException { List<Representation> resultList = new ArrayList<>(); ResultSlice<Representation> resultSlice; String startFrom = null; do { resultSlice = getDataSetRepresentationsChunk(providerId, dataSetId, startFrom); if (resultSlice == null || resultSlice.getResults() == null) { throw new DriverException("Getting DataSet: result chunk obtained but is empty."); } resultList.addAll(resultSlice.getResults()); startFrom = resultSlice.getNextSlice(); } while (resultSlice.getNextSlice() != null); return resultList; } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
@Betamax(tape = "dataSets_shouldThrowDriverExceptionForGetRepresentationsChunk") @Test(expected = DriverException.class) public void shouldThrowDriverExceptionForGetRepresentationsChunk() throws MCSException { String providerId = "Provider001"; String dataSetId = "dataset000002"; DataSetServiceClient instance = new DataSetServiceClient(baseUrl); instance.getDataSetRepresentationsChunk(providerId, dataSetId, null); }
public ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } Response response = null; try { response = target.request().get(); if (response.getStatus() == Status.OK.getStatusCode()) { return response.readEntity(ResultSlice.class); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } }
DataSetServiceClient extends MCSClient { public ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } Response response = null; try { response = target.request().get(); if (response.getStatus() == Status.OK.getStatusCode()) { return response.readEntity(ResultSlice.class); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } } }
DataSetServiceClient extends MCSClient { public ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } Response response = null; try { response = target.request().get(); if (response.getStatus() == Status.OK.getStatusCode()) { return response.readEntity(ResultSlice.class); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); }
DataSetServiceClient extends MCSClient { public ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } Response response = null; try { response = target.request().get(); if (response.getStatus() == Status.OK.getStatusCode()) { return response.readEntity(ResultSlice.class); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
DataSetServiceClient extends MCSClient { public ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); if (startFrom != null) { target = target.queryParam(ParamConstants.F_START_FROM, startFrom); } Response response = null; try { response = target.request().get(); if (response.getStatus() == Status.OK.getStatusCode()) { return response.readEntity(ResultSlice.class); } ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
@Betamax(tape = "dataSets_shouldThrowDriverExceptionForGetRepresentations") @Test(expected = DriverException.class) public void shouldThrowDriverExceptionForGetRepresentations() throws MCSException { String providerId = "Provider001"; String dataSetId = "dataset000002"; DataSetServiceClient instance = new DataSetServiceClient(baseUrl); instance.getDataSetRepresentations(providerId, dataSetId); }
public List<Representation> getDataSetRepresentations(String providerId, String dataSetId) throws MCSException { List<Representation> resultList = new ArrayList<>(); ResultSlice<Representation> resultSlice; String startFrom = null; do { resultSlice = getDataSetRepresentationsChunk(providerId, dataSetId, startFrom); if (resultSlice == null || resultSlice.getResults() == null) { throw new DriverException("Getting DataSet: result chunk obtained but is empty."); } resultList.addAll(resultSlice.getResults()); startFrom = resultSlice.getNextSlice(); } while (resultSlice.getNextSlice() != null); return resultList; }
DataSetServiceClient extends MCSClient { public List<Representation> getDataSetRepresentations(String providerId, String dataSetId) throws MCSException { List<Representation> resultList = new ArrayList<>(); ResultSlice<Representation> resultSlice; String startFrom = null; do { resultSlice = getDataSetRepresentationsChunk(providerId, dataSetId, startFrom); if (resultSlice == null || resultSlice.getResults() == null) { throw new DriverException("Getting DataSet: result chunk obtained but is empty."); } resultList.addAll(resultSlice.getResults()); startFrom = resultSlice.getNextSlice(); } while (resultSlice.getNextSlice() != null); return resultList; } }
DataSetServiceClient extends MCSClient { public List<Representation> getDataSetRepresentations(String providerId, String dataSetId) throws MCSException { List<Representation> resultList = new ArrayList<>(); ResultSlice<Representation> resultSlice; String startFrom = null; do { resultSlice = getDataSetRepresentationsChunk(providerId, dataSetId, startFrom); if (resultSlice == null || resultSlice.getResults() == null) { throw new DriverException("Getting DataSet: result chunk obtained but is empty."); } resultList.addAll(resultSlice.getResults()); startFrom = resultSlice.getNextSlice(); } while (resultSlice.getNextSlice() != null); return resultList; } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); }
DataSetServiceClient extends MCSClient { public List<Representation> getDataSetRepresentations(String providerId, String dataSetId) throws MCSException { List<Representation> resultList = new ArrayList<>(); ResultSlice<Representation> resultSlice; String startFrom = null; do { resultSlice = getDataSetRepresentationsChunk(providerId, dataSetId, startFrom); if (resultSlice == null || resultSlice.getResults() == null) { throw new DriverException("Getting DataSet: result chunk obtained but is empty."); } resultList.addAll(resultSlice.getResults()); startFrom = resultSlice.getNextSlice(); } while (resultSlice.getNextSlice() != null); return resultList; } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
DataSetServiceClient extends MCSClient { public List<Representation> getDataSetRepresentations(String providerId, String dataSetId) throws MCSException { List<Representation> resultList = new ArrayList<>(); ResultSlice<Representation> resultSlice; String startFrom = null; do { resultSlice = getDataSetRepresentationsChunk(providerId, dataSetId, startFrom); if (resultSlice == null || resultSlice.getResults() == null) { throw new DriverException("Getting DataSet: result chunk obtained but is empty."); } resultList.addAll(resultSlice.getResults()); startFrom = resultSlice.getNextSlice(); } while (resultSlice.getNextSlice() != null); return resultList; } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
@Betamax(tape = "dataSets_shouldThrowDataSetNotExistsForUpdateDescription") @Test(expected = DataSetNotExistsException.class) public void shouldThrowDataSetNotExistsForUpdateDescription() throws MCSException { String providerId = "Provider002"; String dataSetId = "noSuchDataset"; String description = "TEST4"; DataSetServiceClient instance = new DataSetServiceClient(baseUrl); instance.updateDescriptionOfDataSet(providerId, dataSetId, description); }
public void updateDescriptionOfDataSet(String providerId, String dataSetId, String description) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Form form = new Form(); form.param(ParamConstants.F_DESCRIPTION, description); Response response = null; try { response = target.request().put(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() != Status.NO_CONTENT.getStatusCode()) { ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } } finally { if (response != null) { response.close(); } } }
DataSetServiceClient extends MCSClient { public void updateDescriptionOfDataSet(String providerId, String dataSetId, String description) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Form form = new Form(); form.param(ParamConstants.F_DESCRIPTION, description); Response response = null; try { response = target.request().put(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() != Status.NO_CONTENT.getStatusCode()) { ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } } finally { if (response != null) { response.close(); } } } }
DataSetServiceClient extends MCSClient { public void updateDescriptionOfDataSet(String providerId, String dataSetId, String description) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Form form = new Form(); form.param(ParamConstants.F_DESCRIPTION, description); Response response = null; try { response = target.request().put(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() != Status.NO_CONTENT.getStatusCode()) { ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); }
DataSetServiceClient extends MCSClient { public void updateDescriptionOfDataSet(String providerId, String dataSetId, String description) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Form form = new Form(); form.param(ParamConstants.F_DESCRIPTION, description); Response response = null; try { response = target.request().put(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() != Status.NO_CONTENT.getStatusCode()) { ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
DataSetServiceClient extends MCSClient { public void updateDescriptionOfDataSet(String providerId, String dataSetId, String description) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Form form = new Form(); form.param(ParamConstants.F_DESCRIPTION, description); Response response = null; try { response = target.request().put(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() != Status.NO_CONTENT.getStatusCode()) { ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
@Betamax(tape = "dataSets_shouldThrowDriverExceptionForUpdateDescription") @Test(expected = DriverException.class) public void shouldThrowDriverExceptionForUpdateDescription() throws MCSException { String providerId = "Provider002"; String dataSetId = "dataset000001"; String description = "TEST3"; DataSetServiceClient instance = new DataSetServiceClient(baseUrl); instance.updateDescriptionOfDataSet(providerId, dataSetId, description); }
public void updateDescriptionOfDataSet(String providerId, String dataSetId, String description) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Form form = new Form(); form.param(ParamConstants.F_DESCRIPTION, description); Response response = null; try { response = target.request().put(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() != Status.NO_CONTENT.getStatusCode()) { ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } } finally { if (response != null) { response.close(); } } }
DataSetServiceClient extends MCSClient { public void updateDescriptionOfDataSet(String providerId, String dataSetId, String description) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Form form = new Form(); form.param(ParamConstants.F_DESCRIPTION, description); Response response = null; try { response = target.request().put(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() != Status.NO_CONTENT.getStatusCode()) { ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } } finally { if (response != null) { response.close(); } } } }
DataSetServiceClient extends MCSClient { public void updateDescriptionOfDataSet(String providerId, String dataSetId, String description) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Form form = new Form(); form.param(ParamConstants.F_DESCRIPTION, description); Response response = null; try { response = target.request().put(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() != Status.NO_CONTENT.getStatusCode()) { ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); }
DataSetServiceClient extends MCSClient { public void updateDescriptionOfDataSet(String providerId, String dataSetId, String description) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Form form = new Form(); form.param(ParamConstants.F_DESCRIPTION, description); Response response = null; try { response = target.request().put(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() != Status.NO_CONTENT.getStatusCode()) { ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
DataSetServiceClient extends MCSClient { public void updateDescriptionOfDataSet(String providerId, String dataSetId, String description) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Form form = new Form(); form.param(ParamConstants.F_DESCRIPTION, description); Response response = null; try { response = target.request().put(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() != Status.NO_CONTENT.getStatusCode()) { ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
@Test public void searchTest() throws IndexerException { boolean ok = false; int i = 0; do { try { createIndex("test"); client().prepareIndex("test", "type", "1").setSource("field1", "value1").execute().actionGet(); client().prepareIndex("test", "type", "2").setSource("field1", "value2").execute().actionGet(); client().prepareIndex("test", "type", "3").setSource(IndexFields.RAW_TEXT, "some full text with lot of informations").execute().actionGet(); client().prepareIndex("test", "type", "4").setSource(IndexFields.RAW_TEXT, "dog is an animal").execute().actionGet(); client().prepareIndex("test", "type", "5").setSource("field1", "value3", "field2", "value1 and value2").execute().actionGet(); client().prepareIndex("test", "type", "6").setSource("field1", "value4", "field2", "value5").execute().actionGet(); client().prepareIndex("test", "type", "7").setSource("field3", "my phrase").execute().actionGet(); client().prepareIndex("test", "type", "8").setSource("field3", "my dog and phrase").execute().actionGet(); client().prepareIndex("test", "type", "9").setSource("field3", "my dog and cat").execute().actionGet(); client().prepareIndex("test", "type", "10").setSource("field3", "my dog and your cat").execute().actionGet(); client().prepareIndex("test", "type", "11").setSource("field3", "my cat and dog").execute().actionGet(); refresh(); Elasticsearch es = new Elasticsearch(client(), "test", "type"); SearchResult result; String[] fields1 = {"field1"}; result = es.search("value2", fields1); assertTrue(result.getTotalHits() == 1); String[] fields2 = {"field1", "field2"}; result = es.search("value2", fields2); assertTrue(result.getTotalHits() == 2); result = es.search("xxxxx", fields2); assertTrue(result.getTotalHits() == 0); result = es.search("value2", fields2, 1, Indexer.TIMEOUT); assertTrue(result.getTotalHits() == 2); assertTrue(result.getHits().size() == 1); result = es.search("value2", fields2, -2, Indexer.TIMEOUT); assertTrue(result.getTotalHits() == 0); result = es.search("value2", null); assertTrue(result.getTotalHits() == 0); result = es.search(null, fields1); assertTrue(result.getTotalHits() == 0); result = es.searchFullText("cat is an animal"); assertTrue(result.getTotalHits() == 1); result = es.searchFullText("superman and batman"); assertTrue(result.getTotalHits() == 0); result = es.searchFullText(null); assertTrue(result.getTotalHits() == 0); result = es.searchPhrase("dog and cat", "field3", 0); assertTrue(result.getTotalHits() == 1); result = es.searchPhrase("dog and cat", "field3", 1); assertTrue(result.getTotalHits() == 2); result = es.searchPhrase("dog and cat", "field3", 4); assertTrue(result.getTotalHits() == 3); result = es.searchPhrase("xxx ccc", "field3", 1); assertTrue(result.getTotalHits() == 0); result = es.searchPhrase("dog and cat", "field3", -1); assertTrue(result.getTotalHits() == 0); result = es.searchPhrase("dog and cat", "field3", 1, -2, Indexer.TIMEOUT); assertTrue(result.getTotalHits() == 0); result = es.searchPhrase("dog and cat", null, 1); assertTrue(result.getTotalHits() == 0); result = es.searchPhrase(null, "field3", 1); assertTrue(result.getTotalHits() == 0); result = es.advancedSearch("field3:(+dog -your phrase^4)"); assertTrue(result.getTotalHits() == 3); assertEquals("8", result.getHits().get(0).getId()); Map<String, Object> p1 = new HashMap<>(); p1.put("default_operator", Indexer.Operator.AND); result = es.advancedSearch("field3:(+dog -your phrase^4)", p1); assertTrue(result.getTotalHits() == 1); Map<String, Object> p2 = new HashMap<>(); p2.put("default_field", "field3"); result = es.advancedSearch("+dog -your phrase^4", p2); assertTrue(result.getTotalHits() == 3); result = es.advancedSearch("field3:(+dog -your phrase^4)", null); assertTrue(result.getTotalHits() == 3); result = es.advancedSearch("field3:(+dog -your phrase^4)", null, -2, Indexer.TIMEOUT); assertTrue(result.getTotalHits() == 0); result = es.advancedSearch(""); assertTrue(result.getTotalHits() == 0); result = es.advancedSearch(null); assertTrue(result.getTotalHits() == 0); ok = true; break; } catch(Exception ex) { i++; } }while(i<4); if(!ok) { fail(); } }
@Override public SearchResult search(String text, String[] fields) throws ConnectionException, IndexerException { return search(text, fields, PAGE_SIZE, 0); }
Elasticsearch implements Indexer { @Override public SearchResult search(String text, String[] fields) throws ConnectionException, IndexerException { return search(text, fields, PAGE_SIZE, 0); } }
Elasticsearch implements Indexer { @Override public SearchResult search(String text, String[] fields) throws ConnectionException, IndexerException { return search(text, fields, PAGE_SIZE, 0); } Elasticsearch(IndexerInformations ii); Elasticsearch(String clasterAddresses, String index, String type); protected Elasticsearch(Client client, String index, String type); }
Elasticsearch implements Indexer { @Override public SearchResult search(String text, String[] fields) throws ConnectionException, IndexerException { return search(text, fields, PAGE_SIZE, 0); } Elasticsearch(IndexerInformations ii); Elasticsearch(String clasterAddresses, String index, String type); protected Elasticsearch(Client client, String index, String type); @Override Object getIndexer(); @Override SupportedIndexers getIndexerName(); @Override IndexerInformations getIndexerInformations(); @Override IndexedDocument getDocument(String documentId); @Override SearchResult getMoreLikeThis(String documentId); @Override SearchResult getMoreLikeThis(String documentId, int size, int timeout); @Override SearchResult getMoreLikeThis(String documentId, String[] fields); @Override SearchResult getMoreLikeThis(String documentId, String[] fields, int size, int timeout); @Override SearchResult getMoreLikeThis(String documentId, String[] fields, int maxQueryTerms, int minTermFreq, int minDocFreq, int maxDocFreq, int minWordLength, int maxWordLength, int size, int timeout, Boolean includeItself); @Override SearchResult search(String text, String[] fields); @Override SearchResult search(String text, String[] fields, int size, int timeout); @Override SearchResult searchFullText(String text); @Override SearchResult searchFullText(String text, int size, int timeout); @Override SearchResult searchPhraseInFullText(String text, int slop); @Override SearchResult searchPhrase(String text, String field, int slop); @Override SearchResult searchPhrase(String text, String field, int slop, int size, int timeout); @Override SearchResult advancedSearch(String query); @Override SearchResult advancedSearch(String query, int size, int timeout); @Override SearchResult advancedSearch(String query, Map<String, Object> parameters); @Override SearchResult advancedSearch(String query, Map<String, Object> parameters, int size, int timeout); @Override void insert(String data); @Override void insert(Map<String, Object> data); @Override void insert(String documentId, String data); @Override void insert(String documentId, Map<String, Object> data); @Override void update(String documentId, String data); @Override void update(String documentId, Map<String, Object> data); @Override void delete(String documentId); @Override SearchResult getNextPage(String scrollId, Object context); }
Elasticsearch implements Indexer { @Override public SearchResult search(String text, String[] fields) throws ConnectionException, IndexerException { return search(text, fields, PAGE_SIZE, 0); } Elasticsearch(IndexerInformations ii); Elasticsearch(String clasterAddresses, String index, String type); protected Elasticsearch(Client client, String index, String type); @Override Object getIndexer(); @Override SupportedIndexers getIndexerName(); @Override IndexerInformations getIndexerInformations(); @Override IndexedDocument getDocument(String documentId); @Override SearchResult getMoreLikeThis(String documentId); @Override SearchResult getMoreLikeThis(String documentId, int size, int timeout); @Override SearchResult getMoreLikeThis(String documentId, String[] fields); @Override SearchResult getMoreLikeThis(String documentId, String[] fields, int size, int timeout); @Override SearchResult getMoreLikeThis(String documentId, String[] fields, int maxQueryTerms, int minTermFreq, int minDocFreq, int maxDocFreq, int minWordLength, int maxWordLength, int size, int timeout, Boolean includeItself); @Override SearchResult search(String text, String[] fields); @Override SearchResult search(String text, String[] fields, int size, int timeout); @Override SearchResult searchFullText(String text); @Override SearchResult searchFullText(String text, int size, int timeout); @Override SearchResult searchPhraseInFullText(String text, int slop); @Override SearchResult searchPhrase(String text, String field, int slop); @Override SearchResult searchPhrase(String text, String field, int slop, int size, int timeout); @Override SearchResult advancedSearch(String query); @Override SearchResult advancedSearch(String query, int size, int timeout); @Override SearchResult advancedSearch(String query, Map<String, Object> parameters); @Override SearchResult advancedSearch(String query, Map<String, Object> parameters, int size, int timeout); @Override void insert(String data); @Override void insert(Map<String, Object> data); @Override void insert(String documentId, String data); @Override void insert(String documentId, Map<String, Object> data); @Override void update(String documentId, String data); @Override void update(String documentId, Map<String, Object> data); @Override void delete(String documentId); @Override SearchResult getNextPage(String scrollId, Object context); }
@Betamax(tape = "dataSets_shouldThrowDataSetNotExistsForDeleteDataSet") @Test(expected = DataSetNotExistsException.class) public void shouldThrowDataSetNotExistsForDeleteDataSet() throws MCSException { String providerId = "Provider002"; String dataSetId = "dataset000033"; DataSet dataSet = new DataSet(); dataSet.setProviderId(providerId); dataSet.setId(dataSetId); dataSet.setDescription(null); DataSetServiceClient instance = new DataSetServiceClient(baseUrl); instance.deleteDataSet(providerId, dataSetId); }
public void deleteDataSet(String providerId, String dataSetId) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Response response = null; try { response = target.request().delete(); if (response.getStatus() != Status.NO_CONTENT.getStatusCode()) { ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } } finally { if (response != null) { response.close(); } } }
DataSetServiceClient extends MCSClient { public void deleteDataSet(String providerId, String dataSetId) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Response response = null; try { response = target.request().delete(); if (response.getStatus() != Status.NO_CONTENT.getStatusCode()) { ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } } finally { if (response != null) { response.close(); } } } }
DataSetServiceClient extends MCSClient { public void deleteDataSet(String providerId, String dataSetId) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Response response = null; try { response = target.request().delete(); if (response.getStatus() != Status.NO_CONTENT.getStatusCode()) { ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); }
DataSetServiceClient extends MCSClient { public void deleteDataSet(String providerId, String dataSetId) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Response response = null; try { response = target.request().delete(); if (response.getStatus() != Status.NO_CONTENT.getStatusCode()) { ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
DataSetServiceClient extends MCSClient { public void deleteDataSet(String providerId, String dataSetId) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Response response = null; try { response = target.request().delete(); if (response.getStatus() != Status.NO_CONTENT.getStatusCode()) { ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
@Betamax(tape = "dataSets_shouldThrowDriverExceptionForDeleteDataSet") @Test(expected = DriverException.class) public void shouldThrowDriverExceptionForDeleteDataSet() throws MCSException { String providerId = "Provider002"; String dataSetId = "dataset000033"; DataSetServiceClient instance = new DataSetServiceClient(baseUrl); instance.deleteDataSet(providerId, dataSetId); }
public void deleteDataSet(String providerId, String dataSetId) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Response response = null; try { response = target.request().delete(); if (response.getStatus() != Status.NO_CONTENT.getStatusCode()) { ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } } finally { if (response != null) { response.close(); } } }
DataSetServiceClient extends MCSClient { public void deleteDataSet(String providerId, String dataSetId) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Response response = null; try { response = target.request().delete(); if (response.getStatus() != Status.NO_CONTENT.getStatusCode()) { ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } } finally { if (response != null) { response.close(); } } } }
DataSetServiceClient extends MCSClient { public void deleteDataSet(String providerId, String dataSetId) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Response response = null; try { response = target.request().delete(); if (response.getStatus() != Status.NO_CONTENT.getStatusCode()) { ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); }
DataSetServiceClient extends MCSClient { public void deleteDataSet(String providerId, String dataSetId) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Response response = null; try { response = target.request().delete(); if (response.getStatus() != Status.NO_CONTENT.getStatusCode()) { ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
DataSetServiceClient extends MCSClient { public void deleteDataSet(String providerId, String dataSetId) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_RESOURCE) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Response response = null; try { response = target.request().delete(); if (response.getStatus() != Status.NO_CONTENT.getStatusCode()) { ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
@Betamax(tape = "dataSets_shouldAssignRepresentation") @Test public void shouldAssignRepresentation() throws MCSException { String providerId = "Provider002"; String dataSetId = "dataset000008"; String cloudId = "1DZ6HTS415W"; String representationName = "schema66"; String versionId = "b95fcda0-994a-11e3-bfe1-1c6f653f6012"; DataSetServiceClient instance = new DataSetServiceClient(baseUrl); instance.assignRepresentationToDataSet(providerId, dataSetId, cloudId, representationName, null); assertEquals(TestUtils.howManyThisRepresentationVersion(instance, providerId, dataSetId, representationName, versionId), 1); }
public void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_ASSIGNMENTS) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Form form = getForm(cloudId, representationName, version); Response response = null; try { response = target.request().post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() != Status.NO_CONTENT.getStatusCode()) { ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } } finally { if (response != null) { response.close(); } } }
DataSetServiceClient extends MCSClient { public void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_ASSIGNMENTS) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Form form = getForm(cloudId, representationName, version); Response response = null; try { response = target.request().post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() != Status.NO_CONTENT.getStatusCode()) { ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } } finally { if (response != null) { response.close(); } } } }
DataSetServiceClient extends MCSClient { public void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_ASSIGNMENTS) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Form form = getForm(cloudId, representationName, version); Response response = null; try { response = target.request().post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() != Status.NO_CONTENT.getStatusCode()) { ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); }
DataSetServiceClient extends MCSClient { public void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_ASSIGNMENTS) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Form form = getForm(cloudId, representationName, version); Response response = null; try { response = target.request().post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() != Status.NO_CONTENT.getStatusCode()) { ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
DataSetServiceClient extends MCSClient { public void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_ASSIGNMENTS) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Form form = getForm(cloudId, representationName, version); Response response = null; try { response = target.request().post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() != Status.NO_CONTENT.getStatusCode()) { ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
@Betamax(tape = "dataSets_shouldAssignRepresentationVersion") @Test public void shouldAssignRepresentationVersion() throws MCSException { String providerId = "Provider001"; String dataSetId = "dataset000066"; String cloudId = "1DZ6HTS415W"; String representationName = "schema77"; String versionId1 = "49398390-9a3f-11e3-9690-1c6f653f6012"; DataSetServiceClient instance = new DataSetServiceClient(baseUrl); instance.assignRepresentationToDataSet(providerId, dataSetId, cloudId, representationName, versionId1); assertEquals(TestUtils.howManyThisRepresentationVersion(instance, providerId, dataSetId, representationName, versionId1), 1); }
public void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_ASSIGNMENTS) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Form form = getForm(cloudId, representationName, version); Response response = null; try { response = target.request().post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() != Status.NO_CONTENT.getStatusCode()) { ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } } finally { if (response != null) { response.close(); } } }
DataSetServiceClient extends MCSClient { public void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_ASSIGNMENTS) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Form form = getForm(cloudId, representationName, version); Response response = null; try { response = target.request().post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() != Status.NO_CONTENT.getStatusCode()) { ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } } finally { if (response != null) { response.close(); } } } }
DataSetServiceClient extends MCSClient { public void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_ASSIGNMENTS) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Form form = getForm(cloudId, representationName, version); Response response = null; try { response = target.request().post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() != Status.NO_CONTENT.getStatusCode()) { ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); }
DataSetServiceClient extends MCSClient { public void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_ASSIGNMENTS) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Form form = getForm(cloudId, representationName, version); Response response = null; try { response = target.request().post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() != Status.NO_CONTENT.getStatusCode()) { ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
DataSetServiceClient extends MCSClient { public void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_ASSIGNMENTS) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Form form = getForm(cloudId, representationName, version); Response response = null; try { response = target.request().post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() != Status.NO_CONTENT.getStatusCode()) { ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
@Betamax(tape = "dataSets_shouldOverrideAssignedRepresentationVersion") @Test public void shouldOverrideAssignedRepresentationVersion() throws MCSException { String providerId = "Provider001"; String dataSetId = "dataset000066"; String cloudId = "1DZ6HTS415W"; String representationName = "schema77"; String versionId2 = "97dd0b70-9a3f-11e3-9690-1c6f653f6012"; DataSetServiceClient instance = new DataSetServiceClient(baseUrl); instance.assignRepresentationToDataSet(providerId, dataSetId, cloudId, representationName, versionId2); assertEquals(TestUtils.howManyThisRepresentationVersion(instance, providerId, dataSetId, representationName, versionId2), 1); }
public void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_ASSIGNMENTS) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Form form = getForm(cloudId, representationName, version); Response response = null; try { response = target.request().post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() != Status.NO_CONTENT.getStatusCode()) { ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } } finally { if (response != null) { response.close(); } } }
DataSetServiceClient extends MCSClient { public void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_ASSIGNMENTS) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Form form = getForm(cloudId, representationName, version); Response response = null; try { response = target.request().post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() != Status.NO_CONTENT.getStatusCode()) { ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } } finally { if (response != null) { response.close(); } } } }
DataSetServiceClient extends MCSClient { public void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_ASSIGNMENTS) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Form form = getForm(cloudId, representationName, version); Response response = null; try { response = target.request().post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() != Status.NO_CONTENT.getStatusCode()) { ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); }
DataSetServiceClient extends MCSClient { public void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_ASSIGNMENTS) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Form form = getForm(cloudId, representationName, version); Response response = null; try { response = target.request().post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() != Status.NO_CONTENT.getStatusCode()) { ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }
DataSetServiceClient extends MCSClient { public void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version) throws MCSException { WebTarget target = client .target(this.baseUrl) .path(DATA_SET_ASSIGNMENTS) .resolveTemplate(PROVIDER_ID, providerId) .resolveTemplate(DATA_SET_ID, dataSetId); Form form = getForm(cloudId, representationName, version); Response response = null; try { response = target.request().post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE)); if (response.getStatus() != Status.NO_CONTENT.getStatusCode()) { ErrorInfo errorInfo = response.readEntity(ErrorInfo.class); throw MCSExceptionProvider.generateException(errorInfo); } } finally { if (response != null) { response.close(); } } } DataSetServiceClient(String baseUrl); DataSetServiceClient(String baseUrl, final String authorization); DataSetServiceClient(String baseUrl, final String username, final String password); DataSetServiceClient(String baseUrl, final String authorizationHeader, final String username, final String password, final int connectTimeoutInMillis, final int readTimeoutInMillis); ResultSlice<DataSet> getDataSetsForProviderChunk(String providerId, String startFrom); List<DataSet> getDataSetsForProvider(String providerId); DataSetIterator getDataSetIteratorForProvider(String providerId); URI createDataSet(String providerId, String dataSetId, String description); ResultSlice<Representation> getDataSetRepresentationsChunk( String providerId, String dataSetId, String startFrom); List<Representation> getDataSetRepresentations(String providerId, String dataSetId); RepresentationIterator getRepresentationIterator(String providerId, String dataSetId); void updateDescriptionOfDataSet(String providerId, String dataSetId, String description); void deleteDataSet(String providerId, String dataSetId); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); void assignRepresentationToDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version, String key, String value); void unassignRepresentationFromDataSet( String providerId, String dataSetId, String cloudId, String representationName, String version); ResultSlice<CloudTagsResponse> getDataSetRevisionsChunk( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp, String startFrom, Integer limit); List<CloudTagsResponse> getDataSetRevisions( String providerId, String dataSetId, String representationName, String revisionName, String revisionProviderId, String revisionTimestamp); ResultSlice<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentationChunk(String dataSetId, String providerId, String representationName, String dateFrom, String tag, String startFrom); List<CloudVersionRevisionResponse> getDataSetCloudIdsByRepresentation(String dataSetId, String providerId, String representationName, String dateFrom, String tag); ResultSlice<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevisionChunk( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted, String startFrom); List<CloudIdAndTimestampResponse> getLatestDataSetCloudIdByRepresentationAndRevision( String dataSetId, String providerId, String revisionProvider, String revisionName, String representationName, Boolean isDeleted); String getLatelyTaggedRecords( String dataSetId, String providerId, String cloudId, String representationName, String revisionName, String revisionProviderId); void useAuthorizationHeader(final String headerValue); void close(); }