Search in sources :

Example 1 with Not

use of org.wso2.siddhi.query.api.expression.condition.Not in project jaggery by wso2.

the class TomcatJaggeryWebappsDeployer method handleZipWebappDeployment.

/**
     * Handle the deployment of a an archive Jaggery app. i.e., a WAR
     *
     * @param webapp                    The WAR Jaggery app file
     * @param webContextParams          ServletContext params for this webapp
     * @param applicationEventListeners Application event listeners
     * @throws CarbonException If a deployment error occurs
     */
@SuppressFBWarnings("PATH_TRAVERSAL_IN")
protected void handleZipWebappDeployment(File webapp, List<WebContextParameter> webContextParams, List<Object> applicationEventListeners) throws CarbonException {
    synchronized (this) {
        String appPath = webapp.getAbsolutePath().substring(0, webapp.getAbsolutePath().indexOf(".zip"));
        try {
            JaggeryDeploymentUtil.unZip(new FileInputStream(webapp), appPath);
            if (!webapp.delete()) {
                throw new CarbonException(appPath + "could not be deleted");
            }
        } catch (FileNotFoundException e) {
            throw new CarbonException(e);
        }
        File unzippedWebapp = new File(appPath);
        handleExplodedWebappDeployment(unzippedWebapp, webContextParams, applicationEventListeners);
    }
}
Also used : CarbonException(org.wso2.carbon.CarbonException) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 2 with Not

use of org.wso2.siddhi.query.api.expression.condition.Not in project jaggery by wso2.

the class RegistryHostObject method jsFunction_newResource.

public static Scriptable jsFunction_newResource(Context cx, Scriptable thisObj, Object[] arguments, Function funObj) throws ScriptException {
    RegistryHostObject registryHostObject = (RegistryHostObject) thisObj;
    if (arguments.length == 0) {
        if (registryHostObject.registry != null) {
            try {
                Resource resource = registryHostObject.registry.newResource();
                ResourceHostObject rho = (ResourceHostObject) cx.newObject(registryHostObject, "Resource", new Object[] { resource });
                return rho;
            } catch (RegistryException e) {
                throw new ScriptException("Error occurred while creating a new Resource", e);
            }
        } else {
            throw new ScriptException("Registry has not initialized");
        }
    } else {
        throw new ScriptException("newResource() Method doesn't accept arguments");
    }
}
Also used : ScriptException(org.jaggeryjs.scriptengine.exceptions.ScriptException) RegistryException(org.wso2.carbon.registry.api.RegistryException)

Example 3 with Not

use of org.wso2.siddhi.query.api.expression.condition.Not in project jaggery by wso2.

the class RegistryHostObject method jsFunction_newCollection.

public static Scriptable jsFunction_newCollection(Context cx, Scriptable thisObj, Object[] arguments, Function funObj) throws ScriptException {
    RegistryHostObject rho = (RegistryHostObject) thisObj;
    if (arguments.length == 0) {
        if (rho.registry != null) {
            try {
                Collection collection = rho.registry.newCollection();
                CollectionHostObject cho = (CollectionHostObject) cx.newObject(rho, "Collection", new Object[] { collection });
                return cho;
            } catch (RegistryException e) {
                throw new ScriptException("Error occurred while creating a new Collection", e);
            }
        } else {
            throw new ScriptException("Registry has not initialized");
        }
    } else {
        throw new ScriptException("newCollection() Method doesn't accept arguments");
    }
}
Also used : ScriptException(org.jaggeryjs.scriptengine.exceptions.ScriptException) Collection(org.wso2.carbon.registry.core.Collection) RegistryException(org.wso2.carbon.registry.api.RegistryException)

Example 4 with Not

use of org.wso2.siddhi.query.api.expression.condition.Not in project siddhi by wso2.

the class SiddhiAnnotationProcessor method process.

@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    // Iterate over all @Extension annotated elements.
    for (Element element : roundEnv.getElementsAnnotatedWith(Extension.class)) {
        // Check if a class has been annotated with @Extension.
        if (element.getKind() == ElementKind.CLASS) {
            String superClass = getMatchingSuperClass(element, new String[] { AnnotationConstants.SINK_MAPPER_SUPER_CLASS, AnnotationConstants.SINK_SUPER_CLASS, AnnotationConstants.FUNCTION_EXECUTOR_SUPER_CLASS, AnnotationConstants.AGGREGATION_ATTRIBUTE_SUPER_CLASS, AnnotationConstants.DISTRIBUTION_STRATEGY_SUPER_CLASS, AnnotationConstants.STREAM_PROCESSOR_SUPER_CLASS, AnnotationConstants.STREAM_FUNCTION_PROCESSOR_SUPER_CLASS, AnnotationConstants.STORE_SUPER_CLASS, AnnotationConstants.SOURCE_SUPER_CLASS, AnnotationConstants.SOURCE_MAPPER_SUPER_CLASS, AnnotationConstants.WINDOW_PROCESSOR_CLASS, AnnotationConstants.SCRIPT_SUPER_CLASS, AnnotationConstants.INCREMENTAL_ATTRIBUTE_AGGREGATOR_SUPER_CLASS });
            AbstractAnnotationProcessor abstractAnnotationProcessor = null;
            Extension annotation = element.getAnnotation(Extension.class);
            String name = annotation.name();
            String description = annotation.description();
            String namespace = annotation.namespace();
            Parameter[] parameters = annotation.parameters();
            ReturnAttribute[] returnAttributes = annotation.returnAttributes();
            SystemParameter[] systemParameters = annotation.systemParameter();
            Example[] examples = annotation.examples();
            String extensionClassFullName = element.asType().toString();
            if (superClass != null) {
                switch(superClass) {
                    case AnnotationConstants.DISTRIBUTION_STRATEGY_SUPER_CLASS:
                        abstractAnnotationProcessor = new DistributionStrategyValidationAnnotationProcessor(extensionClassFullName);
                        break;
                    case AnnotationConstants.SINK_MAPPER_SUPER_CLASS:
                        abstractAnnotationProcessor = new SinkMapperValidationAnnotationProcessor(extensionClassFullName);
                        break;
                    case AnnotationConstants.SINK_SUPER_CLASS:
                        abstractAnnotationProcessor = new SinkValidationAnnotationProcessor(extensionClassFullName);
                        break;
                    case AnnotationConstants.FUNCTION_EXECUTOR_SUPER_CLASS:
                        abstractAnnotationProcessor = new FunctionExecutorValidationAnnotationProcessor(extensionClassFullName);
                        break;
                    case AnnotationConstants.AGGREGATION_ATTRIBUTE_SUPER_CLASS:
                        abstractAnnotationProcessor = new AggregationAttributeValidationAnnotationProcessor(extensionClassFullName);
                        break;
                    case AnnotationConstants.STREAM_PROCESSOR_SUPER_CLASS:
                        abstractAnnotationProcessor = new StreamProcessorValidationAnnotationProcessor(extensionClassFullName);
                        break;
                    case AnnotationConstants.SOURCE_SUPER_CLASS:
                        abstractAnnotationProcessor = new SourceValidationAnnotationProcessor(extensionClassFullName);
                        break;
                    case AnnotationConstants.SOURCE_MAPPER_SUPER_CLASS:
                        abstractAnnotationProcessor = new SourceMapperValidationAnnotationProcessor(extensionClassFullName);
                        break;
                    case AnnotationConstants.STORE_SUPER_CLASS:
                        abstractAnnotationProcessor = new StoreValidationAnnotationProcessor(extensionClassFullName);
                        break;
                    case AnnotationConstants.STREAM_FUNCTION_PROCESSOR_SUPER_CLASS:
                        abstractAnnotationProcessor = new StreamFunctionProcessorValidationAnnotationProcessor(extensionClassFullName);
                        break;
                    case AnnotationConstants.WINDOW_PROCESSOR_CLASS:
                        abstractAnnotationProcessor = new WindowProcessorValidationAnnotationProcessor(extensionClassFullName);
                        break;
                    case AnnotationConstants.SCRIPT_SUPER_CLASS:
                        abstractAnnotationProcessor = new ScriptValidationAnnotationProcessor(extensionClassFullName);
                        break;
                    case AnnotationConstants.INCREMENTAL_ATTRIBUTE_AGGREGATOR_SUPER_CLASS:
                        abstractAnnotationProcessor = new IncrementalAggregationAttributeValidationAnnotationProcessor(extensionClassFullName);
                        break;
                    default:
                        // Throw error if no matching super class.
                        showBuildError(MessageFormat.format("Default switch case executed as there is no " + "matching super class option for @{0}.", superClass), element);
                        break;
                }
                if (abstractAnnotationProcessor != null) {
                    try {
                        abstractAnnotationProcessor.basicParameterValidation(name, description, namespace);
                        abstractAnnotationProcessor.parameterValidation(parameters);
                        abstractAnnotationProcessor.returnAttributesValidation(returnAttributes);
                        abstractAnnotationProcessor.systemParametersValidation(systemParameters);
                        abstractAnnotationProcessor.examplesValidation(examples);
                    } catch (AnnotationValidationException e) {
                        showBuildError(e.getMessage(), element);
                    }
                } else {
                    showBuildError(MessageFormat.format("Error while validation, " + "abstractAnnotationProcessor cannot be null.", superClass), element);
                }
            } else {
                // Throw error if no matching super class.
                showBuildError("Class does not have a matching Siddhi Extension super class.", element);
            }
        } else {
            // Throw error if the element returned is method or package.
            showBuildError(MessageFormat.format("Only classes can be annotated with @{0}.", Extension.class.getCanonicalName()), element);
        }
    }
    // Returning false since this processor only validates.
    return false;
}
Also used : TypeElement(javax.lang.model.element.TypeElement) Element(javax.lang.model.element.Element) AnnotationValidationException(org.wso2.siddhi.annotation.util.AnnotationValidationException) ReturnAttribute(org.wso2.siddhi.annotation.ReturnAttribute) Example(org.wso2.siddhi.annotation.Example) SystemParameter(org.wso2.siddhi.annotation.SystemParameter) Extension(org.wso2.siddhi.annotation.Extension) Parameter(org.wso2.siddhi.annotation.Parameter) SystemParameter(org.wso2.siddhi.annotation.SystemParameter)

Example 5 with Not

use of org.wso2.siddhi.query.api.expression.condition.Not in project siddhi by wso2.

the class SelectiveStateEventPopulator method populateStateEvent.

public void populateStateEvent(ComplexEvent complexEvent) {
    StateEvent stateEvent = (StateEvent) complexEvent;
    for (StateMappingElement stateMappingElement : stateMappingElements) {
        int toPosition = stateMappingElement.getToPosition();
        stateEvent.setOutputData(getFromData(stateEvent, stateMappingElement.getFromPosition()), toPosition);
    // switch (toPosition[0]) {
    // case 0:
    // stateEvent.setPreOutputData(getFromData(stateEvent, stateMappingElement.getFromPosition()),
    // toPosition[1]);
    // break;
    // case 1:
    // stateEvent.setOutputData(getFromData(stateEvent, stateMappingElement.getFromPosition()),
    // toPosition[1]);
    // break;
    // default:
    // //will not happen
    // throw new IllegalStateException("To Position cannot be :" + toPosition[0]);
    // }
    }
}
Also used : StateEvent(org.wso2.siddhi.core.event.state.StateEvent)

Aggregations

Test (org.testng.annotations.Test)579 SiddhiManager (org.wso2.siddhi.core.SiddhiManager)336 SiddhiAppRuntime (org.wso2.siddhi.core.SiddhiAppRuntime)334 InputHandler (org.wso2.siddhi.core.stream.input.InputHandler)334 TestUtil (org.wso2.siddhi.core.TestUtil)300 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)171 HTTPCarbonMessage (org.wso2.transport.http.netty.message.HTTPCarbonMessage)157 HTTPTestRequest (org.ballerinalang.test.services.testutils.HTTPTestRequest)151 HashMap (java.util.HashMap)121 ErrorDTO (org.wso2.carbon.apimgt.rest.api.common.dto.ErrorDTO)115 HttpMessageDataStreamer (org.wso2.transport.http.netty.message.HttpMessageDataStreamer)112 ArrayList (java.util.ArrayList)92 BJSON (org.ballerinalang.model.values.BJSON)88 APIPublisher (org.wso2.carbon.apimgt.core.api.APIPublisher)63 IOException (java.io.IOException)62 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)58 Map (java.util.Map)47 APIStore (org.wso2.carbon.apimgt.core.api.APIStore)45 File (java.io.File)37 Response (javax.ws.rs.core.Response)37