Example usage for com.liferay.portal.kernel.language LanguageUtil get

List of usage examples for com.liferay.portal.kernel.language LanguageUtil get

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.language LanguageUtil get.

Prototype

public static String get(ResourceBundle resourceBundle, String key) 

Source Link

Usage

From source file:de.fhg.fokus.odp.portal.managedatasets.controller.ManageController.java

License:Open Source License

private void add2licences(PortletRequest request, List<Licence> tempDatenlizenzDeutschlandLicences,
        List<Licence> tempEINGESCHRAENKTLicences, Licence licence) {
    if (!licence.isOpen()
            && !licence.getTitle().equals(LanguageUtil.get(request.getLocale(), "od.licence.select"))) {
        licence.setTitle(LanguageUtil.get(request.getLocale(), "od.restricted").toUpperCase(request.getLocale())
                + " - " + licence.getTitle());
        tempEINGESCHRAENKTLicences.add(licence);
    } else if (licence.getTitle().matches("(.*)Datenlizenz Deutschland(.*)")) {
        tempDatenlizenzDeutschlandLicences.add(licence);
    } else/*from   ww w .  j a  v  a 2  s  . c  om*/
        licences.add(licence);
}

From source file:de.fhg.fokus.odp.portal.managedatasets.controller.ManageController.java

License:Open Source License

public void changeSelectedCategories(AjaxBehaviorEvent vcEvent) {
    selectedManyCategories = selectedCategories;

    // get some global objects
    LiferayFacesContext lfc = LiferayFacesContext.getInstance();
    // ThemeDisplay tD = lfc.getThemeDisplay();
    PortletRequest request = (PortletRequest) lfc.getExternalContext().getRequest();

    int maxCats;//from w  ww.j a  v a 2  s  . c  o  m
    String maxCatsStr = PropsUtil.get(PROP_CATEGORY_MAX_CHOOSE_WARN);
    try {
        maxCats = Integer.parseInt(maxCatsStr);
    } catch (NumberFormatException e) {
        maxCats = 3;
    }
    // log.info("changeSelectedCategories:maxCats==" + maxCats);
    String details = LanguageUtil.get(request.getLocale(), "od.category.reference.toomuch.warn.details");
    String summary = LanguageUtil.get(request.getLocale(), "od.category.reference.toomuch.warn.summary");
    if (selectedManyCategories.size() > maxCats) {
        FacesContext.getCurrentInstance().addMessage("categorymessageskey",
                new FacesMessage(FacesMessage.SEVERITY_WARN, summary, details));
    } else {
        Iterator<FacesMessage> msgIterator = FacesContext.getCurrentInstance().getMessages();
        while (msgIterator.hasNext()) {
            msgIterator.next();
            msgIterator.remove();
        }
    }

}

From source file:de.fhg.fokus.odp.portal.managedatasets.controller.MetaDataController.java

/**
 * Gets the heading./*from   w  ww.  j  av a2 s. co  m*/
 * 
 * @param value
 *            the value
 * @param request
 *            the request
 * @return the heading
 */
@ModelAttribute(value = "heading")
public String getHeading(@RequestParam(required = false, value = "ocAction") String value,
        PortletRequest request) {

    String heading = LanguageUtil.get(request.getLocale(), "oc_create_metadata");

    if (value != null && value.equals("editMetaDataRender")) {
        heading = LanguageUtil.get(request.getLocale(), "oc_edit_metadata");
    } else if (value != null && value.equals("editLinkedMetaDataRender")) {
        heading = LanguageUtil.get(request.getLocale(), "oc_edit_linked_metadata");
    } else if (value != null && value.equals("createLinkedMetaDataRender")) {
        heading = LanguageUtil.get(request.getLocale(), "oc_create_linked_metadata");
    }

    return heading;
}

From source file:de.fhg.fokus.odp.portal.managedatasets.utils.HtmlComponentUtils.java

License:Creative Commons License

/**
 * Creates the categories./*from  ww w.  j  ava 2  s. c  o m*/
 * 
 * @param request
 *            the request
 * @return the list
 */
public static List<ValueLabelEntry> createCategories(PortletRequest request) {

    List<ValueLabelEntry> entries = new ArrayList<ValueLabelEntry>();
    entries.add(
            new ValueLabelEntry("rec", LanguageUtil.get(request.getLocale(), "oc_category-art-recreation")));
    entries.add(new ValueLabelEntry("business",
            LanguageUtil.get(request.getLocale(), "oc_category-business-enterprise")));
    entries.add(
            new ValueLabelEntry("budget", LanguageUtil.get(request.getLocale(), "oc_category-city-budget")));
    entries.add(new ValueLabelEntry("stats",
            LanguageUtil.get(request.getLocale(), "oc_category-city-portal-statistic")));
    entries.add(new ValueLabelEntry("housing",
            LanguageUtil.get(request.getLocale(), "oc_category-construction-housing")));
    entries.add(
            new ValueLabelEntry("safety", LanguageUtil.get(request.getLocale(), "oc_category-crime-safety")));
    entries.add(new ValueLabelEntry("demographics",
            LanguageUtil.get(request.getLocale(), "oc_category-demographics")));
    entries.add(new ValueLabelEntry("edu", LanguageUtil.get(request.getLocale(), "oc_category-education")));
    entries.add(
            new ValueLabelEntry("elections", LanguageUtil.get(request.getLocale(), "oc_category-elections")));
    entries.add(new ValueLabelEntry("emergency",
            LanguageUtil.get(request.getLocale(), "oc_category-emergency-services")));
    entries.add(new ValueLabelEntry("energy",
            LanguageUtil.get(request.getLocale(), "oc_category-energy-utilities")));
    entries.add(new ValueLabelEntry("environment",
            LanguageUtil.get(request.getLocale(), "oc_category-environment-geography")));
    entries.add(new ValueLabelEntry("health",
            LanguageUtil.get(request.getLocale(), "oc_category-health-disability")));
    entries.add(
            new ValueLabelEntry("employment", LanguageUtil.get(request.getLocale(), "oc_category-employment")));
    entries.add(new ValueLabelEntry("law", LanguageUtil.get(request.getLocale(), "oc_category-law")));
    entries.add(
            new ValueLabelEntry("politics", LanguageUtil.get(request.getLocale(), "oc_category-political")));
    entries.add(new ValueLabelEntry("tourism", LanguageUtil.get(request.getLocale(), "oc_category-tourism")));
    entries.add(new ValueLabelEntry("transport",
            LanguageUtil.get(request.getLocale(), "oc_category-urban-transport")));
    entries.add(new ValueLabelEntry("misc", LanguageUtil.get(request.getLocale(), "oc_category-misc")));
    return entries;
}

From source file:de.fhg.fokus.odp.portal.managedatasets.utils.MailUtils.java

License:Open Source License

/**
 * Send mail./* w ww  .ja v  a2s.  c o  m*/
 * 
 * @throws MessagingException
 *             the messaging exception
 * @throws SystemException
 * @throws PortalException
 */
public static void sendMail(Metadata metadata) throws PortalException, SystemException, MessagingException {

    // get some global objects
    LiferayFacesContext lfc = LiferayFacesContext.getInstance();
    ThemeDisplay tD = lfc.getThemeDisplay();
    PortletRequest request = (PortletRequest) lfc.getExternalContext().getRequest();

    // get the email subject and body
    String subject = LanguageUtil.get(request.getLocale(), "od.app.announced.email.subject");
    String body = MessageFormat.format(LanguageUtil.get(request.getLocale(), "od.app.announced.email.body"),
            tD.getUser().getLogin(), metadata.getTitle(), metadata.getName());

    // get the from address
    String fromStr = PortalUtil.getPortalProperties().getProperty("admin.email.from.address");
    if (fromStr == null || fromStr.matches("^\\s*$")) {
        try {
            fromStr = PrefsPropsUtil.getString(tD.getCompanyId(), "admin.email.from.address");
        } catch (SystemException e) {
            LOG.error(e.getMessage());
            return;
        }
    }

    // check if an address can be send out
    if (fromStr == null || fromStr.matches("^\\s*%")) {
        LOG.error("No from email address found");
        return;
    }
    InternetAddress from = new InternetAddress(fromStr);

    // prepare the properties and session
    Properties props = new Properties();

    String smtpHost = PropsUtil.get("mail.session.mail.smtp.host");
    if (smtpHost == null || smtpHost.matches("^\\s*$")) {
        LOG.error("No smtp host specified");
        return;
    }

    props.put("mail.smtp.host", smtpHost);
    String port = PropsUtil.get("mail.session.mail.smtp.port");
    if (port != null && !port.matches("^\\s*$")) {
        props.put("mail.smtp.port", port);
    }

    Session session = Session.getDefaultInstance(props);

    // start with building up the message
    Message msg = new MimeMessage(session);

    // add BCC for observing comments
    msg.addRecipient(Message.RecipientType.TO, new InternetAddress(PropsUtil.get("mail.comment.cc.address")));

    msg.setContent(body, "text/plain");
    msg.setFrom(from);
    msg.setSubject(subject);
    Transport.send(msg);
}

From source file:de.fhg.fokus.odp.portal.managedatasets.validator.AgsValidator.java

License:Open Source License

@Override
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {

    if (value != null && !((String) value).isEmpty() && !((String) value).matches("^[0-9 ]*$")) {
        LiferayFacesContext lfc = LiferayFacesContext.getInstance();
        PortletRequest request = (PortletRequest) lfc.getExternalContext().getRequest();

        FacesMessage msg = new FacesMessage(LanguageUtil.get(request.getLocale(), "od.ags.invalid.error"),
                LanguageUtil.get(request.getLocale(), "od.ags.invalid.error"));
        msg.setSeverity(FacesMessage.SEVERITY_ERROR);
        throw new ValidatorException(msg);

    }/*from w ww.  ja v a  2  s. c o  m*/
}

From source file:de.fhg.fokus.odp.portal.managedatasets.validator.DateTemporalCoverageValidator.java

License:Open Source License

@Override
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {

    LiferayFacesContext lfc = LiferayFacesContext.getInstance();
    PortletRequest request = (PortletRequest) lfc.getExternalContext().getRequest();

    SimpleDateFormat sdf = new SimpleDateFormat(ManageController.DATE_PATTERN);

    UIInput startInput = (UIInput) component.getAttributes().get("temporal_coverage_from");
    UIInput endInput = (UIInput) component.getAttributes().get("temporal_coverage_to");

    try {/* w  w w  .jav  a 2 s  . c o m*/

        if (startInput != null && endInput != null) {

            Date startDate = sdf.parse((String) startInput.getSubmittedValue());
            Date endDate = sdf.parse((String) endInput.getSubmittedValue());

            if (!startDate.before(endDate)) {

                FacesMessage msg = new FacesMessage(
                        LanguageUtil.get(request.getLocale(), "od.date.temporal.relation.error"),
                        LanguageUtil.get(request.getLocale(), "od.date.temporal.relation.error"));
                msg.setSeverity(FacesMessage.SEVERITY_ERROR);
                throw new ValidatorException(msg);
            }
        }

    } catch (ParseException e) {
        FacesMessage msg = new FacesMessage(LanguageUtil.get(request.getLocale(), "od.date.invalid"),
                LanguageUtil.get(request.getLocale(), "od.date.invalid"));
        msg.setSeverity(FacesMessage.SEVERITY_ERROR);
        throw new ValidatorException(msg);
    }

}

From source file:de.fhg.fokus.odp.portal.managedatasets.validator.EmailOrURLValidator.java

License:Open Source License

private void throwValidatorException() {
    LiferayFacesContext lfc = LiferayFacesContext.getInstance();
    PortletRequest request = (PortletRequest) lfc.getExternalContext().getRequest();

    FacesMessage msg = new FacesMessage(LanguageUtil.get(request.getLocale(), "od.urloremail.invalid.error"),
            LanguageUtil.get(request.getLocale(), "od.urloremail.invalid.error"));
    msg.setSeverity(FacesMessage.SEVERITY_ERROR);
    throw new ValidatorException(msg);
}

From source file:de.fhg.fokus.odp.portal.managedatasets.validator.JsonGeoPolygonValidator.java

License:Open Source License

private void throwPolygonError(PortletRequest request, String type) {
    FacesMessage msg = new FacesMessage(
            LanguageUtil.get(request.getLocale(), "od.spatial" + type + "invalid.error"),
            LanguageUtil.get(request.getLocale(), "od.spatial" + type + "invalid.error"));
    msg.setSeverity(FacesMessage.SEVERITY_ERROR);
    throw new ValidatorException(msg);

}

From source file:de.fhg.fokus.odp.portal.managedatasets.validator.LicenceValidator.java

License:Open Source License

@Override
public void validate(FacesContext arg0, UIComponent arg1, Object arg2) throws ValidatorException {

    String licence = (String) arg2;

    if (licence.contains("de.fhg.fokus.odp.registry.ckan.impl.LicenceImpl")) {
        LiferayFacesContext lfc = LiferayFacesContext.getInstance();
        PortletRequest request = (PortletRequest) lfc.getExternalContext().getRequest();

        FacesMessage msg = new FacesMessage(LanguageUtil.get(request.getLocale(), "od.validation_required"),
                LanguageUtil.get(request.getLocale(), "od.validation_required"));
        msg.setSeverity(FacesMessage.SEVERITY_ERROR);
        throw new ValidatorException(msg);
    }//from   w  ww. j  a v  a  2 s  .  co m

}