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

项目:odp-manage-datasets-portlet    文件:ImageGalleryUtils.java   
/**
 * Upload image.
 * 
 * @param image
 *            the image
 * @return the uri
 * @throws SystemException
 *             the system exception
 * @throws URISyntaxException
 *             the uRI syntax exception
 * @throws IOException
 * @throws PortalException
 */
public static URI uploadImage(UploadedFile image) throws SystemException, URISyntaxException, IOException, PortalException,
        NullPointerException {

    LiferayFacesContext lfc = LiferayFacesContext.getInstance();
    ThemeDisplay td = lfc.getThemeDisplay();

    ServiceContext serviceContext = new ServiceContext();
    serviceContext.setScopeGroupId(td.getScopeGroupId());

    long imageFolderId = Long.parseLong(PropsUtil.get("image.folder.id"));
    DLFolder folder;

    try {
        /* Check if folder for image exists */
        folder = DLFolderLocalServiceUtil.getDLFolder(imageFolderId);
        LOG.debug("Folder for app images exists.");
    } catch (PortalException e) {
        /* If not -> create */
        folder = DLFolderLocalServiceUtil.createDLFolder(imageFolderId);
        folder.setName("App-Images");
        DLFolderLocalServiceUtil.addDLFolder(folder);
        LOG.debug("Created folder for app images.");
    }

    String uuidExt = null;
    FileEntry file = null;

    uuidExt = td.getUser().getScreenName() + "_" + UUID.randomUUID().toString() + "_" + new Date().getTime() + "_";

    file = DLAppLocalServiceUtil.addFileEntry(td.getUserId(), td.getScopeGroupId(), folder.getFolderId(), uuidExt + image.getName(),
            MimeTypesUtil.getContentType(image.getName()), uuidExt + image.getName(), uuidExt + image.getName(), "new",
            image.getBytes(), serviceContext);

    return new URI(td.getPortalURL() + "/c/document_library/get_file?uuid=" + file.getUuid() + "&groupId=" + td.getScopeGroupId());
}
项目:liferaylms-portlet    文件:ModuleLocalServiceImpl.java   
public boolean userTimeFinished(long moduleId,long userId) throws SystemException, PortalException
{
    Module theModule=ModuleLocalServiceUtil.getModule(moduleId);
    ModuleResult mr=ModuleResultLocalServiceUtil.getByModuleAndUser(theModule.getModuleId(), userId);
    if(mr!=null && !mr.getPassed()&&mr.getStartDate()!=null)
    {
        long courtesyTime=GetterUtil.getLong(PropsUtil.get("lms.module.courtesytime.miliseconds"),0);
        long usedTime=System.currentTimeMillis()-mr.getStartDate().getTime();
        if(theModule.getAllowedTime()!=0)
        {
            if ( theModule.getAllowedTime() + courtesyTime - usedTime < 0)
            {
                return true;
            }
        }
    }
    return false;
}
项目:liferaylms-portlet    文件:CourseAdmin.java   
public void deleteExportedCourse(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
    long groupId  = ParamUtil.getLong(actionRequest, "groupId", 0);
    String fileName = ParamUtil.getString(actionRequest, "fileName", StringPool.BLANK);
    String redirect = ParamUtil.getString(actionRequest, "redirect", StringPool.BLANK);
    File f = new File(PropsUtil.get("liferay.home")+"/data/lms_exports/courses/"+themeDisplay.getCompanyId()+"/"+groupId+"/"+fileName);
    if (themeDisplay.getPermissionChecker().hasPermission(groupId, Course.class.getName(), groupId, ActionKeys.DELETE) && f != null && f.isFile()) {
        FileUtil.delete(f);
        SessionMessages.add(actionRequest, "courseadmin.delete.exported.confirmation.success");
    } else {
        SessionMessages.add(actionRequest, "courseadmin.delete.exported.confirmation.error");
    }
    if (Validator.isNotNull(redirect)) {
        actionResponse.sendRedirect(redirect);
    }
}
项目:liferaylms-portlet    文件:LearningActivityAssetRendererFactory.java   
@Override
public Map<Long, String> getClassTypes(long[] groupId, Locale locale)
        throws Exception {

    Map<Long, String> classTypes = new LinkedHashMap<Long, String>();
    if(CourseLocalServiceUtil.dynamicQueryCount(CourseLocalServiceUtil.dynamicQuery().
            add(PropertyFactoryUtil.forName("groupCreatedId").in(ArrayUtil.toArray(groupId))))>0){
        LearningActivityTypeRegistry learningActivityTypeRegistry = new LearningActivityTypeRegistry();
        ResourceBundle resourceBundle = PortletBagPool.get(getPortletId()).getResourceBundle(locale);       
        long[] invisibleTypes = StringUtil.split(PropsUtil.get("lms.learningactivity.invisibles"), StringPool.COMMA,-1L);
        for(LearningActivityType learningActivityType:learningActivityTypeRegistry.getLearningActivityTypesForCreating()){
            if(learningActivityType != null && !ArrayUtil.contains(invisibleTypes, learningActivityType.getTypeId())){
                String learningActivityTypeName = learningActivityTypeRegistry.getLearningActivityType(learningActivityType.getTypeId()).getName();
                classTypes.put(learningActivityType.getTypeId(), (resourceBundle.containsKey(learningActivityTypeName)?
                        resourceBundle.getString(learningActivityTypeName):learningActivityTypeName));
            }
        }   
    }
    return classTypes;
}
项目: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);
    }
}
项目:edemocracia    文件:HtmlBBCodeTranslatorImpl.java   
protected void handleYoutube(
    StringBundler sb, List<BBCodeItem> bbCodeItems, Stack<String> tags, IntegerWrapper marker) {

        String videoId = extractData(
        bbCodeItems, marker, "youtube", BBCodeParser.TYPE_DATA, true);

    if (videoId.length() > 0) {
        int videoHeight = GetterUtil.get(PropsUtil.get("forum.video.height"), 349);
        int videoWidth = GetterUtil.get(PropsUtil.get("forum.video.width"), 560);
        // Extrai o identificador do video, parar criar o embbed
        for (Pattern p : YOUTUBE_PATTERNS) {
            Matcher m = p.matcher(videoId);
            if (m.find()) {
                sb.append("<iframe ");
                sb.append("width=\"").append(videoWidth).append("\" ");
                sb.append("height=\"").append(videoHeight).append("\" ");
                sb.append("src=\"http://www.youtube.com/embed/");
                sb.append(HtmlUtil.escapeAttribute(m.group(1)));
                sb.append("\" frameborder=\"0\" allowfullscreen></iframe>");
                break;
            }
        }
    }
}
项目:liferay-elasticsearch-integration    文件:ElasticsearchPropsValues.java   
/**
 * This method loads the needed properties from Elastic.props files and
 * makes necessary conversion using utility methods.
 */
public void loadESProperties() {

    /** Load Elastic server home and clustername from Portal level props*/
    this.esServerHome = PropsUtil.get(ElasticsearchPortletConstants.ES_KEY_HOME_PATH);
    this.esClusterName = PropsUtil.get(ElasticsearchPortletConstants.ES_KEY_CLUSTERNAME);

    /** Load other suggestion related props from Portlet properties*/
    this.suggestionsSize = getPortletProperty(ElasticsearchPortletConstants.SUGGESTIONS_SIZE_KEY,
            ElasticsearchPortletConstants.SUGGESTIONS_SIZE_DEFAULT_VALUE);

    this.suggestionsLength = getPortletProperty(ElasticsearchPortletConstants.SUGGESTIONS_LENGTH_KEY,
            ElasticsearchPortletConstants.SUGGESTIONS_LENGTH_DEFAULT_VALUE);

    this.suggestionsQueryMaxHits = getPortletProperty(ElasticsearchPortletConstants.SUGGESTION_QUERY_MAX_HITS_KEY,
            ElasticsearchPortletConstants.SUGGESTIONS_QUERY_MAX_HITS_DEFAULT_VALUE);


    setSuggestionQueryFields();
    setSuggestionExcludedTypes();
}
项目:liferay-elasticsearch-integration    文件:ElasticsearchPropsValues.java   
/**
 * Gets the transport hosts.
 * 
 * @return the transport hosts
 */
public InetSocketTransportAddress[] getTransportHosts() {

    String csNodeList = PropsUtil.get(ElasticsearchPortletConstants.ES_KEY_NODE);
    InetSocketTransportAddress[] transportAddresses = null;
    if (Validator.isNotNull(csNodeList)) {
        String[] nodeList = csNodeList.split(StringPool.COMMA);
        transportAddresses = new InetSocketTransportAddress[nodeList.length];

        /** Prepare a list of Hosts */
        for (int i = 0; i < nodeList.length; i++) {
            String[] hostnames = nodeList[i].split(StringPool.COLON);
            InetSocketTransportAddress transportAddress = new InetSocketTransportAddress(hostnames[0],
                    Integer.parseInt(hostnames[1]));
            transportAddresses[i] = transportAddress;
        }
    } else {
        _log.error("Elastic search nodes are missing from properties...");
    }

    return transportAddresses;
}
项目:odp-manage-datasets-portlet    文件:CurrentUser.java   
/**
 * Inits the.
 */
@PostConstruct
public void init() {

    Properties props = new Properties();
    props.setProperty("ckan.authorization.key", PropsUtil.get("authenticationKey"));
    props.setProperty("ckan.url", PropsUtil.get("cKANurl"));

    LOG.debug("odRClient props:" + props.toString());

    odrClient = OpenDataRegistry.getClient();
    odrClient.init(props);

    PortletRequest request = (PortletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
    @SuppressWarnings("unchecked")
    Map<String, String> userInfo = (Map<String, String>) request.getAttribute(PortletRequest.USER_INFO);
    if (userInfo != null) {
        String loginid = userInfo.get("user.login.id");
        if (loginid != null) {
            currentUser = odrClient.findUser(loginid);
        }
    }
}
项目: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();
}
项目: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");
    }
}
项目:liferaylms-portlet    文件:LiferaylmsUtil.java   
public static void saveStringToFile(String fileName, String text){

    StringBuffer sb = new StringBuffer(PropsUtil.get("java.io.tmpdir"));
    sb.append(File.separator);
    sb.append("custom_logs"); //Directorio para los ficheros.

    File dir = new File(sb.toString());
    if(!dir.exists()){
        dir.mkdir();
    }

    //Nombre del informe
    sb.append(File.separator);
    sb.append(fileName);


    Calendar cal = Calendar.getInstance();

    try {
        BufferedWriter out = new BufferedWriter(new FileWriter(sb.toString(),true));
        out.append("\n"+cal.getTime()+" - "+text);
        out.close();
    }
    catch (IOException e){
        e.printStackTrace();
    }

}
项目:liferaylms-portlet    文件:EvaluationAvgCourseEval.java   
@Override
public boolean especificValidations(UploadRequest uploadRequest,
        PortletResponse portletResponse) {
    if(!Validator.isNumber(PropsUtil.get("lms.course.default.evaluations"))) {
        return true;
    }

    PortletRequest portletRequest = (PortletRequest)uploadRequest.getAttribute(JavaConstants.JAVAX_PORTLET_REQUEST);
    String numOfEvaluations = uploadRequest.getParameter("numOfEvaluations");
    Long courseId = ParamUtil.getLong(uploadRequest, "courseId");

    if (Validator.isNotNull(courseId)) {
        return true;
    }

    if(Validator.isNumber(numOfEvaluations)){
        _numOfEvaluations.set(GetterUtil.getLong(numOfEvaluations));
        return true;
    }

    if(Validator.isNull(numOfEvaluations)) {
        SessionErrors.add(portletRequest, "num-of-evaluations-required");
    }
    else {
        SessionErrors.add(portletRequest, "num-of-evaluations-number");
    }

    return false;
}
项目:liferaylms-portlet    文件:EvaluationAvgCourseEval.java   
@Override
public void setExtraContent(Course course, String actionId, ServiceContext serviceContext)
        throws PortalException, SystemException {
    if((Validator.isNumber(PropsUtil.get("lms.course.default.evaluations")))&&("ADD_COURSE".equals(actionId))) {
        ServiceContext evaluationServiceContext = ServiceContextFactory.getInstance(serviceContext.getRequest());
        long numOfEvaluations = _numOfEvaluations.get();
        Locale locale = LocaleThreadLocal.getThemeDisplayLocale();

        if(locale==null) {
            if(Validator.isNotNull(serviceContext.getLanguageId())){
                locale = LocaleUtil.fromLanguageId(serviceContext.getLanguageId());
            }
            else {
                locale = LocaleUtil.getDefault();
            }
        }
        long[] assetCategoryIds=new long[0];
        evaluationServiceContext.setAssetCategoryIds(assetCategoryIds);
        evaluationServiceContext.setAssetLinkEntryIds(assetCategoryIds);
        String[] emptyArray=new String[0];

        evaluationServiceContext.setAssetTagNames(emptyArray);
        evaluationServiceContext.setGroupPermissions(emptyArray);
        evaluationServiceContext.setGuestPermissions(emptyArray);
        evaluationServiceContext.setDeriveDefaultPermissions(true);


        for(int currentEvaluation=1;currentEvaluation<=numOfEvaluations;currentEvaluation++) {

            Map<Locale,String> evaluationTitle = new HashMap<Locale, String>(1);
            evaluationTitle.put(locale, LanguageUtil.format(locale, "evaluation.number", new Object[]{currentEvaluation}));

            LearningActivityLocalServiceUtil.addLearningActivity(course.getUserId(), course.getGroupCreatedId(), WorkflowConstants.STATUS_APPROVED, 
                    evaluationTitle, evaluationTitle, 8 /* Evaluation */, null, null, 0, 0, 0, 0, null, null, null, 0, 0, evaluationServiceContext);
        }   
    }
}
项目:liferaylms-portlet    文件:LmsPrefsLocalServiceImpl.java   
private void setActivities(LmsPrefs lmsPrefs) throws SystemException {
    if(lmsPrefs.getActivities()==null ||lmsPrefs.getActivities().length()==0)
    {
        LearningActivityTypeRegistry learningActivityTypeRegistry = new LearningActivityTypeRegistry();
        java.util.List<LearningActivityType> lats=learningActivityTypeRegistry.getLearningActivityTypes();
        java.util.Map<Long, LearningActivityType> mapLats = new java.util.HashMap<Long, LearningActivityType>();

        for (LearningActivityType lat : lats) {
            mapLats.put(lat.getTypeId(), lat);
        }

        java.util.List<Long> actids = new java.util.ArrayList<Long>();
        if (PropsUtil.contains("lms.learningactivity.order.default")) 
        {
            String [] defaultOrderArray = PropsUtil.getArray("lms.learningactivity.order.default");
            if (Validator.isNotNull(defaultOrderArray)) 
            {
                for (int i = 0; i < defaultOrderArray.length; i++) {
                    String defaultOrderActIdString = defaultOrderArray[i];
                    if (Validator.isNumber(defaultOrderActIdString)) {
                        Long defaultOrderActId = Long.valueOf(defaultOrderActIdString);
                        if (defaultOrderActId >= 0 && mapLats.get(defaultOrderActId) != null) {
                            actids.add(defaultOrderActId);
                        }
                    }
                }
            }
        }

        for (int i = 0; i < lats.size(); i++)
        {
            Long typeId = lats.get(i).getTypeId();
            if (!actids.contains(typeId)) {
                actids.add(typeId);
            }               
        }
        lmsPrefs.setActivities(StringUtil.merge(actids));
        lmsPrefsPersistence.update(lmsPrefs, true);
    }
}
项目:liferaylms-portlet    文件:CompetenceLocalServiceImpl.java   
public void setBGImage(byte[] data,long groupId, String name) throws IOException
{
    String baseDir=PropsUtil.get("liferay.home")+"/data/compimages";
    File baseDirFile=new File(baseDir);
    if(!baseDirFile.exists())
    {
        baseDirFile.mkdir();
    }
    String fileExtension=name.substring(name.lastIndexOf('.'));
    File imageFile=new File(baseDirFile.getAbsolutePath()+"/"+Long.toString(groupId)+fileExtension.toLowerCase());
    /* Cambios de Miguel que borra imagenes */
     String [] nameOfFiles = baseDirFile.list();
     String [] aux = null;
     File fileToDelete = null;
     for (int i=0; i<nameOfFiles.length; i++){
         aux = nameOfFiles[i].split("\\.");
         if(aux[0].equals(Long.toString(groupId))){
             fileToDelete = new File(baseDirFile.getAbsolutePath()+"/"+Long.toString(groupId)+"."+aux[1]);
             fileToDelete.delete();
             fileExtension = null;
         }
     }
    /* Fin de cambios de Miguel */

    imageFile.createNewFile();
    FileOutputStream fos=new FileOutputStream(imageFile);
    fos.write(data);
    fos.close();
}
项目:liferaylms-portlet    文件:AuditingLogFactory.java   
public static AuditingLog getAuditLog() throws ClassNotFoundException, InstantiationException, IllegalAccessException
{
    if(auditLog==null)
    {
        Class<?> clase= null;
        if(PropsUtil.get("audit.implementation")!=null){
            clase=Class.forName(PropsUtil.get("audit.implementation"));
        }else{
            clase=Class.forName("com.liferay.lms.auditing.NullAuditingLog");
        }
        auditLog=(AuditingLog)clase.newInstance();
    }
    return auditLog;
}
项目: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    文件: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);
    }
}
项目:Discussion-Board-Liferay    文件:CustomThreadCategoryList.java   
/**
 * Method that get list of recent posts by users
 */
public static List<MBThread> getRecentPosts(HttpServletRequest request) throws PortalException{
    _log.debug("Entry : getRecentPosts");
    long groupThreadsUserId = ParamUtil.getLong(request, CustomConstants.GROUP_THREAD_USERID);
    _log.debug("groupThreadsUserId :=>"+groupThreadsUserId);
    List<MBThread> recentThreadList=new ArrayList<>();
    ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
    List<Long> categoryIds=new ArrayList<Long>();
    Calendar calendar = Calendar.getInstance();
    String offset=PropsUtil.get(CustomConstants.RECENT_POST_DATE_OFFSET);
    PortletPreferences preference=(PortletPreferences)request.getAttribute(CustomConstants.PREFERENCE_REQUEST_ATTRIBUTE);
    long preferenceCatId=GetterUtil.getLong(preference.getValue(CustomConstants.PREFERENCE_CATEGORYID, String.valueOf(QueryUtil.ALL_POS)));
    calendar.add(Calendar.DATE, -(Integer.parseInt(offset)));
    List<MBThread> mbThreadList= MBThreadServiceUtil.getGroupThreads(
            themeDisplay.getScopeGroupId(),groupThreadsUserId,calendar.getTime(), WorkflowConstants.STATUS_APPROVED,QueryUtil.ALL_POS, QueryUtil.ALL_POS);
    if(preferenceCatId != QueryUtil.ALL_POS){
        categoryIds=getPreferenceCatChildList(preferenceCatId, request);
         for(MBThread  mbThread:mbThreadList){
             for(Long categoryId:categoryIds){
                 if(mbThread.getCategoryId() == categoryId){
                        recentThreadList.add(mbThread);
                 }
             }
         }
    }
    else{
        recentThreadList=mbThreadList;
    }
        _log.debug("List Size:=>"+recentThreadList.size());
    return recentThreadList;
}
项目: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);
    }
}
项目:odp-manage-datasets-portlet    文件:ManageController.java   
/**
 * check if the titel already exist in ckan.
 * 
 */
public void titelValidator(FacesContext context, UIComponent component,
        Object value) throws ValidatorException {
    if (editMode) {
        return;
    }
    String titel = value.toString();
    Properties props = new Properties();
    props.setProperty("ckan.authorization.key",
            PropsUtil.get("authenticationKey"));
    props.setProperty("ckan.url", PropsUtil.get("cKANurl"));
    ODRClient oDRClient = OpenDataRegistry.getClient();
    oDRClient.init(props);
    boolean nameExist = false;
    try {
        String mungeTitle = oDRClient.mungeTitleToName(titel);
        Metadata metadata = oDRClient.getMetadata(
                currentUser.getCurrentUser(), mungeTitle);
        LOG.debug("titelValidator:Metadata Titel existiert:" + titel);
        nameExist = true;
    } catch (Exception e) {
        LOG.debug("titelValidator:Metadata Titel existiert NICHT:" + titel);
        nameExist = false;
    }

    if (nameExist) {
        // FacesMessage message = new
        // FacesMessage(FacesMessage.SEVERITY_ERROR,"Invalid titel","Titel existiert schon:"
        // + titel);
        // context.addMessage(component.getClientId(), message);

        throw new ValidatorException(new FacesMessage(
                FacesMessage.SEVERITY_ERROR, component.getClientId(),
                "Titel existiert schon:" + titel));
    }
}
项目:odp-manage-datasets-portlet    文件:ManageController.java   
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;
    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();
        }
    }

}
项目: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);
    }

}
项目: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);
}
项目:liferay-oidc-plugin    文件:Liferay62Adapter.java   
@Override
public String getPortalProperty(String propertyKey) {
    return PropsUtil.get(propertyKey);
}
项目:liferay-oidc-plugin    文件:Liferay62Adapter.java   
@Override
public String getPortalProperty(String propertyKey, String defaultString) {
    return GetterUtil.getString(PropsUtil.get(propertyKey), defaultString);
}
项目:liferay-oidc-plugin    文件:Liferay62Adapter.java   
@Override
public boolean getPortalProperty(String propertyKey, boolean defaultBoolean) {
    return GetterUtil.getBoolean(PropsUtil.get(propertyKey), defaultBoolean);
}
项目:liferay-oidc-plugin    文件:Liferay70Adapter.java   
@Override
public String getPortalProperty(String propertyKey) {
    return PropsUtil.get(propertyKey);
}
项目:liferay-oidc-plugin    文件:Liferay70Adapter.java   
@Override
public String getPortalProperty(String propertyKey, String defaultString) {
    return GetterUtil.getString(PropsUtil.get(propertyKey), defaultString);
}