/**
* The service logger.
*/
- final static Logger logger = Logger.getLogger(UserServiceImpl.class);
+ protected final static Logger LOG = Logger.getLogger(UserServiceImpl.class);
/**
* Injected user DAO.
* @see org.splat.service.UserService#createUser(org.splat.dal.bo.kernel.User.Properties)
*/
@Transactional
- public User createUser(User.Properties uprop)
+ public User createUser(final User.Properties uprop)
throws MissedPropertyException, InvalidPropertyException,
MultiplyDefinedException, RuntimeException {
User nuser = new User(uprop);
// For the casting List<String>
@Transactional
- public Set<User> importUsers(File xfile) throws XMLException,
+ public Set<User> importUsers(final File xfile) throws XMLException,
MismatchException {
String[] name = xfile.getName().split("\\x2E"); // Split by '.' (period) character
String fext = name[name.length - 1];
- if (!fext.equals("xml"))
+ if (!fext.equals("xml")) {
throw new MismatchException("filetype");
+ }
try {
DocumentBuilderFactory dfactory = javax.xml.parsers.DocumentBuilderFactory
.newInstance();
DocumentBuilder dBuilder = dfactory.newDocumentBuilder();
org.w3c.dom.Document inDoc = dBuilder.parse(xfile);
String xtag = inDoc.getDocumentElement().getNodeName();
- if (!xtag.equals("users"))
+ if (!xtag.equals("users")) {
throw new MismatchException("filetype");
+ }
org.w3c.dom.NodeList ulist = inDoc.getElementsByTagName("user");
// List<String> result = (List<String>) session
List<User> users = getUserDAO().getAll();
HashSet<String> members = new HashSet<String>();
HashSet<User> imported = new HashSet<User>();
- for (Iterator<User> i = users.iterator(); i.hasNext();)
+ for (Iterator<User> i = users.iterator(); i.hasNext();) {
members.add(i.next().getUsername());
+ }
for (int i = 0; i < ulist.getLength(); i++) {
HashMap<String, Node> row = XDOM.getNamedChildNodes(ulist
// Mandatory properties
String uname = row.get("username").getTextContent();
- if (members.contains(uname))
+ if (members.contains(uname)) {
continue; // This user already exists
+ }
uprop.setUsername(uname)
.setFirstName(row.get("first").getTextContent())
.setName(row.get("last").getTextContent())
}
return imported;
} catch (IOException error) {
- throw new XMLException("XML users file not found");
+ LOG.debug(error.getMessage(), error);
+ throw new XMLException("XML users file not found"); //RKV: NOPMD: Original message is printed
} catch (ParserConfigurationException e) {
- throw new XMLException("XML Organization parser not accessible");
+ LOG.debug(e.getMessage(), e);
+ throw new XMLException("XML Organization parser not accessible"); //RKV: NOPMD: Original message is printed
} catch (Exception e) {
- throw new XMLException("XML users file not valid");
+ LOG.debug(e.getMessage(), e);
+ throw new XMLException("XML users file not valid"); //RKV: NOPMD: Original message is printed
}
}
* the user whose manager is get
* @return the manager of the given user, if defined
*/
- public User getManagerOf(User user) {
+ public User getManagerOf(final User user) {
User result = null;
String orgname = user.getOrganizationName();
- if (orgname.equals("Nx2"))
+ if (orgname.equals("Nx2")) {
return result;
- if (orgname.equals("Nx1"))
+ }
+ if (orgname.equals("Nx1")) {
orgname = "Nx2";
- else {
- if (user.getRoleNames().equals("customer"))
+ } else {
+ if (user.getRoleNames().equals("customer")) {
return result;
+ }
orgname = "Nx1";
}
try {
}
@Transactional(readOnly = true)
- public User selectUser(String username) {
+ public User selectUser(final String username) {
return getUserDAO().findByCriteria(
Restrictions.eq("username", username));
}
- public User selectUser(String username, String password) {
+ public User selectUser(final String username, final String password) {
// WARNING: For not encoding the password here, we better call a selectUsersWhere(User.Properties),
// but this requires a getPassword in User.Properties nested class.
Criterion aCondition = Restrictions.eq("username", username);
}
@Transactional(readOnly = true)
- public User selectUser(long index) {
+ public User selectUser(final long index) {
return getUserDAO().get(index);
}
@SuppressWarnings("unchecked")
- public List<User> selectUsersWhere(User.Properties... uprop) {
+ public List<User> selectUsersWhere(final User.Properties... uprop) {
// StringBuffer query = new StringBuffer("FROM User");
// String separator = " where (";
// String value;
* @param userDAO
* the userDAO to set
*/
- public void setUserDAO(UserDAO userDAO) {
+ public void setUserDAO(final UserDAO userDAO) {
_userDAO = userDAO;
}
}