Example usage for org.springframework.util StringUtils arrayToCommaDelimitedString

List of usage examples for org.springframework.util StringUtils arrayToCommaDelimitedString

Introduction

In this page you can find the example usage for org.springframework.util StringUtils arrayToCommaDelimitedString.

Prototype

public static String arrayToCommaDelimitedString(@Nullable Object[] arr) 

Source Link

Document

Convert a String array into a comma delimited String (i.e., CSV).

Usage

From source file:com.consol.citrus.selenium.action.PageAction.java

private Method getMethod(Class<T> pageClass, Class<?>[] methodTypes) throws IllegalArgumentException,
        InvocationTargetException, IllegalAccessException, CitrusRuntimeException {
    Method methodToRun = ReflectionUtils.findMethod(pageClass, pageAction, methodTypes);

    if (methodToRun == null) {
        throw new CitrusRuntimeException("Unable to find method '" + pageAction + "("
                + StringUtils.arrayToCommaDelimitedString(methodTypes) + ")' for class '" + pageClass + "'");
    }/*from   ww  w.j a  va 2  s  .  c om*/
    return methodToRun;
}

From source file:eu.trentorise.smartcampus.aac.AACService.java

private String generateAuthorizationURI(String redirectUri, String authority, String scope, String state,
        String[] loginAuthorities) {
    String s = aacURL + AUTH_PATH;
    if (authority != null && !authority.trim().isEmpty()) {
        s += authority;/*from w  w w. ja v a  2s .  c o  m*/
    }
    s += "?client_id=" + clientId + "&response_type=code&redirect_uri=" + redirectUri;
    if (scope != null && !scope.trim().isEmpty()) {
        s += "&scope=" + scope;
    }
    if (state != null && !state.trim().isEmpty()) {
        s += "&state=" + state;
    }
    if (loginAuthorities != null) {
        s += "&authorities=" + StringUtils.arrayToCommaDelimitedString(loginAuthorities);
    }
    return s;
}

From source file:org.openxdata.server.dao.hibernate.HibernateEditableDAO.java

@SuppressWarnings("unchecked")
@Override/*from  w  ww  .ja  v  a2  s.  c o  m*/
@Secured("Perm_View_Form_Data")
public List<Object[]> getResponseData(String formBinding, String[] questionBindings, int offset, int limit,
        String sortField, boolean ascending) {
    StringBuilder sql = new StringBuilder();
    sql.append("select openxdata_form_data_id,");
    sql.append(StringUtils.arrayToCommaDelimitedString(questionBindings));
    sql.append(" from ");
    sql.append(formBinding);
    if (sortField != null && !sortField.trim().equals("")) {
        sql.append(" order by ");
        sql.append(sortField);
        if (!ascending)
            sql.append(" DESC");
    }
    log.debug("executing sql: " + sql + " firstResult=" + offset + " maxResults=" + limit);
    // execute + limit results for page
    SQLQuery query = getSession().createSQLQuery(sql.toString());
    query.setFirstResult(offset);
    query.setFetchSize(limit);
    query.setMaxResults(limit);
    List<Object[]> data = (List<Object[]>) query.list();
    return data;
}

From source file:csns.util.EmailUtils.java

public boolean sendTextMail(Email email) {
    SimpleMailMessage message = new SimpleMailMessage();
    message.setSubject(email.getSubject());
    message.setText(getText(email));/*from w w w . j  a  v  a2  s.c o  m*/
    message.setFrom(email.getAuthor().getPrimaryEmail());
    message.setCc(email.getAuthor().getPrimaryEmail());
    String addresses[] = getAddresses(email.getRecipients(), email.isUseSecondaryEmail())
            .toArray(new String[0]);
    if (addresses.length > 1) {
        message.setTo(appEmail);
        message.setBcc(addresses);
    } else
        message.setTo(addresses);

    mailSender.send(message);

    logger.info(email.getAuthor().getUsername() + " sent email to "
            + StringUtils.arrayToCommaDelimitedString(addresses));

    return true;
}

From source file:com.berwickheights.spring.utils.CustomTilesConfigurer.java

/**
 * Set the Tiles definitions, i.e. the list of files containing the definitions.
 * Default is "/WEB-INF/tiles.xml"./*w w  w  .j a  va 2 s .  c  o m*/
 */
public void setDefinitions(String[] definitions) {
    if (definitions != null) {
        String defs = StringUtils.arrayToCommaDelimitedString(definitions);
        if (logger.isInfoEnabled()) {
            logger.info("TilesConfigurer: adding definitions [" + defs + "]");
        }
        this.tilesPropertyMap.put(DefinitionsFactory.DEFINITIONS_CONFIG, defs);
    }
}

From source file:org.jasig.springframework.web.portlet.context.PortletContextLoaderTests.java

@Test
public void testContextLoaderListenerWithRegisteredContextInitializer() {
    MockServletContext sc = new MockServletContext("");
    sc.addInitParameter(PortletContextLoader.CONFIG_LOCATION_PARAM,
            "org/springframework/web/context/WEB-INF/ContextLoaderTests-acc-context.xml");
    sc.addInitParameter(PortletContextLoader.CONTEXT_INITIALIZER_CLASSES_PARAM,
            StringUtils.arrayToCommaDelimitedString(new Object[] { TestContextInitializer.class.getName(),
                    TestWebContextInitializer.class.getName() }));
    PortletContextLoaderListener listener = new PortletContextLoaderListener();
    listener.contextInitialized(new ServletContextEvent(sc));

    //initialize the portlet application context, needed because PortletContextLoaderListener.contextInitialized doesn't actually create
    //the portlet app context due to lack of PortletContext reference
    MockPortletContext pc = new MockPortletContext(sc);
    PortletApplicationContextUtils2.getPortletApplicationContext(pc);

    PortletApplicationContext pac = PortletContextLoader.getCurrentPortletApplicationContext();
    TestBean testBean = pac.getBean(TestBean.class);
    assertThat(testBean.getName(), equalTo("testName"));
    //        assertThat(pac.getServletContext().getAttribute("initialized"), notNullValue());
    assertThat(pac.getPortletContext().getAttribute("initialized"), notNullValue());
}

From source file:com.apporiented.hermesftp.cmd.impl.FtpCmdAuth.java

private SSLSocket createSslSocket() throws IOException {
    String clientHost = getCtx().getClientSocket().getInetAddress().getHostAddress();
    SSLContext sslContext = getCtx().getOptions().getSslContext();
    SSLSocketFactory factory = sslContext.getSocketFactory();
    SSLSocket sslSocket = (SSLSocket) factory.createSocket(getCtx().getClientSocket(), clientHost,
            getCtx().getOptions().getFtpPort(), true);
    sslSocket.setUseClientMode(false);/*from   w w  w .  ja  v  a2s  . c  o  m*/
    sslSocket.addHandshakeCompletedListener(this);
    enableCipherSuites(sslSocket);
    log.info("Enabled cipher suites (explicit SSL): "
            + StringUtils.arrayToCommaDelimitedString(sslSocket.getEnabledCipherSuites()));
    return sslSocket;
}

From source file:org.zilverline.web.SearchController.java

/**
 * Callback function that processes the form submission. It searches over all provided collections, and returns Results into
 * model./*from www  . ja va 2  s . com*/
 * 
 * @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest,
 *      javax.servlet.http.HttpServletResponse, java.lang.Object, org.springframework.validation.BindException)
 */
public ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command,
        BindException errors) throws ServletException {
    SearchForm theForm = (SearchForm) command;
    String queryString = theForm.getQuery();
    int maxResults = theForm.getMaxResults();
    int startAt = theForm.getStartAt() - 1;
    try {
        CollectionTriple[] collections = theForm.getCollections();
        // get the names of selected collections
        String[] selectedNames = new String[] {};
        if (collections != null) {
            List selectedCollectionsList = new ArrayList();
            log.debug("Form mapped via CustomCollectionEditor with collections: " + collections + " of length "
                    + collections.length);
            for (int i = 0; i < collections.length; i++) {
                if (collections[i].isSelected()) {
                    selectedCollectionsList.add(collections[i].getName());
                }
                log.debug(collections[i].getName() + ", " + collections[i].getId() + ", "
                        + collections[i].isSelected());
            }
            selectedNames = (String[]) selectedCollectionsList.toArray(selectedNames);
        } else {
            setAllCollectionsSelected(theForm);
        }

        log.debug("Form called for collections '" + StringUtils.arrayToCommaDelimitedString(selectedNames)
                + "', with query '" + queryString + "', with maxResults '" + maxResults + "', starting at "
                + startAt);
        SearchResult result = new SearchResult(null, maxResults, startAt, startAt + maxResults);
        try {
            result = service.doSearch(selectedNames, queryString, startAt, maxResults);
        } catch (SearchException e) {
            log.error("Error executing query '" + queryString + "', " + e);
            errors.rejectValue("query", "errors.invalidquery", null, e.getLocalizedMessage());
        }
        // TODO SearchResult could be a map
        Map model = new HashMap();
        model.put("results", result.getResults());
        model.put("hits", new Integer(result.getNumberOfHits()));
        model.put("startAt", new Integer(result.getStartAt()));
        model.put("endAt", new Integer(result.getEndAt()));

        // create a ModelAndView that submits to original view
        // keeping the command, adding the model
        log.debug("returning to view: " + getSuccessView() + " with " + result.getNumberOfHits() + " hits");

        return showForm(request, errors, getSuccessView(), model);
    } catch (Exception e) {
        log.error("Error executing query '" + queryString + "', " + e);
        throw new ServletException("Error executing query '" + queryString + "'", e);
    }
}

From source file:csns.util.EmailUtils.java

public boolean sendHtmlMail(Email email) {
    MimeMessage message = mailSender.createMimeMessage();
    MimeMessageHelper helper = new MimeMessageHelper(message);

    try {/* ww  w .  jav a 2s.  c  om*/
        message.setContent(getHtml(email), "text/html");

        helper.setSubject(email.getSubject());
        helper.setFrom(email.getAuthor().getPrimaryEmail());
        helper.setCc(email.getAuthor().getPrimaryEmail());
        String addresses[] = getAddresses(email.getRecipients(), email.isUseSecondaryEmail())
                .toArray(new String[0]);
        if (addresses.length > 1) {
            helper.setTo(appEmail);
            helper.setBcc(addresses);
        } else
            helper.setTo(addresses);

        mailSender.send(message);

        logger.info(email.getAuthor().getUsername() + " sent email to "
                + StringUtils.arrayToCommaDelimitedString(addresses));

        return true;
    } catch (MessagingException e) {
        logger.warn("Fail to send MIME message", e);
    }

    return false;
}

From source file:net.solarnetwork.node.backup.FileBackupResourceProvider.java

/**
 * Get a comma-delimited string of the configured
 * {@code resourceDirectories} property.
 * /* w  ww.j a va  2s. c  o m*/
 * @return a comma-delimited list of paths
 */
public String getResourceDirs() {
    return StringUtils.arrayToCommaDelimitedString(getResourceDirectories());
}