use of org.jivesoftware.openfire.user.User in project Openfire by igniterealtime.
the class Xep227ExporterTest method testImportXInclude.
/**
* Test if XInclude is working
*
* @throws IOException
* @throws DocumentException
*
*/
@Test
public void testImportXInclude() throws DocumentException, IOException {
logger.finest("testImportIncludeUser");
InExporter testobject = new Xep227Exporter("serverName", offlineMessagesStore, vCardManager, privateStorage, userManager, rosterItemProvider);
String IMPORT_FILE_NAME = "/test-export-xinclude/xep227.xml";
URL streamurl = this.getClass().getResource(IMPORT_FILE_NAME);
assertNotNull(streamurl);
logger.fine("testImportIncludeUser:" + streamurl.getFile());
InputStream stream = new FileInputStream(streamurl.getFile());
assertTrue("Invalid input", testobject.validate(stream));
stream.close();
String previousDomain = null;
boolean isUserProviderReadOnly = false;
stream = this.getClass().getResourceAsStream(IMPORT_FILE_NAME);
List<String> res = testobject.importUsers(stream, previousDomain, isUserProviderReadOnly);
assertNotNull(res);
assertEquals(0, res.size());
stream.close();
Collection<User> users = userManager.getUsers();
assertEquals(2, users.size());
}
use of org.jivesoftware.openfire.user.User in project Openfire by igniterealtime.
the class UserServicePlugin method deleteUser.
public void deleteUser(String username) throws UserNotFoundException, SharedGroupException {
User user = getUser(username);
userManager.deleteUser(user);
rosterManager.deleteRoster(server.createJID(username, null));
}
use of org.jivesoftware.openfire.user.User in project Openfire by igniterealtime.
the class UserServicePlugin method getUserGroups.
/**
* Returns all group names or an empty collection for specific user
*
*/
public Collection<String> getUserGroups(String username) throws UserNotFoundException {
User user = getUser(username);
Collection<Group> groups = GroupManager.getInstance().getGroups(user);
Collection<String> groupNames = new ArrayList<String>();
for (Group group : groups) {
groupNames.add(group.getName());
}
return groupNames;
}
use of org.jivesoftware.openfire.user.User in project Openfire by igniterealtime.
the class UserServicePluginNG method addProperties.
/**
* Adds the properties.
*
* @param userEntity
* the user entity
* @throws ServiceException
* the service exception
*/
private void addProperties(UserEntity userEntity) throws ServiceException {
User user = getAndCheckUser(userEntity.getUsername());
user.getProperties().clear();
if (userEntity.getProperties() != null) {
for (UserProperty property : userEntity.getProperties()) {
user.getProperties().put(property.getKey(), property.getValue());
}
}
}
use of org.jivesoftware.openfire.user.User in project Openfire by igniterealtime.
the class UserServicePluginNG method updateUser.
/**
* Update user.
*
* @param username
* the username
* @param userEntity
* the user entity
* @throws ServiceException
* the service exception
*/
public void updateUser(String username, UserEntity userEntity) throws ServiceException {
if (userEntity != null && !username.isEmpty()) {
User user = getAndCheckUser(username);
if (userEntity.getPassword() != null) {
user.setPassword(userEntity.getPassword());
}
if (userEntity.getName() != null) {
user.setName(userEntity.getName());
}
if (userEntity.getEmail() != null) {
user.setEmail(userEntity.getEmail());
}
addProperties(userEntity);
}
}
Aggregations