Example usage for com.liferay.portal.kernel.util PrefsPropsUtil getString

List of usage examples for com.liferay.portal.kernel.util PrefsPropsUtil getString

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util PrefsPropsUtil getString.

Prototype

public static String getString(String name, String defaultValue) 

Source Link

Usage

From source file:org.kisti.edison.science.service.impl.CommonLibLocalServiceImpl.java

License:Open Source License

public int countCommonLib(long companyId, String searchValue) throws SystemException {
    Map<String, Object> searchParam = new HashMap<String, Object>();
    searchParam.put("searchValue", searchValue);
    int cnt = commonLibFinder.countCommonLib(searchParam);

    if (cnt == 0) {
        String headNodeIp = PrefsPropsUtil.getString(companyId, EdisonPropsUtil.LIBRARY_SEARCH_IP);
        int headNodePort = PrefsPropsUtil.getInteger(companyId, EdisonPropsUtil.LIBRARY_SEARCH_PORT);
        String headNodeUserId = PrefsPropsUtil.getString(companyId, EdisonPropsUtil.LIBRARY_SEARCH_ID);
        String headNodePassword = PrefsPropsUtil.getString(companyId, EdisonPropsUtil.LIBRARY_SEARCH_PW);

        this.updateAllLibraries(headNodeIp, headNodePort, headNodeUserId, headNodePassword);

        cnt = commonLibFinder.countCommonLib(searchParam);
    }/*  w w  w.j  av a2s.  c  o  m*/
    return cnt;
}

From source file:org.kisti.edison.science.service.impl.ScienceAppLocalServiceImpl.java

License:Open Source License

public void addScienceAppFile(long companyId, String appName, String appVersion, String fileName,
        InputStream uploadedInputStream) throws SystemException {
    try {//from w w w  .j  a va2 s.co m
        String appBasePath = PrefsPropsUtil.getString(companyId, EdisonPropsUtil.SCIENCEAPP_BASE_PATH) + appName
                + File.separator + appVersion;
        String srcPath = appBasePath + File.separator + "src";
        String binPath = appBasePath + File.separator + "bin";
        this.saveToScienceAppStorage(srcPath, fileName, uploadedInputStream);

        this.unzipScienceAppZipFile(srcPath + File.separator + fileName, binPath);

    } catch (Exception e) {
        throw new SystemException(e);
    }
}

From source file:org.kisti.edison.service.impl.WorkflowLocalServiceImpl.java

License:Open Source License

public JsonNode createWorkflow(Workflow workflow, Map<String, Object> workflowParams,
        HttpServletRequest request) throws SystemException, PortalException, IOException {
    long companyId = PortalUtil.getCompanyId(request);
    Locale locale = PortalUtil.getLocale(request);
    String exec_path = PrefsPropsUtil.getString(companyId, EdisonPropsUtil.SCIENCEAPP_BASE_PATH);
    JSONObject screenLogic = JSONFactoryUtil.createJSONObject(workflow.getScreenLogic());
    JSONArray simulationJsonArray = screenLogic.getJSONArray("elements");
    User user = PortalUtil.getUser(request);
    MWorkflow mWorkflow = new MWorkflow();
    mWorkflow.setTitle(GetterUtil.getString(workflowParams.get("workflowInstanceTitle")));
    mWorkflow.setAccessToken(GetterUtil.getString(workflowParams.get("icebreakerVcToken")));
    mWorkflow.setUserId(user.getScreenName());
    mWorkflow.setSimulations(getSimulations(exec_path, locale, simulationJsonArray));
    return Transformer.pojo2Json(mWorkflow);
}

From source file:org.lsp.liferay.portlet.advertising.events.AdvertisingLandingPageAction.java

License:Open Source License

public void run(HttpServletRequest request, HttpServletResponse response) {

    long userId = PortalUtil.getUserId(request);
    long companyId = PortalUtil.getCompanyId(request);

    String path;//from  www .java2  s .  c  om
    try {
        path = PrefsPropsUtil.getString(companyId, PropsKeys.DEFAULT_LANDING_PAGE_PATH);

        if (_log.isDebugEnabled()) {
            _log.debug(PropsKeys.DEFAULT_LANDING_PAGE_PATH + StringPool.EQUAL + path);
        }

        long campaignIdToDisplay = CampaignLocalServiceUtil.getCampaignIdToDisplay(companyId, userId);

        _log.debug("Redirecting User to: " + path);
        LastPath lastPath = new LastPath(request.getContextPath(), path);
        if (_log.isDebugEnabled()) {
            _log.debug("lastPath = " + lastPath.toString());
        }
        HttpSession session = request.getSession();
        session.setAttribute(WebKeys.LAST_PATH, lastPath);

        if (campaignIdToDisplay > 0) {
            session.setAttribute(CampaignConstants.CAMPAIGN_HEADER,
                    CampaignLocalServiceUtil.getCampaign(campaignIdToDisplay).getJournalArticlePrimaryKey());
            CampaignLogLocalServiceUtil.markDisplayed(campaignIdToDisplay, userId);
        }

    } catch (SystemException e) {
        _log.error(e.getMessage(), e);
    } catch (PortalException e) {
        _log.error(e.getMessage(), e);
    }

}

From source file:org.oep.cmon.portlet.taocongdan.mail.ChangePassRequestMail.java

License:Apache License

/**
 * Send mail/*  w  ww .ja v  a 2s  .  com*/
 * @throws IOException 
 */
public void send(ActionRequest request) throws IOException {
    // Get Mail template content
    URL resource = this.getClass().getClassLoader().getResource(MAIL_TEMPLATE);
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
    MailContext context = new MailContext();

    // Bind value to value place holder

    context.setProperty("citizen_name", this.fullName);
    context.setProperty("citizen_matKhau", this.matKhau);
    context.setProperty("citizen_email", this.email);
    context.setProperty("url", this.url);
    context.setProperty("uri", this.uri);
    try {
        // Create mail content
        String mailContent = MailTemplateUtil.getContent("change_pass_confirmation_mail.template",
                resource.openStream(), context);

        // Get the file from class package structure
        URL configResource = this.getClass().getClassLoader().getResource(MAIL_CONFIG);

        Properties props = new Properties();

        BufferedReader file = new BufferedReader(new InputStreamReader(configResource.openStream(), "utf-8"));
        props.load(file);

        String mailSubject = props.getProperty("MAIL_SUBJECT_ACCOUNT_CONFIRMATION");
        //String fromAddress = props.getProperty("FROM_ADDRESS");
        //String fromPerson = props.getProperty("FROM_PERSON");

        String fromAddress = PrefsPropsUtil.getString(themeDisplay.getCompanyId(),
                PropsKeys.ADMIN_EMAIL_FROM_ADDRESS);
        String fromPerson = PrefsPropsUtil.getString(themeDisplay.getCompanyId(),
                PropsKeys.ADMIN_EMAIL_FROM_NAME);

        SendMailUtil.send(this.email, fromAddress, fromPerson, mailSubject, mailContent);

    } catch (Exception e) {

        // Sending mail failure should not stop the process flow

        // so this exception is swallowed and stack trace is printed out here

        e.printStackTrace();
    }
}

From source file:org.oep.cmon.user.portlet.business.EndorsementBs.java

License:Apache License

/**
 * This is function send email destroy registration
 * Version: 1.0/*w w  w .  jav a2s.  co m*/
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  3-March-2013  Nam Dinh    Create new
 * @param fullname
 * @param email
 * @param password
 * @param url
 * @param actionRequest
 * @throws IOException
 */
public void sendEmailHuyDK(String fullName, String email, String url, ActionRequest actionRequest)
        throws IOException {
    // Get Mail template content
    URL resource = this.getClass().getClassLoader().getResource(MAIL_TEMPLATE_HUY);
    MailContext context = new MailContext();
    context.setProperty("citizen_name", fullName);
    context.setProperty("url", url);
    try {
        String mailContent = MailTemplateUtil.getContent("user_cancel_mail_template", resource.openStream(),
                context);
        URL configResource = this.getClass().getClassLoader().getResource(MAIL_CONFIG_HUY);
        Properties props = new Properties();
        BufferedReader file = new BufferedReader(new InputStreamReader(configResource.openStream(), "utf-8"));
        props.load(file);

        String mailSubject = props.getProperty("MAIL_SUBJECT_USER_CREATION");
        //String fromAddress = props.getProperty("FROM_ADDRESS");
        //String fromPerson = props.getProperty("FROM_PERSON");
        ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
        String fromAddress = PrefsPropsUtil.getString(themeDisplay.getCompanyId(),
                PropsKeys.ADMIN_EMAIL_FROM_ADDRESS);
        //String fromPerson = props.getProperty("FROM_PERSON");
        String fromPerson = PrefsPropsUtil.getString(themeDisplay.getCompanyId(),
                PropsKeys.ADMIN_EMAIL_FROM_NAME);

        SendMailUtil.send(email, fromAddress, fromPerson, mailSubject, mailContent);

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.oep.cmon.user.portlet.mail.UserCreationMail.java

License:Apache License

/**
 * Send mail// w  w w  .  ja  va 2s . c om
 * @throws IOException 
 */
public void send(ActionRequest actionRequest) throws IOException {
    // Get Mail template content
    URL resource = this.getClass().getClassLoader().getResource(MAIL_TEMPLATE);

    MailContext context = new MailContext();

    // Bind value to value place holder

    context.setProperty("citizen_name", this.fullName);

    context.setProperty("user_name", this.userName);

    context.setProperty("user_password", this.password);
    context.setProperty("url", this.url);

    try {
        // Create mail content
        String mailContent = MailTemplateUtil.getContent("user_creation_mail_template", resource.openStream(),
                context);

        // Get the file from class package structure
        URL configResource = this.getClass().getClassLoader().getResource(MAIL_CONFIG);

        Properties props = new Properties();

        BufferedReader file = new BufferedReader(new InputStreamReader(configResource.openStream(), "utf-8"));
        props.load(file);

        String mailSubject = props.getProperty("MAIL_SUBJECT_USER_CREATION");
        //String fromAddress = props.getProperty("FROM_ADDRESS");
        //String fromPerson = props.getProperty("FROM_PERSON");

        ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
        String fromAddress = PrefsPropsUtil.getString(themeDisplay.getCompanyId(),
                PropsKeys.ADMIN_EMAIL_FROM_ADDRESS);
        //String fromPerson = props.getProperty("FROM_PERSON");
        String fromPerson = PrefsPropsUtil.getString(themeDisplay.getCompanyId(),
                PropsKeys.ADMIN_EMAIL_FROM_NAME);
        SendMailUtil.send(this.email, fromAddress, fromPerson, mailSubject, mailContent);

    } catch (Exception e) {

        // Sending mail failure should not stop the process flow

        // so this exception is swallowed and stack trace is printed out here

        e.printStackTrace();
    }
}

From source file:org.oep.cmon.userreg.portlet.mail.CitizenCreationRequestMail.java

License:Apache License

/**
 * This is function send email/*from  w w  w. j  a va  2s.co m*/
 * Version: 1.0
 *  
 * History: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  ------------------------------------------------- 
 *  3-March-2013  Nam Dinh    Create new
 * @throws toAddress
 * @throws request
 * @throws IOException
 */
public void send(String toAddress, ActionRequest request) throws IOException {
    // Get Mail template content
    ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
    URL resource = this.getClass().getClassLoader().getResource(MAIL_TEMPLATE);

    MailContext context = new MailContext();

    // Bind value to value place holder

    context.setProperty("citizen_name", this.fullName);

    context.setProperty("url", this.url);

    context.setProperty("uri", this.uri);

    try {
        // Create mail content
        String mailContent = MailTemplateUtil.getContent("citizen_confirmation_mail_template",
                resource.openStream(), context);
        // Get the file from class package structure
        URL configResource = this.getClass().getClassLoader().getResource(MAIL_CONFIG);

        Properties props = new Properties();

        BufferedReader file = new BufferedReader(new InputStreamReader(configResource.openStream(), "utf-8"));
        props.load(file);

        String mailSubject = props.getProperty("MAIL_SUBJECT_CITIZEN_CREATION");
        String fromAddress = PrefsPropsUtil.getString(themeDisplay.getCompanyId(),
                PropsKeys.ADMIN_EMAIL_FROM_ADDRESS);

        //String fromPerson = props.getProperty("FROM_PERSON");
        String fromPerson = PrefsPropsUtil.getString(themeDisplay.getCompanyId(),
                PropsKeys.ADMIN_EMAIL_FROM_NAME);
        //sendEmail(fromAddress, toAddress, mailSubject, mailContent, true);
        SendMailUtil.send(this.email, fromAddress, fromPerson, mailSubject, mailContent);

    } catch (Exception e) {

        // Sending mail failure should not stop the process flow

        // so this exception is swallowed and stack trace is printed out here

        e.printStackTrace();
    }
}

From source file:org.opencps.notificationmgt.utils.NotificationUtils.java

License:Open Source License

public static void sendEmailNotification(SendNotificationMessage message, String email, long dossierId,
        String userName) {/*from  w ww  .  j  a  v  a  2s.c  om*/

    String fromAddress = StringPool.BLANK;
    String fromName = StringPool.BLANK;
    String to = StringPool.BLANK;
    String subject = StringPool.BLANK;
    String body = StringPool.BLANK;
    boolean htmlFormat = true;

    Locale locale = new Locale("vi", "VN");

    try {

        Dossier dossier = new DossierImpl();

        if (dossierId > 0) {
            dossier = DossierLocalServiceUtil.getDossier(dossierId);
        }

        fromAddress = Validator.isNotNull(dossier)
                ? PrefsPropsUtil.getString(dossier.getCompanyId(), PropsKeys.ADMIN_EMAIL_FROM_ADDRESS)
                : StringPool.BLANK;
        fromName = PrefsPropsUtil.getString(dossier.getCompanyId(), PropsKeys.ADMIN_EMAIL_FROM_NAME);
        to = email;
        subject = PortletPropsValues.SUBJECT_TO_CUSTOMER;
        if (Validator.isNull(dossier.getReceptionNo())) {
            body = PortletPropsValues.CONTENT_TO_CUSTOMER_WITHOUT_RECEPTION_NO;
        } else {
            body = PortletPropsValues.CONTENT_TO_CUSTOMER;
        }
        subject = StringUtil.replace(subject, "[OpenCPS]", "[" + fromName + "]");

        body = StringUtil.replace(body, "[receiverUserName]", "[" + userName + "]");
        body = StringUtil.replace(body, "{OpenCPS}", fromName);
        body = StringUtil.replace(body, "{dossierId}", String.valueOf(message.getDossierId()));
        body = StringUtil.replace(body, "{receptionNo}", dossier.getReceptionNo());
        body = StringUtil.replace(body, "{event}", PortletProps.get(message.getNotificationEventName()));
        body = StringUtil.replace(body, "{message}", message.getNotificationContent());

        _log.info("fromAddress:" + fromAddress);
        _log.info("subject:" + subject);
        _log.info("to:" + to);

        SendMailUtils.sendEmail(fromAddress, fromName, to, StringPool.BLANK, subject, body, htmlFormat);
    } catch (Exception e) {
        _log.error(e);
    }
}

From source file:org.opencps.util.MessageBusUtil.java

License:Open Source License

public static void sendEmailAddressVerification(String uuid, User user, String emailAddress, String type,
        ServiceContext serviceContext) throws PortalException, SystemException {

    if (user.isEmailAddressVerified() && StringUtil.equalsIgnoreCase(emailAddress, user.getEmailAddress())) {

        return;/* w w  w .j  av a2s. c  o m*/
    }

    Ticket ticket = TicketLocalServiceUtil.addDistinctTicket(user.getCompanyId(), User.class.getName(),
            user.getUserId(), TicketConstants.TYPE_EMAIL_ADDRESS, emailAddress, null, serviceContext);

    String verifyEmailAddressURL = serviceContext.getPortalURL() + "/opencps-portlet/verify/email?token=" + uuid
            + "&ticketKey=" + ticket.getKey() + "&type=" + type;

    long plid = serviceContext.getPlid();

    if (plid > 0) {
        Layout layout = LayoutLocalServiceUtil.fetchLayout(plid);

        if (layout != null) {
            Group group = layout.getGroup();

            if (!layout.isPrivateLayout() && !group.isUser()) {
                verifyEmailAddressURL += "&p_l_id=" + serviceContext.getPlid();
            }
        }
    }

    String fromName = PrefsPropsUtil.getString(user.getCompanyId(), PropsKeys.ADMIN_EMAIL_FROM_NAME);
    String fromAddress = PrefsPropsUtil.getString(user.getCompanyId(), PropsKeys.ADMIN_EMAIL_FROM_ADDRESS);

    String toName = user.getFullName();
    String toAddress = emailAddress;

    String subject = PrefsPropsUtil.getContent(user.getCompanyId(), PropsKeys.ADMIN_EMAIL_VERIFICATION_SUBJECT);

    String body = PrefsPropsUtil.getContent(user.getCompanyId(), PropsKeys.ADMIN_EMAIL_VERIFICATION_BODY);

    SubscriptionSender subscriptionSender = new SubscriptionSender();

    subscriptionSender.setBody(body);
    subscriptionSender.setCompanyId(user.getCompanyId());
    subscriptionSender.setContextAttributes("[$EMAIL_VERIFICATION_CODE$]", ticket.getKey(),
            "[$EMAIL_VERIFICATION_URL$]", verifyEmailAddressURL, "[$REMOTE_ADDRESS$]",
            serviceContext.getRemoteAddr(), "[$REMOTE_HOST$]", serviceContext.getRemoteHost(), "[$USER_ID$]",
            user.getUserId(), "[$USER_SCREENNAME$]", user.getScreenName());
    subscriptionSender.setFrom(fromAddress, fromName);
    subscriptionSender.setHtmlFormat(true);
    subscriptionSender.setMailId("user", user.getUserId(), System.currentTimeMillis(),
            PwdGenerator.getPassword());
    subscriptionSender.setServiceContext(serviceContext);
    subscriptionSender.setSubject(subject);
    subscriptionSender.setUserId(user.getUserId());

    subscriptionSender.addRuntimeSubscribers(toAddress, toName);

    subscriptionSender.flushNotificationsAsync();
}