use of org.wso2.siddhi.query.api.annotation.Element in project siddhi by wso2.
the class DefineTableTestCase method test4.
@Test
public void test4() throws SiddhiParserException {
TableDefinition streamDefinition = SiddhiCompiler.parseTableDefinition("" + " @from(datasource='MyDatabase','CUSTOM')" + " define table cseStream ( symbol string, price int, volume float )");
AssertJUnit.assertEquals(TableDefinition.id("cseStream").attribute("symbol", Attribute.Type.STRING).attribute("price", Attribute.Type.INT).attribute("volume", Attribute.Type.FLOAT).annotation(Annotation.annotation("from").element("datasource", "MyDatabase").element("CUSTOM")).toString(), streamDefinition.toString());
}
use of org.wso2.siddhi.query.api.annotation.Element in project siddhi by wso2.
the class SiddhiApp method addPartition.
public SiddhiApp addPartition(Partition partition) {
if (partition == null) {
throw new SiddhiAppValidationException("Partition should not be null");
}
String name = null;
Element element = AnnotationHelper.getAnnotationElement(SiddhiConstants.ANNOTATION_INFO, SiddhiConstants.ANNOTATION_ELEMENT_NAME, partition.getAnnotations());
if (element != null) {
name = element.getValue();
}
if (name != null && executionElementNameList.contains(name)) {
throw new SiddhiAppValidationException("Cannot add Partition as another Execution Element already " + "uses its name=" + name, element.getQueryContextStartIndex(), element.getQueryContextEndIndex());
}
executionElementNameList.add(name);
this.executionElementList.add(partition);
return this;
}
use of org.wso2.siddhi.query.api.annotation.Element in project siddhi by wso2.
the class SiddhiApp method addQuery.
public SiddhiApp addQuery(Query query) {
if (query == null) {
throw new SiddhiAppValidationException("Query should not be null");
}
String name = null;
Element element = AnnotationHelper.getAnnotationElement(SiddhiConstants.ANNOTATION_INFO, SiddhiConstants.ANNOTATION_ELEMENT_NAME, query.getAnnotations());
if (element != null) {
name = element.getValue();
}
if (name != null && executionElementNameList.contains(name)) {
throw new SiddhiAppValidationException("Cannot add Query as another Execution Element already uses " + "its name=" + name, element.getQueryContextStartIndex(), element.getQueryContextEndIndex());
}
executionElementNameList.add(name);
this.executionElementList.add(query);
return this;
}
use of org.wso2.siddhi.query.api.annotation.Element in project carbon-apimgt by wso2.
the class WSDL20ProcessorImpl method init.
/**
* {@inheritDoc}
* Will return true if the provided WSDL is of 2.0 and can be successfully parsed by woden library.
*/
@Override
public boolean init(byte[] wsdlContent) throws APIMgtWSDLException {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
WSDLReader reader = getWsdlFactoryInstance().newWSDLReader();
reader.setFeature(WSDLReader.FEATURE_VALIDATION, false);
Document dom = builder.parse(new ByteArrayInputStream(wsdlContent));
Element domElement = dom.getDocumentElement();
WSDLSource wsdlSource = reader.createWSDLSource();
wsdlSource.setSource(domElement);
wsdlDescription = reader.readWSDL(wsdlSource);
canProcess = true;
if (log.isDebugEnabled()) {
log.debug("Successfully initialized an instance of " + this.getClass().getSimpleName() + " with a single WSDL.");
}
} catch (WSDLException | ParserConfigurationException | SAXException | IOException e) {
// This implementation class cannot process the WSDL.
log.debug("Cannot process the WSDL by " + this.getClass().getName(), e);
canProcess = false;
}
return canProcess;
}
use of org.wso2.siddhi.query.api.annotation.Element in project carbon-apimgt by wso2.
the class XMLAnalyzerTestCase method testMaxEntityExpansionLimit.
@Test(expectedExceptions = APIMThreatAnalyzerException.class)
public void testMaxEntityExpansionLimit() throws Exception {
init();
XMLAnalyzer analyzer = new XMLAnalyzer();
xmlConfig.setEntityExpansionLimit(100);
xmlConfig.setDtdEnabled(true);
analyzer.configure(xmlConfig);
String xmlString = "<?xml version=\"1.0\"?>\n" + "<!DOCTYPE lolz [\n" + " <!ENTITY lol \"lol\">\n" + " <!ELEMENT lolz (#PCDATA)>\n" + " <!ENTITY lol1 \"&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;\">\n" + " <!ENTITY lol2 \"&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;\">\n" + " <!ENTITY lol3 \"&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;\">\n" + " <!ENTITY lol4 \"&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;\">\n" + " <!ENTITY lol5 \"&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;\">\n" + " <!ENTITY lol6 \"&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;\">\n" + " <!ENTITY lol7 \"&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;\">\n" + " <!ENTITY lol8 \"&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;\">\n" + " <!ENTITY lol9 \"&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;\">\n" + "]>\n" + "<lolz>&lol9;</lolz>";
analyzer.analyze(xmlString, "/foo");
}
Aggregations