Example usage for org.apache.commons.lang StringEscapeUtils StringEscapeUtils

List of usage examples for org.apache.commons.lang StringEscapeUtils StringEscapeUtils

Introduction

In this page you can find the example usage for org.apache.commons.lang StringEscapeUtils StringEscapeUtils.

Prototype

StringEscapeUtils

Source Link

Usage

From source file:com.github.luuuis.myzone.preference.MyZonePreferencePanel.java

/**
 * Returns the HTML to display in the preference panel.
 *
 * @param profileUser the User whose profile is being viewed
 * @return a String containing the HTML to display
 *///from w  w  w  . j  a  va2  s .  com
public String getHtml(User profileUser) {
    Locale locale = authContext.getLocale();
    User callingUser = authContext.getUser();
    String selectedTZ = profileUser.getPropertySet().getString(Prefs.SELECTED_TZ);

    Map<String, Object> params = Maps.newHashMap();
    params.put("locale", locale);
    params.put("callingUser", callingUser);
    params.put("profileUser", profileUser);
    params.put("stringEscapeUtils", new StringEscapeUtils());
    params.put("i18n", i18nFactory.getInstance(authContext.getLocale()));
    params.put("timezones", TimeZones.ALL);
    params.put("selectedTZ", selectedTZ != null ? selectedTZ : "");

    return moduleDescriptor.getHtml(VIEW_TEMPLATE, params);
}

From source file:org.motechproject.server.outbox.web.VxmlOutboxController.java

public ModelAndView mainMenu(HttpServletRequest request, HttpServletResponse response) {

    ModelAndView mav = new ModelAndView();
    String contextPath = request.getContextPath();
    mav.addObject("contextPath", contextPath);
    mav.addObject("escape", new StringEscapeUtils());

    String partyId = request.getParameter("pId");
    OutboundVoiceMessage dummyVoiceMessage = new OutboundVoiceMessage();
    if (partyId == null) {
        mav.setViewName(ERROR_MESSAGE_TEMPLATE_NAME);
        return mav;
    } else {//from w w  w  .  j a  va2  s .c o m
        dummyVoiceMessage.setPartyId(partyId);
        mav.setViewName(MAIN_MENU_TEMPLATE_NAME);
        mav.addObject("message", dummyVoiceMessage);
        return mav;
    }
}

From source file:com.sap.dirigible.runtime.scripting.AbstractScriptExecutor.java

protected void registerDefaultVariables(HttpServletRequest request, HttpServletResponse response, Object input,
        Map<Object, Object> executionContext, IRepository repository, Object scope) {
    // put the execution context
    registerDefaultVariable(scope, "context", executionContext); //$NON-NLS-1$
    // put the system out
    registerDefaultVariable(scope, "out", System.out); //$NON-NLS-1$
    // put the default data source
    DataSource dataSource = null;
    if (repository instanceof DBRepository) {
        dataSource = ((DBRepository) repository).getDataSource();
    } else {/*from w ww. j  av a  2 s. co m*/
        dataSource = RepositoryFacade.getInstance().getDataSource();
    }
    registerDefaultVariable(scope, "datasource", dataSource); //$NON-NLS-1$
    // put request
    registerDefaultVariable(scope, "request", request); //$NON-NLS-1$
    // put response
    registerDefaultVariable(scope, "response", response); //$NON-NLS-1$
    // put repository
    registerDefaultVariable(scope, "repository", repository); //$NON-NLS-1$
    // put mail sender
    MailSender mailSender = new MailSender();
    registerDefaultVariable(scope, "mail", mailSender); //$NON-NLS-1$
    // put Apache Commons IOUtils
    IOUtils ioUtils = new IOUtils();
    registerDefaultVariable(scope, "io", ioUtils); //$NON-NLS-1$
    // put Apache Commons HttpClient and related classes wrapped with a
    // factory like HttpUtils
    HttpUtils httpUtils = new HttpUtils();
    registerDefaultVariable(scope, "http", httpUtils); //$NON-NLS-1$
    // put Apache Commons Codecs
    Base64 base64Codec = new Base64();
    registerDefaultVariable(scope, "base64", base64Codec); //$NON-NLS-1$
    Hex hexCodec = new Hex();
    registerDefaultVariable(scope, "hex", hexCodec); //$NON-NLS-1$
    DigestUtils digestUtils = new DigestUtils();
    registerDefaultVariable(scope, "digest", digestUtils); //$NON-NLS-1$
    // standard URLEncoder and URLDecoder functionality
    URLUtils urlUtils = new URLUtils();
    registerDefaultVariable(scope, "url", urlUtils); //$NON-NLS-1$
    // user name
    registerDefaultVariable(scope, "user", RepositoryFacade.getUser(request)); //$NON-NLS-1$
    // file upload
    ServletFileUpload fileUpload = new ServletFileUpload(new DiskFileItemFactory());
    registerDefaultVariable(scope, "upload", fileUpload); //$NON-NLS-1$
    // UUID
    UUID uuid = new UUID(0, 0);
    registerDefaultVariable(scope, "uuid", uuid); //$NON-NLS-1$
    // the input from the execution chain if any
    registerDefaultVariable(scope, "input", input); //$NON-NLS-1$
    // DbUtils
    DbUtils dbUtils = new DbUtils(dataSource);
    registerDefaultVariable(scope, "db", dbUtils); //$NON-NLS-1$
    // EscapeUtils
    StringEscapeUtils stringEscapeUtils = new StringEscapeUtils();
    registerDefaultVariable(scope, "xss", stringEscapeUtils); //$NON-NLS-1$
    // Extension Manager
    ExtensionManager extensionManager = new ExtensionManager(repository, dataSource);
    registerDefaultVariable(scope, "extensionManager", extensionManager); //$NON-NLS-1$
    // Apache Lucene Indexer
    IndexerUtils indexerUtils = new IndexerUtils();
    registerDefaultVariable(scope, "indexer", indexerUtils); //$NON-NLS-1$
    // Mylyn Confluence Format
    WikiUtils wikiUtils = new WikiUtils();
    registerDefaultVariable(scope, "wiki", wikiUtils); //$NON-NLS-1$
    // Simple binary storage
    StorageUtils storageUtils = new StorageUtils(dataSource);
    registerDefaultVariable(scope, "storage", storageUtils); //$NON-NLS-1$
    // Simple file storage
    FileStorageUtils fileStorageUtils = new FileStorageUtils(dataSource);
    registerDefaultVariable(scope, "fileStorage", fileStorageUtils); //$NON-NLS-1$
    // Simple binary storage
    ConfigStorageUtils configStorageUtils = new ConfigStorageUtils(dataSource);
    registerDefaultVariable(scope, "config", configStorageUtils); //$NON-NLS-1$
    // XML to JSON and vice-versa
    XMLUtils xmlUtils = new XMLUtils();
    registerDefaultVariable(scope, "xml", xmlUtils); //$NON-NLS-1$

}

From source file:org.motechproject.server.outbox.web.VxmlOutboxController.java

/**
 * Handles Appointment Reminder HTTP requests and generates a VXML document based on a Velocity template.
 * The HTTP request may contain an optional 'mId' parameter with value of ID of the message for which
 * VXML document will be generated. If the "mId" parameter is not passed the next pending voice message
 * will be obtained from the outbox and a VXML document will be generated for that message
 * <p/>/*from w  w w . ja  v  a 2s.  com*/
 * <p/>
 * URL to request appointment reminder VoiceXML:
 * http://<host>:<port>/<motech-platform-server>/module/outbox/vxml/outboxMessage?mId=<messageId>
 */
public ModelAndView outboxMessage(HttpServletRequest request, HttpServletResponse response) {
    logger.info("Generate appointment reminder VXML");

    response.setContentType("text/plain");
    response.setCharacterEncoding("UTF-8");

    //Interim implementation. Party ID will be obtained from the Authentication context
    //String partyId = "1";
    String partyId = request.getParameter("pId");

    String messageId = request.getParameter(MESSAGE_ID_PARAM);
    String language = request.getParameter(LANGUAGE_PARAM);

    if (language == null) {
        language = "en";
    }

    String contextPath = request.getContextPath();

    ModelAndView mav = new ModelAndView();
    mav.addObject("contextPath", contextPath);
    mav.addObject("language", language);
    mav.addObject("escape", new StringEscapeUtils());

    logger.debug("Message ID: " + messageId);

    OutboundVoiceMessage voiceMessage = null;

    if (messageId != null) {
        logger.info("Generating VXML for the voice message ID: " + messageId);

        try {
            voiceMessage = voiceOutboxService.getMessageById(messageId);
        } catch (Exception e) {
            logger.error("Can not get message by ID: " + messageId + " " + e.getMessage(), e);
            logger.warn("Generating a VXML with the error message...");
            mav.setViewName(ERROR_MESSAGE_TEMPLATE_NAME);
            return mav;
        }
    } else {
        logger.info("Generating VXML for the next voice message in outbox... ");
        try {
            voiceMessage = voiceOutboxService.getNextPendingMessage(partyId);
        } catch (Exception e) {
            logger.error("Can not obtain next message from the outbox of the party ID: " + partyId + " "
                    + e.getMessage(), e);
            logger.warn("Generating a VXML with the error message...");
            mav.setViewName(ERROR_MESSAGE_TEMPLATE_NAME);
            return mav;
        }
    }

    if (voiceMessage == null) {

        logger.info("There are no more messages in the outbox of the party ID: " + partyId);
        mav.setViewName(NO_MESSAGE_TEMPLATE_NAME);
        mav.addObject("partyId", partyId);
        return mav;
    }

    VoiceMessageType voiceMessageType = voiceMessage.getVoiceMessageType();

    if (voiceMessageType == null) {
        logger.error(
                "Invalid Outbound voice message: " + voiceMessage + " Voice message type can not be null.");
        mav.setViewName(ERROR_MESSAGE_TEMPLATE_NAME);
        mav.addObject("partyId", partyId);
        return mav;
    }

    logger.debug(voiceMessage.toString());

    String templateName = voiceMessageType.getTemplateName();
    if (templateName == null) {
        templateName = voiceMessageType.getVoiceMessageTypeName();
    }

    mav.setViewName(templateName);
    mav.addObject("message", voiceMessage);

    try {
        //Pending message should then be "PLAYED"
        voiceOutboxService.setMessageStatus(voiceMessage.getId(), OutboundVoiceMessageStatus.PLAYED);
    } catch (Exception e) {
        logger.error("Can not mark the message with ID: " + messageId + " as PLAYED in the outbox", e);
        mav.setViewName(ERROR_MESSAGE_TEMPLATE_NAME);
        return mav;
    }

    return mav;

}

From source file:org.motechproject.server.outbox.web.VxmlOutboxController.java

public ModelAndView messageMenu(HttpServletRequest request, HttpServletResponse response) {
    logger.info("Generating the message menu VXML...");

    response.setContentType("text/plain");
    response.setCharacterEncoding("UTF-8");

    ModelAndView mav = new ModelAndView();

    String messageId = request.getParameter(MESSAGE_ID_PARAM);
    String language = request.getParameter(LANGUAGE_PARAM);

    logger.info("Message ID: " + messageId);

    if (messageId == null) {
        logger.error("Invalid request - missing parameter: " + MESSAGE_ID_PARAM);
        mav.setViewName(ERROR_MESSAGE_TEMPLATE_NAME);
        return mav;
    }//from   w ww . j av  a  2s.c  o m

    OutboundVoiceMessage voiceMessage;

    try {
        voiceMessage = voiceOutboxService.getMessageById(messageId);
    } catch (Exception e) {
        logger.error("Can not get message by ID: " + messageId + " " + e.getMessage(), e);
        logger.warn("Generating a VXML with the error message...");
        mav.setViewName(ERROR_MESSAGE_TEMPLATE_NAME);
        return mav;
    }

    if (voiceMessage == null) {

        logger.error("Can not get message by ID: " + messageId + "service returned null");
        logger.warn("Generating a VXML with the error message...");
        mav.setViewName(ERROR_MESSAGE_TEMPLATE_NAME);
        return mav;
    }

    if (voiceMessage.getStatus() == OutboundVoiceMessageStatus.SAVED) {

        mav.setViewName(SAVED_MESSAGE_MENU_TEMPLATE_NAME);
    } else {
        try {
            voiceOutboxService.setMessageStatus(messageId, OutboundVoiceMessageStatus.PLAYED);
        } catch (Exception e) {
            logger.error("Can not set message status to " + OutboundVoiceMessageStatus.PLAYED
                    + " to the message ID: " + messageId, e);
        }
        mav.setViewName(MESSAGE_MENU_TEMPLATE_NAME);
    }

    String contextPath = request.getContextPath();

    logger.debug(voiceMessage.toString());
    logger.debug(mav.getViewName());

    mav.addObject("contextPath", contextPath);
    mav.addObject("message", voiceMessage);
    mav.addObject("language", language);
    mav.addObject("escape", new StringEscapeUtils());
    return mav;

}

From source file:org.motechproject.server.outbox.web.VxmlOutboxController.java

public ModelAndView save(HttpServletRequest request, HttpServletResponse response) {
    logger.info("Saving messageL...");

    response.setContentType("text/plain");
    response.setCharacterEncoding("UTF-8");

    String messageId = request.getParameter(MESSAGE_ID_PARAM);
    String language = request.getParameter(LANGUAGE_PARAM);

    ModelAndView mav = new ModelAndView();

    String contextPath = request.getContextPath();

    mav.setViewName(MESSAGE_SAVED_CONFIRMATION_TEMPLATE_NAME);
    mav.addObject("contextPath", contextPath);
    mav.addObject("language", language);
    mav.addObject("escape", new StringEscapeUtils());

    logger.info("Message ID: " + messageId);

    if (messageId == null) {
        logger.error("Invalid request - missing parameter: " + MESSAGE_ID_PARAM);
        mav.setViewName(ERROR_MESSAGE_TEMPLATE_NAME);
        return mav;
    }/*w  w w .  ja v a2  s  .c om*/

    try {
        voiceOutboxService.saveMessage(messageId);
    } catch (Exception e) {
        logger.error("Can not mark the message with ID: " + messageId + " as saved in the outbox", e);
        mav.setViewName(SAVE_MESSAGE_ERROR_TEMPLATE_NAME);
        return mav;
    }

    //TODO - get party ID proper way from security principal or authentication context when it is available
    String partyId;
    try {
        OutboundVoiceMessage message = voiceOutboxService.getMessageById(messageId);
        partyId = message.getPartyId();
    } catch (Exception e) {
        logger.error("Can not obtain message ID: " + messageId + " to get party ID");
        mav.setViewName(ERROR_MESSAGE_TEMPLATE_NAME);
        return mav;
    }

    mav.addObject("days", voiceOutboxService.getNumDayskeepSavedMessages());
    mav.addObject("partyId", partyId);
    return mav;

}

From source file:com.epimorphics.lda.renderers.velocity.VelocityRendering.java

/** Add generic tools to the Velocity context */
protected void addTools(VelocityContext vc) {
    vc.put("esc", new StringEscapeUtils());
    vc.put("log", log);
}

From source file:org.motechproject.server.outbox.web.VxmlOutboxController.java

/**
* Handles Outbox HTTP requests to remove saved in the outbox message and generates a VXML document
 * with message remove confirmation. The generated VXML document based on the msgRemovedConf.vm  Velocity template.
 *
 * The message will not be physically removed. The message status will be set to PLAYED.
 *
* <p/>//  w  w  w  .  j  a v  a2 s .c  om
* <p/>
* URL to request a saved VoiceXML message from outbox :
* http://<host>:<port>/<motech-platform-server>/module/outbox/vxml/remove?mId=$message.id&ln=$language>
*/
public ModelAndView remove(HttpServletRequest request, HttpServletResponse response) {
    logger.info("Removing saved message message...");

    response.setContentType("text/plain");
    response.setCharacterEncoding("UTF-8");

    String messageId = request.getParameter(MESSAGE_ID_PARAM);
    String language = request.getParameter(LANGUAGE_PARAM);

    String contextPath = request.getContextPath();

    ModelAndView mav = new ModelAndView();
    mav.setViewName(MESSAGE_REMOVED_CONFIRMATION_TEMPLATE_NAME);
    mav.addObject("contextPath", contextPath);
    mav.addObject("language", language);
    mav.addObject("escape", new StringEscapeUtils());

    logger.info("Message ID: " + messageId);

    if (messageId == null) {
        logger.error("Invalid request - missing parameter: " + MESSAGE_ID_PARAM);
        mav.setViewName(ERROR_MESSAGE_TEMPLATE_NAME);
        return mav;
    }

    try {
        voiceOutboxService.setMessageStatus(messageId, OutboundVoiceMessageStatus.PLAYED);
    } catch (Exception e) {
        logger.error("Can not mark the message with ID: " + messageId + " as PLAYED in the outbox", e);
        mav.setViewName(REMOVE_SAVED_MESSAGE_ERROR_TEMPLATE_NAME);
        return mav;
    }

    //TODO - get party ID proper way from security principal or authentication context when it is available
    String partyId;
    try {
        OutboundVoiceMessage message = voiceOutboxService.getMessageById(messageId);
        partyId = message.getPartyId();
    } catch (Exception e) {
        logger.error("Can not obtain message ID: " + messageId + " to get party ID");
        mav.setViewName(ERROR_MESSAGE_TEMPLATE_NAME);
        return mav;
    }

    logger.debug("partyId: " + partyId);

    mav.addObject("partyId", partyId);
    return mav;

}

From source file:org.motechproject.server.outbox.web.VxmlOutboxController.java

/**
 * Handles Outbox HTTP requests and generates a VXML document based on a Velocity template and data saved in the outbox.
 * <p/>/*from  ww  w .  j a  v  a 2 s. c o m*/
 * <p/>
 * URL to request a saved VoiceXML message from outbox :
 * http://<host>:<port>/<motech-platform-server>/module/outbox/vxml/savedMessage>
 */
public ModelAndView savedMessage(HttpServletRequest request, HttpServletResponse response) {
    logger.info("Generate VXML for the next saved in the outbox message");

    response.setContentType("text/plain");
    response.setCharacterEncoding("UTF-8");

    //Interim implementation. Party ID will be obtained from the Authentication context
    //String partyId = "1";
    String partyId = request.getParameter("pId");

    String language = request.getParameter(LANGUAGE_PARAM);

    String contextPath = request.getContextPath();

    ModelAndView mav = new ModelAndView();
    mav.addObject("contextPath", contextPath);
    mav.addObject("language", language);
    mav.addObject("escape", new StringEscapeUtils());

    logger.debug("Party ID: " + partyId);

    OutboundVoiceMessage voiceMessage = null;

    logger.info("Generating VXML for the next saved voice message in outbox... ");
    try {
        voiceMessage = voiceOutboxService.getNextSavedMessage(partyId);
    } catch (Exception e) {
        logger.error("Can not obtain next saved message from the outbox of the party ID: " + partyId + " "
                + e.getMessage(), e);
        logger.warn("Generating a VXML with the error message...");
        mav.setViewName(ERROR_MESSAGE_TEMPLATE_NAME);
        return mav;
    }

    if (voiceMessage == null) {

        logger.info("There are no more messages in the outbox of the party ID: " + partyId);
        mav.setViewName(NO_SAVED_MESSAGE_TEMPLATE_NAME);
        mav.addObject("partyId", partyId);
        return mav;
    }

    VoiceMessageType voiceMessageType = voiceMessage.getVoiceMessageType();

    if (voiceMessageType == null) {
        logger.error(
                "Invalid Outbound voice message: " + voiceMessage + " Voice message type can not be null.");
        mav.setViewName(ERROR_MESSAGE_TEMPLATE_NAME);
        mav.addObject("partyId", partyId);
        return mav;
    }

    String templateName = voiceMessageType.getTemplateName();
    if (templateName == null) {
        templateName = voiceMessageType.getVoiceMessageTypeName();
    }

    mav.setViewName(templateName);
    mav.addObject("message", voiceMessage);

    return mav;

}

From source file:org.eclipse.dirigible.runtime.scripting.AbstractScriptExecutor.java

@Override
public void registerDefaultVariables(HttpServletRequest request, HttpServletResponse response, Object input,
        Map<Object, Object> executionContext, IRepository repository, Object scope) {

    InjectedAPIBuilder apiBuilder = new InjectedAPIBuilder();

    if (executionContext == null) {
        // in case executionContext is not provided from outside
        executionContext = new HashMap<Object, Object>();
    }/*from ww w  . java 2  s .  c om*/

    // Objects

    // put the execution context
    registerDefaultVariable(scope, IInjectedAPIAliases.EXECUTION_CONTEXT, executionContext);
    apiBuilder.setExecutionContext(executionContext);

    // put the console
    Console console = new Console();
    registerDefaultVariableInContextAndScope(executionContext, scope, IInjectedAPIAliases.CONSOLE, console);
    apiBuilder.setConsole(console);

    // put the system out
    registerDefaultVariableInContextAndScope(executionContext, scope, IInjectedAPIAliases.SYSTEM_OUTPUT,
            System.out);
    apiBuilder.setSystemOutput(System.out);

    // put the default data source
    DataSource dataSource = null;
    dataSource = registerDefaultDatasource(request, executionContext, scope, apiBuilder);

    // put request
    registerRequest(request, executionContext, scope, apiBuilder);

    // put response
    registerResponse(response, executionContext, scope, apiBuilder);

    // put repository
    registerRepository(executionContext, repository, scope, apiBuilder);

    // user name
    registerUserName(request, executionContext, scope, apiBuilder);

    // the input from the execution chain if any
    registerRequestInput(input, executionContext, scope, apiBuilder);

    // put JNDI
    registerInitialContext(request, executionContext, scope, apiBuilder);

    // Simple binary storage
    registerBinaryStorage(executionContext, scope, apiBuilder, dataSource);

    // Simple file storage
    registerFileStorage(executionContext, scope, apiBuilder, dataSource);

    // Simple configuration storage
    registerConfigurationStorage(executionContext, scope, apiBuilder, dataSource);

    // Services

    // put mail sender
    registerMailService(request, executionContext, scope, apiBuilder);

    // Extension Manager
    registerExtensionManager(request, executionContext, repository, scope, apiBuilder, dataSource);

    // Apache Lucene Indexer
    registerIndexingService(executionContext, scope, apiBuilder);

    // Connectivity Configuration service
    registerConnectivityService(executionContext, scope, apiBuilder);

    // Document service
    registerDocumentService(executionContext, scope, apiBuilder);

    // Messaging Service
    registerMessagingService(request, executionContext, scope, apiBuilder, dataSource);

    // Templating Service
    registerTemplatingService(executionContext, scope, apiBuilder);

    // Executing Service
    registerExecutingService(executionContext, scope, apiBuilder);

    // Generation Service
    registerGenerationService(executionContext, scope, apiBuilder);

    // Lifecycle Service
    registerLifecycleService(executionContext, scope, apiBuilder);

    // Workspaces Service
    registerWorkspacesService(executionContext, scope, apiBuilder);

    // Utils

    // put Apache Commons IOUtils
    IOUtils ioUtils = new IOUtils();
    registerDefaultVariableInContextAndScope(executionContext, scope, IInjectedAPIAliases.IO_UTILS, ioUtils);
    apiBuilder.setIOUtils(ioUtils);

    // put Apache Commons HttpClient and related classes wrapped with a factory like HttpUtils
    HttpUtils httpUtils = new HttpUtils();
    registerDefaultVariableInContextAndScope(executionContext, scope, IInjectedAPIAliases.HTTP_UTILS,
            httpUtils);
    apiBuilder.setHttpUtils(httpUtils);

    // put Apache Commons Codecs
    Base64 base64Codec = new Base64();
    registerDefaultVariableInContextAndScope(executionContext, scope, IInjectedAPIAliases.BASE64_UTILS,
            base64Codec);
    apiBuilder.setBase64Utils(base64Codec);

    Hex hexCodec = new Hex();
    registerDefaultVariableInContextAndScope(executionContext, scope, IInjectedAPIAliases.HEX_UTILS, hexCodec);
    apiBuilder.setHexUtils(hexCodec);

    DigestUtils digestUtils = new DigestUtils();
    registerDefaultVariableInContextAndScope(executionContext, scope, IInjectedAPIAliases.DIGEST_UTILS,
            digestUtils);
    apiBuilder.setDigestUtils(digestUtils);

    // standard URLEncoder and URLDecoder functionality
    URLUtils urlUtils = new URLUtils();
    registerDefaultVariableInContextAndScope(executionContext, scope, IInjectedAPIAliases.URL_UTILS, urlUtils);
    apiBuilder.setUrlUtils(urlUtils);

    // file upload
    ServletFileUpload fileUpload = new ServletFileUpload(new DiskFileItemFactory());
    registerDefaultVariableInContextAndScope(executionContext, scope, IInjectedAPIAliases.UPLOAD_UTILS,
            fileUpload);
    apiBuilder.setUploadUtils(fileUpload);

    // UUID
    UUID uuid = new UUID(0, 0);
    registerDefaultVariableInContextAndScope(executionContext, scope, IInjectedAPIAliases.UUID_UTILS, uuid);
    apiBuilder.setUuidUtils(uuid);

    // DbUtils
    DbUtils dbUtils = new DbUtils(dataSource);
    registerDefaultVariableInContextAndScope(executionContext, scope, IInjectedAPIAliases.DB_UTILS, dbUtils);
    apiBuilder.setDatabaseUtils(dbUtils);

    // EscapeUtils
    StringEscapeUtils stringEscapeUtils = new StringEscapeUtils();
    registerDefaultVariableInContextAndScope(executionContext, scope, IInjectedAPIAliases.XSS_UTILS,
            stringEscapeUtils);
    apiBuilder.setXssUtils(stringEscapeUtils);

    // XML to JSON and vice-versa
    XMLUtils xmlUtils = new XMLUtils();
    registerDefaultVariableInContextAndScope(executionContext, scope, IInjectedAPIAliases.XML_UTILS, xmlUtils);
    apiBuilder.setXmlUtils(xmlUtils);

    // ExceptionUtils
    ExceptionUtils exceptionUtils = new ExceptionUtils();
    registerDefaultVariableInContextAndScope(executionContext, scope, IInjectedAPIAliases.EXCEPTION_UTILS,
            exceptionUtils);
    apiBuilder.setExceptionUtils(exceptionUtils);

    // Named DataSources Utils
    NamedDataSourcesUtils namedDataSourcesUtils = new NamedDataSourcesUtils(request);
    registerDefaultVariableInContextAndScope(executionContext, scope, IInjectedAPIAliases.DATASOURCES_UTILS,
            namedDataSourcesUtils);
    apiBuilder.setNamedDataSourcesUtils(namedDataSourcesUtils);

    // register objects via extension
    try {
        BundleContext context = RuntimeActivator.getContext();
        if (context != null) {
            Collection<ServiceReference<IContextService>> serviceReferences = context
                    .getServiceReferences(IContextService.class, null);
            for (ServiceReference<IContextService> serviceReference : serviceReferences) {
                try {
                    IContextService contextService = context.getService(serviceReference);
                    registerDefaultVariableInContextAndScope(executionContext, scope, contextService.getName(),
                            contextService.getInstance());
                    apiBuilder.set(contextService.getName(), contextService.getInstance());
                } catch (Throwable t) {
                    logger.error(t.getMessage(), t);
                }
            }
        }
    } catch (InvalidSyntaxException e) {
        logger.error(e.getMessage(), e);
    }

    InjectedAPIWrapper api = new InjectedAPIWrapper(apiBuilder);
    registerDefaultVariableInContextAndScope(executionContext, scope, IInjectedAPIAliases.API, api);
}