converted logging to slf4j
This commit is contained in:
@ -1,14 +1,14 @@
|
||||
package de.muehlencord.shared.sharepoint.api;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.xml.transform.OutputKeys;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
@ -17,6 +17,8 @@ import org.w3c.dom.Node;
|
||||
* @author jomu
|
||||
*/
|
||||
public abstract class SPObject {
|
||||
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(SPObject.class.getName());
|
||||
|
||||
private SPContext context;
|
||||
|
||||
@ -53,7 +55,7 @@ public abstract class SPObject {
|
||||
//print the XML
|
||||
returnString = returnString + xmlString;
|
||||
} catch (TransformerException ex) {
|
||||
Logger.getLogger(SPObject.class.getName()).log(Level.SEVERE, null, ex);
|
||||
LOGGER.error (ex.toString(), ex);
|
||||
}
|
||||
return returnString;
|
||||
}
|
||||
@ -83,7 +85,7 @@ public abstract class SPObject {
|
||||
//print the XML
|
||||
returnString = returnString + xmlString;
|
||||
} catch (TransformerException ex) {
|
||||
Logger.getLogger(SPObject.class.getName()).log(Level.SEVERE, null, ex);
|
||||
LOGGER.error (ex.toString(), ex);
|
||||
}
|
||||
return returnString;
|
||||
}
|
||||
|
||||
@ -0,0 +1,73 @@
|
||||
package de.muehlencord.shared.sharepoint.api;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author joern.muehlencord
|
||||
*/
|
||||
public class SharepointConfig {
|
||||
|
||||
private Properties properties;
|
||||
|
||||
public void loadFromFile() throws IOException {
|
||||
File configFile = new File(getConfigFile());
|
||||
if (!configFile.exists()) {
|
||||
properties = createDefaultConfig();
|
||||
storeToFile("sample");
|
||||
|
||||
System.out.println(createDefaultConfig());
|
||||
throw new FileNotFoundException("Config file " + configFile.toString() + " not found. Please create it");
|
||||
}
|
||||
|
||||
FileInputStream fin = new FileInputStream(configFile);
|
||||
properties = new Properties();
|
||||
properties.loadFromXML(fin);
|
||||
}
|
||||
|
||||
public void storeToFile() throws IOException {
|
||||
storeToFile(null);
|
||||
}
|
||||
|
||||
public String getProperty(String key) {
|
||||
if (properties.containsKey(key)) {
|
||||
return properties.getProperty(key);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void storeToFile(String postfix) throws IOException {
|
||||
String configFileName = getConfigFile();
|
||||
if (postfix != null) {
|
||||
configFileName += "." + postfix;
|
||||
}
|
||||
File configFile = new File(configFileName);
|
||||
FileOutputStream fos = new FileOutputStream(configFile);
|
||||
properties.storeToXML(fos, "Example config", "UTF-8");
|
||||
}
|
||||
|
||||
private Properties createDefaultConfig() {
|
||||
Properties p = new Properties();
|
||||
p.put("domainname", "domainname");
|
||||
p.put("username", "username");
|
||||
p.put("password", "password");
|
||||
p.put("sharepointurl", "http://server/path/to/root");
|
||||
p.put("workdir", "workdir");
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
private String getConfigFile() {
|
||||
String configPath = System.getProperty("user.home");
|
||||
configPath = (configPath.endsWith(File.separator) ? configPath : configPath + File.separator);
|
||||
configPath += ".wincornixdorf/sharepoint/sharepoint.properties";
|
||||
return configPath;
|
||||
}
|
||||
|
||||
}
|
||||
@ -59,9 +59,8 @@ public class SPUserGroup extends SPObject {
|
||||
getUserGroupPort().removeUserFromGroup(groupName, user.getUserLoginName());
|
||||
} else {
|
||||
getUserGroupPort().removeUserFromGroup(groupName, "i:0#.w|" + user.getUserLoginName());
|
||||
}
|
||||
}
|
||||
LOGGER.info("User " + user.getUserName() + " removed from group " + groupName);
|
||||
|
||||
}
|
||||
|
||||
public boolean isUserMemberOfGroup(String userLoginName, String groupName) throws NoSuchAlgorithmException, KeyManagementException, MalformedURLException {
|
||||
@ -193,11 +192,5 @@ public class SPUserGroup extends SPObject {
|
||||
}
|
||||
|
||||
/* *** unsorted *** */
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* History:
|
||||
*
|
||||
* $$Log$$
|
||||
*
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user