use of com.liferay.portal.kernel.util.UnicodeProperties in project liferay-ide by liferay.
the class SongLocalServiceImpl method moveSongToTrash.
@Indexable(type = IndexableType.REINDEX)
public Song moveSongToTrash(long userId, Song song) throws PortalException, SystemException {
ServiceContext serviceContext = new ServiceContext();
// Entry
User user = userPersistence.findByPrimaryKey(userId);
Date now = new Date();
int oldStatus = song.getStatus();
song.setModifiedDate(serviceContext.getModifiedDate(now));
song.setStatus(WorkflowConstants.STATUS_IN_TRASH);
song.setStatusByUserId(user.getUserId());
song.setStatusByUserName(user.getFullName());
song.setStatusDate(serviceContext.getModifiedDate(now));
// Asset
assetEntryLocalService.updateVisible(Song.class.getName(), song.getSongId(), false);
// Trash
UnicodeProperties typeSettingsProperties = new UnicodeProperties();
typeSettingsProperties.put("title", song.getName());
TrashEntry trashEntry = trashEntryLocalService.addTrashEntry(userId, song.getGroupId(), Song.class.getName(), song.getSongId(), song.getUuid(), null, oldStatus, null, typeSettingsProperties);
song.setName(TrashUtil.getTrashTitle(trashEntry.getEntryId()));
songPersistence.update(song);
return song;
}
use of com.liferay.portal.kernel.util.UnicodeProperties in project liferay-ide by liferay.
the class UserLocalServiceImpl method addDefaultRolesAndTeams.
protected void addDefaultRolesAndTeams(long groupId, long[] userIds) throws PortalException, SystemException {
List<Role> defaultSiteRoles = new ArrayList<Role>();
Group group = groupLocalService.getGroup(groupId);
UnicodeProperties typeSettingsProperties = group.getTypeSettingsProperties();
long[] defaultSiteRoleIds = StringUtil.split(typeSettingsProperties.getProperty("defaultSiteRoleIds"), 0L);
for (long defaultSiteRoleId : defaultSiteRoleIds) {
Role defaultSiteRole = rolePersistence.fetchByPrimaryKey(defaultSiteRoleId);
if (defaultSiteRole == null) {
if (_log.isWarnEnabled()) {
_log.warn("Unable to find role " + defaultSiteRoleId);
}
continue;
}
defaultSiteRoles.add(defaultSiteRole);
}
List<Team> defaultTeams = new ArrayList<Team>();
long[] defaultTeamIds = StringUtil.split(typeSettingsProperties.getProperty("defaultTeamIds"), 0L);
for (long defaultTeamId : defaultTeamIds) {
Team defaultTeam = teamPersistence.findByPrimaryKey(defaultTeamId);
if (defaultTeam == null) {
if (_log.isWarnEnabled()) {
_log.warn("Unable to find team " + defaultTeamId);
}
continue;
}
defaultTeams.add(defaultTeam);
}
for (long userId : userIds) {
Set<Long> userRoleIdsSet = new HashSet<Long>();
for (Role role : defaultSiteRoles) {
if (!userPersistence.containsRole(userId, role.getRoleId())) {
userRoleIdsSet.add(role.getRoleId());
}
}
long[] userRoleIds = ArrayUtil.toArray(userRoleIdsSet.toArray(new Long[userRoleIdsSet.size()]));
userGroupRoleLocalService.addUserGroupRoles(userId, groupId, userRoleIds);
Set<Long> userTeamIdsSet = new HashSet<Long>();
for (Team team : defaultTeams) {
if (!userPersistence.containsTeam(userId, team.getTeamId())) {
userTeamIdsSet.add(team.getTeamId());
}
}
long[] userTeamIds = ArrayUtil.toArray(userTeamIdsSet.toArray(new Long[userTeamIdsSet.size()]));
userPersistence.addTeams(userId, userTeamIds);
}
}
Aggregations