use of ddf.catalog.operation.impl.CreateRequestImpl in project ddf by codice.
the class TestRegistryStore method testCreateNoExistingMetacard.
@Test
public void testCreateNoExistingMetacard() throws Exception {
Metacard mcard = getDefaultMetacard();
Csw csw = mock(Csw.class);
TransactionResponseType responseType = mock(TransactionResponseType.class);
InsertResultType insertResultType = mock(InsertResultType.class);
BriefRecordType briefRecord = mock(BriefRecordType.class);
JAXBElement identifier = mock(JAXBElement.class);
SimpleLiteral literal = mock(SimpleLiteral.class);
when(literal.getContent()).thenReturn(Collections.singletonList(mcard.getId()));
when(identifier.getValue()).thenReturn(literal);
when(briefRecord.getIdentifier()).thenReturn(Collections.singletonList(identifier));
when(insertResultType.getBriefRecord()).thenReturn(Collections.singletonList(briefRecord));
when(responseType.getInsertResult()).thenReturn(Collections.singletonList(insertResultType));
when(factory.getClientForSubject(any())).thenReturn(csw);
when(csw.transaction(any())).thenReturn(responseType);
when(transformer.getTransformerIdForSchema(any())).thenReturn("myInsertType");
queryResults.add(new ResultImpl(mcard));
CreateRequest request = new CreateRequestImpl(mcard);
CreateResponse response = registryStore.create(request);
assertThat(response.getCreatedMetacards().get(0), is(mcard));
}
use of ddf.catalog.operation.impl.CreateRequestImpl in project ddf by codice.
the class TestRegistryStore method testCreateNonRegistryMetacard.
@Test(expected = IngestException.class)
public void testCreateNonRegistryMetacard() throws Exception {
MetacardImpl mcard = getDefaultMetacard();
mcard.setAttribute(RegistryObjectMetacardType.REGISTRY_ID, null);
CreateRequest request = new CreateRequestImpl(mcard);
registryStore.create(request);
}
use of ddf.catalog.operation.impl.CreateRequestImpl in project ddf by codice.
the class FederationAdminServiceImpl method addRegistryEntries.
@Override
public List<String> addRegistryEntries(List<Metacard> metacards, Set<String> destinations) throws FederationAdminException {
validateRegistryMetacards(metacards);
List<String> registryIds;
Map<String, Serializable> properties = new HashMap<>();
CreateRequest createRequest = new CreateRequestImpl(metacards, properties, destinations);
try {
CreateResponse createResponse = security.runWithSubjectOrElevate(() -> catalogFramework.create(createRequest));
//loop through to get id's
if (!createResponse.getProcessingErrors().isEmpty()) {
throw new FederationAdminException("Processing error occurred while creating registry entry. Details:" + System.lineSeparator() + stringifyProcessingErrors(createResponse.getProcessingErrors()));
}
registryIds = createResponse.getCreatedMetacards().stream().filter(RegistryUtility::isRegistryMetacard).map(RegistryUtility::getRegistryId).collect(Collectors.toList());
} catch (SecurityServiceException | InvocationTargetException e) {
throw new FederationAdminException("Error adding local registry entry.", e);
}
return registryIds;
}
use of ddf.catalog.operation.impl.CreateRequestImpl in project ddf by codice.
the class WorkspacePreIngestPluginTest method testSuccessfulIngest.
@Test
public void testSuccessfulIngest() throws Exception {
WorkspacePreIngestPlugin wpip = makePlugin();
WorkspaceMetacardImpl workspace = new WorkspaceMetacardImpl();
wpip.process(new CreateRequestImpl(workspace));
assertThat(workspace.getOwner(), is("admin@localhost"));
}
use of ddf.catalog.operation.impl.CreateRequestImpl in project ddf by codice.
the class TestMetacardGroomerPlugin method processCreate.
private Metacard processCreate(Metacard inputMetacard) throws PluginExecutionException, StopProcessingException {
CreateRequestImpl inputRequest = new CreateRequestImpl(copy(inputMetacard));
CreateRequest returnedRequest = plugin.process(inputRequest);
assertNotNull(returnedRequest);
assertThat(returnedRequest.getMetacards().size(), is(1));
return returnedRequest.getMetacards().get(0);
}
Aggregations