Example usage for java.util Collections EMPTY_LIST

List of usage examples for java.util Collections EMPTY_LIST

Introduction

In this page you can find the example usage for java.util Collections EMPTY_LIST.

Prototype

List EMPTY_LIST

To view the source code for java.util Collections EMPTY_LIST.

Click Source Link

Document

The empty list (immutable).

Usage

From source file:info.magnolia.jaas.sp.jcr.MagnoliaAuthenticationModule.java

protected void initUser() throws LoginException {
    if (logAdmin || !"admin".equals(name)) {
        log.debug("initializing user {}", name);
    }//www . j a v a 2s. c  o  m
    // we do not verify admin user, against our user base (which is in repo we are trying to access with this user), but we still check the password.
    // This user has assigned no privileges, just dummy near empty user object (with name and pwd only).
    if (isAdmin()) {
        Map<String, String> props = new HashMap<String, String>();
        //TODO: double check if we need to reset pwd here or if getAdminSession() is enough!!!
        props.put(MgnlUserManager.PROPERTY_PASSWORD, new String(Base64.encodeBase64("admin".getBytes())));
        MgnlUser user = new MgnlUser(name, null, Collections.EMPTY_LIST, Collections.EMPTY_LIST, props);
        this.user = user;
        // admin user is used by system and have no access to regular user stuff
        return;
    }

    long start = System.currentTimeMillis();
    this.user = getUserManager().getUser(name);
    if (logAdmin || !"admin".equals(name)) {
        log.debug("initialized user {} in {}ms", name, (System.currentTimeMillis() - start));
    }
}

From source file:com.wavemaker.tools.apidocs.tools.parser.impl.ReflectionModelParser.java

protected Map<String, Property> parsePropertiesUsingFields(Class<?> classToScan) {
    Map<String, Property> properties = new LinkedHashMap<>();
    Collection<Field> fields = Collections.EMPTY_LIST;
    try {/*  w  w w  .  jav a 2s. c om*/
        fields = ReflectionUtils.getFields(classToScan, NonStaticMemberPredicate.getInstance());
    } catch (Throwable th) {
        // XXX should throw? if we throw error entire swagger generation will get failed.
        // Here issues with class loader, like NoClassDefFoundError and ClassNotFound exception.
        LOGGER.error("Error while reading fields for class:{}", classToScan, th);
    }
    for (Field field : fields) {
        PropertyParser parser = new PropertyParserImpl(field.getGenericType());
        final Property property = parser.parse();
        property.setRequired(isRequired(field));
        properties.put(findFieldName(field), property);
    }
    return properties;
}

From source file:org.sipfoundry.sipxconfig.freeswitchcustomextensions.CustomFreeswitchExtensionsContextImpl.java

@Override
public List<Replicable> getReplicables() {
    if (m_featureManager.isFeatureEnabled(FEATURE)) {
        List<Replicable> replicables = new ArrayList<Replicable>();
        replicables.addAll(getFreeswitchExtensions());
        return replicables;
    }/*from  ww  w . j  a v a2 s  .c  om*/
    return Collections.EMPTY_LIST;
}

From source file:architecture.ee.web.community.social.facebook.FacebookServiceProvider.java

public java.util.List<Post> getHomeFeed(int offset, int limit) {
    Token accessToken = getAccessToken(getAccessToken(), "");
    OAuthRequest request = new OAuthRequest(Verb.GET, GRAPH_API_URL + "me/home");
    request.addBodyParameter("offset", String.valueOf(offset));
    request.addBodyParameter("limit", String.valueOf(limit));
    getOAuthService().signRequest(accessToken, request);
    Response response = request.send();

    List<Post> posts;/*from   www .j  a  va2s  . co m*/
    try {
        ObjectMapper mapper = getObjectMapper();
        JsonNode dataNode = mapper.readTree(response.getBody());
        JsonNode dataNode2 = dataNode.get("data");
        posts = new ArrayList<Post>();
        for (Iterator<JsonNode> iterator = dataNode2.iterator(); iterator.hasNext();) {
            JsonNode node = iterator.next();
            posts.add(deserializePost(mapper, null, Post.class, (ObjectNode) node));
        }
    } catch (Exception e) {
        return Collections.EMPTY_LIST;
    }

    return posts;
}

From source file:de.betterform.agent.web.WebProcessor.java

public void configure() throws XFormsException {
    initConfig();/*from   w w  w  . j  a va2s .  c  o  m*/
    Cookie[] cookies = request.getCookies();
    List<Cookie> cookiesList;

    if (cookies != null) {
        cookiesList = Arrays.asList(request.getCookies());
    } else {
        cookiesList = Collections.EMPTY_LIST;
    }

    WebUtil.storeCookies(cookiesList, this);
    WebUtil.setContextParams(request, httpSession, this, getKey());
    WebUtil.copyHttpHeaders(request, this);
    setLocale();
    configureUpload();
}

From source file:com.ultrapower.eoms.common.plugin.ecside.core.RetrievalUtils.java

static Collection retrieveNestedCollection(WebContext context, String collection, String scope)
        throws Exception {
    String split[] = StringUtils.split(collection, ".");
    Object obj = RetrievalUtils.retrieve(context, split[0], scope);
    String collectionToFind = StringUtils.substringAfter(collection, ".");
        //from  w w  w .j av  a2  s.co m
    Object value=null;
    try {
     // if (ExtremeUtils.isBeanPropertyReadable(bean, property)) {
     value = PropertyUtils.getProperty(obj, collectionToFind);
     obj = value;
     // }
  } catch (Exception e) {
     if (logger.isDebugEnabled()) {
        logger.debug("Could not find the property [" + collectionToFind
              + "]. Either the bean or property is null");
     }
  }
              
    if (!(obj instanceof Collection)) {
        if (logger.isDebugEnabled()) {
            logger.debug("The object is not of type Collection.");
        }

        return Collections.EMPTY_LIST;
    }

    return (Collection) obj;
}

From source file:com.redhat.rhn.frontend.action.errata.ErrataSearchAction.java

protected ActionForward doExecute(HttpServletRequest request, ActionMapping mapping, DynaActionForm form)
        throws MalformedURLException, XmlRpcFault {
    RequestContext ctx = new RequestContext(request);

    String search = form.getString(SEARCH_STR);

    String viewmode = form.getString(VIEW_MODE);
    Boolean fineGrained = (Boolean) form.get(FINE_GRAINED);

    List searchOptions = new ArrayList();
    // setup the option list for select box (view_mode).
    addOption(searchOptions, OPT_ALL_FIELDS, OPT_ALL_FIELDS);
    addOption(searchOptions, OPT_ADVISORY, OPT_ADVISORY);
    addOption(searchOptions, OPT_PKG_NAME, OPT_PKG_NAME);
    addOption(searchOptions, OPT_CVE, OPT_CVE);

    request.setAttribute(SEARCH_STR, search);
    request.setAttribute(VIEW_MODE, viewmode);
    request.setAttribute(SEARCH_OPT, searchOptions);
    request.setAttribute(FINE_GRAINED, fineGrained);

    // Process the dates, default the start date to yesterday
    // and end date to today.
    Calendar today = Calendar.getInstance();
    today.setTime(new Date());
    Calendar yesterday = Calendar.getInstance();
    yesterday.setTime(new Date());
    yesterday.add(Calendar.DAY_OF_YEAR, -1);

    DateRangePicker picker = new DateRangePicker(form, request, yesterday.getTime(), today.getTime(),
            DatePicker.YEAR_RANGE_NEGATIVE, "erratasearch.jsp.start_date", "erratasearch.jsp.end_date");
    DatePickerResults dates = null;/*from w ww .  ja  v a 2s.co m*/
    Boolean dateSearch = getOptionIssueDateSearch(request);

    /*
     * If search/viewmode aren't null, we need to search and set
     * pageList to the resulting DataResult.
     *
     * NOTE:  There is a special case when called from rhn/Search.do
     * (header search bar)
     * that we will be coming into this action and running the
     * performSearch on the first run through this action, i.e.
     * we'll never have been called with search being blank,
     * therefore normal setup of the form vars will not have happened.
     */
    if (!StringUtils.isBlank(search) || dateSearch) {
        // If doing a dateSearch use the DatePicker values from the
        // request params otherwise use the defaults.
        dates = picker.processDatePickers(dateSearch, true);
        if (LOG.isDebugEnabled()) {
            LOG.debug("search is NOT blank");
            LOG.debug("Issue Start Date = " + dates.getStart().getDate());
            LOG.debug("End Start Date = " + dates.getEnd().getDate());
        }
        List results = performSearch(request, ctx.getWebSession().getId(), search, viewmode, form);

        request.setAttribute(RequestContext.PAGE_LIST, results != null ? results : Collections.EMPTY_LIST);
    } else {
        // Reset info on date pickers
        dates = picker.processDatePickers(false, true);
        if (LOG.isDebugEnabled()) {
            LOG.debug("search is blank");
            LOG.debug("Issue Start Date = " + dates.getStart().getDate());
            LOG.debug("End Start Date = " + dates.getEnd().getDate());
        }
        request.setAttribute(RequestContext.PAGE_LIST, Collections.EMPTY_LIST);

    }
    ActionMessages dateErrors = dates.getErrors();
    addErrors(request, dateErrors);
    return mapping.findForward(RhnHelper.DEFAULT_FORWARD);
}

From source file:com.googlecode.jtiger.modules.ecside.core.RetrievalUtils.java

static Collection retrieveNestedCollection(WebContext context, String collection, String scope)
        throws Exception {
    String split[] = StringUtils.split(collection, ".");
    Object obj = RetrievalUtils.retrieve(context, split[0], scope);
    String collectionToFind = StringUtils.substringAfter(collection, ".");

    Object value = null;//from  ww w  . jav a2s.com
    try {
        // if (ExtremeUtils.isBeanPropertyReadable(bean, property)) {
        value = PropertyUtils.getProperty(obj, collectionToFind);
        obj = value;
        // }
    } catch (Exception e) {
        if (logger.isDebugEnabled()) {
            logger.debug("Could not find the property [" + collectionToFind
                    + "]. Either the bean or property is null");
        }
    }

    if (!(obj instanceof Collection)) {
        if (logger.isDebugEnabled()) {
            logger.debug("The object is not of type Collection.");
        }

        return Collections.EMPTY_LIST;
    }

    return (Collection) obj;
}

From source file:org.esco.portlet.changeetab.service.impl.BasicUserInfoService.java

/**
 * Retrieve the user info attribute from portlet context, or the Mocked user info
 * if the system property testEnv = true.
 *
 * @param request the portlet request// w ww .j  ava2 s  . c o m
 * @param atributeName the attribute to retrieve
 * @return the user info attribute values
 */
@SuppressWarnings("unchecked")
public List<String> getUserInfo(final PortletRequest request, final String attributeName) {
    Map<String, List<String>> userInfo = (Map<String, List<String>>) request
            .getAttribute("org.jasig.portlet.USER_INFO_MULTIVALUED");

    if ((userInfo == null) && "true".equals(System.getProperty("testEnv"))) {
        userInfo = this.testUserInfoMap;
    }

    List<String> attributeValues = null;

    if (userInfo != null) {
        attributeValues = userInfo.get(attributeName);
    } else {
        BasicUserInfoService.LOG.error("Unable to retrieve Portal UserInfo !");
        //throw new IllegalStateException("Unable to retrieve Portal UserInfo !");
    }

    if (attributeValues == null) {
        attributeValues = Collections.EMPTY_LIST;
    }

    return attributeValues;
}

From source file:eu.ggnet.dwoss.redtape.position.PositionUpdateCask.java

@Override
public void accept(Position position) {
    if (position == null)
        return;//from ww  w  . j  a va  2  s.com

    PostLedger postLedger = lookup(MandatorSupporter.class).loadPostLedger();
    List bookingAccounts = new ArrayList();
    bookingAccounts.add(postLedger.get(position.getType()).orElse(-1));
    bookingAccounts.addAll(postLedger.getPossible(position.getType()).orElse(Collections.EMPTY_LIST));
    bookingAccountBox.setModel(new DefaultComboBoxModel(bookingAccounts.toArray()));

    this.position = position;
    this.setPositionName(position.getName());
    this.setPrice(position.getPrice());
    this.setDescription(position.getDescription());
    this.setAmount(position.getAmount());
    this.setPreDecimal((int) (position.getAmount() - (position.getAmount() % 1)));
    this.setPostDecimal((int) ((position.getAmount() % 1) * 100));
    this.setBookingAccount(position.getBookingAccount());

    System.out.println("Pre: " + this.getPreDecimal());
    System.out.println("Post: " + this.getPostDecimal());

    this.accessCos = lookup(Guardian.class);

    if (position.getDocument() != null && EnumSet.of(DocumentType.ANNULATION_INVOICE, DocumentType.CREDIT_MEMO)
            .contains(position.getDocument().getType())) {
        disableComponents(preDecimalSpinner, postDecimalSpinner, nameArea, bookingAccountBox, priceField,
                afterTaxPriceField, descriptionArea);
        accessCos.add(priceSumField, UPDATE_POSITION_WITH_EXISTING_DOCUMENT);
        accessCos.add(afterTaxSumField, UPDATE_POSITION_WITH_EXISTING_DOCUMENT);
        accessCos.add(priceField, UPDATE_POSITION_WITH_EXISTING_DOCUMENT);
        accessCos.add(afterTaxPriceField, UPDATE_POSITION_WITH_EXISTING_DOCUMENT);
    } else {
        if (position.getType() == PRODUCT_BATCH || position.getType() == UNIT) {
            disableComponents(postDecimalSpinner);
            accessCos.add(priceField, UPDATE_PRICE_OF_UNITS_AND_PRODUCT_BATCH);
            accessCos.add(afterTaxPriceField, UPDATE_PRICE_OF_UNITS_AND_PRODUCT_BATCH);
        }
        if (position.getType() == UNIT) {
            disableComponents(preDecimalSpinner);
            bookingAccountBox.setEnabled(true);
        }
        if (position.getType() == COMMENT) {
            disableComponents(priceField, priceSumField, afterTaxPriceField, afterTaxSumField,
                    preDecimalSpinner, postDecimalSpinner);
        }
        if (position.getType() == SHIPPING_COST) {
            disableComponents(nameArea, afterTaxPriceField, afterTaxSumField, preDecimalSpinner,
                    postDecimalSpinner);
        }

        if (EnumSet.of(COMMENT, SERVICE, PRODUCT_BATCH).contains(position.getType())) {
            nameArea.setEditable(true);
            if (position.getType() == SERVICE)
                bookingAccountBox.setEnabled(true);
        }
    }
}