optimized logging
This commit is contained in:
@ -9,8 +9,10 @@ import javax.xml.soap.SOAPMessage;
|
|||||||
import javax.xml.ws.handler.MessageContext;
|
import javax.xml.ws.handler.MessageContext;
|
||||||
import javax.xml.ws.handler.soap.SOAPHandler;
|
import javax.xml.ws.handler.soap.SOAPHandler;
|
||||||
import javax.xml.ws.handler.soap.SOAPMessageContext;
|
import javax.xml.ws.handler.soap.SOAPMessageContext;
|
||||||
|
import org.apache.logging.log4j.Level;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -19,7 +21,9 @@ import org.apache.logging.log4j.Logger;
|
|||||||
*/
|
*/
|
||||||
public class ServiceLogHandler implements SOAPHandler<SOAPMessageContext> {
|
public class ServiceLogHandler implements SOAPHandler<SOAPMessageContext> {
|
||||||
|
|
||||||
/** the logging object. */
|
/**
|
||||||
|
* the logging object.
|
||||||
|
*/
|
||||||
private final static Logger LOGGER = LogManager.getLogger(ServiceLogHandler.class);
|
private final static Logger LOGGER = LogManager.getLogger(ServiceLogHandler.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -49,19 +53,20 @@ public class ServiceLogHandler implements SOAPHandler<SOAPMessageContext> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handleMessage(SOAPMessageContext arg0) {
|
public boolean handleMessage(SOAPMessageContext arg0) {
|
||||||
LOGGER.info("Test");
|
|
||||||
SOAPMessage message = arg0.getMessage();
|
SOAPMessage message = arg0.getMessage();
|
||||||
boolean isOutboundMessage = (Boolean) arg0.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
|
boolean isOutboundMessage = (Boolean) arg0.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
|
||||||
if (isOutboundMessage) {
|
if (LOGGER.isTraceEnabled()) {
|
||||||
LOGGER.debug("OUTBOUND MESSAGE");
|
if (isOutboundMessage) {
|
||||||
} else {
|
LOGGER.log(Level.TRACE, "OUTBOUND MESSAGE");
|
||||||
LOGGER.debug("INBOUND MESSAGE");
|
} else {
|
||||||
|
LOGGER.log(Level.TRACE, "INBOUND MESSAGE");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
|
try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
|
||||||
message.writeTo(os);
|
message.writeTo(os);
|
||||||
LOGGER.debug(os.toString("UTF-8"));
|
LOGGER.log(Level.TRACE, os.toString("UTF-8"));
|
||||||
} catch (SOAPException | IOException e) {
|
} catch (SOAPException | IOException e) {
|
||||||
LOGGER.debug(e.toString(), e);
|
LOGGER.log(Level.DEBUG, e.toString(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -107,7 +107,6 @@ public class SPLists extends SPJaxbObject<de.muehlencord.shared.sharepoint.api.l
|
|||||||
// Parse XML file
|
// Parse XML file
|
||||||
Element rootElement = (Element) content;
|
Element rootElement = (Element) content;
|
||||||
String listsString = SPObject.xmlToString(rootElement.getOwnerDocument());
|
String listsString = SPObject.xmlToString(rootElement.getOwnerDocument());
|
||||||
// System.out.println(listsString);
|
|
||||||
this.setValue(listsString);
|
this.setValue(listsString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,6 +19,9 @@ import javax.xml.bind.JAXBException;
|
|||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import javax.xml.ws.BindingProvider;
|
import javax.xml.ws.BindingProvider;
|
||||||
import javax.xml.ws.handler.Handler;
|
import javax.xml.ws.handler.Handler;
|
||||||
|
import org.apache.logging.log4j.Level;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.NamedNodeMap;
|
import org.w3c.dom.NamedNodeMap;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
@ -31,21 +34,24 @@ import org.xml.sax.SAXException;
|
|||||||
*/
|
*/
|
||||||
public class SPUserGroup extends SPObject {
|
public class SPUserGroup extends SPObject {
|
||||||
|
|
||||||
|
private final static Logger LOGGER = LogManager.getLogger(SPUserGroup.class.getName());
|
||||||
|
|
||||||
public SPUserGroup(SPContext context) {
|
public SPUserGroup(SPContext context) {
|
||||||
super(context);
|
super(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addUserToGroup(String userLoginName, String groupName) throws JAXBException, SAXException, ParserConfigurationException,
|
public void addUserToGroup(String userLoginName, String groupName) throws JAXBException, SAXException, ParserConfigurationException,
|
||||||
NoSuchAlgorithmException, IOException, KeyManagementException {
|
NoSuchAlgorithmException, IOException, KeyManagementException {
|
||||||
SPUser user = getUser(userLoginName);
|
SPUser user = getUser(userLoginName);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
throw new SAXException("User not found");
|
throw new SAXException("User not found");
|
||||||
}
|
}
|
||||||
getUserGroupPort().addUserToGroup(groupName, user.getUserName(), user.getUserLoginName(), user.getUserEmail(), user.getUserNotes());
|
getUserGroupPort().addUserToGroup(groupName, user.getUserName(), user.getUserLoginName(), user.getUserEmail(), user.getUserNotes());
|
||||||
|
LOGGER.info("User " + user.getUserName() + " added to group " + groupName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeUserFromGroup(String userLoginName, String groupName) throws NoSuchAlgorithmException, KeyManagementException, MalformedURLException,
|
public void removeUserFromGroup(String userLoginName, String groupName) throws NoSuchAlgorithmException, KeyManagementException, MalformedURLException,
|
||||||
JAXBException, SAXException {
|
JAXBException, SAXException {
|
||||||
SPUser user = getUser(userLoginName);
|
SPUser user = getUser(userLoginName);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
throw new SAXException("User not found");
|
throw new SAXException("User not found");
|
||||||
@ -55,6 +61,7 @@ public class SPUserGroup extends SPObject {
|
|||||||
} else {
|
} else {
|
||||||
getUserGroupPort().removeUserFromGroup(groupName, "i:0#.w|" + user.getUserLoginName());
|
getUserGroupPort().removeUserFromGroup(groupName, "i:0#.w|" + user.getUserLoginName());
|
||||||
}
|
}
|
||||||
|
LOGGER.info("User " + user.getUserName() + " removed from group " + groupName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,14 +78,22 @@ public class SPUserGroup extends SPObject {
|
|||||||
Node userNode = userNodeList.item(i);
|
Node userNode = userNodeList.item(i);
|
||||||
NamedNodeMap attributes = userNode.getAttributes();
|
NamedNodeMap attributes = userNode.getAttributes();
|
||||||
if ((attributes.getNamedItem("LoginName") != null)
|
if ((attributes.getNamedItem("LoginName") != null)
|
||||||
&& (attributes.getNamedItem("LoginName").getNodeValue().equals("i:0#.w|" + userLoginName))) {
|
&& (attributes.getNamedItem("LoginName").getNodeValue().equals("i:0#.w|" + userLoginName))) {
|
||||||
|
if (LOGGER.isDebugEnabled()) {
|
||||||
|
LOGGER.log(Level.DEBUG, "User " + userLoginName + " is member of group " + groupName);
|
||||||
|
}
|
||||||
return true; // user found
|
return true; // user found
|
||||||
} else {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (LOGGER.isDebugEnabled()) {
|
||||||
|
LOGGER.log(Level.DEBUG, "User " + userLoginName + " is not a member of group " + groupName);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
if (LOGGER.isDebugEnabled()) {
|
||||||
|
LOGGER.log(Level.DEBUG, "User " + userLoginName + " not found");
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -120,7 +135,7 @@ public class SPUserGroup extends SPObject {
|
|||||||
|
|
||||||
// TODO does not return full object, how to refresh the object to get all attributes?
|
// TODO does not return full object, how to refresh the object to get all attributes?
|
||||||
public SPUser getUserFromEmail(String emailAddress) throws JAXBException, ParserConfigurationException, SAXException, IOException,
|
public SPUser getUserFromEmail(String emailAddress) throws JAXBException, ParserConfigurationException, SAXException, IOException,
|
||||||
NoSuchAlgorithmException, KeyManagementException {
|
NoSuchAlgorithmException, KeyManagementException {
|
||||||
|
|
||||||
String xml = "<Users><User Email=\"" + emailAddress + "\"/></Users>";
|
String xml = "<Users><User Email=\"" + emailAddress + "\"/></Users>";
|
||||||
EmailXml emailXml = new GetUserLoginFromEmail.EmailXml();
|
EmailXml emailXml = new GetUserLoginFromEmail.EmailXml();
|
||||||
|
|||||||
Reference in New Issue
Block a user