List of usage examples for java.lang Boolean booleanValue
@HotSpotIntrinsicCandidate public boolean booleanValue()
From source file:fedora.server.security.servletfilters.BaseCaching.java
@Override public void authenticate(ExtendedHttpServletRequest extendedHttpServletRequest) throws Exception { String method = "authenticate()"; if (log.isDebugEnabled()) { log.debug(enter(method));/*from www .ja v a 2 s .c o m*/ } try { String userid = extendedHttpServletRequest.getUser(); if (log.isDebugEnabled()) { log.debug(format(method, null, "userid", userid)); } boolean authenticated = false; if (userid != null && !"".equals(userid)) { String password = extendedHttpServletRequest.getPassword(); if (log.isDebugEnabled()) { log.debug(format(method, null, "password", password)); } Cache cache = getCache(FILTER_NAME); if (log.isDebugEnabled()) { log.debug(format(method, "calling cache.authenticate()")); } Boolean result = cache.authenticate(this, userid, password); authenticated = result != null && result.booleanValue(); if (authenticated) { Principal authenticatingPrincipal = new fedora.server.security.servletfilters.Principal(userid); extendedHttpServletRequest.setAuthenticated(authenticatingPrincipal, FILTER_NAME); if (log.isDebugEnabled()) { log.debug(format(method, "set authenticated")); } } if (log.isDebugEnabled()) { log.debug(format(method, "calling audit", "user", userid)); } cache.audit(userid); } } catch (Throwable th) { showThrowable(th, log, "general " + method + " failure"); } if (log.isDebugEnabled()) { log.debug(exit(method)); } }
From source file:com.aurel.track.fieldType.runtime.custom.check.CustomCheckBoxSingleRT.java
/** * Gets the string value to be stored by lucene * @param value the value of the field// ww w. ja va 2 s . c om * @param workItemBean the lucene value might depend on other fields of the workItem * @return */ @Override public String getLuceneValue(Object value, TWorkItemBean workItemBean) { if (value != null) { try { //if the attribute value of the workItem (or workItemOld) was loaded from the database //than it is set to a boolean value (see getSpecificAttribute()) //So try converting it to a Boolean Boolean boolValue = (Boolean) value; if (boolValue.booleanValue() == true) { return LuceneUtil.BOOLEAN_YES; } } catch (Exception e) { LOGGER.debug("Converting the value " + value + "of class " + value.getClass().getName() + " to Boolean failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } } return LuceneUtil.BOOLEAN_NO; }
From source file:com.redhat.rhn.manager.monitoring.ModifyFilterCommand.java
/** * Update the recurrance logic of the filter. If <code>recurring</code> is * {@link Boolean#TRUE}, set the filter to be active for <code>duration</code> * time units every <code>frequency</code>; the time units are given * by <code>durationType</code>. The frequency is one of the constants mentioned in * {@link Filter#setRecurringFrequency}//from ww w.j a va 2 s .c o m * @param recurring whether the filter is recurring or not * @param duration the number of time units the filter is active for * @param durationType one of {@link Calendar#YEAR}, {@link Calendar#WEEK_OF_YEAR}, * {@link Calendar#DAY_OF_MONTH}, {@link Calendar#HOUR_OF_DAY}, * {@link Calendar#HOUR_OF_DAY} * @param frequency the frequency with which the filter is activated, as described in * {@link Filter#setRecurringFrequency} */ public void updateRecurring(Boolean recurring, int duration, int durationType, Long frequency) { filter.setRecurringBool(recurring); if (recurring.booleanValue()) { // Calculate duration Calendar expires = Calendar.getInstance(); expires.setTime(filter.getStartDate()); expires.add(durationType, duration); if (durationType == Calendar.MINUTE) { // durationType == 12 // NOOP since minutes is the base type. } else if (durationType == Calendar.HOUR_OF_DAY) { // durationType == 11 duration = duration * 60; } else if (durationType == Calendar.DAY_OF_MONTH) { // durationType == 5 duration = duration * 60 * 24; } else if (durationType == Calendar.WEEK_OF_YEAR) { // durationType == 3 duration = duration * 60 * 24 * 7; } else if (durationType == Calendar.YEAR) { // durationType == 1 duration = duration * 60 * 24 * 7 * 365; } else { throw new IllegalArgumentException("Durration for recurring " + "should be either Calendar.MINUTE, HOURS_OF_DAY, " + "DAY_OF_MONTH, WEEK_OF_YEAR, YEAR"); } filter.setRecurringDuration(new Long(duration)); filter.setRecurringFrequency(frequency); filter.setRecurringDurationType(new Long(durationType)); } }
From source file:com.glaf.jbpm.action.HibernateMultiNativeSQLAction.java
@SuppressWarnings("unchecked") public void execute(ExecutionContext ctx) throws Exception { logger.debug("-------------------------------------------------------"); logger.debug("---------------HibernateMultiNativeSQLAction-----------"); logger.debug("-------------------------------------------------------"); ContextInstance contextInstance = ctx.getContextInstance(); Map<String, Object> params = new java.util.HashMap<String, Object>(); Map<String, Object> variables = contextInstance.getVariables(); if (variables != null && variables.size() > 0) { Set<Entry<String, Object>> entrySet = variables.entrySet(); for (Entry<String, Object> entry : entrySet) { String name = entry.getKey(); Object value = entry.getValue(); if (name != null && value != null) { params.put(name, value); }// w w w .j a va 2s.c om } } boolean executable = true; if (StringUtils.isNotEmpty(expression)) { if (expression.startsWith("#{") && expression.endsWith("}")) { Object value = DefaultExpressionEvaluator.evaluate(expression, params); if (value != null) { if (value instanceof Boolean) { Boolean b = (Boolean) value; executable = b.booleanValue(); } } } } if (!executable) { logger.debug("???false??"); return; } params.put("now", new java.util.Date()); params.put("date", new java.util.Date()); params.put("timestamp", new java.util.Date()); params.put("dateTime", new java.util.Date()); params.put("actorId", ctx.getJbpmContext().getActorId()); ProcessInstance processInstance = ctx.getProcessInstance(); params.put("processInstanceId", processInstance.getId()); String bindValue = (String) contextInstance.getVariable(bindName); if (StringUtils.isNotEmpty(bindValue)) { JSONArray array = JSON.parseArray(bindValue); if (array != null && !array.isEmpty()) { java.util.Date now = new java.util.Date(); Object rowId = contextInstance.getVariable(Constant.PROCESS_ROWID); for (int i = 0, len = array.size(); i < len; i++) { JSONObject jsonObject = array.getJSONObject(i); Map<String, Object> dataMap = new java.util.HashMap<String, Object>(); dataMap.putAll(params); Iterator<Entry<String, Object>> iterator = jsonObject.entrySet().iterator(); while (iterator.hasNext()) { Entry<String, Object> entry = iterator.next(); String key = (String) entry.getKey(); Object value = entry.getValue(); if (value != null) { if (value instanceof String) { String tmp = (String) value; if ("#{processInstanceId}".equals(tmp)) { value = contextInstance.getProcessInstance().getId(); } else if ("#{taskInstanceId}".equals(tmp)) { TaskInstance taskInstance = ctx.getTaskInstance(); if (taskInstance != null) { value = taskInstance.getId(); } } else if ("#{taskName}".equals(tmp)) { Task task = ctx.getTask(); if (task != null) { value = task.getName(); } else { if (ctx.getTaskInstance() != null) { value = ctx.getTaskInstance().getName(); } } } else if (tmp.equals("now()")) { value = new java.sql.Date(now.getTime()); } else if (tmp.equals("date()")) { value = new java.sql.Date(now.getTime()); } else if (tmp.equals("time()")) { value = new java.sql.Time(now.getTime()); } else if (tmp.equals("timestamp()")) { value = new java.sql.Timestamp(now.getTime()); } else if (tmp.equals("#{rowId}")) { value = rowId; } else if (tmp.equals("#{actorId}")) { value = ctx.getJbpmContext().getActorId(); } else if (tmp.equals("#{status}")) { value = contextInstance.getVariable("status"); } else if (tmp.startsWith("#P{") && tmp.endsWith("}")) { tmp = StringTools.replaceIgnoreCase(tmp, "#P{", ""); tmp = StringTools.replaceIgnoreCase(tmp, "}", ""); value = contextInstance.getVariable(tmp); } else if (tmp.startsWith("#{") && tmp.endsWith("}")) { Map<String, Object> vars = contextInstance.getVariables(); if (vars != null && vars.size() > 0) { Iterator<String> it = vars.keySet().iterator(); while (it.hasNext()) { String variableName = it.next(); if (dataMap.get(variableName) == null) { Object object = contextInstance.getVariable(variableName); dataMap.put(variableName, object); } } } value = DefaultExpressionEvaluator.evaluate(tmp, dataMap); } if (key.endsWith("_datetime")) { java.util.Date date = DateUtils.toDate(tmp); value = date; dataMap.put(key.substring(0, key.length() - 9), value); } dataMap.put(key, value); } if (value instanceof Long) { if (key.endsWith("_datetime")) { Long time = (Long) value; java.util.Date date = new java.util.Date(time); value = date; dataMap.put(key.substring(0, key.length() - 9), value); } dataMap.put(key, value); } else { dataMap.put(key, value); } } } SqlExecutor sqlExecutor = HibernateUtils.replaceSQL(sql, dataMap); String sqlx = sqlExecutor.getSql(); if (sqlExecutor.getParameter() != null) { logger.debug("sqlExecutor.getParameter():" + sqlExecutor.getParameter()); if (sqlExecutor.getParameter() instanceof Map) { dataMap = (Map<String, Object>) sqlExecutor.getParameter(); } } if (sqlx.indexOf("#{tableName}") != -1) { String tableName = (String) contextInstance.getVariable("tableName"); if (StringUtils.isNotEmpty(tableName)) { sqlx = StringTools.replaceIgnoreCase(sqlx, "#{tableName}", tableName); } } logger.debug(sqlx); logger.debug(dataMap); Query query = ctx.getJbpmContext().getSession().createSQLQuery(sqlx); HibernateUtils.fillParameters(query, dataMap); query.executeUpdate(); } } } }
From source file:com.adintellig.UDFJson.java
private Object extract(Object json, String path) throws JSONException { // Cache patternkey.matcher(path).matches() Matcher mKey = null;/* w w w.j a v a 2 s .c o m*/ Boolean mKeyMatches = mKeyMatchesCache.get(path); if (mKeyMatches == null) { mKey = patternKey.matcher(path); mKeyMatches = mKey.matches() ? Boolean.TRUE : Boolean.FALSE; mKeyMatchesCache.put(path, mKeyMatches); } if (!mKeyMatches.booleanValue()) { return null; } // Cache mkey.group(1) String mKeyGroup1 = mKeyGroup1Cache.get(path); if (mKeyGroup1 == null) { if (mKey == null) { mKey = patternKey.matcher(path); } mKeyGroup1 = mKey.group(1); mKeyGroup1Cache.put(path, mKeyGroup1); } json = extract_json_withkey(json, mKeyGroup1); // Cache indexList ArrayList<String> indexList = indexListCache.get(path); if (indexList == null) { Matcher mIndex = patternIndex.matcher(path); indexList = new ArrayList<String>(); while (mIndex.find()) { indexList.add(mIndex.group(1)); } indexListCache.put(path, indexList); } if (indexList.size() > 0) { json = extract_json_withindex(json, indexList); } return json; }
From source file:com.adobe.acs.commons.wcm.impl.ComponentErrorHandlerImpl.java
private boolean isComponentErrorHandlingSuppressed(final ServletRequest request) { final Boolean suppress = (Boolean) request.getAttribute(SUPPRESS_ATTR); if (suppress != null) { return suppress.booleanValue(); } else {/* ww w .j a v a 2 s . com*/ return false; } }
From source file:es.pode.administracion.presentacion.nodos.altaNodo.AltaNodoControllerImpl.java
/** * @see es.pode.administracion.presentacion.nodos.altaNodo.AltaNodoController#altaNodo(org.apache.struts.action.ActionMapping, * es.pode.administracion.presentacion.nodos.altaNodo.AltaNodoForm, * javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse) *///from ww w . j av a 2 s . c om public final void altaNodo(ActionMapping mapping, es.pode.administracion.presentacion.nodos.altaNodo.AltaNodoForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { try { NodoVO nodoVO = new NodoVO(); String nodo = form.getNodo(); String url = form.getUrl(); String puerto = form.getPuerto(); Long ccaaId = form.getComunidad(); String urlWS = form.getUrlWS(); // Validaciones de los campos que recogemos del formulario Pattern mask = Pattern.compile("[^\\\\?\\\\!\\>\\#\\&\\<\\@\\$\\\'\\\"]+"); Matcher matcher = null; //Validacion de nombre de nodo if (nodo == null || nodo.equals("")) { log.error("el nombre del nodo no puede estar vacio"); throw new ValidatorException("{errors.altanodo.nodo}"); } matcher = mask.matcher(nodo); if (!matcher.matches()) { if (log.isDebugEnabled()) log.debug("nodo caracter ilegal"); throw new ValidatorException("{errors.altanodo.nodo.caracterIlegal}"); } //Validacion de la url del nodo if (url == null || url.equals("")) { log.error("la url del nodo no puede estar vacio"); throw new ValidatorException("{errors.altanodo.url}"); } matcher = mask.matcher(url); if (!matcher.matches()) { if (log.isDebugEnabled()) log.debug("nodo caracter ilegal"); throw new ValidatorException("{errors.altanodo.url.caracterIlegal}"); } //Validacion de la url de Webservice if (urlWS == null || urlWS.equals("")) { log.error("la url del WebService no puede estar vacio"); throw new ValidatorException("{errors.altanodo.urlWS}"); } matcher = mask.matcher(urlWS); if (!matcher.matches()) { if (log.isDebugEnabled()) log.debug("nodo caracter ilegal"); throw new ValidatorException("{errors.altanodo.urlWS.caracterIlegal}"); } //Comprobamos que no existe ningun nodo con el nombre introducido para dar de alta if (this.getSrvNodoService().existeNombreNodo(nodo).booleanValue()) throw new ValidatorException("{errors.altanodo.nombreNodoYaExiste}"); //Comprobamos la url del nodo para evitar que un nodo se federe consigo mismo String urlHost = AgregaPropertiesImpl.getInstance().getProperty(AgregaProperties.HOST); if (log.isDebugEnabled()) log.debug("El valor de urlHost es " + urlHost); if (urlHost.trim().equalsIgnoreCase(url.trim())) { if (log.isDebugEnabled()) log.debug("Se esta intentando federar un nodo consigo mismo"); throw new ValidatorException("{errors.altanodo.url.federadoConsigoMismo}"); } //Compruebo si ya existen otro nodo en la BD con los mismos valores de url y urlWS Boolean estaDadoAlta = this.getSrvNodoService().estaDadoAlta(url, urlWS); if (log.isDebugEnabled()) log.debug("estaDadoAlta " + estaDadoAlta); if (estaDadoAlta.booleanValue()) { if (log.isDebugEnabled()) log.debug("esta dado de alta"); throw new ValidatorException("{errors.altanodo.url.yaEstaDadoAlta}"); } //Comprobamos si se introdcue puerto que este sea numerico if (puerto != null && !puerto.matches("[0-9]*")) throw new ValidatorException("{errors.altanodo.puerto.NoNumerico}"); nodoVO.setNodo(nodo); nodoVO.setUrl(url); nodoVO.setPuerto(puerto); nodoVO.setUrlWS(urlWS); if (ccaaId != null) { CcaaVO ccaa = new CcaaVO(); ccaa.setId(ccaaId); nodoVO.setCcaa(ccaa); } //Comprobamos si al crear el nodo todo ha ido bien o se ha producido algun error Integer codigo_devuelto = this.getSrvNodoService().crearNodo(nodoVO); if (codigo_devuelto.intValue() == 1) throw new ValidatorException("{errors.altanodo.urlWS.timeout}"); } catch (ValidatorException e) { throw e; } catch (Exception e) { log.error("Error!! " + e); throw new ValidatorException("{errors.altanodo}"); } }
From source file:com.activecq.samples.slingauthenticationhandler.impl.TokenSlingAuthenticationHandler.java
/** * Extract the credentials contained inside the request, parameter or cookie * * @see com .day.cq.auth.impl.AbstractHTTPAuthHandler#authenticate(javax.servlet.http.HttpServletRequest, * javax.servlet.http.HttpServletResponse) *///from ww w . j av a 2s . c om @Override public AuthenticationInfo extractCredentials(HttpServletRequest request, HttpServletResponse response) { if (!accepts(request)) { return null; } final String extractedUserID = request.getParameter("j_sample_username"); final String extractedPassword = "do not auth";//request.getParameter("j_password"); // Execute any pre-authentication here such as authenticating cookies // or authentication credentials to third-party systems String crxUserID = extractedUserID; // Example to work w Sample RememeberMe Authentication Handler final Boolean rememberMe = (Boolean) request .getAttribute(RememberMeSlingAuthenticationHandler.REMEMBER_ME_ROUTINE); if (rememberMe != null && rememberMe.booleanValue()) { crxUserID = "david"; } boolean preauthenticated = "david".equalsIgnoreCase(crxUserID); // hased on pre-authentication success if (preauthenticated) { Session adminSession = null; try { adminSession = slingRepository.loginAdministrative(null); if (!this.userExists(crxUserID, adminSession)) { this.createUser(crxUserID, adminSession); } return TokenUtil.createCredentials(request, response, slingRepository, crxUserID, true); } catch (RepositoryException e) { log.error("Repository error authenticating user: {} ~> {}", crxUserID, e); } finally { if (adminSession != null) { adminSession.logout(); } } } // If accepts == true, and conditions have not been met to create a Token AuthInfo object, then authentication has failed return AuthenticationInfo.FAIL_AUTH; }
From source file:edu.caltechUcla.sselCassel.projects.jMarkets.server.control.UpdateServ.java
/** Set the given client to connected status */ protected boolean setConnected(int dbId) { try {//from w w w. j a v a2 s . c o m Integer clientInt = new Integer(dbId); if (!disconnected.containsKey(clientInt)) { log.warn("Cannot update connection status of client " + dbId + " -- client is not connected to any session!"); return false; } Boolean ds = (Boolean) disconnected.get(clientInt); if (ds.booleanValue()) { disconnected.put(clientInt, Boolean.FALSE); } return true; } catch (Exception e) { log.error("UpdateServ failed to update admin monitor with client " + dbId + " connection status"); } return false; }
From source file:gate.corpora.FastInfosetDocumentFormat.java
/** * Unpacks markup in the GATE-specific standoff XML markup format. * /*from w w w. j a v a 2 s .com*/ * @param doc * the document to process * @param statusListener * optional status listener to receive status messages * @throws DocumentFormatException * if a fatal error occurs during parsing */ private void unpackGateFormatMarkup(Document doc, StatusListener statusListener) throws DocumentFormatException { boolean docHasContentButNoValidURL = hasContentButNoValidUrl(doc); try { Reader inputReader = null; InputStream inputStream = null; XMLStreamReader xsr = null; String encoding = ((TextualDocument) doc).getEncoding(); if (docHasContentButNoValidURL) { xsr = new StAXDocumentParser(IOUtils.toInputStream(doc.getContent().toString(), encoding), getStAXManager()); } else { inputStream = doc.getSourceUrl().openStream(); xsr = new StAXDocumentParser(inputStream, getStAXManager()); } // find the opening GateDocument tag xsr.nextTag(); // parse the document try { DocumentStaxUtils.readGateXmlDocument(xsr, doc, statusListener); } finally { xsr.close(); if (inputStream != null) { inputStream.close(); } if (inputReader != null) { inputReader.close(); } } } catch (XMLStreamException e) { doc.getFeatures().put("parsingError", Boolean.TRUE); Boolean bThrow = (Boolean) doc.getFeatures().get(GateConstants.THROWEX_FORMAT_PROPERTY_NAME); if (bThrow != null && bThrow.booleanValue()) { // the next line is commented to avoid Document creation fail on // error throw new DocumentFormatException(e); } else { Out.println("Warning: Document remains unparsed. \n" + "\n Stack Dump: "); e.printStackTrace(Out.getPrintWriter()); } // if } catch (IOException ioe) { throw new DocumentFormatException("I/O exception for " + doc.getSourceUrl().toString(), ioe); } }