/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.asset.entry.query.processor.custom.user.attributes.internal;
import com.liferay.asset.kernel.service.persistence.AssetEntryQuery;
import com.liferay.asset.kernel.util.AssetEntryQueryProcessor;
import com.liferay.asset.publisher.web.constants.AssetPublisherPortletKeys;
import com.liferay.asset.publisher.web.util.AssetPublisherUtil;
import com.liferay.portal.kernel.model.User;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.StringUtil;
import java.io.IOException;
import java.util.Locale;
import javax.portlet.PortletPreferences;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
/**
* @author Jorge Ferrer
*/
@Component(
immediate = true,
property = {
"javax.portlet.name=" + AssetPublisherPortletKeys.ASSET_PUBLISHER
},
service = AssetEntryQueryProcessor.class
)
public class CustomUserAttributesAssetEntryQueryProcessor
implements AssetEntryQueryProcessor {
@Override
public String getKey() {
return null;
}
@Override
public String getTitle(Locale locale) {
return null;
}
@Override
public void include(
HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse)
throws IOException {
}
@Override
public void processAssetEntryQuery(
User user, PortletPreferences preferences,
AssetEntryQuery assetEntryQuery)
throws Exception {
String customUserAttributes = GetterUtil.getString(
preferences.getValue("customUserAttributes", StringPool.BLANK));
_assetPublisherUtil.addUserAttributes(
user, StringUtil.split(customUserAttributes), assetEntryQuery);
}
@Reference
private AssetPublisherUtil _assetPublisherUtil;
}