Skip to content

Commit

Permalink
Minor fixes, mostly nonfuncional
Browse files Browse the repository at this point in the history
  • Loading branch information
guusdk committed Jun 23, 2022
1 parent c38960d commit cc5b5d0
Showing 1 changed file with 20 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,22 @@
* The Class UserServiceController.
*/
public class UserServiceController {
private static Logger LOG = LoggerFactory.getLogger(UserServiceController.class);
private static final Logger LOG = LoggerFactory.getLogger(UserServiceController.class);

/** The Constant INSTANCE. */
private static UserServiceController INSTANCE = null;

/** The user manager. */
private UserManager userManager;
private final UserManager userManager;

/** The roster manager. */
private RosterManager rosterManager;
private final RosterManager rosterManager;

/** The server. */
private XMPPServer server;
private final XMPPServer server;

/** The lock out manager. */
private LockOutManager lockOutManager;
private final LockOutManager lockOutManager;

/**
* Gets the single instance of UserServiceController.
Expand Down Expand Up @@ -192,10 +192,15 @@ public void deleteUser(String username) throws ServiceException {
/**
* Gets the user entities.
*
* When a property key (and possibly value) is provided, then the user that is returned is one for which the
* specified property has been defined.
*
* @param userSearch
* the user search
* @param propertyValue
* @param propertyKey
* the property key (can be null)
* @param propertyValue
* the property value (can be null)
* @return the user entities
* @throws ServiceException
* the service exception
Expand Down Expand Up @@ -275,7 +280,7 @@ public RosterEntities getRosterEntities(String username) throws ServiceException
log("Get roster entities for user: " + username);
Roster roster = getUserRoster(username);

List<RosterItemEntity> rosterEntities = new ArrayList<RosterItemEntity>();
List<RosterItemEntity> rosterEntities = new ArrayList<>();
for (RosterItem rosterItem : roster.getRosterItems()) {
RosterItemEntity rosterItemEntity = new RosterItemEntity(rosterItem.getJid().toBareJID(),
rosterItem.getNickname(), rosterItem.getSubStatus().getValue());
Expand Down Expand Up @@ -318,13 +323,11 @@ public void addRosterItem(String username, RosterItemEntity rosterItemEntity) th
// Roster item does not exist. Try to add it.
}

if (roster != null) {
RosterItem rosterItem = roster.createRosterItem(jid, rosterItemEntity.getNickname(),
rosterItemEntity.getGroups(), false, true);
UserUtils.checkSubType(rosterItemEntity.getSubscriptionType());
rosterItem.setSubStatus(RosterItem.SubType.getTypeFromInt(rosterItemEntity.getSubscriptionType()));
roster.updateRosterItem(rosterItem);
}
RosterItem rosterItem = roster.createRosterItem(jid, rosterItemEntity.getNickname(),
rosterItemEntity.getGroups(), false, true);
UserUtils.checkSubType(rosterItemEntity.getSubscriptionType());
rosterItem.setSubStatus(RosterItem.SubType.getTypeFromInt(rosterItemEntity.getSubscriptionType()));
roster.updateRosterItem(rosterItem);
}

/**
Expand Down Expand Up @@ -412,7 +415,7 @@ public List<String> getUserGroups(String username) throws ServiceException {
}
User user = getAndCheckUser(username);
Collection<Group> groups = GroupManager.getInstance().getGroups(user);
List<String> groupNames = new ArrayList<String>();
List<String> groupNames = new ArrayList<>();
for (Group group : groups) {
groupNames.add(group.getName());
}
Expand All @@ -433,7 +436,7 @@ public List<String> getUserGroups(String username) throws ServiceException {
public void addUserToGroups(String username, UserGroupsEntity userGroupsEntity) throws ServiceException {
if (userGroupsEntity != null) {
log("Adding user: " + username + " to groups");
Collection<Group> groups = new ArrayList<Group>();
Collection<Group> groups = new ArrayList<>();

for (String groupName : userGroupsEntity.getGroupNames()) {
Group group;
Expand Down Expand Up @@ -534,7 +537,7 @@ public void deleteUserFromGroup(String username, String groupName) throws Servic
public UserEntities getUserEntitiesByProperty(String propertyKey, String propertyValue) throws ServiceException {
log("Get user entities by property key : " + propertyKey + "and property value: " + propertyValue);
List<String> usernames = PropertyDAO.getUsernameByProperty(propertyKey, propertyValue);
List<UserEntity> users = new ArrayList<UserEntity>();
List<UserEntity> users = new ArrayList<>();
UserEntities userEntities = new UserEntities();

for (String username : usernames) {
Expand Down

0 comments on commit cc5b5d0

Please sign in to comment.