Example usage for com.liferay.portal.kernel.util ClassUtil getClassName

List of usage examples for com.liferay.portal.kernel.util ClassUtil getClassName

Introduction

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

Prototype

public static String getClassName(Object object) 

Source Link

Usage

From source file:com.liferay.item.selector.BaseItemSelectorCriterionHandler.java

License:Open Source License

private boolean _isItemSelectorViewSupported(ItemSelectorView itemSelectorView,
        ItemSelectorReturnType itemSelectorReturnType) {

    String itemSelectorReturnTypeClassName = ClassUtil.getClassName(itemSelectorReturnType);

    List<ItemSelectorReturnType> supportedItemSelectorReturnTypes = null;

    ItemSelectorViewReturnTypeProviderHandler itemSelectorViewReturnTypeProviderHandler = _serviceTracker
            .getService();//from   ww w .j  av a 2  s  .  c om

    if (itemSelectorViewReturnTypeProviderHandler != null) {
        supportedItemSelectorReturnTypes = itemSelectorViewReturnTypeProviderHandler
                .getSupportedItemSelectorReturnTypes(itemSelectorView);
    } else {
        supportedItemSelectorReturnTypes = itemSelectorView.getSupportedItemSelectorReturnTypes();
    }

    for (ItemSelectorReturnType supportedItemSelectorReturnType : supportedItemSelectorReturnTypes) {

        String supportedItemSelectorReturnTypeClassName = ClassUtil
                .getClassName(supportedItemSelectorReturnType);

        if (itemSelectorReturnTypeClassName.equals(supportedItemSelectorReturnTypeClassName)) {

            return true;
        }
    }

    return false;
}

From source file:com.liferay.item.selector.ItemSelectorReturnTypeResolverHandler.java

License:Open Source License

protected ItemSelectorReturnType getFirstAvailableItemSelectorReturnType(
        List<ItemSelectorReturnType> desiredItemSelectorReturnTypes,
        List<ItemSelectorReturnType> supportedItemSelectorReturnTypes) {

    List<String> supportedItemSelectorReturnTypeNames = ListUtil.toList(supportedItemSelectorReturnTypes,
            ClassUtil::getClassName);/*from  w  ww.  ja va 2  s.c om*/

    for (ItemSelectorReturnType itemSelectorReturnType : desiredItemSelectorReturnTypes) {

        String className = ClassUtil.getClassName(itemSelectorReturnType);

        if (supportedItemSelectorReturnTypeNames.contains(className)) {
            return itemSelectorReturnType;
        }
    }

    return null;
}

From source file:com.liferay.item.selector.taglib.internal.util.ItemSelectorRepositoryEntryBrowserUtil.java

License:Open Source License

public static String getItemSelectorReturnTypeClassName(
        ItemSelectorReturnTypeResolver<? extends ItemSelectorReturnType, FileEntry> itemSelectorReturnTypeResolver,
        ItemSelectorReturnType itemSelectorReturnType) throws Exception {

    if (itemSelectorReturnTypeResolver != null) {
        Class<? extends ItemSelectorReturnType> itemSelectorReturnTypeClass = itemSelectorReturnTypeResolver
                .getItemSelectorReturnTypeClass();

        return itemSelectorReturnTypeClass.getName();
    }/*from   w  w w.  ja  va 2s  .co m*/

    return ClassUtil.getClassName(itemSelectorReturnType);
}

From source file:com.liferay.item.selector.taglib.ItemSelectorRepositoryEntryBrowserReturnTypeUtil.java

License:Open Source License

public static String getValue(ItemSelectorReturnType itemSelectorReturnType, FileEntry fileEntry,
        ThemeDisplay themeDisplay) throws Exception {

    String className = ClassUtil.getClassName(itemSelectorReturnType);

    if (className.equals(FileEntryItemSelectorReturnType.class.getName())) {
        return getFileEntryValue(fileEntry, themeDisplay);
    } else if (className.equals(URLItemSelectorReturnType.class.getName())) {
        return DLUtil.getPreviewURL(fileEntry, fileEntry.getFileVersion(), themeDisplay, StringPool.BLANK,
                false, false);//from  ww w .j  a v  a  2 s  .  c  o  m
    }

    return StringPool.BLANK;
}

From source file:com.liferay.item.selector.taglib.ItemSelectorRepositoryEntryBrowserReturnTypeUtil.java

License:Open Source License

protected static ItemSelectorReturnType getFirstAvailableItemSelectorReturnType(
        List<ItemSelectorReturnType> desiredItemSelectorReturnTypes, List<String> itemSelectorReturnTypeTypes) {

    Iterator<ItemSelectorReturnType> iterator = desiredItemSelectorReturnTypes.iterator();

    while (iterator.hasNext()) {
        ItemSelectorReturnType itemSelectorReturnType = iterator.next();

        String className = ClassUtil.getClassName(itemSelectorReturnType);

        if (itemSelectorReturnTypeTypes.contains(className)) {
            return itemSelectorReturnType;
        }//from  w ww .j a  v  a2 s . c o  m
    }

    return null;
}

From source file:com.liferay.sync.util.SyncUtil.java

License:Open Source License

public static String buildExceptionMessage(Throwable throwable) {

    // SYNC-1253//from   www  .j a  va  2  s.co m

    StringBundler sb = new StringBundler(13);

    if (throwable instanceof InvocationTargetException) {
        throwable = throwable.getCause();
    }

    String throwableMessage = throwable.getMessage();

    if (Validator.isNull(throwableMessage)) {
        throwableMessage = throwable.toString();
    }

    sb.append(StringPool.QUOTE);
    sb.append(throwableMessage);
    sb.append(StringPool.QUOTE);
    sb.append(StringPool.COMMA_AND_SPACE);
    sb.append("\"error\": ");

    JSONObject errorJSONObject = JSONFactoryUtil.createJSONObject();

    errorJSONObject.put("message", throwableMessage);
    errorJSONObject.put("type", ClassUtil.getClassName(throwable));

    sb.append(errorJSONObject.toString());

    sb.append(StringPool.COMMA_AND_SPACE);
    sb.append("\"throwable\": \"");
    sb.append(throwable.toString());
    sb.append(StringPool.QUOTE);

    if (throwable.getCause() == null) {
        return StringUtil.unquote(sb.toString());
    }

    sb.append(StringPool.COMMA_AND_SPACE);
    sb.append("\"rootCause\": ");

    Throwable rootCauseThrowable = throwable;

    while (rootCauseThrowable.getCause() != null) {
        rootCauseThrowable = rootCauseThrowable.getCause();
    }

    JSONObject rootCauseJSONObject = JSONFactoryUtil.createJSONObject();

    throwableMessage = rootCauseThrowable.getMessage();

    if (Validator.isNull(throwableMessage)) {
        throwableMessage = rootCauseThrowable.toString();
    }

    rootCauseJSONObject.put("message", throwableMessage);

    rootCauseJSONObject.put("type", ClassUtil.getClassName(rootCauseThrowable));

    sb.append(rootCauseJSONObject);

    return StringUtil.unquote(sb.toString());
}