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

项目:data-manipulator    文件:SiteHandler.java   
public SiteHandler() throws Exception {
    super("Site", "site");

    ClassLoader portalClassLoader = PortalClassLoaderUtil.getClassLoader();

    updateLayoutSetPrototypesLinksClass = portalClassLoader.loadClass(
        "com.liferay.sites.kernel.util.SitesUtil");

    updateLayoutSetPrototypesLinksMethod =
        updateLayoutSetPrototypesLinksClass.getMethod(
            "updateLayoutSetPrototypesLinks",
            new Class<?>[] {
                Group.class, Long.TYPE, Long.TYPE, Boolean.TYPE,
                Boolean.TYPE
            });
}
项目:servicebuilder-reflection    文件:ServiceUtil.java   
@SuppressWarnings("unchecked")
protected static Class<? extends ClassedModel> getClassModelFromPortal(
    String className) {

    try {
        return (Class<? extends ClassedModel>)
            PortalClassLoaderUtil.getClassLoader().loadClass(className);
    }
    catch (ClassNotFoundException e) {
        if (_log.isDebugEnabled()) {
            _log.debug("ClassModel not found: " + className);
        }

        return null;
    }
}
项目:liferaylms-portlet    文件:CourseLocalServiceImpl.java   
@SuppressWarnings("unchecked")
public boolean existsCourseName(Long companyId, Long courseId, String groupName) throws SystemException, PortalException {

    DynamicQuery consulta = DynamicQueryFactoryUtil.forClass(Group.class, PortalClassLoaderUtil.getClassLoader());
    consulta.add(PropertyFactoryUtil.forName("name").eq(groupName));
    consulta.add(PropertyFactoryUtil.forName("companyId").eq(companyId));
    if (courseId != null) {
        Course course = CourseLocalServiceUtil.getCourse(courseId);
        consulta.add(PropertyFactoryUtil.forName("groupId").ne(course.getGroupCreatedId()));
    }

    List<Group> list = (List<Group>)GroupLocalServiceUtil.dynamicQuery(consulta);

    if(!list.isEmpty() && list.size() > 0){
        return true;
    }

    return false;
}
项目:edemocracia    文件:DashboardLocalServiceImpl.java   
/**
 * Lista todas as comunidades públicas, privadas e restritas da companhia
 * 
 * @throws SystemException
 */
@SuppressWarnings("unchecked")
public List<Group> getComunidadesDisponiveis(final long companyId) throws SystemException {

    final long groupClassNameId = ClassNameLocalServiceUtil.getClassNameId(Group.class);

    final DynamicQuery query = DynamicQueryFactoryUtil.forClass(Group.class, PortalClassLoaderUtil.getClassLoader());
    query.add(RestrictionsFactoryUtil.eq("companyId", companyId));
    query.add(RestrictionsFactoryUtil.eq("classNameId", groupClassNameId));
    query.add(RestrictionsFactoryUtil.in("type", new Object[] { GroupConstants.TYPE_SITE_OPEN, GroupConstants.TYPE_SITE_PRIVATE,
            GroupConstants.TYPE_SITE_RESTRICTED }));
    query.add(RestrictionsFactoryUtil.eq("parentGroupId", GroupConstants.DEFAULT_PARENT_GROUP_ID));
    query.add(RestrictionsFactoryUtil.eq("active", true));
    query.add(RestrictionsFactoryUtil.ne("name", GroupConstants.CONTROL_PANEL));
    query.addOrder(OrderFactoryUtil.asc("name"));

    return (List<Group>) GroupLocalServiceUtil.dynamicQuery(query);
}
项目:edemocracia    文件:ChatRoomLocalServiceImpl.java   
/**
 * Verifica se há usuários no portal com o mesmo fullname
 * 
 * @param fullName
 * @return
 */
@SuppressWarnings("unchecked")
public boolean isFullNameInUseInPortal(long companyId, String fullName) {
    FullNameGenerator fullNameGenerator = new DefaultFullNameGenerator();
    String[] name = fullNameGenerator.splitFullName(fullName);

    DynamicQuery query = DynamicQueryFactoryUtil.forClass(User.class, PortalClassLoaderUtil.getClassLoader());
    query.setProjection(ProjectionFactoryUtil.property("userId"));
    query.add(PropertyFactoryUtil.forName("companyId").eq(companyId));
    query.add(PropertyFactoryUtil.forName("firstName").eq(name[0]));
    query.add(PropertyFactoryUtil.forName("middleName").eq(name[1]));
    query.add(PropertyFactoryUtil.forName("lastName").eq(name[2]));

    List<Long> list = null;

    try {
        list = UserLocalServiceUtil.dynamicQuery(query);
    } catch (SystemException e) {
        LOG.error(e);
    }

    return list != null && !list.isEmpty();
}
项目:edemocracia    文件:ContadorAcessoLocalServiceImpl.java   
/**
 * Lista todas as comunidades públicas, privadas e restritas da companhia
 * 
 * @throws SystemException
 */
private List<Group> getComunidades(long companyId) throws SystemException {

    long groupClassNameId = ClassNameLocalServiceUtil
            .getClassNameId(Group.class);

    DynamicQuery query = DynamicQueryFactoryUtil.forClass(Group.class,
            PortalClassLoaderUtil.getClassLoader());
    query.add(RestrictionsFactoryUtil.eq("companyId", companyId));
    query.add(RestrictionsFactoryUtil.eq("classNameId", groupClassNameId));
    query.add(RestrictionsFactoryUtil.in("type", new Object[] {
            GroupConstants.TYPE_SITE_OPEN,
            GroupConstants.TYPE_SITE_PRIVATE,
            GroupConstants.TYPE_SITE_RESTRICTED }));
    query.add(RestrictionsFactoryUtil.eq("parentGroupId",
            GroupConstants.DEFAULT_PARENT_GROUP_ID));
    query.add(RestrictionsFactoryUtil.eq("active", true));
    query.add(RestrictionsFactoryUtil.ne("name",
            GroupConstants.CONTROL_PANEL));
    query.addOrder(OrderFactoryUtil.asc("name"));

    @SuppressWarnings("unchecked")
    List<Group> ret = GroupLocalServiceUtil.dynamicQuery(query);
    return ret;
}
项目:edemocracia    文件:ParticipacaoLocalServiceImpl.java   
/**
 * Lista todas as comunidades públicas, privadas e restritas da companhia
 * 
 * @throws SystemException
 */
@SuppressWarnings("unchecked")
public List<Group> getComunidadesDisponiveis(final long companyId)
        throws SystemException {

    final long groupClassNameId = ClassNameLocalServiceUtil
            .getClassNameId(Group.class);

    final DynamicQuery query = DynamicQueryFactoryUtil.forClass(
            Group.class, PortalClassLoaderUtil.getClassLoader());
    query.add(RestrictionsFactoryUtil.eq("companyId", companyId));
    query.add(RestrictionsFactoryUtil.eq("classNameId", groupClassNameId));
    query.add(RestrictionsFactoryUtil.in("type", new Object[] {
            GroupConstants.TYPE_SITE_OPEN,
            GroupConstants.TYPE_SITE_PRIVATE,
            GroupConstants.TYPE_SITE_RESTRICTED }));
    query.add(RestrictionsFactoryUtil.eq("parentGroupId",
            GroupConstants.DEFAULT_PARENT_GROUP_ID));
    query.add(RestrictionsFactoryUtil.eq("active", true));
    query.add(RestrictionsFactoryUtil.ne("name",
            GroupConstants.CONTROL_PANEL));
    query.addOrder(OrderFactoryUtil.asc("name"));

    return (List<Group>) GroupLocalServiceUtil.dynamicQuery(query);
}
项目:servicebuilder-reflection    文件:ServiceUtil.java   
protected static Class<?> getJavaClass(
        ClassLoader classloader, String className)
    throws ClassNotFoundException {

    Class<?> clazz = null;

    if (Validator.isNull(className)) {
        className = StringPool.NULL;
    }

    try {
        clazz = PortalClassLoaderUtil.getClassLoader().loadClass(className);
    }
    catch (ClassNotFoundException e) {
    }

    if ((clazz == null) && (classloader != null)) {
        clazz = classloader.loadClass(className);
    }

    if (_log.isDebugEnabled()) {
        _log.debug(
            "loaded class: " + clazz + " from classloader: " + classloader);
    }

    return clazz;
}
项目:liferaylms-portlet    文件:CourseDiplomaRegistry.java   
private static ClassLoader getPortletClassLoader() {
    if(_portletClassLoader==null) {
        ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
        if(currentClassLoader.equals(PortalClassLoaderUtil.getClassLoader())) {
            _portletClassLoader=PortletClassLoaderUtil.getClassLoader(LMS_ACTIVITIES_LIST_PORTLET_ID);
        }
        else {
            _portletClassLoader=currentClassLoader;
        }
    }
    return _portletClassLoader;
}
项目:liferaylms-portlet    文件:CalificationTypeRegistry.java   
private static ClassLoader getPortletClassLoader() {
    if(_portletClassLoader==null) {
        ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
        if(currentClassLoader.equals(PortalClassLoaderUtil.getClassLoader())) {
            _portletClassLoader=PortletClassLoaderUtil.getClassLoader(LMS_ACTIVITIES_LIST_PORTLET_ID);
        }
        else {
            _portletClassLoader=currentClassLoader;
        }
    }
    return _portletClassLoader;
}
项目:liferaylms-portlet    文件:CourseEvalRegistry.java   
private static ClassLoader getPortletClassLoader() {
    if(_portletClassLoader==null) {
        ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
        if(currentClassLoader.equals(PortalClassLoaderUtil.getClassLoader())) {
            _portletClassLoader=PortletClassLoaderUtil.getClassLoader(LMS_ACTIVITIES_LIST_PORTLET_ID);
        }
        else {
            _portletClassLoader=currentClassLoader;
        }
    }
    return _portletClassLoader;
}
项目:liferaylms-portlet    文件:DescriptionFilterRegistry.java   
private static ClassLoader getPortletClassLoader() {
    if(_portletClassLoader==null) {
        ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
        if(currentClassLoader.equals(PortalClassLoaderUtil.getClassLoader())) {
            _portletClassLoader=PortletClassLoaderUtil.getClassLoader(LMS_ACTIVITIES_LIST_PORTLET_ID);
        }
        else {
            _portletClassLoader=currentClassLoader;
        }
    }
    return _portletClassLoader;
}
项目:liferaylms-portlet    文件:LearningActivityTypeRegistry.java   
private static ClassLoader getPortletClassLoader() {
    if(_portletClassLoader==null) {
        ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
        if(currentClassLoader.equals(PortalClassLoaderUtil.getClassLoader())) {
            _portletClassLoader=PortletClassLoaderUtil.getClassLoader(LMS_ACTIVITIES_LIST_PORTLET_ID);
        }
        else {
            _portletClassLoader=currentClassLoader;
        }
    }
    return _portletClassLoader;
}
项目:liferaylms-portlet    文件:LearningActivityClp.java   
public void setTitleMap(Map<Locale, String> titleMap, Locale defaultLocale) {
    if (titleMap == null) {
        return;
    }

    ClassLoader portalClassLoader = PortalClassLoaderUtil.getClassLoader();

    Thread currentThread = Thread.currentThread();

    ClassLoader contextClassLoader = currentThread.getContextClassLoader();

    try {
        if (contextClassLoader != portalClassLoader) {
            currentThread.setContextClassLoader(portalClassLoader);
        }

        Locale[] locales = LanguageUtil.getAvailableLocales();

        for (Locale locale : locales) {
            String title = titleMap.get(locale);

            setTitle(title, locale, defaultLocale);
        }
    }
    finally {
        if (contextClassLoader != portalClassLoader) {
            currentThread.setContextClassLoader(contextClassLoader);
        }
    }
}
项目:liferaylms-portlet    文件:LearningActivityClp.java   
public void setDescriptionMap(Map<Locale, String> descriptionMap,
    Locale defaultLocale) {
    if (descriptionMap == null) {
        return;
    }

    ClassLoader portalClassLoader = PortalClassLoaderUtil.getClassLoader();

    Thread currentThread = Thread.currentThread();

    ClassLoader contextClassLoader = currentThread.getContextClassLoader();

    try {
        if (contextClassLoader != portalClassLoader) {
            currentThread.setContextClassLoader(portalClassLoader);
        }

        Locale[] locales = LanguageUtil.getAvailableLocales();

        for (Locale locale : locales) {
            String description = descriptionMap.get(locale);

            setDescription(description, locale, defaultLocale);
        }
    }
    finally {
        if (contextClassLoader != portalClassLoader) {
            currentThread.setContextClassLoader(contextClassLoader);
        }
    }
}
项目:liferaylms-portlet    文件:CompetenceClp.java   
public void setTitleMap(Map<Locale, String> titleMap, Locale defaultLocale) {
    if (titleMap == null) {
        return;
    }

    ClassLoader portalClassLoader = PortalClassLoaderUtil.getClassLoader();

    Thread currentThread = Thread.currentThread();

    ClassLoader contextClassLoader = currentThread.getContextClassLoader();

    try {
        if (contextClassLoader != portalClassLoader) {
            currentThread.setContextClassLoader(portalClassLoader);
        }

        Locale[] locales = LanguageUtil.getAvailableLocales();

        for (Locale locale : locales) {
            String title = titleMap.get(locale);

            setTitle(title, locale, defaultLocale);
        }
    }
    finally {
        if (contextClassLoader != portalClassLoader) {
            currentThread.setContextClassLoader(contextClassLoader);
        }
    }
}
项目:liferaylms-portlet    文件:CompetenceClp.java   
public void setDescriptionMap(Map<Locale, String> descriptionMap,
    Locale defaultLocale) {
    if (descriptionMap == null) {
        return;
    }

    ClassLoader portalClassLoader = PortalClassLoaderUtil.getClassLoader();

    Thread currentThread = Thread.currentThread();

    ClassLoader contextClassLoader = currentThread.getContextClassLoader();

    try {
        if (contextClassLoader != portalClassLoader) {
            currentThread.setContextClassLoader(portalClassLoader);
        }

        Locale[] locales = LanguageUtil.getAvailableLocales();

        for (Locale locale : locales) {
            String description = descriptionMap.get(locale);

            setDescription(description, locale, defaultLocale);
        }
    }
    finally {
        if (contextClassLoader != portalClassLoader) {
            currentThread.setContextClassLoader(contextClassLoader);
        }
    }
}
项目:liferaylms-portlet    文件:CompetenceClp.java   
public void setDiplomaTemplateMap(Map<Locale, String> diplomaTemplateMap,
    Locale defaultLocale) {
    if (diplomaTemplateMap == null) {
        return;
    }

    ClassLoader portalClassLoader = PortalClassLoaderUtil.getClassLoader();

    Thread currentThread = Thread.currentThread();

    ClassLoader contextClassLoader = currentThread.getContextClassLoader();

    try {
        if (contextClassLoader != portalClassLoader) {
            currentThread.setContextClassLoader(portalClassLoader);
        }

        Locale[] locales = LanguageUtil.getAvailableLocales();

        for (Locale locale : locales) {
            String diplomaTemplate = diplomaTemplateMap.get(locale);

            setDiplomaTemplate(diplomaTemplate, locale, defaultLocale);
        }
    }
    finally {
        if (contextClassLoader != portalClassLoader) {
            currentThread.setContextClassLoader(contextClassLoader);
        }
    }
}
项目:liferaylms-portlet    文件:ModuleClp.java   
public void setTitleMap(Map<Locale, String> titleMap, Locale defaultLocale) {
    if (titleMap == null) {
        return;
    }

    ClassLoader portalClassLoader = PortalClassLoaderUtil.getClassLoader();

    Thread currentThread = Thread.currentThread();

    ClassLoader contextClassLoader = currentThread.getContextClassLoader();

    try {
        if (contextClassLoader != portalClassLoader) {
            currentThread.setContextClassLoader(portalClassLoader);
        }

        Locale[] locales = LanguageUtil.getAvailableLocales();

        for (Locale locale : locales) {
            String title = titleMap.get(locale);

            setTitle(title, locale, defaultLocale);
        }
    }
    finally {
        if (contextClassLoader != portalClassLoader) {
            currentThread.setContextClassLoader(contextClassLoader);
        }
    }
}
项目:liferaylms-portlet    文件:ModuleClp.java   
public void setDescriptionMap(Map<Locale, String> descriptionMap,
    Locale defaultLocale) {
    if (descriptionMap == null) {
        return;
    }

    ClassLoader portalClassLoader = PortalClassLoaderUtil.getClassLoader();

    Thread currentThread = Thread.currentThread();

    ClassLoader contextClassLoader = currentThread.getContextClassLoader();

    try {
        if (contextClassLoader != portalClassLoader) {
            currentThread.setContextClassLoader(portalClassLoader);
        }

        Locale[] locales = LanguageUtil.getAvailableLocales();

        for (Locale locale : locales) {
            String description = descriptionMap.get(locale);

            setDescription(description, locale, defaultLocale);
        }
    }
    finally {
        if (contextClassLoader != portalClassLoader) {
            currentThread.setContextClassLoader(contextClassLoader);
        }
    }
}
项目:liferaylms-portlet    文件:CourseClp.java   
public void setTitleMap(Map<Locale, String> titleMap, Locale defaultLocale) {
    if (titleMap == null) {
        return;
    }

    ClassLoader portalClassLoader = PortalClassLoaderUtil.getClassLoader();

    Thread currentThread = Thread.currentThread();

    ClassLoader contextClassLoader = currentThread.getContextClassLoader();

    try {
        if (contextClassLoader != portalClassLoader) {
            currentThread.setContextClassLoader(portalClassLoader);
        }

        Locale[] locales = LanguageUtil.getAvailableLocales();

        for (Locale locale : locales) {
            String title = titleMap.get(locale);

            setTitle(title, locale, defaultLocale);
        }
    }
    finally {
        if (contextClassLoader != portalClassLoader) {
            currentThread.setContextClassLoader(contextClassLoader);
        }
    }
}
项目:liferaylms-portlet    文件:CourseClp.java   
public void setDescriptionMap(Map<Locale, String> descriptionMap,
    Locale defaultLocale) {
    if (descriptionMap == null) {
        return;
    }

    ClassLoader portalClassLoader = PortalClassLoaderUtil.getClassLoader();

    Thread currentThread = Thread.currentThread();

    ClassLoader contextClassLoader = currentThread.getContextClassLoader();

    try {
        if (contextClassLoader != portalClassLoader) {
            currentThread.setContextClassLoader(portalClassLoader);
        }

        Locale[] locales = LanguageUtil.getAvailableLocales();

        for (Locale locale : locales) {
            String description = descriptionMap.get(locale);

            setDescription(description, locale, defaultLocale);
        }
    }
    finally {
        if (contextClassLoader != portalClassLoader) {
            currentThread.setContextClassLoader(contextClassLoader);
        }
    }
}
项目:liferaylms-portlet    文件:ActivityViewer.java   
@Override
public void init(PortletConfig config) throws PortletException {
    super.init(config);
    try {
        Class<?> publicRenderParametersPoolClass = PortalClassLoaderUtil.getClassLoader().loadClass("com.liferay.portlet.PublicRenderParametersPool");
        getPublicParameters = publicRenderParametersPoolClass.getMethod("get", HttpServletRequest.class, Long.TYPE);

        Class<?> componentContextClass = PortalClassLoaderUtil.getClassLoader().loadClass("org.apache.struts.tiles.ComponentContext");
        createComponentContext = componentContextClass.getConstructor(Map.class);
        getContext = componentContextClass.getMethod("getContext", ServletRequest.class);
        setContext = componentContextClass.getMethod("setContext",componentContextClass,ServletRequest.class);
    } catch (Throwable e) {
        throw new PortletException(e);
    }
}
项目:liferaylms-portlet    文件:modulePortlet.java   
public static Object invoke(
        boolean newInstance, String className, String methodName,
        String[] parameterTypeNames, Object... arguments)
                throws Exception {

    Thread currentThread = Thread.currentThread();

    ClassLoader contextClassLoader = currentThread.getContextClassLoader();

    try {
        currentThread.setContextClassLoader(
                PortalClassLoaderUtil.getClassLoader());

        MethodKey methodKey = new MethodKeyPatched(
                className, methodName, parameterTypeNames,
                PortalClassLoaderUtil.getClassLoader());

        MethodHandler methodHandler = new MethodHandler(
                methodKey, arguments);

        return methodHandler.invoke(newInstance);
    }
    catch (InvocationTargetException ite) {
        throw (Exception)ite.getCause();
    }
    finally {
        currentThread.setContextClassLoader(contextClassLoader);
    }
}
项目:liferaylms-portlet    文件:CourseFinderImpl.java   
public List<Group> getDistinctCourseGroups(long companyId){
    Session session = null;
    List<Group> distinctCourseGroups = new ArrayList<Group>();

    try{

        session = openSessionLiferay();

        String sql = CustomSQLUtil.get(GET_DISTINCT_COURSE_GROUPS);
        if(log.isDebugEnabled()){
            log.debug("sql: " + sql);
        }
        SQLQuery q = session.createSQLQuery(sql);
        q.addEntity("Group_",PortalClassLoaderUtil.getClassLoader().loadClass("com.liferay.portal.model.impl.GroupImpl"));

        QueryPos qPos = QueryPos.getInstance(q);            
        qPos.add(companyId);                
        distinctCourseGroups = (List<Group>)q.list();



    } catch (Exception e) {
       e.printStackTrace();
    } finally {
        closeSessionLiferay(session);
    }

    return distinctCourseGroups;
}
项目:liferaylms-portlet    文件:CourseFinderImpl.java   
private final Class<?> getPortalClass(String className) {
    ClassLoader portalCl = PortalClassLoaderUtil.getClassLoader();

    try {
        return portalCl.loadClass(className);
    } catch (ClassNotFoundException e) {
        throw new RuntimeException(e);
    }
}
项目:liferaylms-portlet    文件:LearningActivityFinderImpl.java   
private final Class<?> getPortalClass(String className) {
    ClassLoader portalCl = PortalClassLoaderUtil.getClassLoader();

    try {
        return portalCl.loadClass(className);
    } catch (ClassNotFoundException e) {
        throw new RuntimeException(e);
    }
}
项目:liferaylms-portlet    文件:LearningActivityAssetRendererFactory.java   
public LearningActivityAssetRendererFactory() throws SystemException {
    try {
            Class<?> assetPublisherUtilClass = PortalClassLoaderUtil.getClassLoader().loadClass("com.liferay.portlet.assetpublisher.util.AssetPublisherUtil");
            getGroupIds = assetPublisherUtilClass.getMethod("getGroupIds", PortletPreferences.class, Long.TYPE, Layout.class);
    } catch (Throwable e) {
        throw new SystemException(e);
    }
}
项目:liferaylms-portlet    文件:PortalClassInvokerPatched.java   
public static Object invoke(
                boolean newInstance, String className, String methodName,
                String[] parameterTypeNames, Object... arguments)
        throws Exception {

        Thread currentThread = Thread.currentThread();

        ClassLoader contextClassLoader = currentThread.getContextClassLoader();

        try {
                currentThread.setContextClassLoader(
                        PortalClassLoaderUtil.getClassLoader());

                MethodKey methodKey = new MethodKeyPatched(
                        className, methodName, parameterTypeNames,
                        PortalClassLoaderUtil.getClassLoader());

                MethodHandler methodHandler = new MethodHandler(
                        methodKey, arguments);

                return methodHandler.invoke(newInstance);
        }
        catch (InvocationTargetException ite) {
                throw (Exception)ite.getCause();
        }
        finally {
                currentThread.setContextClassLoader(contextClassLoader);
        }
}
项目:edemocracia    文件:ClassPathResourceUtil.java   
/**
 * Carrega um template, utilizando inicialmente o classloader local e, 
 * depois, o classloader do portal.
 * 
 * Caso não encontre nenhum arquivo, retorna uma string vazia
 * 
 * @param fileName
 * @return
 */
public static final String loadResource(String fileName) {
    ClassLoader clPortal = PortalClassLoaderUtil.getClassLoader();
    ClassLoader clThread = Thread.currentThread().getContextClassLoader();

    InputStream is = clThread.getResourceAsStream(fileName);
    if (is == null) {
        is = clPortal.getResourceAsStream(fileName);
        if (is == null)
            return "";
    }
    InputStreamReader reader = new InputStreamReader(is);
    try {
        char[] chr = new char[1024];
        StringBuilder sb = new StringBuilder();
        int readed;
        while ( (readed = reader.read(chr)) != -1) {
            sb.append(chr, 0, readed);
        }
        return sb.toString();
    } catch (IOException e) {
        _log.error(String.format("Erro recuperando template %s", fileName), e);
        return "";
    } finally {
        try {
            is.close();
        } catch (IOException ignore) {
        }
    }
}
项目:edemocracia    文件:OutrasComunidades.java   
@Override
protected List<Group> getComunidades(PortletRequest renderRequest, ThemeDisplay td) {
    List<Group> comunidades = Collections.<Group> emptyList();

    try {
        // Consulta feita na mão para evitar cache trashing
        DynamicQuery query = DynamicQueryFactoryUtil.forClass(Group.class, PortalClassLoaderUtil.getClassLoader());
        query.add(RestrictionsFactoryUtil.eq("companyId", td.getCompanyId()));
        query.add(RestrictionsFactoryUtil.eq("active", true));
        query.add(RestrictionsFactoryUtil.in("type", new Object[] {GroupConstants.TYPE_SITE_OPEN, GroupConstants.TYPE_SITE_RESTRICTED} ));
        query.add(RestrictionsFactoryUtil.not(RestrictionsFactoryUtil.in("name", new Object[] {GroupConstants.GUEST, GroupConstants.CONTROL_PANEL, ""})));
        query.add(RestrictionsFactoryUtil.ne("groupId", td.getScopeGroupId()));
        query.add(RestrictionsFactoryUtil.eq("classNameId", PortalUtil.getClassNameId(Group.class)));
        query.addOrder(OrderFactoryUtil.asc("name"));

        @SuppressWarnings("unchecked")
        List<Group> groups = GroupLocalServiceUtil.dynamicQuery(query) ;

        comunidades = new ArrayList<Group>(groups.size());
        for (Group grp : groups) {
            if (grp.getPublicLayoutsPageCount() != 0)
                comunidades.add(grp);
        }
    } catch (SystemException e) {
        _log.error(e);
    }
    return comunidades;
}
项目:edemocracia    文件:TodasComunidades.java   
private List<Group> getComunidadesAtivas(PortletRequest renderRequest, ThemeDisplay td) {

    List<Group> comunidades = Collections.<Group> emptyList();

    try {

        DynamicQuery query = DynamicQueryFactoryUtil.forClass(Group.class, PortalClassLoaderUtil.getClassLoader());
        query.add(RestrictionsFactoryUtil.eq("companyId", td.getCompanyId()));
        query.add(RestrictionsFactoryUtil.eq("active", true));
        query.add(RestrictionsFactoryUtil.in("type", new Object[] { GroupConstants.TYPE_SITE_OPEN, GroupConstants.TYPE_SITE_RESTRICTED }));
        query.add(RestrictionsFactoryUtil.not(RestrictionsFactoryUtil.in("name", new Object[] { GroupConstants.GUEST, GroupConstants.CONTROL_PANEL, "" })));
        // query.add(RestrictionsFactoryUtil.ne("groupId",
        // td.getScopeGroupId()));
        query.add(RestrictionsFactoryUtil.eq("classNameId", PortalUtil.getClassNameId(Group.class)));
        query.addOrder(OrderFactoryUtil.desc("name"));

        @SuppressWarnings("unchecked")
        List<Group> groups = GroupLocalServiceUtil.dynamicQuery(query);

        comunidades = new ArrayList<Group>(groups.size());

        for (Group grp : groups) {

        if (grp.getPublicLayoutsPageCount() != 0) {
            Boolean finished = (Boolean) grp.getExpandoBridge().getAttribute("Encerrada");
            if (finished == null || !finished)
            comunidades.add(grp);
        }

        }

    } catch (SystemException e) {
        _log.error(e);
    }

    return comunidades;
    }
项目:edemocracia    文件:TodasComunidades.java   
private List<Group> getComunidadesEncerradas(PortletRequest renderRequest, ThemeDisplay td) {

    List<Group> comunidades = Collections.<Group> emptyList();

    try {

        DynamicQuery query = DynamicQueryFactoryUtil.forClass(Group.class, PortalClassLoaderUtil.getClassLoader());
        query.add(RestrictionsFactoryUtil.eq("companyId", td.getCompanyId()));
        query.add(RestrictionsFactoryUtil.eq("active", true));
        query.add(RestrictionsFactoryUtil.in("type", new Object[] { GroupConstants.TYPE_SITE_OPEN, GroupConstants.TYPE_SITE_RESTRICTED }));
        query.add(RestrictionsFactoryUtil.not(RestrictionsFactoryUtil.in("name", new Object[] { GroupConstants.GUEST, GroupConstants.CONTROL_PANEL, "" })));
        // query.add(RestrictionsFactoryUtil.ne("groupId",
        // td.getScopeGroupId()));
        query.add(RestrictionsFactoryUtil.eq("classNameId", PortalUtil.getClassNameId(Group.class)));
        query.addOrder(OrderFactoryUtil.desc("name"));

        @SuppressWarnings("unchecked")
        List<Group> groups = GroupLocalServiceUtil.dynamicQuery(query);

        comunidades = new ArrayList<Group>(groups.size());

        for (Group grp : groups) {
        if (grp.getPublicLayoutsPageCount() != 0) {
            Boolean finished = (Boolean) grp.getExpandoBridge().getAttribute("Encerrada");
            if (finished != null && finished)
            comunidades.add(grp);
        }
        }

    } catch (SystemException e) {
        _log.error(e);
    }

    return comunidades;
    }
项目:Discussion-Board-Liferay    文件:CustomThreadCategoryList.java   
/**
 * Method that get list of banned users
 */
public static List<MBBan> getBannedUsersList(HttpServletRequest request) throws PortalException{
    _log.debug("Entry:getBannedUsersList");
    ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
    List<MBBan> banUsersList=MBBanLocalServiceUtil.getBans(themeDisplay.getScopeGroupId(),QueryUtil.ALL_POS, QueryUtil.ALL_POS);
    List<MBBan> banUsersSelectedCategoryList=new ArrayList<>();
    Map<MBBan,Long> catUserMap=new HashMap<MBBan,Long>();
    PortletPreferences preferences = PortletPreferencesFactoryUtil.getLayoutPortletSetup(themeDisplay.getLayout(), CustomConstants.MESSAGE_BOARDS);
    long preferenceCatId=GetterUtil.getLong(preferences.getValue(CustomConstants.PREFERENCE_CATEGORYID, String.valueOf(QueryUtil.ALL_POS)));
    List<Long> preferenceCatList=new ArrayList<Long>();
    if(preferenceCatId != QueryUtil.ALL_POS){
        preferenceCatList=getPreferenceCatChildList(preferenceCatId,request);
    }
    for(MBBan banUser:banUsersList){
        DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(MBThread.class, PortalClassLoaderUtil.getClassLoader());
        dynamicQuery.add(PropertyFactoryUtil.forName(CustomConstants.USERID).eq(banUser.getBanUserId()));
        Projection projection=ProjectionFactoryUtil.distinct(ProjectionFactoryUtil.property(CustomConstants.THREAD_CATEGORYID));
        dynamicQuery.setProjection(projection);
         List<Long> categories=MBThreadLocalServiceUtil.dynamicQuery(dynamicQuery);
         for(Long cat:categories){
             catUserMap.put(banUser, cat);
         }
    }
    banUsersSelectedCategoryList=getBanUerList(catUserMap,preferenceCatList,banUsersSelectedCategoryList);

    return banUsersSelectedCategoryList;

}
项目:data-manipulator    文件:GetterUtil.java   
public static Class<?> getClass(String className)
    throws ClassNotFoundException {

    return Class.forName(
        className, false, PortalClassLoaderUtil.getClassLoader());
}
项目:edemocracia    文件:DadosForumServiceImpl.java   
private List<Group> getGroups(long groupId) throws SystemException {
    DynamicQuery query = DynamicQueryFactoryUtil.forClass(GroupModel.class, PortalClassLoaderUtil.getClassLoader()).addOrder(OrderFactoryUtil.asc("groupId"));
    query.add(RestrictionsFactoryUtil.or(PropertyFactoryUtil.forName("groupId").eq(groupId), PropertyFactoryUtil.forName("parentGroupId").eq(groupId)));

    return (List<Group>) GroupLocalServiceUtil.dynamicQuery(query);
}