Example usage for java.lang Boolean Boolean

List of usage examples for java.lang Boolean Boolean

Introduction

In this page you can find the example usage for java.lang Boolean Boolean.

Prototype

@Deprecated(since = "9")
public Boolean(String s) 

Source Link

Document

Allocates a Boolean object representing the value true if the string argument is not null and is equal, ignoring case, to the string "true" .

Usage

From source file:com.salesmanager.core.service.system.impl.dao.CentralMenuDao.java

public Collection<CentralFunction> loadAllCentralFunction() {

    try {//from  www  .jav  a 2  s  . c  o  m
        List list = super.getSession().createCriteria(CentralFunction.class)
                .add(Restrictions.eq("centralFunctionVisible", new Boolean(true)))
                .addOrder(org.hibernate.criterion.Order.asc("centralFunctionPosition")).list();

        return list;
    } catch (RuntimeException re) {
        log.error("get failed", re);
        throw re;
    }
}

From source file:org.openmrs.notification.web.controller.AlertListController.java

/**
 * This is called prior to displaying a form for the first time. It tells Spring the
 * form/command object to load into the request
 *
 * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest)
 *//*from   w  w  w  . j  a  va2s  .  co  m*/
protected Object formBackingObject(HttpServletRequest request) throws Exception {

    //map containing the privilege and true/false whether the privilege is core or not
    List<Alert> alertList = new Vector<Alert>();

    //only fill the list if the user has authenticated properly
    if (Context.isAuthenticated()) {
        AlertService as = Context.getAlertService();
        boolean b = new Boolean(request.getParameter("includeExpired"));
        alertList = as.getAllAlerts(b);
    }

    return alertList;
}

From source file:com.google.gsa.valve.modules.noauth.HTTPNoAuthenticationProcess.java

/**
 * This method simulates the authentication process against a content 
 * source, so that every document is consider here as public.
 * <p>//  ww w .  ja  v  a 2 s .  c o  m
 * Creates the authentication cookie and always return 200, unless there is 
 * any problem processing the request.
 * 
 * @param request HTTP request
 * @param response HTTP response
 * @param authCookies vector that contains the authentication cookies
 * @param url the document url
 * @param creds an array of credentials for all external sources
 * @param id the default credential id to be retrieved from creds
        
 * @return the HTTP error code
        
 * @throws HttpException
 * @throws IOException
 */
public int authenticate(HttpServletRequest request, HttpServletResponse response, Vector<Cookie> authCookies,
        String url, Credentials creds, String id) throws HttpException, IOException {

    Cookie[] cookies = null;

    // Initialize status code
    int statusCode = HttpServletResponse.SC_UNAUTHORIZED;

    // Read cookies
    cookies = request.getCookies();

    // Debug
    logger.debug("HTTP No authentication start");

    //
    // Launch the authentication process
    //

    // Protection
    try {

        Cookie extAuthCookie = null;
        extAuthCookie = new Cookie("gsa_basic_noauth", "");

        extAuthCookie.setValue("true");

        String authCookieDomain = null;
        String authCookiePath = null;
        int authMaxAge = -1;

        // Cache cookie properties
        authCookieDomain = (request.getAttribute("authCookieDomain")).toString();
        authCookiePath = (request.getAttribute("authCookiePath")).toString();
        //authMaxAge
        try {
            authMaxAge = Integer.parseInt(valveConf.getAuthMaxAge());
        } catch (NumberFormatException nfe) {
            logger.error(
                    "Configuration error: chack the configuration file as the number set for authMaxAge is not OK:");
        }

        // Set extra cookie parameters
        extAuthCookie.setDomain(authCookieDomain);
        extAuthCookie.setPath(authCookiePath);
        extAuthCookie.setMaxAge(authMaxAge);

        // Log info
        if (logger.isDebugEnabled())
            logger.debug("Adding gsa_basic_noauth cookie: " + extAuthCookie.getName() + ":"
                    + extAuthCookie.getValue() + ":" + extAuthCookie.getPath() + ":" + extAuthCookie.getDomain()
                    + ":" + extAuthCookie.getSecure());

        //add sendCookies support
        boolean isSessionEnabled = new Boolean(valveConf.getSessionConfig().isSessionEnabled()).booleanValue();
        boolean sendCookies = false;
        if (isSessionEnabled) {
            sendCookies = new Boolean(valveConf.getSessionConfig().getSendCookies()).booleanValue();
        }
        if ((!isSessionEnabled) || ((isSessionEnabled) && (sendCookies))) {
            response.addCookie(extAuthCookie);
        }

        //add cookie to the array
        authCookies.add(extAuthCookie);

        statusCode = HttpServletResponse.SC_OK;

    } catch (Exception e) {

        // Log error
        logger.error("HTTP Basic authentication failure: " + e.getMessage(), e);

        // Update status code
        statusCode = HttpServletResponse.SC_UNAUTHORIZED;

    }

    // End of the authentication process
    logger.debug("HTTP No Authentication completed (" + statusCode + ")");

    // Return status code
    return statusCode;

}

From source file:com.npower.dm.hibernate.management.HibernateSessionFactory.java

private void initSessionFactory() throws HibernateException {
    synchronized (initialized) {
        if (initialized.booleanValue() == false) {
            try {
                config.setProperties(this.loadProperties());

                config.configure(CONFIG_FILE_LOCATION);
                sessionFactory = config.buildSessionFactory();
                initialized = new Boolean(true);
            } catch (IOException e) {
                System.err.println("%%%% Error Creating SessionFactory %%%%");
                DMUtil.print(Thread.currentThread().getContextClassLoader());
                e.printStackTrace();//from w ww  . j a  v  a2  s. c o m
                log.fatal("%%%% Error Creating SessionFactory %%%%", e);
                throw new HibernateException("Error Creating SessionFactory", e);
            } catch (HibernateException e) {
                System.err.println("%%%% Error Creating SessionFactory %%%%");
                DMUtil.print(Thread.currentThread().getContextClassLoader());
                e.printStackTrace();
                log.fatal("%%%% Error Creating SessionFactory %%%%", e);
                throw e;
            } catch (Exception e) {
                System.err.println("%%%% Error Creating SessionFactory %%%%");
                DMUtil.print(Thread.currentThread().getContextClassLoader());
                e.printStackTrace();
                log.fatal("%%%% Error Creating SessionFactory %%%%", e);
                throw new HibernateException("Error Creating SessionFactory", e);
            }
        }
    }
}

From source file:modelibra.designer.metaneighbor.GenMetaNeighbor.java

/**
 * Sets internal./*from w ww. java  2s  .  c o  m*/
 * 
 * @param internal
 *            internal
 */
public void setInternal(boolean internal) {
    setInternal(new Boolean(internal));
}

From source file:org.myjerry.evenstar.web.blog.PostCommentController.java

public ModelAndView postComment(HttpServletRequest request, HttpServletResponse response) throws Exception {
    ModelAndView mav = new ModelAndView();

    String postID = request.getParameter("postID");
    String blogID = request.getParameter("blogID");
    String parentID = request.getParameter("parentID");
    String thoughts = request.getParameter("thoughts");
    String postURL = request.getParameter("postURL");
    String privacy = request.getParameter("privacy");

    Comment comment = new Comment();
    comment.setAuthorID(StringUtils.getLong(GAEUserUtil.getUserID()));
    comment.setBlogID(StringUtils.getLong(blogID));
    comment.setContent(thoughts);// w  w w.  j av a2s  .  co  m
    comment.setPostID(StringUtils.getLong(postID));
    comment.setParentID(StringUtils.getLong(parentID));

    if ("private".equalsIgnoreCase(privacy)) {
        comment.setPermissions(Comment.PRIVACY_MODE_PRIVATE);
    } else {
        comment.setPermissions(Comment.PRIVACY_MODE_PUBLIC);
    }

    CommentModerationType moderation = CommentModerationType.getModeration(this.blogPreferenceService
            .getPreference(StringUtils.getLong(blogID), BlogPreferenceConstants.commentModeration));

    boolean result = this.commentService.postComment(comment);
    if (!result) {
        mav = view(request, response);
        mav.addObject("thoughts", thoughts);
    }

    mav.addObject("moderation", moderation);
    mav.addObject("postURL", postURL);
    mav.addObject("result", new Boolean(result));

    mav.setViewName(".post.comments");
    return mav;
}

From source file:com.duroty.application.admin.utils.AdminDefaultAction.java

/**
 * DOCUMENT ME!/*from  w  w  w .  j av a  2s  . c o m*/
 *
 * @param request DOCUMENT ME!
 *
 * @return DOCUMENT ME!
 *
 * @throws NamingException DOCUMENT ME!
 * @throws RemoteException DOCUMENT ME!
 * @throws CreateException DOCUMENT ME!
 */
protected Mail getMailInstance(HttpServletRequest request)
        throws NamingException, RemoteException, CreateException {
    MailHome home = null;

    Boolean localServer = new Boolean(Configuration.properties.getProperty(Configuration.LOCAL_WEB_SERVER));

    if (localServer.booleanValue()) {
        home = MailUtil.getHome();
    } else {
        Hashtable environment = getContextProperties(request);
        home = MailUtil.getHome(environment);
    }

    return home.create();
}

From source file:edu.ku.brc.af.ui.forms.DataGetterForObj.java

@Override
public Object getFieldValue(final Object dataObjArg, final String fieldName) {
    Object dataObj = dataObjArg;//from   w ww  . j  a  v  a  2  s  .  c  o  m
    //System.out.println("["+fieldName+"]["+(dataObj != null ? dataObj.getClass().toString() : "N/A")+"]");
    Object value = null;
    if (dataObj != null) {
        try {
            Iterator<?> iter = null;
            if (dataObj instanceof Set<?>) {
                iter = ((Set<?>) dataObj).iterator();

            } else if (dataObj instanceof org.hibernate.collection.PersistentSet) {
                iter = ((org.hibernate.collection.PersistentSet) dataObj).iterator();
            }

            if (iter != null) {
                while (iter.hasNext()) {
                    Object obj = iter.next();
                    if (obj instanceof AttributeIFace) // Not scalable (needs interface)
                    {
                        AttributeIFace asg = (AttributeIFace) obj;
                        //log.debug("["+asg.getDefinition().getFieldName()+"]["+fieldName+"]");
                        if (asg.getDefinition().getFieldName().equals(fieldName)) {
                            if (asg.getDefinition().getDataType() == AttributeIFace.FieldType.StringType
                                    .getType()) {
                                return asg.getStrValue();

                                //} else if (asg.getDefinition().getDataType() == AttributeIFace.FieldType.MemoType.getType())
                                //{
                                //    return asg.getStrValue();

                            } else if (asg.getDefinition().getDataType() == AttributeIFace.FieldType.IntegerType
                                    .getType()) {
                                return asg.getDblValue().intValue();

                            } else if (asg.getDefinition().getDataType() == AttributeIFace.FieldType.FloatType
                                    .getType()) {
                                return asg.getDblValue().floatValue();

                            } else if (asg.getDefinition().getDataType() == AttributeIFace.FieldType.DoubleType
                                    .getType()) {
                                return asg.getDblValue();

                            } else if (asg.getDefinition().getDataType() == AttributeIFace.FieldType.BooleanType
                                    .getType()) {
                                return new Boolean(asg.getDblValue() != 0.0);
                            }
                        }
                    } else if (obj instanceof FormDataObjIFace) {
                        dataObj = obj;
                        break;

                    } else {
                        return null;
                    }
                }
            }
            //log.debug(fieldName);

            if (fieldName.startsWith("@get")) {
                try {
                    String methodName = fieldName.substring(1, fieldName.length()).trim();
                    Method method = dataObj.getClass().getMethod(methodName, new Class<?>[] {});
                    if (method != null) {
                        value = method.invoke(dataObj, new Object[] {});
                    }

                } catch (NoSuchMethodException ex) {
                    ex.printStackTrace();
                    edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
                    edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(DataGetterForObj.class, ex);

                } catch (IllegalAccessException ex) {
                    ex.printStackTrace();
                    edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
                    edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(DataGetterForObj.class, ex);

                } catch (InvocationTargetException ex) {
                    ex.printStackTrace();
                    edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
                    edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(DataGetterForObj.class, ex);
                }

            } else {
                PropertyDescriptor descr = PropertyUtils.getPropertyDescriptor(dataObj, fieldName.trim());
                if (descr != null) {
                    Method getter = PropertyUtils.getReadMethod(descr);

                    if (getter != null) {
                        value = getter.invoke(dataObj, (Object[]) null);
                        if (value instanceof PersistentSet) {
                            PersistentSet vSet = (PersistentSet) value;
                            if (vSet.getSession() != null && !vSet.isDirty()) {
                                int loadCode = dataObj instanceof FormDataObjIFace
                                        ? ((FormDataObjIFace) dataObj).shouldForceLoadChildSet(getter)
                                        : -1;
                                if (loadCode != 0) {
                                    int max = loadCode == -1 ? vSet.size() : loadCode + 1;
                                    int i = 0;
                                    for (Object v : vSet) {
                                        if (v instanceof FormDataObjIFace) {
                                            ((FormDataObjIFace) v).forceLoad();
                                        }
                                        if (++i == max) {
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                } else if (showErrors) {
                    log.error("We could not find a field named[" + fieldName.trim() + "] in data object ["
                            + dataObj.getClass().toString() + "]");
                }
            }
        } catch (Exception ex) {
            log.error(ex);
            if (!(ex instanceof org.hibernate.LazyInitializationException)) {
                edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
                edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(DataGetterForObj.class, ex);
            }
        }
    }
    return value;
}

From source file:org.squale.squaleweb.applicationlayer.action.results.ReviewAction.java

/**
 * Rcupre la liste des TREs correspondant au composant slectionn
 * //from  w  w  w .  ja v a 2  s .co  m
 * @param pMapping le mapping.
 * @param pForm le formulaire  lire.
 * @param pRequest la requte HTTP.
 * @param pResponse la rponse de la servlet.
 * @return l'action  raliser.
 */
public ActionForward review(ActionMapping pMapping, ActionForm pForm, HttpServletRequest pRequest,
        HttpServletResponse pResponse) {
    ActionForward forward = null;
    ActionErrors errors = new ActionErrors();
    try {
        forward = pMapping.findForward("review");
        String tre;
        String ruleId;
        boolean isManualMark = false;
        // Dtermination du type de paramtre
        boolean isMetric = (pRequest.getParameter("kind") == null)
                || (pRequest.getParameter("kind").equals("metric"));
        if (isMetric) {
            tre = pRequest.getParameter("which");
            ruleId = "";
        } else {
            // Rcupration du vritable nom de la rgle
            IApplicationComponent ac = AccessDelegateHelper.getInstance("QualityGrid");
            QualityRuleDTO dto = new QualityRuleDTO();
            ruleId = pRequest.getParameter("which");
            dto.setId(Integer.valueOf(ruleId).longValue());
            dto = (QualityRuleDTO) ac.execute("getQualityRule", new Object[] { dto, new Boolean(false) });
            tre = dto.getName();
            if (dto instanceof PracticeRuleDTO) {
                //If the practice is a manual practice 
                if (((PracticeRuleDTO) dto).getFormulaType() == null) {
                    isManualMark = true;
                    forward = pMapping.findForward("reviewManualMark");
                }
            }
        }
        // si un composant est prcis, on le prend sinon on prend le projet
        String componentId = pRequest.getParameter("component");
        if (componentId == null) {
            componentId = pRequest.getParameter("projectId");
        }
        WTransformerFactory.objToForm(ParamReviewTransformer.class, (WActionForm) pForm,
                new Object[] { tre, ruleId, componentId, isManualMark });
        IApplicationComponent ac = AccessDelegateHelper.getInstance("Component");
        ComponentDTO dto = new ComponentDTO();
        dto.setID(new Long(componentId).longValue());
        Object[] paramIn = { dto };
        dto = (ComponentDTO) ac.execute("get", paramIn);
        Object obj[] = { dto };
        ComponentForm cForm = (ComponentForm) WTransformerFactory.objToForm(ComponentTransformer.class, obj);
        ((ParamReviewForm) pForm).setComponentName(cForm.getName());
        ((ParamReviewForm) pForm).setComponentType(cForm.getType());
        // Met  jour les champs graph et comments du form
        setParamsInForm(pForm, pRequest);

    } catch (Exception e) {
        // Factorisation du traitement des erreurs
        handleException(e, errors, pRequest);
    }
    if (!errors.isEmpty()) {
        // Sauvegarde des message et transfert vers la page d'erreur
        saveErrors(pRequest, errors);
        forward = pMapping.findForward("failure");
    }
    // Mise en place du traceur historique
    String displayName = WebMessages.getString(pRequest.getLocale(), "tracker.mark.history");
    // Dans le cas ou on arrive depuis la vue composant
    // il ne faut pas faire un updateTracker car ce n'est pas le TrackerHist
    // qui est affich mais le Tracker des composants.
    // Par consquent, il faut crr un nouveau form dont le seul champ  remplir est le nom,
    // car ce sera le dernier lment et ne sera donc pas cliquable.
    if (pRequest.getSession().getAttribute(SqualeWebConstants.TRACKER_BOOL).equals("true")) {
        // nouveau form dont on ne fait que remplir le nom
        ComponentForm form = new ComponentForm();
        form.setName(displayName);
        // remet  jour le Tracker des composants
        updateTrackerComponent(form.getId(), form.getName(), pRequest);
    } else {
        updateHistTracker(displayName, "", TrackerStructure.UNDEFINED, pRequest, false); // Le lien est vide car
                                                                                         // c'est action
                                                                                         // terminale
    }
    return forward;
}

From source file:de.julielab.jcore.ae.lingpipegazetteer.chunking.ChunkerProviderImpl.java

public void load(DataResource resource) throws ResourceInitializationException {
    Properties properties = new Properties();
    try {/*  w w  w.  j  a  v  a  2  s.  c o  m*/
        properties.load(resource.getInputStream());
    } catch (IOException e) {
        LOGGER.error("Error while loading properties file", e);
        throw new ResourceInitializationException(e);
    }

    LOGGER.info("Creating dictionary chunker with " + resource.getUrl() + " properties file.");

    String dictionaryFilePath = properties.getProperty(PARAM_DICTIONARY_FILE);
    if (dictionaryFilePath == null)
        throw new ResourceInitializationException(ResourceInitializationException.CONFIG_SETTING_ABSENT,
                new Object[] { PARAM_DICTIONARY_FILE });

    String stopwordFilePath = properties.getProperty(PARAM_STOPWORD_FILE);
    if (stopwordFilePath == null)
        throw new ResourceInitializationException(ResourceInitializationException.CONFIG_SETTING_ABSENT,
                new Object[] { PARAM_STOPWORD_FILE });

    String serializedDictionaryPath = properties.getProperty(PARAM_SERIALIZED_DICTIONARY_FILE);
    File serializedDictionaryFile = serializedDictionaryPath != null ? new File(serializedDictionaryPath)
            : null;
    LOGGER.debug("Serialized dictionary path: {}", serializedDictionaryPath);

    String generateVariantsString = properties.getProperty(PARAM_MAKE_VARIANTS);
    generateVariants = true;
    if (generateVariantsString != null)
        generateVariants = new Boolean(generateVariantsString);
    LOGGER.debug("Generate variants: {}", generateVariants);

    String caseSensitiveString = properties.getProperty(PARAM_CASE_SENSITIVE);
    caseSensitive = false;
    if (caseSensitiveString != null)
        caseSensitive = new Boolean(caseSensitiveString);
    LOGGER.debug("Case sensitive: {}", caseSensitive);

    String useApproximateMatchingString = properties.getProperty(PARAM_USE_APPROXIMATE_MATCHING);
    useApproximateMatching = false;
    if (useApproximateMatchingString != null)
        useApproximateMatching = new Boolean(useApproximateMatchingString);
    LOGGER.debug("Use approximate matching: {}", useApproximateMatchingString);

    try {
        InputStream dictFile;
        if (new File(dictionaryFilePath).exists())
            dictFile = new FileInputStream(dictionaryFilePath);
        else {
            String resourceLocation = dictionaryFilePath.startsWith("/") ? dictionaryFilePath
                    : "/" + dictionaryFilePath;
            dictFile = getClass().getResourceAsStream(resourceLocation);
        }

        InputStream stopFile;
        if (new File(stopwordFilePath).exists())
            stopFile = new FileInputStream(stopwordFilePath);
        else {
            String resourceLocation = stopwordFilePath.startsWith("/") ? stopwordFilePath
                    : "/" + stopwordFilePath;
            stopFile = getClass().getResourceAsStream(resourceLocation);
        }
        if (null != serializedDictionaryFile && serializedDictionaryFile.exists()) {
            readSerializedDictionaryFile(serializedDictionaryFile);
        } else {
            initStopWords(stopFile);
            readDictionary(dictFile);
            if (!StringUtils.isBlank(serializedDictionaryPath))
                serializeDictionary(serializedDictionaryFile);
        }

        if (useApproximateMatching) {
            dictChunker = new ApproxDictionaryChunker((TrieDictionary<String>) dict,
                    IndoEuropeanTokenizerFactory.INSTANCE, ApproxDictionaryChunker.TT_DISTANCE,
                    APPROX_MATCH_THRESHOLD_SCORE);
        } else {
            dictChunker = new ExactDictionaryChunker(dict, IndoEuropeanTokenizerFactory.INSTANCE, false,
                    caseSensitive);
        }

    } catch (Exception e) {
        LOGGER.error("Exception while creating chunker instance", e);
    }
}