use of ddf.catalog.data.impl.AttributeImpl in project ddf by codice.
the class PptxInputTransformer method extractThumbnail.
/**
* SlideShowFactory.create() will perform the tests for password protected files.
* <p/>
* Because Apache POI dynamically loads the classes needed to handle a PPTX file, the default
* class loader is unable to find the dependencies during runtime. Therefore, the original class
* loader is saved, then current class loader is set to this class's class loader, and finally
* the original class loader is restored.
*
* @param metacard
* @param input
* @throws IOException
*/
private void extractThumbnail(Metacard metacard, InputStream input) throws IOException {
ClassLoader originalContextClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
SlideShow<?, ?> genericSlideShow = SlideShowFactory.create(input);
if (genericSlideShow instanceof XMLSlideShow) {
XMLSlideShow xmlSlideShow = (XMLSlideShow) genericSlideShow;
byte[] thumbnail = generatePptxThumbnail(xmlSlideShow);
if (thumbnail != null) {
metacard.setAttribute(new AttributeImpl(Metacard.THUMBNAIL, thumbnail));
}
} else {
LOGGER.debug("Cannot transform old style (OLE2) ppt : id = {}", metacard.getId());
}
} finally {
Thread.currentThread().setContextClassLoader(originalContextClassLoader);
}
}
use of ddf.catalog.data.impl.AttributeImpl in project ddf by codice.
the class TestDuplicationValidator method setup.
@Before
public void setup() throws UnsupportedQueryException, SourceUnavailableException, FederationException {
QueryResponse response = mock(QueryResponse.class);
when(mockFramework.query(any(QueryRequest.class))).thenReturn(response);
testMetacard = new MetacardImpl();
matchingMetacard = new MetacardImpl();
matchingMetacard.setId(ID);
testMetacard.setId("test metacard ID");
matchingMetacard.setAttribute(new AttributeImpl(Metacard.CHECKSUM, "checksum-value"));
testMetacard.setAttribute(new AttributeImpl(Metacard.CHECKSUM, "checksum-value"));
matchingMetacard.setTags(tags);
testMetacard.setTags(tags);
List<Result> results = Arrays.asList(new ResultImpl(matchingMetacard));
when(response.getResults()).thenReturn(results);
validator = new DuplicationValidator(mockFramework, mockFilterBuilder);
}
use of ddf.catalog.data.impl.AttributeImpl in project ddf by codice.
the class HistorianTest method getMetacardUpdatePair.
private List<Metacard> getMetacardUpdatePair() {
Metacard old = new MetacardImpl();
old.setAttribute(new AttributeImpl(Metacard.ID, METACARD_ID));
old.setAttribute(new AttributeImpl(Metacard.RESOURCE_URI, RESOURCE_URI));
Metacard update = new MetacardImpl();
update.setAttribute(new AttributeImpl(Metacard.ID, METACARD_ID));
update.setAttribute(new AttributeImpl(Metacard.RESOURCE_URI, RESOURCE_URI));
update.setAttribute(new AttributeImpl(Metacard.DESCRIPTION, UPDATE_DESCRIPTION));
return Arrays.asList(old, update);
}
use of ddf.catalog.data.impl.AttributeImpl in project ddf by codice.
the class QueryOperations method populateQueryResponsePolicyMap.
private QueryResponse populateQueryResponsePolicyMap(QueryResponse queryResponse) throws FederationException {
HashMap<String, Set<String>> responsePolicyMap = new HashMap<>();
Map<String, Serializable> unmodifiableProperties = Collections.unmodifiableMap(queryResponse.getProperties());
for (Result result : queryResponse.getResults()) {
HashMap<String, Set<String>> itemPolicyMap = new HashMap<>();
for (PolicyPlugin plugin : frameworkProperties.getPolicyPlugins()) {
try {
PolicyResponse policyResponse = plugin.processPostQuery(result, unmodifiableProperties);
opsSecuritySupport.buildPolicyMap(itemPolicyMap, policyResponse.itemPolicy().entrySet());
opsSecuritySupport.buildPolicyMap(responsePolicyMap, policyResponse.operationPolicy().entrySet());
} catch (StopProcessingException e) {
throw new FederationException("Query could not be executed.", e);
}
}
result.getMetacard().setAttribute(new AttributeImpl(Metacard.SECURITY, itemPolicyMap));
}
queryResponse.getProperties().put(PolicyPlugin.OPERATION_SECURITY, responsePolicyMap);
return queryResponse;
}
use of ddf.catalog.data.impl.AttributeImpl in project ddf by codice.
the class CachedResourceMetacardComparatorTest method createMetacard.
private MetacardImpl createMetacard(String metacardId, Instant createdDate, Instant effectiveDate, Instant expireDate, Instant modDate) throws Exception {
String locWkt = "POLYGON ((30 10, 10 20, 20 40, 40 40, 30 10))";
URI nsUri = new URI("http://" + CachedResourceMetacardComparatorTest.class.getName());
URI resourceUri = new URI(nsUri.toString() + "/resource1.png");
URI derivedResourceUri = new URI(nsUri.toString() + "/derived.png");
URL deriverResourceUrl = derivedResourceUri.toURL();
HashMap<String, List<String>> securityMap = new HashMap<>();
securityMap.put("key1", ImmutableList.of("value1"));
securityMap.put("key2", ImmutableList.of("value1", "value2"));
MetacardImpl metacard = new MetacardImpl(BasicTypes.BASIC_METACARD);
metacard.setContentTypeName("testContentType");
metacard.setContentTypeVersion("testContentTypeVersion");
metacard.setCreatedDate(Date.from(createdDate));
metacard.setDescription("testDescription");
metacard.setEffectiveDate(Date.from(effectiveDate));
metacard.setExpirationDate(Date.from(expireDate));
metacard.setId(metacardId);
metacard.setLocation(locWkt);
metacard.setMetadata("testMetadata");
metacard.setModifiedDate(Date.from(modDate));
metacard.setPointOfContact("pointOfContact");
metacard.setResourceURI(resourceUri);
metacard.setSourceId("testSourceId");
metacard.setTargetNamespace(nsUri);
metacard.setThumbnail(new byte[] { 1, 2, 3, 4, 5 });
metacard.setTitle("testTitle");
metacard.setResourceSize("1");
metacard.setSecurity(securityMap);
metacard.setTags(ImmutableSet.of("tag1", "tag2"));
metacard.setAttribute(Metacard.CHECKSUM, "1");
metacard.setAttribute(new AttributeImpl(Metacard.CHECKSUM_ALGORITHM, "sha1"));
metacard.setAttribute(new AttributeImpl(Metacard.DEFAULT_TAG, "tag1"));
metacard.setAttribute(new AttributeImpl(Metacard.DERIVED, "derivedMetacard"));
metacard.setAttribute(new AttributeImpl(Metacard.DERIVED_RESOURCE_DOWNLOAD_URL, deriverResourceUrl));
metacard.setAttribute(new AttributeImpl(Metacard.DERIVED_RESOURCE_URI, derivedResourceUri));
metacard.setAttribute(new AttributeImpl(Metacard.RELATED, "otherMetacardId"));
return metacard;
}
Aggregations