List of usage examples for java.lang Boolean valueOf
public static Boolean valueOf(String s)
From source file:org.syncope.core.rest.controller.UserRequestController.java
private Boolean isCreateAllowedByConf() { SyncopeConf createRequestAllowed = confDAO.find("createRequest.allowed", "false"); return Boolean.valueOf(createRequestAllowed.getValue()); }
From source file:com.bstek.dorado.data.entity.BeanEntityEnhancer.java
protected synchronized void buildReflectionCahce() throws Exception { synchronized (cachedTypes) { if (!cachedTypes.contains(beanType)) { cachedTypes.add(beanType);//from w w w .j a va 2s . c om Map<String, Boolean> properties = new Hashtable<String, Boolean>(); Map<Method, String> readMethods = new Hashtable<Method, String>(); Map<Method, String> writeMethods = new Hashtable<Method, String>(); PropertyDescriptor[] propertyDescriptors = PropertyUtils.getPropertyDescriptors(beanType); for (PropertyDescriptor propertyDescriptor : propertyDescriptors) { String property = propertyDescriptor.getName(); if (propertyDescriptor.getReadMethod() == null) { continue; } properties.put(property, Boolean.valueOf(propertyDescriptor.getWriteMethod() != null)); Method readMethod = propertyDescriptor.getReadMethod(); Method writeMethod = propertyDescriptor.getWriteMethod(); if (readMethod != null) { if (readMethod.getDeclaringClass() != beanType) { readMethod = beanType.getMethod(readMethod.getName(), readMethod.getParameterTypes()); } readMethods.put(readMethod, property); } if (writeMethod != null) { if (writeMethod.getDeclaringClass() != beanType) { writeMethod = beanType.getMethod(writeMethod.getName(), writeMethod.getParameterTypes()); } writeMethods.put(writeMethod, property); } } propertiesCache.put(beanType, properties); readMethodsCache.put(beanType, readMethods); writeMethodsCache.put(beanType, writeMethods); this.properties = properties; this.readMethods = readMethods; this.writeMethods = writeMethods; } else { this.properties = propertiesCache.get(beanType); this.readMethods = readMethodsCache.get(beanType); this.writeMethods = writeMethodsCache.get(beanType); } } }
From source file:it.reply.orchestrator.config.persistence.OrchestratorPersistenceConfig.java
/** * Creates an {@link EntityManagerFactory}. *//*from w w w. jav a2 s . c o m*/ @Bean @OrchestratorPersistenceUnit public LocalContainerEntityManagerFactoryBean entityManagerFactory() { LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); vendorAdapter.setGenerateDdl(Boolean.TRUE); vendorAdapter.setShowSql(Boolean.valueOf(this.env.getProperty(HIBERNATE_SHOW_SQL))); factory.setJtaDataSource(orchestratorDataSource()); factory.setJpaVendorAdapter(vendorAdapter); factory.setPackagesToScan(this.env.getProperty(ENTITY_MANAGER_PACKAGE_TO_SCAN)); factory.setPersistenceUnitName("orchestrator"); LOG.debug(env.getProperty(ENTITY_MANAGER_PACKAGE_TO_SCAN)); LOG.debug(env.getProperty(HIBERNATE_HBM2DDL_AUTO)); LOG.debug(env.getProperty(HIBERNATE_DIALECT)); LOG.debug(env.getProperty(HIBERNATE_TRANSACTION_JTA_PLATFORM)); Properties jpaProperties = new Properties(); jpaProperties.put(HIBERNATE_HBM2DDL_AUTO, env.getProperty(HIBERNATE_HBM2DDL_AUTO)); jpaProperties.put(HIBERNATE_DIALECT, env.getProperty(HIBERNATE_DIALECT)); jpaProperties.put(HIBERNATE_TRANSACTION_JTA_PLATFORM, env.getProperty(HIBERNATE_TRANSACTION_JTA_PLATFORM)); jpaProperties.put("hibernate.transaction.manager_lookup_class", "org.hibernate.transaction.JBossTransactionManagerLookup"); factory.setJpaProperties(jpaProperties); return factory; }
From source file:com.samknows.measurement.schedule.datacollection.BaseDataCollector.java
public static BaseDataCollector parseXml(Element node) { BaseDataCollector c = null;//from w ww. ja v a 2 s .com try { Type type = Type.valueOf(node.getAttribute("type")); switch (type) { case Location: { c = LocationDataCollector.parseXml(node); break; } case Environment: { c = new EnvironmentDataCollector(); break; } default: Logger.e(BaseDataCollector.class, "not such data collector: " + type); } } catch (Exception e) { Logger.e(BaseDataCollector.class, "Error in parsing data collector type: " + e.getMessage()); } if (c != null) { c.isEnabled = true; if (!node.getAttribute("enabled").equals("")) { c.isEnabled = Boolean.valueOf(node.getAttribute("enabled")); } } return c; }
From source file:com.kijes.ela.android.ElaService.java
public UserStatus getUserStatus(String userId) { if (D)// w w w .j a v a2 s . c o m Log.d(TAG, "getUserStatus [" + userId + "]"); ClientResource res = service.getChild("/ela/user/" + userId); UserStatus userStatus = null; try { JsonRepresentation jsonRep = new JsonRepresentation(res.get()); JSONObject jsonUser = jsonRep.getJsonObject(); if (D) Log.d(TAG, "JSON RES:" + jsonUser.toString()); Boolean enteredArea = Boolean.valueOf(jsonUser.getString("entered_area")); if (enteredArea) { userStatus = new UserStatus(ElaStatusReader.MESSAGE_REQUEST_OK, STATUS_OK_USER_ENTERED_AREA); } else { userStatus = new UserStatus(ElaStatusReader.MESSAGE_REQUEST_OK, STATUS_OK_USER_LEFT_AREA); } } catch (ResourceException e1) { userStatus = new UserStatus(ElaStatusReader.MESSAGE_REQUEST_FAIL, STATUS_ERROR_RESOURCE_PROBLEM); } catch (IOException e3) { userStatus = new UserStatus(ElaStatusReader.MESSAGE_REQUEST_FAIL, STATUS_ERROR_CONNECTION_PROBLEM); } catch (JSONException e4) { userStatus = new UserStatus(ElaStatusReader.MESSAGE_REQUEST_FAIL, STATUS_ERROR_MALFORMED_MESSAGE); } if (D) Log.d(TAG, "Single user [" + userId + "] retrieved"); return userStatus; }
From source file:com.bfd.harpc.config.spring.HarpcBeanDefinitionParser.java
/** * {@link#parse}/* w w w .ja v a2 s. c om*/ * <p> * * @param element * @param parserContext * @param clazz * @return {@link BeanDefinition} */ private BeanDefinition parse(Element element, ParserContext parserContext, Class<?> clazz) { RootBeanDefinition beanDefinition = new RootBeanDefinition(); beanDefinition.setBeanClass(clazz); Method[] methods = clazz.getMethods(); String id = StringUtils.EMPTY; for (Method method : methods) { if (method.getName().length() > 3 && method.getName().startsWith("set") && method.getParameterTypes().length == 1) { String attribute = method.getName().substring(3); char ch = attribute.charAt(0); attribute = Character.toLowerCase(ch) + attribute.substring(1); String value = element.getAttribute(attribute); if (StringUtils.isNotEmpty(value)) { Type type = method.getParameterTypes()[0]; if (type == boolean.class) { beanDefinition.getPropertyValues().addPropertyValue(attribute, Boolean.valueOf(value)); } else { if ("ref".equals(attribute) && parserContext.getRegistry().containsBeanDefinition(value)) { beanDefinition.getPropertyValues().addPropertyValue(attribute, new RuntimeBeanReference(value)); } else { beanDefinition.getPropertyValues().addPropertyValue(attribute, value); if ("id".equals(attribute)) { id = value; } } } } } } parserContext.getRegistry().registerBeanDefinition(id, beanDefinition); return beanDefinition; }
From source file:de.hybris.platform.b2b.services.impl.DefaultB2BApproverServiceMockTest.java
@Test public void testGetAllApprovers() throws Exception { final B2BCustomerModel mockB2BCustomerModel = Mockito.mock(B2BCustomerModel.class); final B2BUnitModel mockB2BUnitModel = Mockito.mock(B2BUnitModel.class); final B2BUserGroupModel mockB2BUserGroupModel = Mockito.mock(B2BUserGroupModel.class); final PrincipalGroupModel mockPrincipalGroupModel = Mockito.mock(PrincipalGroupModel.class); when(mockB2BCustomerModel.getCustomerID()).thenReturn("customer123"); when(mockB2BUserGroupModel.getUid()).thenReturn(B2BConstants.B2BAPPROVERGROUP); when(mockB2BCustomerModel.getGroups()).thenReturn(Collections.singleton(mockPrincipalGroupModel)); when(b2bUnitService.getParent(mockB2BCustomerModel)).thenReturn(mockB2BUnitModel); when(mockB2BCustomerModel.getApprovers()).thenReturn(Collections.singleton(mockB2BCustomerModel)); when(mockB2BCustomerModel.getApproverGroups()).thenReturn(Collections.singleton(mockB2BUserGroupModel)); when(userService.getUserGroupForUID(B2BConstants.B2BAPPROVERGROUP)).thenReturn(mockB2BUserGroupModel); when(Boolean.valueOf(userService.isMemberOfGroup(mockB2BCustomerModel, mockB2BUserGroupModel))) .thenReturn(Boolean.TRUE); //Only return active approvers when(mockB2BCustomerModel.getActive()).thenReturn(Boolean.TRUE); final List<B2BCustomerModel> allApprovers = defaultB2BApproverService.getAllApprovers(mockB2BCustomerModel); Assert.assertNotNull(allApprovers);/*from ww w . j ava2 s. c om*/ Assert.assertTrue(CollectionUtils.isNotEmpty(allApprovers)); Assert.assertEquals(allApprovers.get(0).getCustomerID(), mockB2BCustomerModel.getCustomerID()); }
From source file:org.ameba.http.AbstractTenantAwareFilter.java
/** * {@inheritDoc}// w ww .jav a 2 s. c o m */ @Override protected final void doFilterInternal(HttpServletRequest r, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { String fromSC = (String) r.getServletContext().getAttribute(Constants.PARAM_MULTI_TENANCY_ENABLED); boolean multiTenancyEnabled = Boolean .valueOf(fromSC == null ? getFilterConfig().getInitParameter(Constants.PARAM_MULTI_TENANCY_ENABLED) : fromSC); String tenant = null; if (multiTenancyEnabled && !"OPTIONS".equalsIgnoreCase(r.getMethod())) { tenant = r.getHeader(Constants.HEADER_VALUE_TENANT) == null || r.getHeader(Constants.HEADER_VALUE_TENANT).isEmpty() ? r.getHeader(Constants.HEADER_VALUE_X_TENANT) : r.getHeader(Constants.HEADER_VALUE_TENANT); if (null == tenant || tenant.isEmpty()) { String throwParam = (String) r.getServletContext() .getAttribute(Constants.PARAM_MULTI_TENANCY_THROW_IF_NOT_PRESENT); boolean throwIfNotPresent = Boolean.valueOf(throwParam == null ? getFilterConfig().getInitParameter(Constants.PARAM_MULTI_TENANCY_THROW_IF_NOT_PRESENT) : throwParam); if (throwIfNotPresent) { response.setStatus(HttpStatus.BAD_REQUEST.value()); throw new IllegalArgumentException(String.format( "No tenant information available in http header. Expected header [%s/%s] attribute not present.", Constants.HEADER_VALUE_TENANT, Constants.HEADER_VALUE_X_TENANT)); } } else { doBefore(r, response, filterChain, tenant); } } try { filterChain.doFilter(r, response); } finally { doAfter(r, response, filterChain, tenant); } }
From source file:net.sf.jasperreports.engine.xml.JRAbstractStyleFactory.java
@Override public Object createObject(Attributes atts) { JRDesignStyle style = new JRDesignStyle(); // get style name style.setName(atts.getValue(JRXmlConstants.ATTRIBUTE_name)); String isDefault = atts.getValue(JRXmlConstants.ATTRIBUTE_isDefault); if (isDefault != null && isDefault.length() > 0) { style.setDefault(Boolean.valueOf(isDefault)); }//from www. jav a2 s .c o m // get parent style if (atts.getValue(JRXmlConstants.ATTRIBUTE_style) != null) { setParentStyle(style, atts.getValue(JRXmlConstants.ATTRIBUTE_style)); } // set common style attributes setCommonStyle(style, atts); return style; }