use of com.liferay.portal.kernel.search.Indexer in project liferay-ide by liferay.
the class AlbumLocalServiceImpl method moveDependentsToTrash.
protected void moveDependentsToTrash(List<Song> songs, long trashEntryId) throws PortalException, SystemException {
for (Song song : songs) {
if (song.isInTrash()) {
continue;
}
int oldStatus = song.getStatus();
song.setStatus(WorkflowConstants.STATUS_IN_TRASH);
songPersistence.update(song);
// Trash
int status = oldStatus;
if (oldStatus == WorkflowConstants.STATUS_PENDING) {
status = WorkflowConstants.STATUS_DRAFT;
}
if (oldStatus != WorkflowConstants.STATUS_APPROVED) {
trashVersionLocalService.addTrashVersion(trashEntryId, Song.class.getName(), song.getSongId(), status, null);
}
// Asset
assetEntryLocalService.updateVisible(Song.class.getName(), song.getSongId(), false);
// Indexer
Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(Song.class);
indexer.reindex(song);
}
}
use of com.liferay.portal.kernel.search.Indexer in project liferay-ide by liferay.
the class AlbumLocalServiceImpl method restoreDependentsFromTrash.
protected void restoreDependentsFromTrash(List<Song> songs, long trashEntryId) throws PortalException, SystemException {
for (Song song : songs) {
// Song
TrashEntry trashEntry = trashEntryLocalService.fetchEntry(Song.class.getName(), song.getSongId());
if (trashEntry != null) {
continue;
}
TrashVersion trashVersion = trashVersionLocalService.fetchVersion(trashEntryId, Song.class.getName(), song.getSongId());
int oldStatus = WorkflowConstants.STATUS_APPROVED;
if (trashVersion != null) {
oldStatus = trashVersion.getStatus();
}
song.setStatus(oldStatus);
songPersistence.update(song);
if (trashVersion != null) {
trashVersionLocalService.deleteTrashVersion(trashVersion);
}
if (oldStatus == WorkflowConstants.STATUS_APPROVED) {
assetEntryLocalService.updateVisible(Song.class.getName(), song.getSongId(), true);
}
// Indexer
Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(Song.class);
indexer.reindex(song);
}
}
use of com.liferay.portal.kernel.search.Indexer in project liferay-ide by liferay.
the class UserLocalServiceImpl method addGroupUsers.
/**
* Adds the users to the group.
*
* @param groupId the primary key of the group
* @param userIds the primary keys of the users
* @throws PortalException if a group or user with the primary key could not
* be found
* @throws SystemException if a system exception occurred
*/
@Override
public void addGroupUsers(long groupId, long[] userIds) throws PortalException, SystemException {
groupPersistence.addUsers(groupId, userIds);
Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(User.class);
indexer.reindex(userIds);
PermissionCacheUtil.clearCache();
addDefaultRolesAndTeams(groupId, userIds);
}
use of com.liferay.portal.kernel.search.Indexer in project liferay-ide by liferay.
the class UserLocalServiceImpl method unsetRoleUsers.
/**
* Removes the users from the role.
*
* @param roleId the primary key of the role
* @param userIds the primary keys of the users
* @throws PortalException if a portal exception occurred
* @throws SystemException if a system exception occurred
*/
@Override
public void unsetRoleUsers(long roleId, long[] userIds) throws PortalException, SystemException {
Role role = rolePersistence.findByPrimaryKey(roleId);
String roleName = role.getName();
if (roleName.equals(RoleConstants.USER) || (roleName.equals(RoleConstants.ADMINISTRATOR) && getRoleUsersCount(role.getRoleId()) <= 1)) {
return;
}
rolePersistence.removeUsers(roleId, userIds);
Indexer indexer = IndexerRegistryUtil.nullSafeGetIndexer(User.class);
indexer.reindex(userIds);
PermissionCacheUtil.clearCache();
}
use of com.liferay.portal.kernel.search.Indexer in project liferay-ide by liferay.
the class SearchPermissionCheckerImpl method addPermissionFields.
@Override
public void addPermissionFields(long companyId, Document document) {
try {
long groupId = GetterUtil.getLong(document.get(Field.GROUP_ID));
String className = document.get(Field.ENTRY_CLASS_NAME);
boolean relatedEntry = GetterUtil.getBoolean(document.get(Field.RELATED_ENTRY));
if (relatedEntry) {
long classNameId = GetterUtil.getLong(document.get(Field.CLASS_NAME_ID));
className = PortalUtil.getClassName(classNameId);
}
if (Validator.isNull(className)) {
return;
}
String classPK = document.get(Field.ROOT_ENTRY_CLASS_PK);
if (Validator.isNull(classPK)) {
classPK = document.get(Field.ENTRY_CLASS_PK);
}
if (relatedEntry) {
classPK = document.get(Field.CLASS_PK);
}
if (Validator.isNull(classPK)) {
return;
}
Indexer indexer = IndexerRegistryUtil.getIndexer(className);
if (!indexer.isPermissionAware()) {
return;
}
doAddPermissionFields_6(companyId, groupId, className, classPK, document);
} catch (NoSuchResourceException nsre) {
} catch (Exception e) {
_log.error(e, e);
}
}
Aggregations