All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.liferay.friendly.url.internal.provider.FriendlyURLSeparatorProviderImpl Maven / Gradle / Ivy

The newest version!
/**
 * SPDX-FileCopyrightText: (c) 2024 Liferay, Inc. https://liferay.com
 * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
 */

package com.liferay.friendly.url.internal.provider;

import com.liferay.friendly.url.configuration.manager.FriendlyURLSeparatorConfigurationManager;
import com.liferay.friendly.url.provider.FriendlyURLSeparatorProvider;
import com.liferay.portal.kernel.json.JSONFactory;
import com.liferay.portal.kernel.json.JSONObject;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;

import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

/**
 * @author Mikel Lorza
 */
@Component(service = FriendlyURLSeparatorProvider.class)
public class FriendlyURLSeparatorProviderImpl
	implements FriendlyURLSeparatorProvider {

	@Override
	public String getFriendlyURLSeparator(long companyId, String key) {
		try {
			JSONObject friendlyURLSeparatorsJSONObject =
				_jsonFactory.createJSONObject(
					_friendlyURLSeparatorConfigurationManager.
						getFriendlyURLSeparatorsJSON(companyId));

			return friendlyURLSeparatorsJSONObject.getString(key);
		}
		catch (Exception exception) {
			if (_log.isDebugEnabled()) {
				_log.debug(exception);
			}
		}

		return null;
	}

	private static final Log _log = LogFactoryUtil.getLog(
		FriendlyURLSeparatorProviderImpl.class.getName());

	@Reference
	private FriendlyURLSeparatorConfigurationManager
		_friendlyURLSeparatorConfigurationManager;

	@Reference
	private JSONFactory _jsonFactory;

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy