com.liferay.change.tracking.internal.CTCollectionIdSupplierImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com.liferay.change.tracking.service
Show all versions of com.liferay.change.tracking.service
Liferay Change Tracking Service
/**
* SPDX-FileCopyrightText: (c) 2000 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.change.tracking.internal;
import com.liferay.change.tracking.constants.CTConstants;
import com.liferay.change.tracking.model.CTPreferences;
import com.liferay.change.tracking.service.CTPreferencesLocalService;
import com.liferay.portal.kernel.change.tracking.CTCollectionIdSupplier;
import com.liferay.portal.kernel.model.CompanyConstants;
import com.liferay.portal.kernel.model.UserConstants;
import com.liferay.portal.kernel.security.auth.CompanyThreadLocal;
import com.liferay.portal.kernel.security.auth.PrincipalThreadLocal;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
/**
* @author Preston Crary
*/
@Component(service = CTCollectionIdSupplier.class)
public class CTCollectionIdSupplierImpl implements CTCollectionIdSupplier {
@Override
public long getCTCollectionId() {
long ctCollectionId =
CTCollectionPreviewThreadLocal.getCTCollectionId();
if (ctCollectionId > -1) {
return ctCollectionId;
}
long companyId = CompanyThreadLocal.getCompanyId();
long userId = PrincipalThreadLocal.getUserId();
if ((companyId == CompanyConstants.SYSTEM) &&
(userId == UserConstants.USER_ID_DEFAULT)) {
return CTConstants.CT_COLLECTION_ID_PRODUCTION;
}
CTPreferences ctPreferences =
_ctPreferencesLocalService.fetchCTPreferences(companyId, userId);
if (ctPreferences == null) {
return CTConstants.CT_COLLECTION_ID_PRODUCTION;
}
return ctPreferences.getCtCollectionId();
}
@Reference
private CTPreferencesLocalService _ctPreferencesLocalService;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy