Java 类com.liferay.portal.kernel.util.PropsKeys 实例源码

项目:OEPv2    文件:ManagerLdap.java   
public String getNameInNamespace(long companyId, Binding binding)
        throws Exception {

    String baseDN = PrefsPropsUtil.getString(companyId,
            PropsKeys.LDAP_BASE_DN);

    if (Validator.isNull(baseDN)) {
        return binding.getName();
    } else {
        StringBuilder sb = new StringBuilder();

        sb.append(binding.getName());
        sb.append(StringPool.COMMA);
        sb.append(baseDN);

        return sb.toString();
    }
}
项目:govapps    文件:MailUtil.java   
public static void sendInternal(String subject, String body, boolean isHtml)
        throws SystemException, AddressException, PortalException {

    Company cmp = null;
    try {
      cmp = CompanyServiceUtil.getCompanyByVirtualHost(AppConstants.COMPANY_VIRTUAL_HOST);
    } catch (Throwable t) {

    }
    if (cmp != null) {
        long cmpId = cmp.getCompanyId();
        String toStr = PrefsPropsUtil.getString(cmpId,
                PropsKeys.ADMIN_EMAIL_FROM_ADDRESS);
        send(toStr, subject, body, isHtml);
    }
}
项目:govapps    文件:MailUtil.java   
public static void send(String toStr, String subject,
        String body, boolean isHtml) throws SystemException, AddressException, PortalException {

    Company cmp = null;
    try {
      cmp = CompanyServiceUtil.getCompanyByVirtualHost(AppConstants.COMPANY_VIRTUAL_HOST);
    } catch (Throwable t) {

    }
    if (cmp != null) {
        long cmpId = cmp.getCompanyId();
        String fromStr = PrefsPropsUtil.getString(cmpId,
                PropsKeys.ADMIN_EMAIL_FROM_ADDRESS);
        InternetAddress from = new InternetAddress(fromStr);
        InternetAddress to = new InternetAddress(toStr);
        if (from != null && to != null && subject != null && body != null) {
            MailMessage message = new MailMessage(from, to, subject, body, isHtml);
            MailServiceUtil.sendEmail(message);
        }
    }

}
项目:particity    文件:MessageComposer.java   
/**
 * Refresh cfg.
 */
public void refreshCfg() {
    try {
        this.m_strPortalName = CustomPortalServiceHandler
                .getConfigValue(E_ConfigKey.MGMT_CONTACT_NAME);
        this.m_strOfferPermaBase = CustomPortalServiceHandler
                .getConfigValue(E_ConfigKey.MGMT_PATH_OFFER_PERMALINK);
        this.m_objDefCompany = CompanyLocalServiceUtil
                .getCompany(PortalUtil
                        .getDefaultCompanyId());
        if (this.m_objDefCompany == null)
            this.m_objDefCompany = CompanyLocalServiceUtil.getCompanyByMx(PropsUtil.get(PropsKeys.COMPANY_DEFAULT_WEB_ID));
        this.m_strPortalURL = PortalUtil.getPortalURL(
                this.m_objDefCompany.getVirtualHostname(),
                PortalUtil.getPortalPort(), false);
        // FIX: #5 - somethimes portal port is -1 for unknown reasons
        if (this.m_strPortalURL.contains(":-1"))
            this.m_strPortalURL = this.m_strPortalURL.replace(":-1", "");
        m_objLog.info("Portal URL is "+this.m_strPortalURL);
    } catch (final Throwable e) {
        m_objLog.error(e);
    }
}
项目:particity    文件:MailListener.java   
/**
 * Send news update mail.
 *
 * @param sub the sub
 * @param offers the offers
 */
public void sendNewsUpdateMail(final AHSubscription sub,
        final List<AHOffer> offers) {
    try {
        final String addr = PrefsPropsUtil.getString(
                PortalUtil.getDefaultCompanyId(),
                PropsKeys.ADMIN_EMAIL_FROM_ADDRESS);
        final InternetAddress from = new InternetAddress(addr);
        final InternetAddress to = new InternetAddress(sub.getEmail());
        final String subj = CustomPortalServiceHandler
                .getConfigValue(E_ConfigKey.NEWS_UPDATE_SUBJ);
        final String body = CustomPortalServiceHandler
                .getConfigValue(E_ConfigKey.NEWS_UPDATE_BODY);
        this.sendNewsMail(from, to, subj, body, sub, offers);
    } catch (final Throwable t) {
        m_objLog.error(t);
    }
}
项目:liferay-blade-samples    文件:CustomScreenNameValidator.java   
/**
 * Returns the JavaScript function to validate the screen name client-side.
 *
 * @return the JavaScript function
 */
@Override
public String getAUIValidatorJS() {
    StringBuilder javascript = new StringBuilder();

    try {
        Company company = _companyLocalService.getCompanyByWebId(
            PropsUtil.get(PropsKeys.COMPANY_DEFAULT_WEB_ID));

        long companyId = company.getCompanyId();

        String[] reservedWords = _getReservedWords(companyId);

        javascript.append("function(val) { return !(");

        for (int i = 0; i < reservedWords.length; i++) {
            javascript.append(
                "val.indexOf(\"" + reservedWords[i] + "\") !== -1");

            if ((reservedWords.length > 1) &&
                (i < (reservedWords.length - 1))) {

                javascript.append(" || ");
            }
        }

        javascript.append(")}");
    }
    catch (PortalException pe) {
        _log.error(pe);
    }

    return javascript.toString();
}
项目:liferay-blade-samples    文件:CustomScreenNameValidator.java   
/**
 * Returns the JavaScript function to validate the screen name client-side.
 *
 * @return the JavaScript function
 */
@Override
public String getAUIValidatorJS() {
    StringBuilder javascript = new StringBuilder();

    try {
        Company company = _companyLocalService.getCompanyByWebId(
            PropsUtil.get(PropsKeys.COMPANY_DEFAULT_WEB_ID));

        long companyId = company.getCompanyId();

        String[] reservedWords = _getReservedWords(companyId);

        javascript.append("function(val) { return !(");

        for (int i = 0; i < reservedWords.length; i++) {
            javascript.append(
                "val.indexOf(\"" + reservedWords[i] + "\") !== -1");

            if ((reservedWords.length > 1) &&
                (i < (reservedWords.length - 1))) {

                javascript.append(" || ");
            }
        }

        javascript.append(")}");
    }
    catch (PortalException pe) {
        _log.error(pe);
    }

    return javascript.toString();
}
项目:liferay-blade-samples    文件:CustomScreenNameValidator.java   
/**
 * Returns the JavaScript function to validate the screen name client-side.
 *
 * @return the JavaScript function
 */
@Override
public String getAUIValidatorJS() {
    StringBuilder javascript = new StringBuilder();

    try {
        Company company = _companyLocalService.getCompanyByWebId(
            PropsUtil.get(PropsKeys.COMPANY_DEFAULT_WEB_ID));

        long companyId = company.getCompanyId();

        String[] reservedWords = _getReservedWords(companyId);

        javascript.append("function(val) { return !(");

        for (int i = 0; i < reservedWords.length; i++) {
            javascript.append(
                "val.indexOf(\"" + reservedWords[i] + "\") !== -1");

            if ((reservedWords.length > 1) &&
                (i < (reservedWords.length - 1))) {

                javascript.append(" || ");
            }
        }

        javascript.append(")}");
    }
    catch (PortalException pe) {
        _log.error(pe);
    }

    return javascript.toString();
}
项目:mqtt-liferay-plugins    文件:MqttLocalServiceImpl.java   
private void _notityMail(String context, Throwable e) {

        try {
            String errorMailTo =
                PrefsPropsUtil.getString(
                    PortletPropsKeys.MQTT_ERRORS_SEND_MAIL_TO,
                    PortletPropsValues.MQTT_ERRORS_SEND_MAIL_TO);

            if (Validator.isNotNull(errorMailTo)) {
                MailMessage mailMessage = new MailMessage();

                long companyId = PortalUtil.getDefaultCompanyId();

                String fromAddress = PrefsPropsUtil.getString(
                    companyId, PropsKeys.ADMIN_EMAIL_FROM_ADDRESS);

                mailMessage.setHTMLFormat(false);
                mailMessage.setTo(new InternetAddress(errorMailTo));
                mailMessage.setSubject(String.format(
                    "%s Mqtt connector error", PortalUtil.getComputerName()));
                mailMessage.setFrom(new InternetAddress(fromAddress));

                StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);
                e.printStackTrace(pw);

                mailMessage.setBody(String.format(
                    "context: %s\nerror: %s\n stacktrace:%s\n", context,
                    e.getMessage(), sw.toString()));

                MailServiceUtil.sendEmail(mailMessage);
            }
        }
        catch (Exception e1) {
            _log.error(e1);
        }
    }
项目:liferay-7-workspace    文件:SPATransitionsTopHeadJSPDynamicInclude.java   
@Override
public void register(DynamicIncludeRegistry dynamicIncludeRegistry) {

    boolean singlePageApplicationEnabled = GetterUtil.getBoolean(
        PropsUtil.get(
            PropsKeys.JAVASCRIPT_SINGLE_PAGE_APPLICATION_ENABLED));

    if (singlePageApplicationEnabled) {
        dynamicIncludeRegistry.register(
            "/html/common/themes/top_head.jsp#post");
    }
}
项目:OEPv2    文件:ManagerLdap.java   
public Binding getUser(long companyId, String screenName) throws Exception {

        LdapContext ctx = getContext(companyId);

        if (ctx == null) {
            return null;
        }

        String baseDN = PrefsPropsUtil.getString(companyId,
                PropsKeys.LDAP_BASE_DN);

        Properties userMappings = getUserMappings(companyId);

        StringBuilder filter = new StringBuilder();

        filter.append(StringPool.OPEN_PARENTHESIS);
        filter.append(userMappings.getProperty("screenName"));
        filter.append(StringPool.EQUAL);
        filter.append(screenName);
        filter.append(StringPool.CLOSE_PARENTHESIS);

        SearchControls cons = new SearchControls(SearchControls.SUBTREE_SCOPE,
                1, 0, null, false, false);

        NamingEnumeration<SearchResult> enu = ctx.search(baseDN,
                filter.toString(), cons);
        //System.out.println("TTTTTTTTT " + baseDN + " --------- "  + filter.toString() + "  ==== " + cons + "");
        ctx.close();

        if (enu.hasMoreElements()) {
            Binding binding = enu.nextElement();
        //  System.out.println("TTTTTTTTT " + binding);
            return binding;
        } else {
            return null;
        }
    }
项目:OEPv2    文件:ManagerLdap.java   
public LdapContext getContext(long companyId) throws Exception {
    String baseProviderURL = PrefsPropsUtil.getString(companyId,
            PropsKeys.LDAP_BASE_PROVIDER_URL);
    String pricipal = PrefsPropsUtil.getString(companyId,
            PropsKeys.LDAP_SECURITY_PRINCIPAL);
    String credentials = PrefsPropsUtil.getString(companyId,
            PropsKeys.LDAP_SECURITY_CREDENTIALS);
    return getContext(companyId, baseProviderURL, pricipal, credentials);
}
项目:OEPv2    文件:EmployeeExportToLdap.java   
public Binding getUser(LdapContext ctx, long companyId, String screenName) throws Exception {


        if (ctx == null) {
            return null;
        }

        String baseDN = PrefsPropsUtil.getString(companyId,
                PropsKeys.LDAP_BASE_DN);

        Properties userMappings = getUserMappings(companyId);

        StringBuilder filter = new StringBuilder();

        filter.append(StringPool.OPEN_PARENTHESIS);
        filter.append(userMappings.getProperty("screenName"));
        filter.append(StringPool.EQUAL);
        filter.append(screenName);
        filter.append(StringPool.CLOSE_PARENTHESIS);

        SearchControls cons = new SearchControls(SearchControls.SUBTREE_SCOPE,
                1, 0, null, false, false);

        NamingEnumeration<SearchResult> enu = ctx.search(baseDN,
                filter.toString(), cons);
        ///System.out.println("TTTTTTTTT " + baseDN + " --------- "  + filter.toString() + "  ==== " + cons + "");
        ctx.close();

        if (enu.hasMoreElements()) {
            Binding binding = enu.nextElement();
        //  System.out.println("TTTTTTTTT " + binding);
            return binding;
        } else {
            return null;
        }
    }
项目:OEPv2    文件:EmployeeExportToLdap.java   
public LdapContext getContext(long companyId) throws Exception {
    String baseProviderURL = PrefsPropsUtil.getString(companyId,
            PropsKeys.LDAP_BASE_PROVIDER_URL);
    String pricipal = PrefsPropsUtil.getString(companyId,
            PropsKeys.LDAP_SECURITY_PRINCIPAL);
    String credentials = PrefsPropsUtil.getString(companyId,
            PropsKeys.LDAP_SECURITY_CREDENTIALS);
    return getContext(companyId, baseProviderURL, pricipal, credentials);
}
项目:liferaylms-portlet    文件:P2PSendMailAsignation.java   
public static void sendMail(String emailTo, String nameTo, String content[], long companyId, Locale userLocale) {

    try{
        InternetAddress to = new InternetAddress(emailTo, nameTo);

        String portal = LanguageUtil.get(userLocale, "p2ptaskactivity.mail.portal");
        String subject= LanguageUtil.get(userLocale, "p2ptaskactivity.mail.subject");

        String bodyTitle   = LanguageUtil.format(userLocale, "p2ptaskactivity.mail.body.title", nameTo);
        String bodyMessage = LanguageUtil.format(userLocale, "p2ptaskactivity.mail.body.message", content);
        String bodyEnd     = LanguageUtil.get(userLocale, "p2ptaskactivity.mail.body.end");

        String body = bodyTitle +"\n\n"+ bodyMessage +"\n\n"+ bodyEnd +"\n\n"+ portal+"\n";
        log.debug("MESSAGE: "+bodyMessage);
        String fromName=PrefsPropsUtil.getString(companyId,PropsKeys.ADMIN_EMAIL_FROM_NAME,"");
        String fromAddress=PrefsPropsUtil.getString(companyId,PropsKeys.ADMIN_EMAIL_FROM_ADDRESS,"");

        InternetAddress from = new InternetAddress(fromAddress, fromName);

        MailMessage mailm = new MailMessage(from, to, subject, body, true);
        MailServiceUtil.sendEmail(mailm);
    }
    catch(Exception ex)
    {
    }   

}
项目:mqtt-liferay-plugins    文件:MqttLocalServiceImpl.java   
private void _notityMail(String context, Throwable e) {

        try {
            String errorMailTo =
                PrefsPropsUtil.getString(
                    PortletPropsKeys.MQTT_ERRORS_SEND_MAIL_TO,
                    PortletPropsValues.MQTT_ERRORS_SEND_MAIL_TO);

            if (Validator.isNotNull(errorMailTo)) {
                MailMessage mailMessage = new MailMessage();

                long companyId = PortalUtil.getDefaultCompanyId();

                String fromAddress = PrefsPropsUtil.getString(
                    companyId, PropsKeys.ADMIN_EMAIL_FROM_ADDRESS);

                mailMessage.setHTMLFormat(false);
                mailMessage.setTo(new InternetAddress(errorMailTo));
                mailMessage.setSubject(String.format(
                    "%s Mqtt connector error", PortalUtil.getComputerName()));
                mailMessage.setFrom(new InternetAddress(fromAddress));

                StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);
                e.printStackTrace(pw);

                mailMessage.setBody(String.format(
                    "context: %s\nerror: %s\n stacktrace:%s\n", context,
                    e.getMessage(), sw.toString()));

                MailServiceUtil.sendEmail(mailMessage);
            }
        }
        catch (Exception e1) {
            _log.error(e1);
        }
    }
项目:particity    文件:ParticityInitializer.java   
public static void initGlobals() {
    try {
        // get default company
        Company company = CompanyLocalServiceUtil.getCompanyByWebId(PropsUtil.get(PropsKeys.COMPANY_DEFAULT_WEB_ID));
        // fallback
        if (company == null)
            company = CompanyLocalServiceUtil.getCompany(PortalUtil.getDefaultCompanyId()); 

        globalCompanyId = company.getCompanyId();
        globalGroupId = company.getGroup().getGroupId();
        globalAdminId = company.getDefaultUser().getUserId(); 
        m_objLog.debug("Initial company is "+globalCompanyId+", group "+globalGroupId+", user "+globalAdminId);

        // get welcome page
        Layout layout = getLayout(globalGroupId, E_ContextPath.HOME.getPath());
        if (layout != null) {
            // correct values
            globalCompanyId = layout.getCompanyId();
            globalGroupId = layout.getGroupId();
            homeLayoutId = layout.getLayoutId();
            User admin = getDefaultAdmin(globalCompanyId);
            if (admin != null) {
                globalAdminId = admin.getUserId();
            } 
            m_objLog.debug("Corrected company is "+globalCompanyId+", group "+globalGroupId+", user "+globalAdminId);
        }

    } catch (Throwable t) {
        m_objLog.error(t);
    }
}
项目:edemocracia    文件:CaptchaImpl.java   
private void _initialize() {
    if (_captcha != null) {
        return;
    }

    synchronized (this) {
        if (_captcha != null) {
            return;
        }

        try {
            String captchaClassName = PrefsPropsUtil.getString(
                PropsKeys.CAPTCHA_ENGINE_IMPL,
                PropsValues.CAPTCHA_ENGINE_IMPL);

            if (_log.isInfoEnabled()) {
                _log.info("Initializing " + captchaClassName);
            }

            _captcha = (Captcha)InstanceFactory.newInstance(
                PACLClassLoaderUtil.getPortalClassLoader(),
                captchaClassName);

            _originalCaptcha = _captcha;
        }
        catch (Exception e) {
            _log.error(e, e);
        }
    }
}
项目:edemocracia    文件:UrlRewriterUtil.java   
/**
 * Converte a URL para HTTP
 * 
 * @param url
 * @return
 */
public static final String convertToHttp(String url) {
    if (!url.startsWith("https://"))
        return url;

    url = "http://" + url.substring(8);
    int slashPos = url.indexOf('/', 8);
    if (slashPos == -1)
        slashPos = url.length();
    int dotPos = url.indexOf(':', 8);

    // Retira a porta
    if (dotPos != -1 && dotPos < slashPos) {
        url = url.substring(0, dotPos) + url.substring(slashPos);
        slashPos = url.indexOf('/', 8);
        if (slashPos == -1)
            slashPos = url.length();
    }

    String portString = PropsUtil.get(PropsKeys.WEB_SERVER_HTTP_PORT);
    int port = Http.HTTP_PORT;
    if (portString != null) {
        try {
            port = Integer.parseInt(portString);
        } catch (NumberFormatException e) {
            port = Http.HTTP_PORT;
        }
    }
    if (port == -1 || port == 80)
        return url;

    // Acrescenta a porta
    url = url.substring(0, slashPos) + ":" + port + url.substring(slashPos);
    return url;
}
项目:edemocracia    文件:LoginPortlet.java   
private boolean isComunidadeEDemocracia(ActionResponse response, String currentUrl, Company company) throws IOException {
    String defaultWebId = PropsUtil.get(PropsKeys.COMPANY_DEFAULT_WEB_ID);
    if (!company.getWebId().equals(defaultWebId)) {
        return false;
    } else {
        return true;
    }
}
项目:liferay-evernote    文件:FileSystemImporter.java   
protected void addDDMStructures(
        String parentDDMStructureKey, String fileName,
        InputStream inputStream)
    throws Exception {

    String ddmStructureKey = getJournalId(fileName);

    String name = FileUtil.stripExtension(fileName);

    Map<Locale, String> nameMap = getMap(name);

    String xsd = StringUtil.read(inputStream);

    if (isJournalStructureXSD(xsd)) {
        xsd = JournalConverterUtil.getDDMXSD(xsd);
    }

    setServiceContext(fileName);

    DDMStructure ddmStructure = DDMStructureLocalServiceUtil.addStructure(
        userId, groupId, parentDDMStructureKey,
        PortalUtil.getClassNameId(JournalArticle.class), ddmStructureKey,
        nameMap, null, xsd,
        PropsUtil.get(PropsKeys.JOURNAL_ARTICLE_STORAGE_TYPE),
        DDMStructureConstants.TYPE_DEFAULT, serviceContext);

    addDDMTemplates(
        ddmStructure.getStructureKey(),
        _JOURNAL_DDM_TEMPLATES_DIR_NAME + name);

    if (Validator.isNull(parentDDMStructureKey)) {
        addDDMStructures(
            ddmStructure.getStructureKey(),
            _JOURNAL_DDM_STRUCTURES_DIR_NAME + name);
    }
}
项目:liferay-elasticsearch-integration    文件:FileSystemImporter.java   
protected void addDDMStructures(
        String parentDDMStructureKey, String fileName,
        InputStream inputStream)
    throws Exception {

    String ddmStructureKey = getJournalId(fileName);

    String name = FileUtil.stripExtension(fileName);

    Map<Locale, String> nameMap = getMap(name);

    String xsd = StringUtil.read(inputStream);

    if (isJournalStructureXSD(xsd)) {
        xsd = JournalConverterUtil.getDDMXSD(xsd);
    }

    setServiceContext(fileName);

    DDMStructure ddmStructure = DDMStructureLocalServiceUtil.addStructure(
        userId, groupId, parentDDMStructureKey,
        PortalUtil.getClassNameId(JournalArticle.class), ddmStructureKey,
        nameMap, null, xsd,
        PropsUtil.get(PropsKeys.JOURNAL_ARTICLE_STORAGE_TYPE),
        DDMStructureConstants.TYPE_DEFAULT, serviceContext);

    addDDMTemplates(
        ddmStructure.getStructureKey(),
        _JOURNAL_DDM_TEMPLATES_DIR_NAME + name);

    if (Validator.isNull(parentDDMStructureKey)) {
        addDDMStructures(
            ddmStructure.getStructureKey(),
            _JOURNAL_DDM_STRUCTURES_DIR_NAME + name);
    }
}
项目:liferay-microsite-manager    文件:FileSystemImporter.java   
protected void addDDMStructures(
        String parentDDMStructureKey, String fileName,
        InputStream inputStream)
    throws Exception {

    String ddmStructureKey = getJournalId(fileName);

    String name = FileUtil.stripExtension(fileName);

    Map<Locale, String> nameMap = getMap(name);

    String xsd = StringUtil.read(inputStream);

    if (isJournalStructureXSD(xsd)) {
        xsd = JournalConverterUtil.getDDMXSD(xsd);
    }

    setServiceContext(fileName);

    DDMStructure ddmStructure = DDMStructureLocalServiceUtil.addStructure(
        userId, groupId, parentDDMStructureKey,
        PortalUtil.getClassNameId(JournalArticle.class), ddmStructureKey,
        nameMap, null, xsd,
        PropsUtil.get(PropsKeys.JOURNAL_ARTICLE_STORAGE_TYPE),
        DDMStructureConstants.TYPE_DEFAULT, serviceContext);

    addDDMTemplates(
        ddmStructure.getStructureKey(),
        _JOURNAL_DDM_TEMPLATES_DIR_NAME + name);

    if (Validator.isNull(parentDDMStructureKey)) {
        addDDMStructures(
            ddmStructure.getStructureKey(),
            _JOURNAL_DDM_STRUCTURES_DIR_NAME + name);
    }
}
项目:liferay-document-and-media-treeview    文件:FileSystemImporter.java   
protected void addDDMStructures(
        String parentDDMStructureKey, String fileName,
        InputStream inputStream)
    throws Exception {

    String ddmStructureKey = getJournalId(fileName);

    String name = FileUtil.stripExtension(fileName);

    Map<Locale, String> nameMap = getMap(name);

    String xsd = StringUtil.read(inputStream);

    if (isJournalStructureXSD(xsd)) {
        xsd = JournalConverterUtil.getDDMXSD(xsd);
    }

    setServiceContext(fileName);

    DDMStructure ddmStructure = DDMStructureLocalServiceUtil.addStructure(
        userId, groupId, parentDDMStructureKey,
        PortalUtil.getClassNameId(JournalArticle.class), ddmStructureKey,
        nameMap, null, xsd,
        PropsUtil.get(PropsKeys.JOURNAL_ARTICLE_STORAGE_TYPE),
        DDMStructureConstants.TYPE_DEFAULT, serviceContext);

    addDDMTemplates(
        ddmStructure.getStructureKey(),
        _JOURNAL_DDM_TEMPLATES_DIR_NAME + name);

    if (Validator.isNull(parentDDMStructureKey)) {
        addDDMStructures(
            ddmStructure.getStructureKey(),
            _JOURNAL_DDM_STRUCTURES_DIR_NAME + name);
    }
}
项目:hr-portal    文件:FileSystemImporter.java   
protected void addDDMStructures(
        String parentDDMStructureKey, String fileName,
        InputStream inputStream)
    throws Exception {

    String ddmStructureKey = getJournalId(fileName);

    String name = FileUtil.stripExtension(fileName);

    Map<Locale, String> nameMap = getMap(name);

    String xsd = StringUtil.read(inputStream);

    if (isJournalStructureXSD(xsd)) {
        xsd = JournalConverterUtil.getDDMXSD(xsd);
    }

    setServiceContext(fileName);

    DDMStructure ddmStructure = DDMStructureLocalServiceUtil.addStructure(
        userId, groupId, parentDDMStructureKey,
        PortalUtil.getClassNameId(JournalArticle.class), ddmStructureKey,
        nameMap, null, xsd,
        PropsUtil.get(PropsKeys.JOURNAL_ARTICLE_STORAGE_TYPE),
        DDMStructureConstants.TYPE_DEFAULT, serviceContext);

    addDDMTemplates(
        ddmStructure.getStructureKey(),
        _JOURNAL_DDM_TEMPLATES_DIR_NAME + name);

    if (Validator.isNull(parentDDMStructureKey)) {
        addDDMStructures(
            ddmStructure.getStructureKey(),
            _JOURNAL_DDM_STRUCTURES_DIR_NAME + name);
    }
}
项目:liferay-voice-command    文件:FileSystemImporter.java   
protected void addDDMStructures(String fileName, InputStream inputStream)
    throws Exception {

    fileName = FileUtil.stripExtension(fileName);

    String name = getName(fileName);

    DDMStructure ddmStructure = DDMStructureLocalServiceUtil.fetchStructure(
        groupId, PortalUtil.getClassNameId(DDLRecordSet.class),
        getKey(fileName));

    if (ddmStructure != null) {
        if (!developerModeEnabled) {
            if (_log.isInfoEnabled()) {
                _log.info(
                    "DDM structure with name " + name + " and version " +
                        version + " already exists");
            }

            return;
        }

        DDMStructureLocalServiceUtil.deleteDDMStructure(ddmStructure);
    }

    ddmStructure = DDMStructureLocalServiceUtil.addStructure(
        userId, groupId, DDMStructureConstants.DEFAULT_PARENT_STRUCTURE_ID,
        PortalUtil.getClassNameId(DDLRecordSet.class), getKey(fileName),
        getMap(name), null, StringUtil.read(inputStream),
        PropsUtil.get(PropsKeys.DYNAMIC_DATA_LISTS_STORAGE_TYPE),
        DDMStructureConstants.TYPE_DEFAULT, serviceContext);

    addDDLDisplayTemplates(
        ddmStructure.getStructureKey(),
        _DDL_STRUCTURE_DISPLAY_TEMPLATE_DIR_NAME, fileName);

    addDDLFormTemplates(
        ddmStructure.getStructureKey(),
        _DDL_STRUCTURE_FORM_TEMPLATE_DIR_NAME, fileName);
}
项目:jukebox    文件:FileSystemImporter.java   
protected void addDDMStructures(
        String parentDDMStructureKey, String fileName,
        InputStream inputStream)
    throws Exception {

    String ddmStructureKey = getJournalId(fileName);

    String name = FileUtil.stripExtension(fileName);

    Map<Locale, String> nameMap = getMap(name);

    String xsd = StringUtil.read(inputStream);

    if (isJournalStructureXSD(xsd)) {
        xsd = JournalConverterUtil.getDDMXSD(xsd);
    }

    setServiceContext(fileName);

    DDMStructure ddmStructure = DDMStructureLocalServiceUtil.addStructure(
        userId, groupId, parentDDMStructureKey,
        PortalUtil.getClassNameId(JournalArticle.class), ddmStructureKey,
        nameMap, null, xsd,
        PropsUtil.get(PropsKeys.JOURNAL_ARTICLE_STORAGE_TYPE),
        DDMStructureConstants.TYPE_DEFAULT, serviceContext);

    addDDMTemplates(
        ddmStructure.getStructureKey(),
        _JOURNAL_DDM_TEMPLATES_DIR_NAME + name);

    if (Validator.isNull(parentDDMStructureKey)) {
        addDDMStructures(
            ddmStructure.getStructureKey(),
            _JOURNAL_DDM_STRUCTURES_DIR_NAME + name);
    }
}
项目:hr-portal    文件:FileSystemImporter.java   
protected void addDDMStructures(
        String parentDDMStructureKey, String fileName,
        InputStream inputStream)
    throws Exception {

    String ddmStructureKey = getJournalId(fileName);

    String name = FileUtil.stripExtension(fileName);

    Map<Locale, String> nameMap = getMap(name);

    String xsd = StringUtil.read(inputStream);

    if (isJournalStructureXSD(xsd)) {
        xsd = JournalConverterUtil.getDDMXSD(xsd);
    }

    setServiceContext(fileName);

    DDMStructure ddmStructure = DDMStructureLocalServiceUtil.addStructure(
        userId, groupId, parentDDMStructureKey,
        PortalUtil.getClassNameId(JournalArticle.class), ddmStructureKey,
        nameMap, null, xsd,
        PropsUtil.get(PropsKeys.JOURNAL_ARTICLE_STORAGE_TYPE),
        DDMStructureConstants.TYPE_DEFAULT, serviceContext);

    addDDMTemplates(
        ddmStructure.getStructureKey(),
        _JOURNAL_DDM_TEMPLATES_DIR_NAME + name);

    if (Validator.isNull(parentDDMStructureKey)) {
        addDDMStructures(
            ddmStructure.getStructureKey(),
            _JOURNAL_DDM_STRUCTURES_DIR_NAME + name);
    }
}
项目:liferay-newsletter    文件:SubscriberEmailSender.java   
private void sendEmail(String email, String subject, String body, boolean sendHtml) throws Exception {
    InternetAddress rcpt = new InternetAddress(email);
    InternetAddress from = new InternetAddress(PrefsPropsUtil.getString(LiferayUtil.getThemeDisplay().getCompanyId(), PropsKeys.ADMIN_EMAIL_FROM_ADDRESS));

    MailMessage mailMessage = new MailMessage();
    mailMessage.setBody(body);
    mailMessage.setHTMLFormat(sendHtml);
    mailMessage.setFrom(from);
    mailMessage.setTo(rcpt);
    mailMessage.setSubject(subject);
    MailServiceUtil.sendEmail(mailMessage);
}
项目:opencps-v2    文件:SendMailUtils.java   
public static void sendEmailNotification(JSONObject payLoad, ServiceContext serviceContext) throws SystemException {

        if(Validator.isNotNull(payLoad)){
//          String fromName = PrefsPropsUtil.getString(payLoad.getLong("companyId"), PropsKeys.ADMIN_EMAIL_FROM_NAME);
            String fromName = "MOBILINK Mail System";

            String fromAddress = PrefsPropsUtil.getString(payLoad.getLong("companyId"), PropsKeys.ADMIN_EMAIL_FROM_ADDRESS);

            String toName = payLoad.getString("toName");

            String toAddress = payLoad.getString("toAddress");

            String subject = payLoad.getString("subject");

            String body = payLoad.getString("body");

            SubscriptionSender subscriptionSender = new SubscriptionSender();

            subscriptionSender.setBody(body);

            subscriptionSender.setCompanyId(serviceContext.getCompanyId());

            subscriptionSender.setFrom(fromAddress, fromName);

            subscriptionSender.setHtmlFormat(true);

            subscriptionSender.setServiceContext(serviceContext);

            subscriptionSender.setSubject(subject);

            subscriptionSender.setUserId(payLoad.getLong("userId"));

            subscriptionSender.setMailId("user", payLoad.getLong("userId"));

            subscriptionSender.addRuntimeSubscribers(toAddress, toName);

            subscriptionSender.flushNotificationsAsync();

            //SendUserNotification
            try {
                long toUserId = payLoad.getLong("toUserId");
                long activityId = payLoad.getLong("activityId");
                JSONObject payloadJSON = JSONFactoryUtil.createJSONObject();
                payloadJSON.put("userId", payLoad.getLong("userId"));
                payloadJSON.put("toUserId", toUserId);
                payloadJSON.put("activityId", activityId);
                payloadJSON.put("contentNotification", payLoad.getString("contentNotification"));
                payloadJSON.put("subject", payLoad.getString("subject"));
//              if(toUserId == 0){
//                  List<Participant> listMParticipants = ParticipantLocalServiceUtil.findByF_activityId(activityId);
//                  for (MParticipant mParticipant : listMParticipants) {
//                      UserNotificationEventLocalServiceUtil.addUserNotificationEvent(mParticipant.getUserMappingId(), 
//                              ActivitiesConstants.MEETUP_MGT_CENTER, 
//                              (new Date()).getTime(),
//                              mParticipant.getUserId(),
//                              payloadJSON.toString(),
//                              false, serviceContext);
//                  }
//              }else{
//                  UserNotificationEventLocalServiceUtil.addUserNotificationEvent(toUserId, 
//                          ActivitiesConstants.MEETUP_MGT_CENTER, 
//                          (new Date()).getTime(),
//                          payLoad.getLong("userId"),
//                          payloadJSON.toString(),
//                          false, serviceContext);
//              }

            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }       
        }

    }
项目:opencps-v2    文件:UserRegisterTaskScheduler.java   
@Override
protected void doReceive(Message message) throws Exception {

    Company company = CompanyLocalServiceUtil.getCompanyByMx(PropsUtil.get(PropsKeys.COMPANY_DEFAULT_WEB_ID));

    List<NotificationQueue> queues = NotificationQueueLocalServiceUtil.getNotificationQueues(QueryUtil.ALL_POS,
            QueryUtil.ALL_POS);

    ServiceContext serviceContext = new ServiceContext();
    serviceContext.setCompanyId(company.getCompanyId());

    for (NotificationQueue queue : queues) {

        JSONObject jsonPayload = JSONFactoryUtil.createJSONObject(queue.getPayload());

        SendMailUtils.sendEmailNotification(jsonPayload, serviceContext);

        NotificationQueueLocalServiceUtil.deleteNotificationQueue(queue);
    }

}
项目:opencps-v2    文件:SendMailUtils.java   
public static void sendEmailNotification(JSONObject payLoad, ServiceContext serviceContext) throws SystemException {

        if(Validator.isNotNull(payLoad)){
//          String fromName = PrefsPropsUtil.getString(payLoad.getLong("companyId"), PropsKeys.ADMIN_EMAIL_FROM_NAME);
            String fromName = "Mail System";

            String fromAddress = PrefsPropsUtil.getString(payLoad.getLong("companyId"), PropsKeys.ADMIN_EMAIL_FROM_ADDRESS);

            String toName = payLoad.getString("toName");

            String toAddress = payLoad.getString("toAddress");

            String subject = payLoad.getString("subject");

            String body = payLoad.getString("body");

            SubscriptionSender subscriptionSender = new SubscriptionSender();

            subscriptionSender.setBody(body);

            subscriptionSender.setCompanyId(serviceContext.getCompanyId());

            subscriptionSender.setFrom(fromAddress, fromName);

            subscriptionSender.setHtmlFormat(true);

            subscriptionSender.setServiceContext(serviceContext);

            subscriptionSender.setSubject(subject);

            subscriptionSender.setUserId(payLoad.getLong("userId"));

            subscriptionSender.setMailId("user", payLoad.getLong("userId"));

            subscriptionSender.addRuntimeSubscribers(toAddress, toName);

            subscriptionSender.flushNotificationsAsync();

//          //SendUserNotification
//          try {
//              long toUserId = payLoad.getLong("toUserId");
//              long activityId = payLoad.getLong("activityId");
//              JSONObject payloadJSON = JSONFactoryUtil.createJSONObject();
//              payloadJSON.put("userId", payLoad.getLong("userId"));
//              payloadJSON.put("toUserId", toUserId);
//              payloadJSON.put("activityId", activityId);
//              payloadJSON.put("contentNotification", payLoad.getString("contentNotification"));
//              payloadJSON.put("subject", payLoad.getString("subject"));
//              if(toUserId == 0){
//                  List<MParticipant> listMParticipants = MParticipantLocalServiceUtil.findByF_activityId(activityId);
//                  for (MParticipant mParticipant : listMParticipants) {
//                      UserNotificationEventLocalServiceUtil.addUserNotificationEvent(mParticipant.getUserMappingId(), 
//                              ActivitiesConstants.MEETUP_MGT_CENTER, 
//                              (new Date()).getTime(),
//                              mParticipant.getUserId(),
//                              payloadJSON.toString(),
//                              false, serviceContext);
//                  }
//              }else{
//                  UserNotificationEventLocalServiceUtil.addUserNotificationEvent(toUserId, 
//                          ActivitiesConstants.MEETUP_MGT_CENTER, 
//                          (new Date()).getTime(),
//                          payLoad.getLong("userId"),
//                          payloadJSON.toString(),
//                          false, serviceContext);
//              }
//              
//          } catch (PortalException e) {
//              // TODO Auto-generated catch block
//              e.printStackTrace();
//          }       
        }

    }
项目:ScreensDemos    文件:DDLRecordModelListener.java   
private List<User> findSomeUsers(int from, int to) throws PortalException, SystemException {
    Company company = CompanyLocalServiceUtil.getCompanyByMx(PropsUtil.get(PropsKeys.COMPANY_DEFAULT_WEB_ID));
    long companyId = company.getCompanyId();
    return UserLocalServiceUtil.getCompanyUsers(companyId, from, to);
}
项目:OEPv2    文件:ManagerLdap.java   
public Properties getUserMappings(long companyId) throws Exception {
    Properties userMappings = PropertiesUtil.load(PrefsPropsUtil.getString(
            companyId, PropsKeys.LDAP_USER_MAPPINGS));
    LogUtil.debug(_log, userMappings);
    return userMappings;
}
项目:OEPv2    文件:ManagerLdap.java   
public String getUsersDN(long companyId) throws Exception {
    return PrefsPropsUtil.getString(companyId, PropsKeys.LDAP_USERS_DN);
}
项目:OEPv2    文件:ManagerLdap.java   
protected String getEncryptedPasswordForLDAP(
        User user, Properties userMappings)
    throws SystemException {

    String password = user.getPasswordUnencrypted();
    //

    if (Validator.isNull(password)) {
        return password;
    }

    String algorithm = PrefsPropsUtil.getString(
        user.getCompanyId(),
        PropsKeys.LDAP_AUTH_PASSWORD_ENCRYPTION_ALGORITHM);

    if (Validator.isNull(algorithm)) {
        return password;
    }

    try {
        StringBundler sb = new StringBundler(4);

//      if (!algorithm.equals(PasswordEncryptor.TYPE_NONE)) {
    //      sb.append(StringPool.OPEN_CURLY_BRACE);
    //      sb.append(algorithm);
    //      sb.append(StringPool.CLOSE_CURLY_BRACE);
    //  }

        //sb.append(PasswordEncryptorUtil.encrypt(algorithm, password, null));

        String passwordKey = userMappings.getProperty(
            UserConverterKeys.PASSWORD);

        if (passwordKey.equals("unicodePwd")) {
            String quotedPassword = StringPool.QUOTE.concat(
                sb.toString()).concat(StringPool.QUOTE);

            byte[] unicodePassword = quotedPassword.getBytes("UTF-16LE");

            return new String(unicodePassword);
        }

        return sb.toString();
    }
    catch (Exception e) {
        throw new SystemException(e);
    }
}
项目:OEPv2    文件:EmployeeExportToLdap.java   
protected String getEncryptedPasswordForLDAP(
        User user, Properties userMappings)
    throws SystemException {

    String password = user.getPasswordUnencrypted();
    //

    if (Validator.isNull(password)) {
        return password;
    }

    String algorithm = PrefsPropsUtil.getString(
        user.getCompanyId(),
        PropsKeys.LDAP_AUTH_PASSWORD_ENCRYPTION_ALGORITHM);

    if (Validator.isNull(algorithm)) {
        return password;
    }

    try {
        StringBundler sb = new StringBundler(4);

//      if (!algorithm.equals(PasswordEncryptor.TYPE_NONE)) {
    //      sb.append(StringPool.OPEN_CURLY_BRACE);
    //      sb.append(algorithm);
    //      sb.append(StringPool.CLOSE_CURLY_BRACE);
    //  }

        //sb.append(PasswordEncryptorUtil.encrypt(algorithm, password, null));

        String passwordKey = userMappings.getProperty(
            UserConverterKeys.PASSWORD);

        if (passwordKey.equals("unicodePwd")) {
            String quotedPassword = StringPool.QUOTE.concat(
                sb.toString()).concat(StringPool.QUOTE);

            byte[] unicodePassword = quotedPassword.getBytes("UTF-16LE");

            return new String(unicodePassword);
        }

        return sb.toString();
    }
    catch (Exception e) {
        throw new SystemException(e);
    }
}
项目:OEPv2    文件:EmployeeExportToLdap.java   
public Attributes getLDAPUserAttributes(
        User user, Properties userMappings)
    throws SystemException {

    Attributes attributes = new BasicAttributes(true);

    Attribute objectClass = new BasicAttribute(_OBJECT_CLASS);
//  String postfix = LDAPSettingsUtil.getPropertyPostfix(ldapServerId);

    String[] defaultObjectClasses = PrefsPropsUtil.getStringArray(
        user.getCompanyId(),PropsKeys.LDAP_USER_DEFAULT_OBJECT_CLASSES,
        StringPool.COMMA);

    for (int i = 0; i < defaultObjectClasses.length; i++) {
        objectClass.add(defaultObjectClasses[i]);
    }
    attributes.put(objectClass);
    addAttributeMapping(
        userMappings.getProperty(UserConverterKeys.UUID), user.getUuid(),
        attributes);
    addAttributeMapping(
        userMappings.getProperty(UserConverterKeys.SCREEN_NAME),
        user.getScreenName(), attributes);
    addAttributeMapping(
        userMappings.getProperty(UserConverterKeys.PASSWORD),
        getEncryptedPasswordForLDAP(user, userMappings), attributes);
    addAttributeMapping(
        userMappings.getProperty(UserConverterKeys.EMAIL_ADDRESS),
        user.getEmailAddress(), attributes);
    addAttributeMapping(
        userMappings.getProperty(UserConverterKeys.FULL_NAME),
        user.getFullName(), attributes);
    addAttributeMapping(
        userMappings.getProperty(UserConverterKeys.FIRST_NAME),
        user.getFirstName(), attributes);
    addAttributeMapping(
        userMappings.getProperty(UserConverterKeys.MIDDLE_NAME),
        user.getMiddleName(), attributes);
    addAttributeMapping(
        userMappings.getProperty(UserConverterKeys.LAST_NAME),
        user.getLastName(), attributes);
    addAttributeMapping(
        userMappings.getProperty(UserConverterKeys.JOB_TITLE),
        user.getJobTitle(), attributes);
    //addAttributeMapping(
    //  userMappings.getProperty(UserConverterKeys.PORTRAIT),
    //  getUserPortrait(user), attributes);
    addAttributeMapping(
        userMappings.getProperty(UserConverterKeys.STATUS),
        String.valueOf(user.getStatus()), attributes);

    return attributes;
}
项目:OEPv2    文件:EmployeeExportToLdap.java   
public Properties getUserMappings(long companyId) throws Exception {
    Properties userMappings = PropertiesUtil.load(PrefsPropsUtil.getString(
            companyId, PropsKeys.LDAP_USER_MAPPINGS));
    return userMappings;
}