Search in sources :

Example 16 with CreateResponseImpl

use of ddf.catalog.operation.impl.CreateResponseImpl in project ddf by codice.

the class FederationAdminServiceImplTest method testAddRegistryEntry.

@Test
public void testAddRegistryEntry() throws Exception {
    String destination = TEST_DESTINATION;
    Metacard metacard = testMetacard;
    Metacard createdMetacard = testMetacard;
    Set<String> destinations = new HashSet<>();
    destinations.add(destination);
    Subject systemSubject = security.getSystemSubject();
    Map<String, Serializable> properties = new HashMap<>();
    properties.put(SecurityConstants.SECURITY_SUBJECT, systemSubject);
    CreateRequest request = new CreateRequestImpl(Collections.singletonList(metacard), properties, destinations);
    CreateResponse response = new CreateResponseImpl(request, null, Collections.singletonList(createdMetacard));
    when(catalogFramework.create(any(CreateRequest.class))).thenReturn(response);
    String createdMetacardId = federationAdminServiceImpl.addRegistryEntry(metacard, destinations);
    assertThat(createdMetacardId, is(equalTo(RegistryObjectMetacardType.REGISTRY_ID)));
    verify(catalogFramework).create(any(CreateRequest.class));
}
Also used : Metacard(ddf.catalog.data.Metacard) Serializable(java.io.Serializable) HashMap(java.util.HashMap) CreateRequest(ddf.catalog.operation.CreateRequest) CreateResponse(ddf.catalog.operation.CreateResponse) CreateRequestImpl(ddf.catalog.operation.impl.CreateRequestImpl) Subject(ddf.security.Subject) HashSet(java.util.HashSet) CreateResponseImpl(ddf.catalog.operation.impl.CreateResponseImpl) Test(org.junit.Test)

Example 17 with CreateResponseImpl

use of ddf.catalog.operation.impl.CreateResponseImpl in project ddf by codice.

the class FederationAdminServiceImplTest method testAddRegistryEntryWithNullDestinations.

@Test
public void testAddRegistryEntryWithNullDestinations() throws Exception {
    String registryId = RegistryObjectMetacardType.REGISTRY_ID;
    Metacard metacard = testMetacard;
    Metacard createdMetacard = testMetacard;
    Set<String> destinations = null;
    Subject systemSubject = security.getSystemSubject();
    Map<String, Serializable> properties = new HashMap<>();
    properties.put(SecurityConstants.SECURITY_SUBJECT, systemSubject);
    CreateRequest request = new CreateRequestImpl(Collections.singletonList(metacard), properties, destinations);
    CreateResponse response = new CreateResponseImpl(request, null, Collections.singletonList(createdMetacard));
    when(catalogFramework.create(any(CreateRequest.class))).thenReturn(response);
    String createdMetacardId = federationAdminServiceImpl.addRegistryEntry(metacard, destinations);
    assertThat(createdMetacardId, is(equalTo(registryId)));
    verify(catalogFramework).create(any(CreateRequest.class));
}
Also used : Metacard(ddf.catalog.data.Metacard) Serializable(java.io.Serializable) HashMap(java.util.HashMap) CreateRequest(ddf.catalog.operation.CreateRequest) CreateResponse(ddf.catalog.operation.CreateResponse) CreateRequestImpl(ddf.catalog.operation.impl.CreateRequestImpl) Subject(ddf.security.Subject) CreateResponseImpl(ddf.catalog.operation.impl.CreateResponseImpl) Test(org.junit.Test)

Example 18 with CreateResponseImpl

use of ddf.catalog.operation.impl.CreateResponseImpl in project ddf by codice.

the class CreateOperations method doRemoteCreate.

private CreateResponse doRemoteCreate(CreateRequest createRequest) {
    HashSet<ProcessingDetails> exceptions = new HashSet<>();
    Map<String, Serializable> properties = new HashMap<>();
    List<CatalogStore> stores = opsCatStoreSupport.getCatalogStoresForRequest(createRequest, exceptions);
    for (CatalogStore store : stores) {
        try {
            if (!store.isAvailable()) {
                exceptions.add(new ProcessingDetailsImpl(store.getId(), null, "CatalogStore is not available"));
            } else {
                CreateResponse response = store.create(createRequest);
                properties.put(store.getId(), new ArrayList<>(response.getCreatedMetacards()));
            }
        } catch (IngestException e) {
            INGEST_LOGGER.error("Error creating metacards for CatalogStore {}", store.getId(), e);
            exceptions.add(new ProcessingDetailsImpl(store.getId(), e));
        }
    }
    return new CreateResponseImpl(createRequest, properties, createRequest.getMetacards(), exceptions);
}
Also used : Serializable(java.io.Serializable) HashMap(java.util.HashMap) CreateResponse(ddf.catalog.operation.CreateResponse) ProcessingDetailsImpl(ddf.catalog.operation.impl.ProcessingDetailsImpl) ProcessingDetails(ddf.catalog.operation.ProcessingDetails) CatalogStore(ddf.catalog.source.CatalogStore) InternalIngestException(ddf.catalog.source.InternalIngestException) IngestException(ddf.catalog.source.IngestException) HashSet(java.util.HashSet) CreateResponseImpl(ddf.catalog.operation.impl.CreateResponseImpl)

Example 19 with CreateResponseImpl

use of ddf.catalog.operation.impl.CreateResponseImpl in project ddf by codice.

the class TestCswEndpoint method setUpBeforeClass.

@org.junit.Before
public void setUpBeforeClass() throws URISyntaxException, SourceUnavailableException, UnsupportedQueryException, FederationException, ParseException, IngestException {
    URI mockUri = new URI("http://example.com/services/csw");
    when(mockUriInfo.getBaseUri()).thenReturn(mockUri);
    URL resourceUrl = TestCswEndpoint.class.getResource("/record.xsd");
    URL resourceUrlDot = TestCswEndpoint.class.getClass().getResource(".");
    when(mockBundle.getResource("record.xsd")).thenReturn(resourceUrl);
    when(mockBundle.getResource("csw/2.0.2/record.xsd")).thenReturn(resourceUrl);
    when(mockBundle.getResource("gmd/record_gmd.xsd")).thenReturn(resourceUrl);
    when(mockBundle.getResource(".")).thenReturn(resourceUrlDot);
    csw = new CswEndpointStub(catalogFramework, mockMimeTypeManager, mockSchemaManager, mockInputManager, validator, queryFactory, mockBundle);
    csw.setUri(mockUriInfo);
    when(mockMimeTypeManager.getAvailableMimeTypes()).thenReturn(Arrays.asList(MediaType.APPLICATION_XML));
    when(mockSchemaManager.getAvailableSchemas()).thenReturn(new ArrayList<>(Arrays.asList(CswConstants.CSW_OUTPUT_SCHEMA)));
    when(mockSchemaManager.getTransformerBySchema(CswConstants.CSW_OUTPUT_SCHEMA)).thenReturn(mockTransformer);
    when(mockInputManager.getAvailableIds()).thenReturn(Arrays.asList(CswConstants.CSW_RECORD));
    QueryResponseImpl response = new QueryResponseImpl(null, new LinkedList<>(), 0);
    argument = ArgumentCaptor.forClass(QueryRequest.class);
    reset(catalogFramework);
    when(catalogFramework.query(argument.capture())).thenReturn(response);
    when(catalogFramework.getSourceIds()).thenReturn(new HashSet<>(Arrays.asList("source1", "source2", "source3")));
    CreateResponseImpl createResponse = new CreateResponseImpl(null, null, Arrays.asList(new MetacardImpl()));
    when(catalogFramework.create(any(CreateRequest.class))).thenReturn(createResponse);
}
Also used : QueryResponseImpl(ddf.catalog.operation.impl.QueryResponseImpl) QueryRequest(ddf.catalog.operation.QueryRequest) CreateRequest(ddf.catalog.operation.CreateRequest) URI(java.net.URI) URL(java.net.URL) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) CreateResponseImpl(ddf.catalog.operation.impl.CreateResponseImpl)

Example 20 with CreateResponseImpl

use of ddf.catalog.operation.impl.CreateResponseImpl in project ddf by codice.

the class TestPlugin method testCreate.

@Test
@Ignore
public void testCreate() throws PluginExecutionException, CatalogTransformerException, IOException, IngestException, SourceUnavailableException {
    // given
    CreateResponse createResponse = new CreateResponseImpl(new CreateRequestImpl(metacard), null, Arrays.asList(metacard));
    // when
    CreateResponse response = plugin.process(createResponse);
    // then
    verify(endpoint).addDocument(isA(HttpHeaders.class), isA(UriInfo.class), isA(InputStream.class));
    assertThat(response, sameInstance(createResponse));
}
Also used : HttpHeaders(javax.ws.rs.core.HttpHeaders) CreateResponse(ddf.catalog.operation.CreateResponse) InputStream(java.io.InputStream) CreateRequestImpl(ddf.catalog.operation.impl.CreateRequestImpl) UriInfo(javax.ws.rs.core.UriInfo) CreateResponseImpl(ddf.catalog.operation.impl.CreateResponseImpl) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

CreateResponseImpl (ddf.catalog.operation.impl.CreateResponseImpl)28 CreateResponse (ddf.catalog.operation.CreateResponse)24 Test (org.junit.Test)21 Metacard (ddf.catalog.data.Metacard)17 CreateRequestImpl (ddf.catalog.operation.impl.CreateRequestImpl)16 HashMap (java.util.HashMap)15 CreateRequest (ddf.catalog.operation.CreateRequest)14 ArrayList (java.util.ArrayList)10 Serializable (java.io.Serializable)9 List (java.util.List)7 Subject (ddf.security.Subject)6 Exchange (org.apache.camel.Exchange)6 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)6 IngestException (ddf.catalog.source.IngestException)5 InputStream (java.io.InputStream)5 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)4 DeleteResponse (ddf.catalog.operation.DeleteResponse)4 HashSet (java.util.HashSet)4 DeleteResponseImpl (ddf.catalog.operation.impl.DeleteResponseImpl)3 HttpHeaders (javax.ws.rs.core.HttpHeaders)3