Example usage for com.liferay.portal.kernel.util PropsUtil get

List of usage examples for com.liferay.portal.kernel.util PropsUtil get

Introduction

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

Prototype

public static String get(String key) 

Source Link

Usage

From source file:br.com.seatecnologia.treinamento.service.ClpSerializer.java

License:Open Source License

public static String getServletContextName() {
    if (Validator.isNotNull(_servletContextName)) {
        return _servletContextName;
    }//from   www  .j av  a  2s .c  o  m

    synchronized (ClpSerializer.class) {
        if (Validator.isNotNull(_servletContextName)) {
            return _servletContextName;
        }

        try {
            ClassLoader classLoader = ClpSerializer.class.getClassLoader();

            Class<?> portletPropsClass = classLoader.loadClass("com.liferay.util.portlet.PortletProps");

            Method getMethod = portletPropsClass.getMethod("get", new Class<?>[] { String.class });

            String portletPropsServletContextName = (String) getMethod.invoke(null,
                    "agencia-modelos-portlet-deployment-context");

            if (Validator.isNotNull(portletPropsServletContextName)) {
                _servletContextName = portletPropsServletContextName;
            }
        } catch (Throwable t) {
            if (_log.isInfoEnabled()) {
                _log.info("Unable to locate deployment context from portlet properties");
            }
        }

        if (Validator.isNull(_servletContextName)) {
            try {
                String propsUtilServletContextName = PropsUtil
                        .get("agencia-modelos-portlet-deployment-context");

                if (Validator.isNotNull(propsUtilServletContextName)) {
                    _servletContextName = propsUtilServletContextName;
                }
            } catch (Throwable t) {
                if (_log.isInfoEnabled()) {
                    _log.info("Unable to locate deployment context from portal properties");
                }
            }
        }

        if (Validator.isNull(_servletContextName)) {
            _servletContextName = "agencia-modelos-portlet";
        }

        return _servletContextName;
    }
}

From source file:br.com.thiagomoreira.liferay.plugins.fixvirtualhost.FixVirtualHostAction.java

License:Apache License

private void doRun(final long companyId) throws Exception {
    final String virtualHostOldPrefix = PropsUtil.get("virtual.host.old.prefix");
    final String virtualHostNewPrefix = PropsUtil.get("virtual.host.new.prefix");

    if (Validator.isNotNull(virtualHostOldPrefix) && !virtualHostOldPrefix.equals(virtualHostNewPrefix)) {
        Company company = CompanyLocalServiceUtil.getCompany(companyId);

        String companyVirtualHost = company.getVirtualHostname();
        companyVirtualHost = fixVirtualHost(companyVirtualHost, virtualHostOldPrefix, virtualHostNewPrefix);

        if (Validator.isNotNull(companyVirtualHost)) {
            log.info("Updating company virtual host to: " + companyVirtualHost);

            CompanyLocalServiceUtil.updateCompany(companyId, companyVirtualHost, company.getMx(),
                    company.getMaxUsers(), company.getActive());
        }/*from   w w  w. j a v a 2s  .c  o m*/

        GroupActionableDynamicQuery actionableDynamicQuery = new GroupActionableDynamicQuery() {

            @Override
            protected void performAction(Object object) throws PortalException, SystemException {
                Group group = (Group) object;

                LayoutSet layoutSet = group.getPublicLayoutSet();

                if (layoutSet != null) {
                    String layoutVirtualHost = layoutSet.getVirtualHostname();
                    layoutVirtualHost = fixVirtualHost(layoutVirtualHost, virtualHostOldPrefix,
                            virtualHostNewPrefix);

                    if (Validator.isNotNull(layoutVirtualHost)) {
                        log.info("Updating layout virtual host to: " + layoutVirtualHost);

                        LayoutSetLocalServiceUtil.updateVirtualHost(group.getGroupId(), false,
                                layoutVirtualHost);
                    }
                }

                layoutSet = group.getPrivateLayoutSet();

                if (layoutSet != null) {
                    String layoutVirtualHost = layoutSet.getVirtualHostname();
                    layoutVirtualHost = fixVirtualHost(layoutVirtualHost, virtualHostOldPrefix,
                            virtualHostNewPrefix);

                    if (Validator.isNotNull(layoutVirtualHost)) {
                        log.info("Updating layout virtual host to: " + layoutVirtualHost);

                        LayoutSetLocalServiceUtil.updateVirtualHost(group.getGroupId(), true,
                                layoutVirtualHost);
                    }
                }
            }

            @Override
            protected void addCriteria(DynamicQuery dynamicQuery) {
                Property property = PropertyFactoryUtil.forName("site");

                dynamicQuery.add(property.eq(true));
            }
        };

        actionableDynamicQuery.setCompanyId(companyId);
        actionableDynamicQuery.performActions();
    } else {
        log.info("Skiiping executing due properties values virtual.host.old.prefix=" + virtualHostOldPrefix
                + " and virtual.host.new.prefix=" + virtualHostNewPrefix);
    }
}

From source file:br.com.thiagomoreira.liferay.plugins.notfound.services.service.ClpSerializer.java

License:Apache License

public static String getServletContextName() {
    if (Validator.isNotNull(_servletContextName)) {
        return _servletContextName;
    }//from w ww .ja va2s.  c  o  m

    synchronized (ClpSerializer.class) {
        if (Validator.isNotNull(_servletContextName)) {
            return _servletContextName;
        }

        try {
            ClassLoader classLoader = ClpSerializer.class.getClassLoader();

            Class<?> portletPropsClass = classLoader.loadClass("com.liferay.util.portlet.PortletProps");

            Method getMethod = portletPropsClass.getMethod("get", new Class<?>[] { String.class });

            String portletPropsServletContextName = (String) getMethod.invoke(null,
                    "not-found-services-web-deployment-context");

            if (Validator.isNotNull(portletPropsServletContextName)) {
                _servletContextName = portletPropsServletContextName;
            }
        } catch (Throwable t) {
            if (_log.isInfoEnabled()) {
                _log.info("Unable to locate deployment context from portlet properties");
            }
        }

        if (Validator.isNull(_servletContextName)) {
            try {
                String propsUtilServletContextName = PropsUtil.get("not-found-services-web-deployment-context");

                if (Validator.isNotNull(propsUtilServletContextName)) {
                    _servletContextName = propsUtilServletContextName;
                }
            } catch (Throwable t) {
                if (_log.isInfoEnabled()) {
                    _log.info("Unable to locate deployment context from portal properties");
                }
            }
        }

        if (Validator.isNull(_servletContextName)) {
            _servletContextName = "not-found-services-web";
        }

        return _servletContextName;
    }
}

From source file:br.gov.demoiselle.portal.evento.service.ClpSerializer.java

License:Open Source License

public static String getServletContextName() {
    if (Validator.isNotNull(_servletContextName)) {
        return _servletContextName;
    }//from  w  ww .j a  va2  s .c  o  m

    synchronized (ClpSerializer.class) {
        if (Validator.isNotNull(_servletContextName)) {
            return _servletContextName;
        }

        try {
            ClassLoader classLoader = ClpSerializer.class.getClassLoader();

            Class<?> portletPropsClass = classLoader.loadClass("com.liferay.util.portlet.PortletProps");

            Method getMethod = portletPropsClass.getMethod("get", new Class<?>[] { String.class });

            String portletPropsServletContextName = (String) getMethod.invoke(null,
                    "eventos-demoiselle-portlet-deployment-context");

            if (Validator.isNotNull(portletPropsServletContextName)) {
                _servletContextName = portletPropsServletContextName;
            }
        } catch (Throwable t) {
            if (_log.isInfoEnabled()) {
                _log.info("Unable to locate deployment context from portlet properties");
            }
        }

        if (Validator.isNull(_servletContextName)) {
            try {
                String propsUtilServletContextName = PropsUtil
                        .get("eventos-demoiselle-portlet-deployment-context");

                if (Validator.isNotNull(propsUtilServletContextName)) {
                    _servletContextName = propsUtilServletContextName;
                }
            } catch (Throwable t) {
                if (_log.isInfoEnabled()) {
                    _log.info("Unable to locate deployment context from portal properties");
                }
            }
        }

        if (Validator.isNull(_servletContextName)) {
            _servletContextName = "eventos-demoiselle-portlet";
        }

        return _servletContextName;
    }
}

From source file:br.ufpe.cin.da.salada.service.ClpSerializer.java

License:Open Source License

public static String getServletContextName() {
    if (Validator.isNotNull(_servletContextName)) {
        return _servletContextName;
    }//w ww.  j  a  va  2s .c o m

    synchronized (ClpSerializer.class) {
        if (Validator.isNotNull(_servletContextName)) {
            return _servletContextName;
        }

        try {
            ClassLoader classLoader = ClpSerializer.class.getClassLoader();

            Class<?> portletPropsClass = classLoader.loadClass("com.liferay.util.portlet.PortletProps");

            Method getMethod = portletPropsClass.getMethod("get", new Class<?>[] { String.class });

            String portletPropsServletContextName = (String) getMethod.invoke(null,
                    "salada-portlet-deployment-context");

            if (Validator.isNotNull(portletPropsServletContextName)) {
                _servletContextName = portletPropsServletContextName;
            }
        } catch (Throwable t) {
            if (_log.isInfoEnabled()) {
                _log.info("Unable to locate deployment context from portlet properties");
            }
        }

        if (Validator.isNull(_servletContextName)) {
            try {
                String propsUtilServletContextName = PropsUtil.get("salada-portlet-deployment-context");

                if (Validator.isNotNull(propsUtilServletContextName)) {
                    _servletContextName = propsUtilServletContextName;
                }
            } catch (Throwable t) {
                if (_log.isInfoEnabled()) {
                    _log.info("Unable to locate deployment context from portal properties");
                }
            }
        }

        if (Validator.isNull(_servletContextName)) {
            _servletContextName = "salada-portlet";
        }

        return _servletContextName;
    }
}

From source file:by.cnb.liferay.portlet.collapsableadvert.service.ClpSerializer.java

License:Open Source License

public static String getServletContextName() {
    if (Validator.isNotNull(_servletContextName)) {
        return _servletContextName;
    }/*from   ww  w.  ja v  a2  s . com*/

    synchronized (ClpSerializer.class) {
        if (Validator.isNotNull(_servletContextName)) {
            return _servletContextName;
        }

        try {
            ClassLoader classLoader = ClpSerializer.class.getClassLoader();

            Class<?> portletPropsClass = classLoader.loadClass("com.liferay.util.portlet.PortletProps");

            Method getMethod = portletPropsClass.getMethod("get", new Class<?>[] { String.class });

            String portletPropsServletContextName = (String) getMethod.invoke(null,
                    "collapsable-advert-portlet-deployment-context");

            if (Validator.isNotNull(portletPropsServletContextName)) {
                _servletContextName = portletPropsServletContextName;
            }
        } catch (Throwable t) {
            if (_log.isInfoEnabled()) {
                _log.info("Unable to locate deployment context from portlet properties");
            }
        }

        if (Validator.isNull(_servletContextName)) {
            try {
                String propsUtilServletContextName = PropsUtil
                        .get("collapsable-advert-portlet-deployment-context");

                if (Validator.isNotNull(propsUtilServletContextName)) {
                    _servletContextName = propsUtilServletContextName;
                }
            } catch (Throwable t) {
                if (_log.isInfoEnabled()) {
                    _log.info("Unable to locate deployment context from portal properties");
                }
            }
        }

        if (Validator.isNull(_servletContextName)) {
            _servletContextName = "collapsable-advert-portlet";
        }

        return _servletContextName;
    }
}

From source file:ca.queensu.res.soar.portlet.service.ClpSerializer.java

License:Open Source License

public static String getServletContextName() {
    if (Validator.isNotNull(_servletContextName)) {
        return _servletContextName;
    }//from  w w  w .  j  av  a  2s.  c om

    synchronized (ClpSerializer.class) {
        if (Validator.isNotNull(_servletContextName)) {
            return _servletContextName;
        }

        try {
            ClassLoader classLoader = ClpSerializer.class.getClassLoader();

            Class<?> portletPropsClass = classLoader.loadClass("com.liferay.util.portlet.PortletProps");

            Method getMethod = portletPropsClass.getMethod("get", new Class<?>[] { String.class });

            String portletPropsServletContextName = (String) getMethod.invoke(null,
                    "SOAR2-portlet-deployment-context");

            if (Validator.isNotNull(portletPropsServletContextName)) {
                _servletContextName = portletPropsServletContextName;
            }
        } catch (Throwable t) {
            if (_log.isInfoEnabled()) {
                _log.info("Unable to locate deployment context from portlet properties");
            }
        }

        if (Validator.isNull(_servletContextName)) {
            try {
                String propsUtilServletContextName = PropsUtil.get("SOAR2-portlet-deployment-context");

                if (Validator.isNotNull(propsUtilServletContextName)) {
                    _servletContextName = propsUtilServletContextName;
                }
            } catch (Throwable t) {
                if (_log.isInfoEnabled()) {
                    _log.info("Unable to locate deployment context from portal properties");
                }
            }
        }

        if (Validator.isNull(_servletContextName)) {
            _servletContextName = "SOAR2-portlet";
        }

        return _servletContextName;
    }
}

From source file:calportlet.service.ClpSerializer.java

License:Open Source License

public static String getServletContextName() {
    if (Validator.isNotNull(_servletContextName)) {
        return _servletContextName;
    }//from  w  w w . ja  v a  2  s.c o m

    synchronized (ClpSerializer.class) {
        if (Validator.isNotNull(_servletContextName)) {
            return _servletContextName;
        }

        try {
            ClassLoader classLoader = ClpSerializer.class.getClassLoader();

            Class<?> portletPropsClass = classLoader.loadClass("com.liferay.util.portlet.PortletProps");

            Method getMethod = portletPropsClass.getMethod("get", new Class<?>[] { String.class });

            String portletPropsServletContextName = (String) getMethod.invoke(null,
                    "academic-calendar-portlet-deployment-context");

            if (Validator.isNotNull(portletPropsServletContextName)) {
                _servletContextName = portletPropsServletContextName;
            }
        } catch (Throwable t) {
            if (_log.isInfoEnabled()) {
                _log.info("Unable to locate deployment context from portlet properties");
            }
        }

        if (Validator.isNull(_servletContextName)) {
            try {
                String propsUtilServletContextName = PropsUtil
                        .get("academic-calendar-portlet-deployment-context");

                if (Validator.isNotNull(propsUtilServletContextName)) {
                    _servletContextName = propsUtilServletContextName;
                }
            } catch (Throwable t) {
                if (_log.isInfoEnabled()) {
                    _log.info("Unable to locate deployment context from portal properties");
                }
            }
        }

        if (Validator.isNull(_servletContextName)) {
            _servletContextName = "academic-calendar-portlet";
        }

        return _servletContextName;
    }
}

From source file:ch.inofix.referencemanager.service.impl.ReferenceLocalServiceImpl.java

License:Open Source License

@Indexable(type = IndexableType.REINDEX)
@Override/* w w  w  . j  ava  2 s  . co  m*/
public Reference addReference(long userId, String bibTeX, long[] bibliographyIds, ServiceContext serviceContext)
        throws PortalException {

    // Reference

    User user = userPersistence.findByPrimaryKey(userId);

    long groupId = serviceContext.getScopeGroupId();

    long companyId = user.getCompanyId();

    long referenceId = counterLocalService.increment();

    Reference reference = referencePersistence.create(referenceId);

    reference.setUuid(serviceContext.getUuid());
    reference.setGroupId(groupId);
    reference.setCompanyId(companyId);
    reference.setUserId(user.getUserId());
    reference.setUserName(user.getFullName());
    reference.setExpandoBridgeAttributes(serviceContext);

    BibTeXEntry bibTeXEntry = BibTeXUtil.getBibTeXEntry(bibTeX);
    if (bibTeXEntry != null) {
        Key key = new Key("bibshare-id");
        Value value = new StringValue(String.valueOf(referenceId), Style.QUOTED);
        bibTeXEntry.addField(key, value);
    } else {
        // TODO: raise an error and report to the user that something is
        // wrong with the bibtex-src.
    }

    bibTeX = BibTeXUtil.format(bibTeXEntry);

    reference.setBibTeX(bibTeX);

    referencePersistence.update(reference);

    // Match user and group references against common references

    long defaultGroupId = GetterUtil.getLong(PropsUtil.get("default.group.id"));

    if (reference.getGroupId() != defaultGroupId) {

        match(reference);

    }

    // BibRefRelation

    for (long bibliographyId : bibliographyIds) {

        Bibliography bibliography = bibliographyLocalService.getBibliography(bibliographyId);

        long bibRefRelationId = counterLocalService.increment();
        BibRefRelation bibRefRelation = bibRefRelationPersistence.create(bibRefRelationId);

        bibRefRelation.setGroupId(bibliography.getGroupId());
        bibRefRelation.setCompanyId(bibliography.getCompanyId());
        bibRefRelation.setUserId(bibliography.getUserId());
        bibRefRelation.setUserName(bibliography.getUserName());

        bibRefRelation.setBibliographyId(bibliography.getBibliographyId());
        bibRefRelation.setReferenceId(referenceId);

        bibRefRelationPersistence.update(bibRefRelation);

    }

    // Resources

    resourceLocalService.addModelResources(reference, serviceContext);

    // Asset

    updateAsset(userId, reference, serviceContext.getAssetCategoryIds(), serviceContext.getAssetTagNames(),
            serviceContext.getAssetLinkEntryIds(), serviceContext.getAssetPriority());

    // Social

    JSONObject extraDataJSONObject = JSONFactoryUtil.createJSONObject();

    extraDataJSONObject.put("title", reference.getCitation());

    socialActivityLocalService.addActivity(userId, groupId, Reference.class.getName(), referenceId,
            ReferenceActivityKeys.ADD_REFERENCE, extraDataJSONObject.toString(), 0);

    return reference;

}

From source file:ch.inofix.referencemanager.service.impl.ReferenceLocalServiceImpl.java

License:Open Source License

public void match(Reference reference) throws PortalException {

    _log.info("match");

    long defaultGroupId = GetterUtil.getLong(PropsUtil.get("default.group.id"));

    Hits hits = search(reference.getUserId(), defaultGroupId, -1, null, reference.getTitle(), null,
            WorkflowConstants.STATUS_ANY, null, false, 0, 20, null);

    _log.info("hits.getLength() = " + hits.getLength());

    if (hits.getLength() == 0) {

        // not yet in the pool of common references

        _log.info("not yet in the global references ");

        // TODO: strip the private fields from the reference
        String bibTeX = reference.getBibTeX();

        ServiceContext serviceContext = new ServiceContext();
        serviceContext.setScopeGroupId(defaultGroupId);

        Reference globalReference = addReference(reference.getUserId(), bibTeX, serviceContext);

        refRefRelationLocalService.addRefRefRelation(reference.getUserId(), globalReference.getReferenceId(),
                reference.getReferenceId(), new ServiceContext());
    }/*ww w  .j  a va  2 s  .  co m*/
}