use of net.opengis.gml._3.ObjectFactory in project struts by apache.
the class AbstractBeanSelectionProvider method alias.
protected void alias(Class type, String key, ContainerBuilder builder, Properties props, Scope scope) {
if (!builder.contains(type, Container.DEFAULT_NAME)) {
String foundName = props.getProperty(key, DEFAULT_BEAN_NAME);
if (builder.contains(type, foundName)) {
LOG.trace("Choosing bean ({}) for ({})", foundName, type.getName());
builder.alias(type, foundName, Container.DEFAULT_NAME);
} else {
try {
Class cls = ClassLoaderUtil.loadClass(foundName, this.getClass());
LOG.trace("Choosing bean ({}) for ({})", cls.getName(), type.getName());
builder.factory(type, cls, scope);
} catch (ClassNotFoundException ex) {
// Perhaps a spring bean id, so we'll delegate to the object factory at runtime
LOG.trace("Choosing bean ({}) for ({}) to be loaded from the ObjectFactory", foundName, type.getName());
if (DEFAULT_BEAN_NAME.equals(foundName)) {
// Probably an optional bean, will ignore
} else {
if (ObjectFactory.class != type) {
builder.factory(type, new ObjectFactoryDelegateFactory(foundName, type), scope);
} else {
throw new ConfigurationException("Cannot locate the chosen ObjectFactory implementation: " + foundName);
}
}
}
}
} else {
LOG.warn("Unable to alias bean type ({}), default mapping already assigned.", type.getName());
}
}
use of net.opengis.gml._3.ObjectFactory in project struts by apache.
the class Dispatcher method cleanup.
/**
* Releases all instances bound to this dispatcher instance.
*/
public void cleanup() {
// clean up ObjectFactory
ObjectFactory objectFactory = getContainer().getInstance(ObjectFactory.class);
if (objectFactory == null) {
LOG.warn("Object Factory is null, something is seriously wrong, no clean up will be performed");
}
if (objectFactory instanceof ObjectFactoryDestroyable) {
try {
((ObjectFactoryDestroyable) objectFactory).destroy();
} catch (Exception e) {
// catch any exception that may occurred during destroy() and log it
LOG.error("Exception occurred while destroying ObjectFactory [{}]", objectFactory.toString(), e);
}
}
// clean up Dispatcher itself for this thread
instance.set(null);
servletContext.setAttribute(StrutsStatics.SERVLET_DISPATCHER, null);
// clean up DispatcherListeners
if (!dispatcherListeners.isEmpty()) {
for (DispatcherListener l : dispatcherListeners) {
l.dispatcherDestroyed(this);
}
}
// clean up all interceptors by calling their destroy() method
Set<Interceptor> interceptors = new HashSet<>();
Collection<PackageConfig> packageConfigs = configurationManager.getConfiguration().getPackageConfigs().values();
for (PackageConfig packageConfig : packageConfigs) {
for (Object config : packageConfig.getAllInterceptorConfigs().values()) {
if (config instanceof InterceptorStackConfig) {
for (InterceptorMapping interceptorMapping : ((InterceptorStackConfig) config).getInterceptors()) {
interceptors.add(interceptorMapping.getInterceptor());
}
}
}
}
for (Interceptor interceptor : interceptors) {
interceptor.destroy();
}
// Clear container holder when application is unloaded / server shutdown
ContainerHolder.clear();
// cleanup action context
ActionContext.clear();
// clean up configuration
configurationManager.destroyConfiguration();
configurationManager = null;
}
use of net.opengis.gml._3.ObjectFactory in project struts by apache.
the class DomHelper method parse.
/**
* Creates a W3C Document that remembers the location of each element in
* the source file. The location of element nodes can then be retrieved
* using the {@link #getLocationObject(Element)} method.
*
* @param inputSource the inputSource to read the document from
* @param dtdMappings a map of DTD names and public ids
*
* @return the W3C Document
*/
public static Document parse(InputSource inputSource, Map<String, String> dtdMappings) {
SAXParserFactory factory = null;
String parserProp = System.getProperty("xwork.saxParserFactory");
if (parserProp != null) {
try {
ObjectFactory objectFactory = ActionContext.getContext().getContainer().getInstance(ObjectFactory.class);
Class clazz = objectFactory.getClassInstance(parserProp);
factory = (SAXParserFactory) clazz.newInstance();
} catch (Exception e) {
LOG.error("Unable to load saxParserFactory set by system property 'xwork.saxParserFactory': {}", parserProp, e);
}
}
if (factory == null) {
factory = SAXParserFactory.newInstance();
}
factory.setValidating((dtdMappings != null));
factory.setNamespaceAware(true);
SAXParser parser;
try {
parser = factory.newSAXParser();
} catch (Exception ex) {
throw new StrutsException("Unable to create SAX parser", ex);
}
DOMBuilder builder = new DOMBuilder();
// Enhance the sax stream with location information
ContentHandler locationHandler = new LocationAttributes.Pipe(builder);
try {
parser.parse(inputSource, new StartHandler(locationHandler, dtdMappings));
} catch (Exception ex) {
throw new StrutsException(ex);
}
return builder.getDocument();
}
use of net.opengis.gml._3.ObjectFactory in project ddf by codice.
the class CswEndpoint method getInsertResultFromResponse.
private InsertResultType getInsertResultFromResponse(CreateResponse createResponse) throws CswException {
InsertResultType result = new InsertResultType();
WKTReader reader = new WKTReader();
for (Metacard metacard : createResponse.getCreatedMetacards()) {
BoundingBoxType boundingBox = new BoundingBoxType();
Geometry geometry = null;
String bbox = null;
try {
if (metacard.getAttribute(CswConstants.BBOX_PROP) != null) {
bbox = metacard.getAttribute(CswConstants.BBOX_PROP).getValue().toString();
geometry = reader.read(bbox);
} else if (StringUtils.isNotBlank(metacard.getLocation())) {
bbox = metacard.getLocation();
geometry = reader.read(bbox);
}
} catch (ParseException e) {
LOGGER.debug("Unable to parse BoundingBox : {}", bbox, e);
}
BriefRecordType briefRecordType = new BriefRecordType();
if (geometry != null) {
Envelope bounds = geometry.getEnvelopeInternal();
if (bounds != null) {
boundingBox.setCrs(CswConstants.SRS_NAME);
boundingBox.setLowerCorner(Arrays.asList(bounds.getMinX(), bounds.getMinY()));
boundingBox.setUpperCorner(Arrays.asList(bounds.getMaxX(), bounds.getMaxY()));
briefRecordType.getBoundingBox().add(new net.opengis.ows.v_1_0_0.ObjectFactory().createBoundingBox(boundingBox));
}
}
SimpleLiteral identifier = new SimpleLiteral();
identifier.getContent().add(metacard.getId());
briefRecordType.getIdentifier().add(new JAXBElement<>(CswConstants.DC_IDENTIFIER_QNAME, SimpleLiteral.class, identifier));
SimpleLiteral title = new SimpleLiteral();
title.getContent().add(metacard.getTitle());
briefRecordType.getTitle().add(new JAXBElement<>(CswConstants.DC_TITLE_QNAME, SimpleLiteral.class, title));
SimpleLiteral type = new SimpleLiteral();
type.getContent().add(metacard.getContentTypeName());
briefRecordType.setType(type);
result.getBriefRecord().add(briefRecordType);
}
return result;
}
use of net.opengis.gml._3.ObjectFactory in project ddf by codice.
the class XacmlClientTest method testEvaluateroleuseractionquerycitizenshipCA.
@Test
public void testEvaluateroleuseractionquerycitizenshipCA() throws Exception {
LOGGER.debug("\n\n\n##### testEvaluate_role_user_action_query_citizenship_CA");
final String country = "CA";
testSetup();
RequestType xacmlRequestType = new RequestType();
xacmlRequestType.setCombinedDecision(false);
xacmlRequestType.setReturnPolicyIdList(false);
AttributesType actionAttributes = new AttributesType();
actionAttributes.setCategory(ACTION_CATEGORY);
AttributeType actionAttribute = new AttributeType();
actionAttribute.setAttributeId(ACTION_ID);
actionAttribute.setIncludeInResult(false);
AttributeValueType actionValue = new AttributeValueType();
actionValue.setDataType(STRING_DATA_TYPE);
actionValue.getContent().add(QUERY_ACTION);
actionAttribute.getAttributeValue().add(actionValue);
actionAttributes.getAttribute().add(actionAttribute);
AttributesType subjectAttributes = new AttributesType();
subjectAttributes.setCategory(SUBJECT_CATEGORY);
AttributeType subjectAttribute = new AttributeType();
subjectAttribute.setAttributeId(SUBJECT_ID);
subjectAttribute.setIncludeInResult(false);
AttributeValueType subjectValue = new AttributeValueType();
subjectValue.setDataType(STRING_DATA_TYPE);
subjectValue.getContent().add(TEST_USER_2);
subjectAttribute.getAttributeValue().add(subjectValue);
subjectAttributes.getAttribute().add(subjectAttribute);
AttributeType roleAttribute = new AttributeType();
roleAttribute.setAttributeId(ROLE_CLAIM);
roleAttribute.setIncludeInResult(false);
AttributeValueType roleValue = new AttributeValueType();
roleValue.setDataType(STRING_DATA_TYPE);
roleValue.getContent().add(ROLE);
roleAttribute.getAttributeValue().add(roleValue);
subjectAttributes.getAttribute().add(roleAttribute);
AttributesType categoryAttributes = new AttributesType();
categoryAttributes.setCategory(PERMISSIONS_CATEGORY);
AttributeType citizenshipAttribute = new AttributeType();
citizenshipAttribute.setAttributeId(CITIZENSHIP_ATTRIBUTE);
citizenshipAttribute.setIncludeInResult(false);
AttributeValueType citizenshipValue = new AttributeValueType();
citizenshipValue.setDataType(STRING_DATA_TYPE);
citizenshipValue.getContent().add(country);
citizenshipAttribute.getAttributeValue().add(citizenshipValue);
categoryAttributes.getAttribute().add(citizenshipAttribute);
xacmlRequestType.getAttributes().add(actionAttributes);
xacmlRequestType.getAttributes().add(subjectAttributes);
xacmlRequestType.getAttributes().add(categoryAttributes);
XacmlClient pdp = new XacmlClient(tempDir.getCanonicalPath(), new XmlParser(), mock(SecurityLogger.class));
// Perform Test
ResponseType xacmlResponse = pdp.evaluate(xacmlRequestType);
// Verify
JAXBContext jaxbContext = JAXBContext.newInstance(ResponseType.class);
Marshaller marshaller = jaxbContext.createMarshaller();
ObjectFactory objectFactory = new ObjectFactory();
Writer writer = new StringWriter();
marshaller.marshal(objectFactory.createResponse(xacmlResponse), writer);
LOGGER.debug("\nXACML 3.0 Response:\n{}", writer.toString());
assertEquals(xacmlResponse.getResult().get(0).getDecision(), DecisionType.DENY);
}
Aggregations