Example usage for org.apache.commons.lang BooleanUtils toBoolean

List of usage examples for org.apache.commons.lang BooleanUtils toBoolean

Introduction

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

Prototype

public static boolean toBoolean(String str) 

Source Link

Document

Converts a String to a boolean (optimised for performance).

'true', 'on' or 'yes' (case insensitive) will return true.

Usage

From source file:info.magnolia.init.DefaultMagnoliaInitPaths.java

/**
 * Figures out the local host name, makes sure it's lowercase, and use its unqualified name if the {@value #MAGNOLIA_UNQUALIFIED_SERVER_NAME} init parameter is set to true.
 *///  w  w  w  . ja  v a2 s . c  o  m
protected String determineServerName(ServletContext context) {
    final boolean unqualifiedServerName = BooleanUtils
            .toBoolean(context.getInitParameter(MAGNOLIA_UNQUALIFIED_SERVER_NAME));
    final String retroCompatMethodCall = magnoliaServletContextListener.initServername(unqualifiedServerName);
    if (retroCompatMethodCall != null) {
        DeprecationUtil.isDeprecated(
                "You should update your code and override determineServerName(ServletContext) instead of initServername(String)");
        return retroCompatMethodCall;
    }

    try {
        String serverName = StringUtils.lowerCase(InetAddress.getLocalHost().getHostName());

        if (unqualifiedServerName && StringUtils.contains(serverName, ".")) {
            serverName = StringUtils.substringBefore(serverName, ".");
        }
        return serverName;
    } catch (UnknownHostException e) {
        log.error(e.getMessage());
        return null;
    }
}

From source file:info.magnolia.cms.servlets.RequestInterceptor.java

/**
 * Request and Response here is same as receivced by the original page so it includes all post/get data. Sub action
 * could be called from here once this action finishes, it will continue loading the requested page.
 *///from   ww  w . j  a  v  a2  s. c o  m
public void doGet(HttpServletRequest request, HttpServletResponse response) {
    String action = request.getParameter(EntryServlet.INTERCEPT);
    String repository = request.getParameter(PARAM_REPOSITORY);
    if (repository == null) {
        repository = ContentRepository.WEBSITE;
    }
    HierarchyManager hm = MgnlContext.getHierarchyManager(repository);
    synchronized (ExclusiveWrite.getInstance()) {
        if (action.equals(ACTION_PREVIEW)) {
            // preview mode (button in main bar)
            String preview = request.getParameter(Resource.MGNL_PREVIEW_ATTRIBUTE);
            if (preview != null) {

                // @todo IMPORTANT remove use of http session
                HttpSession httpsession = request.getSession(true);
                if (BooleanUtils.toBoolean(preview)) {
                    httpsession.setAttribute(Resource.MGNL_PREVIEW_ATTRIBUTE, Boolean.TRUE);
                } else {
                    httpsession.removeAttribute(Resource.MGNL_PREVIEW_ATTRIBUTE);
                }
            }
        } else if (action.equals(ACTION_NODE_DELETE)) {
            // delete paragraph
            try {
                String path = request.getParameter(PARAM_PATH);
                // deactivate
                updatePageMetaData(request, hm);
                hm.delete(path);
                hm.save();
            } catch (RepositoryException e) {
                log.error("Exception caught: " + e.getMessage(), e); //$NON-NLS-1$
            }
        } else if (action.equals(ACTION_NODE_SORT)) {
            // sort paragrpahs
            try {
                String pathSelected = request.getParameter(PARAM_PATH_SELECTED);
                String pathSortAbove = request.getParameter(PARAM_PATH_SORT_ABOVE);
                String pathParent = StringUtils.substringBeforeLast(pathSelected, "/"); //$NON-NLS-1$
                String srcName = StringUtils.substringAfterLast(pathSelected, "/");
                String destName = StringUtils.substringAfterLast(pathSortAbove, "/");
                if (StringUtils.equalsIgnoreCase(destName, "mgnlNew")) {
                    destName = null;
                }
                hm.getContent(pathParent).orderBefore(srcName, destName);
                hm.save();
            } catch (RepositoryException e) {
                if (log.isDebugEnabled())
                    log.debug("Exception caught: " + e.getMessage(), e); //$NON-NLS-1$
            }
        }
    }
}

From source file:edu.mayo.cts2.framework.service.provider.ServiceProviderFactory.java

@Override
public void setApplicationContext(ApplicationContext applicationContext) {
    if (BooleanUtils.toBoolean(System.getProperty(USE_CLASSPATH_PROVIDER_PROP))) {
        ServiceProvider classpathServiceProvider = null;
        try {//w w  w  .j  a  v a2  s.c  om
            classpathServiceProvider = applicationContext.getBean(ServiceProvider.class);

            log.warn("NOTICE: Found a ServiceProvider on the Classpath: " + classpathServiceProvider
                    + ". This Service Provider will be set as active cannot be disabled.");
        } catch (NoSuchBeanDefinitionException e) {
            log.info("No ServiceProvider found on the Classpath... waiting for a Service Plugin.");
        }

        this.classPathServiceProvider = classpathServiceProvider;
    }
}

From source file:com.dsh105.holoapi.command.sub.TouchCommand.java

@Command(command = "touch add <id> <r:(?i)\"true|false|yes|no\",n:as_console> <command...>", description = "Add an action to perform when a certain hologram is touched", permission = "holoapi.holo.touch.add")
public boolean addWithBoolean(CommandEvent event) {
    Hologram hologram = HoloAPI.getManager().getHologram(event.variable("id"));
    if (hologram == null) {
        event.respond(Lang.HOLOGRAM_NOT_FOUND.getValue("id", event.variable("id")));
        return true;
    }/*from   www . j  ava 2  s.  c om*/

    hologram.addTouchAction(new CommandTouchAction(event.variable("command"),
            BooleanUtils.toBoolean(event.variable("as_console"))));
    event.respond(Lang.COMMAND_TOUCH_ACTION_ADDED.getValue("command", "/" + event.variable("command"), "id",
            hologram.getSaveId()));
    return true;
}

From source file:com.redhat.rhn.frontend.xmlrpc.user.external.UserExternalHandler.java

/**
 * Set the value of EXT_AUTH_KEEP_ROLES//w ww.  j  a v  a2  s .  c  o m
 * @param loggedInUser The current user
 * @param keepRoles True if we should keep temporary roles between login sessions
 * @return 1 on success
 * @throws PermissionCheckFailureException if the user is not a Sat admin
 *
 * @xmlrpc.doc Set whether we should keeps roles assigned to users because of
 * their IPA groups even after they log in through a non-IPA method. Can only be
 * called by a satellite_admin.
 * @xmlrpc.param #param("string", "sessionKey")
 * @xmlrpc.param #param_desc("boolean", "keepRoles", "True if we should keep roles
 * after users log in through non-IPA method, false otherwise.")
 * @xmlrpc.returntype #return_int_success()
 */
public int setKeepTemporaryRoles(User loggedInUser, Boolean keepRoles) throws PermissionCheckFailureException {
    // Make sure we're logged in and a Sat Admin
    ensureSatAdmin(loggedInUser);

    if (SatConfigFactory.getSatConfigBooleanValue(SatConfigFactory.EXT_AUTH_KEEP_ROLES)
            && !BooleanUtils.toBoolean(keepRoles)) {
        // if the option was turned off, delete temporary roles
        // across the whole satellite
        UserGroupFactory.deleteTemporaryRoles();
    }
    // store the value
    SatConfigFactory.setSatConfigBooleanValue(SatConfigFactory.EXT_AUTH_KEEP_ROLES, keepRoles);

    return 1;
}

From source file:fr.paris.lutece.plugins.directory.modules.gismap.business.portlet.GismapDirectoryPortlet.java

/**
 * Returns the Xml code of the form portlet without XML heading
 *
 * @param request The HTTP Servlet request
 * @return the Xml code of the form portlet content
 */// www . j  a  v  a2  s .c  o  m
@Override
public String getXml(HttpServletRequest request) {
    GismapDirectoryPortlet portlet = (GismapDirectoryPortlet) PortletHome.findByPrimaryKey(getId());
    List<DirectoryGismapSourceQuery> listGeojsonSources = portlet.getListMapSource();

    String viewId = String.valueOf(portlet.getView());

    StringBuffer strXml = new StringBuffer();
    XmlUtil.beginElement(strXml, TAG_GISMAP_PORTLET);
    if (!BooleanUtils.toBoolean(portlet.getDisplayPortletTitle())) {
        XmlUtil.addElementHtml(strXml, TAG_GISMAP_PORTLET_CONTENT, "<h3>" + portlet.getName() + "</h3>");
    }
    XmlUtil.addElementHtml(strXml, TAG_GISMAP_PORTLET_CONTENT, GismapDirectoryService.getInstance()
            .getMapTemplateWithDirectoryGismapSources(request, viewId, listGeojsonSources));

    XmlUtil.endElement(strXml, TAG_GISMAP_PORTLET);

    return addPortletTags(strXml);
}

From source file:com.redhat.rhn.frontend.dto.ActivationKeyDto.java

/**
 *
 * @return true if this is the org default
 */
public boolean isOrgDefault() {
    return BooleanUtils.toBoolean(orgDefault);
}

From source file:com.dsh105.holoapi.command.sub.RemoveCommand.java

@Command(command = "remove <id> <keep>", description = "Remove an existing hologram using its ID", permission = "holoapi.holo.remove", help = {
        "<keep> defines whether the hologram is removed from the save files",
        "If set to false, the hologram will only be removed from memory" })
public boolean withKeep(CommandEvent event) {
    Hologram hologram = HoloAPI.getManager().getHologram(event.variable("id"));
    if (hologram == null) {
        event.respond(Lang.HOLOGRAM_NOT_FOUND.getValue("id", event.variable("id")));
        return true;
    }/*  www  . j  a  v  a 2 s . c o m*/

    if (BooleanUtils.toBoolean(event.variable("keep"))) {
        HoloAPI.getManager().clearFromFile(hologram.getSaveId());
    } else {
        Lang.HOLOGRAM_REMOVED_MEMORY.getValue("id", hologram.getSaveId());
    }

    HoloAPI.getManager().stopTracking(hologram);
    return true;
}

From source file:com.edgenius.wiki.render.handler.BlogHandler.java

public Page invoke(String spaceUname, String... tokens) {
    int pageNumber = 1;
    int retCount = 10;
    boolean homepagePassed = false;
    if (tokens != null) {
        if (tokens.length > 0)
            pageNumber = NumberUtils.toInt(tokens[0], 1);
        if (tokens.length > 1)
            retCount = NumberUtils.toInt(tokens[1], 10);
        if (tokens.length > 2)
            homepagePassed = BooleanUtils.toBoolean(tokens[2]);
    }//  w  w w .j  a va 2s .c  o m
    //must use spaceUname in method parameters
    Space space = spaceService.getSpaceByUname(spaceUname);
    Page page = space.getHomepage();
    securityService.fillPageWikiOperations(WikiUtil.getUser(userReadingService), page);

    page.setRenderPieces(getBlogHomePage(spaceUname, pageNumber, retCount));

    return page;
}

From source file:com.cloud.hypervisor.ovm3.resources.helpers.Ovm3Configuration.java

public Ovm3Configuration(Map<String, Object> params) throws ConfigurationException {
    setAgentZoneId(Long.parseLong((String) params.get("zone")));
    setAgentPodId(Long.parseLong(validateParam("PodId", (String) params.get("pod"))));
    setAgentClusterId(Long.parseLong((String) params.get("cluster")));
    setOvm3PoolVip(String.valueOf(params.get("ovm3vip")));
    setAgentInOvm3Pool(BooleanUtils.toBoolean((String) params.get("ovm3pool")));
    setAgentInOvm3Cluster(BooleanUtils.toBoolean((String) params.get("ovm3cluster")));
    setAgentHostname(validateParam("Hostname", (String) params.get("host")));
    setAgentIp((String) params.get("ip"));
    if (params.get("agentport") != null) {
        setAgentOvsAgentPort(Integer.parseInt((String) params.get("agentport")));
    }//  w  ww. ja v  a 2  s. c  o m
    setAgentSshUserName(validateParam("Username", (String) params.get("username")));
    setAgentSshPassword(validateParam("Password", (String) params.get("password")));
    setCsHostGuid(validateParam("Cloudstack Host GUID", (String) params.get("guid")));
    setAgentOvsAgentUser(validateParam("OVS Username", (String) params.get("agentusername")));
    setAgentOvsAgentPassword(validateParam("OVS Password", (String) params.get("agentpassword")));
    setAgentPrivateNetworkName((String) params.get("private.network.device"));
    setAgentPublicNetworkName((String) params.get("public.network.device"));
    setAgentGuestNetworkName((String) params.get("guest.network.device"));
    setAgentStorageNetworkName((String) params.get("storage.network.device1"));
    this.setAgentStorageCheckTimeout(
            NumbersUtil.parseInt((String) params.get("ovm3.heartbeat.timeout"), agentStorageCheckTimeout));
    this.setAgentStorageCheckInterval(
            NumbersUtil.parseInt((String) params.get("ovm3.heartbeat.interval"), agentStorageCheckInterval));
    validatePoolAndCluster();
    if (params.containsKey("istest")) {
        setIsTest((Boolean) params.get("istest"));
    }
}