fixed sonar bugs

This commit is contained in:
jomu
2015-02-21 15:20:43 +00:00
parent f8fb86003b
commit 161fc43fc3
10 changed files with 45 additions and 50 deletions

View File

@ -43,7 +43,7 @@ public class CidrTool {
} }
protected static final int[] CIDR2MASK = new int[]{0x00000000, 0x80000000, private static final int[] CIDR2MASK = new int[]{0x00000000, 0x80000000,
0xC0000000, 0xE0000000, 0xF0000000, 0xF8000000, 0xFC000000, 0xC0000000, 0xE0000000, 0xF0000000, 0xF8000000, 0xFC000000,
0xFE000000, 0xFF000000, 0xFF800000, 0xFFC00000, 0xFFE00000, 0xFE000000, 0xFF000000, 0xFF800000, 0xFFC00000, 0xFFE00000,
0xFFF00000, 0xFFF80000, 0xFFFC0000, 0xFFFE0000, 0xFFFF0000, 0xFFF00000, 0xFFF80000, 0xFFFC0000, 0xFFFE0000, 0xFFFF0000,

View File

@ -11,7 +11,7 @@ import org.apache.log4j.Logger;
* *
* @author joern.muehlencord * @author joern.muehlencord
*/ */
public class PortScan { public final class PortScan {
private final static Logger LOGGER = Logger.getLogger(PortScan.class); private final static Logger LOGGER = Logger.getLogger(PortScan.class);

View File

@ -21,7 +21,7 @@ public class FTPConnection {
/** the default timeout in ms */ /** the default timeout in ms */
public static final int DEFAULTTIMEOUT = 30000; public static final int DEFAULTTIMEOUT = 30000;
/** the logger object */ /** the logger object */
private final Logger LOGGER = Logger.getLogger(FTPConnection.class); private final static Logger LOGGER = Logger.getLogger(FTPConnection.class);
/** the username to connect with */ /** the username to connect with */
private String userName; private String userName;
/** the password to connect with */ /** the password to connect with */

View File

@ -8,9 +8,9 @@ import java.util.Date;
* @author joern.muehlencord * @author joern.muehlencord
*/ */
public class SPHelper { public class SPHelper {
private static final SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
private static final SimpleDateFormat dateOnlyFormat = new SimpleDateFormat("yyyy-MM-dd"); private static final SimpleDateFormat dateOnlyFormat = new SimpleDateFormat("yyyy-MM-dd");
// private static final SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
/* -- Format for Date Only Field -- */ /* -- Format for Date Only Field -- */
public static String toSPDate(Date d) { public static String toSPDate(Date d) {
@ -27,6 +27,7 @@ public class SPHelper {
} }
/* -- Format for DateTime Field -- */ /* -- Format for DateTime Field -- */
/*
private static String toSPDateAndTime(Date d) { private static String toSPDateAndTime(Date d) {
if (d == null) { if (d == null) {
return ""; return "";
@ -38,5 +39,6 @@ public class SPHelper {
} }
return result; return result;
} }
*/
} }

View File

@ -14,6 +14,7 @@ import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema; import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory; import javax.xml.validation.SchemaFactory;
import org.apache.log4j.Logger;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
@ -23,17 +24,31 @@ import org.xml.sax.SAXException;
* @param <T> * @param <T>
*/ */
public abstract class SPJaxbObject<T> extends AbstractSpJaxbObject { public abstract class SPJaxbObject<T> extends AbstractSpJaxbObject {
private static JAXBContext jaxbContext = null; /** the logging object. */
private final static Logger LOGGER = Logger.getLogger(SPJaxbObject.class);
/** /**
* list of packages to search in * list of packages to search in
*/ */
private static final String packages = "" // private final static String packages = "" //
+ "de.muehlencord.shared.sharepoint.api.batch" // + "de.muehlencord.shared.sharepoint.api.batch" //
+ ":de.muehlencord.shared.sharepoint.api.lists" // + ":de.muehlencord.shared.sharepoint.api.lists" //
+ ":de.muehlencord.shared.sharepoint.api.usergroup"; // + ":de.muehlencord.shared.sharepoint.api.usergroup"; //
/** the JAX-B context to use */
private static JAXBContext jaxbContext = null;
/** the value object */
protected T value;
/** the class type of the object */
protected Class<T> cl;
/**
* returns the jax-b context.
* @return the jax-b context.
* @throws JAXBException if the context cannot be obtained.
*/
public static JAXBContext getJaxbContext() throws JAXBException { public static JAXBContext getJaxbContext() throws JAXBException {
if (jaxbContext == null) { if (jaxbContext == null) {
jaxbContext = JAXBContext.newInstance(packages); jaxbContext = JAXBContext.newInstance(packages);
@ -41,8 +56,6 @@ public abstract class SPJaxbObject<T> extends AbstractSpJaxbObject {
return jaxbContext; return jaxbContext;
} }
protected T value;
protected Class<T> cl;
public SPJaxbObject(Class<T> cl, SPContext context) throws JAXBException { public SPJaxbObject(Class<T> cl, SPContext context) throws JAXBException {
super(context); super(context);
@ -116,8 +129,7 @@ public abstract class SPJaxbObject<T> extends AbstractSpJaxbObject {
try { try {
value = cl.newInstance(); value = cl.newInstance();
} catch (InstantiationException | IllegalAccessException ex) { } catch (InstantiationException | IllegalAccessException ex) {
ex.printStackTrace(); LOGGER.debug (ex.toString(), ex);
// TODO add logging, correct error handling
return null; return null;
} }
} }
@ -125,10 +137,3 @@ public abstract class SPJaxbObject<T> extends AbstractSpJaxbObject {
} }
} }
/**
* History:
*
* $$Log$$
*
*/

View File

@ -17,6 +17,7 @@ import org.apache.log4j.Logger;
*/ */
public class ServiceLogHandler implements SOAPHandler<SOAPMessageContext> { public class ServiceLogHandler implements SOAPHandler<SOAPMessageContext> {
/** the logging object. */
private final static Logger LOGGER = Logger.getLogger(ServiceLogHandler.class); private final static Logger LOGGER = Logger.getLogger(ServiceLogHandler.class);
@Override @Override
@ -34,17 +35,19 @@ public class ServiceLogHandler implements SOAPHandler<SOAPMessageContext> {
@Override @Override
public boolean handleFault(SOAPMessageContext arg0) { public boolean handleFault(SOAPMessageContext arg0) {
SOAPMessage message = arg0.getMessage(); SOAPMessage message = arg0.getMessage();
try { try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
message.writeTo(System.out); message.writeTo(os);
LOGGER.error(os.toString("UTF-8"));
} catch (SOAPException | IOException e) { } catch (SOAPException | IOException e) {
// TODO add error handling LOGGER.debug(e.toString(), e);
return false;
} }
return true; return true;
} }
@Override @Override
public boolean handleMessage(SOAPMessageContext arg0) { public boolean handleMessage(SOAPMessageContext arg0) {
LOGGER.info ("Test"); 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 (isOutboundMessage) {
@ -52,13 +55,11 @@ public class ServiceLogHandler implements SOAPHandler<SOAPMessageContext> {
} else { } else {
LOGGER.debug("INBOUND MESSAGE"); LOGGER.debug("INBOUND MESSAGE");
} }
try { try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
ByteArrayOutputStream os = new ByteArrayOutputStream();
message.writeTo(os); message.writeTo(os);
LOGGER.debug (os.toString("UTF-8")); LOGGER.debug(os.toString("UTF-8"));
os.close();
} catch (SOAPException | IOException e) { } catch (SOAPException | IOException e) {
// TODO add error handling LOGGER.debug(e.toString(), e);
} }
return true; return true;

View File

@ -1,16 +1,7 @@
package de.muehlencord.shared.sharepoint.api.authentication; package de.muehlencord.shared.sharepoint.api.authentication;
import com.microsoft.schemas.sharepoint.soap.authentication.Authentication;
import com.microsoft.schemas.sharepoint.soap.authentication.AuthenticationSoap;
import com.microsoft.schemas.sharepoint.soap.authentication.LoginResult;
import de.muehlencord.shared.sharepoint.api.AbstractAuthenticator;
import de.muehlencord.shared.sharepoint.api.SPContext; import de.muehlencord.shared.sharepoint.api.SPContext;
import de.muehlencord.shared.sharepoint.api.SPObject; import de.muehlencord.shared.sharepoint.api.SPObject;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import javax.xml.ws.BindingProvider;
/** /**
* *
@ -22,6 +13,7 @@ public class SPAuthentication extends SPObject {
super(context); super(context);
} }
/*
private AuthenticationSoap getAuthenticationPort() throws NoSuchAlgorithmException, KeyManagementException, MalformedURLException { private AuthenticationSoap getAuthenticationPort() throws NoSuchAlgorithmException, KeyManagementException, MalformedURLException {
URL wsURL = new URL(getContext().getSiteURL().toString() + "/_vti_bin/Authentication.asmx"); URL wsURL = new URL(getContext().getSiteURL().toString() + "/_vti_bin/Authentication.asmx");
URL wsdlURL = new URL(SPContext.class.getResource("/wsdl/authentication.wsdl").toExternalForm()); URL wsdlURL = new URL(SPContext.class.getResource("/wsdl/authentication.wsdl").toExternalForm());
@ -30,4 +22,5 @@ public class SPAuthentication extends SPObject {
((BindingProvider) alertsPort).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, wsURL.toString()); ((BindingProvider) alertsPort).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, wsURL.toString());
return alertsPort; return alertsPort;
} }
*/
} }

View File

@ -1,7 +1,6 @@
package de.muehlencord.shared.sharepoint.api.lists; package de.muehlencord.shared.sharepoint.api.lists;
import com.microsoft.schemas.sharepoint.soap.lists.GetListCollectionResponse; import com.microsoft.schemas.sharepoint.soap.lists.GetListCollectionResponse;
import com.microsoft.schemas.sharepoint.soap.lists.GetListResponse.GetListResult;
import com.microsoft.schemas.sharepoint.soap.lists.Lists; import com.microsoft.schemas.sharepoint.soap.lists.Lists;
import com.microsoft.schemas.sharepoint.soap.lists.ListsSoap; import com.microsoft.schemas.sharepoint.soap.lists.ListsSoap;
import de.muehlencord.shared.sharepoint.api.SPContext; import de.muehlencord.shared.sharepoint.api.SPContext;
@ -125,6 +124,7 @@ public class SPLists extends SPJaxbObject<de.muehlencord.shared.sharepoint.api.l
return null; return null;
} }
/*
private List getListByName(String listName) { private List getListByName(String listName) {
for (List list : this.getValue().lists) { for (List list : this.getValue().lists) {
if (list.getName().equals(listName)) { if (list.getName().equals(listName)) {
@ -134,5 +134,6 @@ public class SPLists extends SPJaxbObject<de.muehlencord.shared.sharepoint.api.l
// return null, if list is not found // return null, if list is not found
return null; return null;
} }
*/
} }

View File

@ -1,16 +1,7 @@
package de.muehlencord.shared.sharepoint.api.sites; package de.muehlencord.shared.sharepoint.api.sites;
import com.microsoft.schemas.sharepoint.soap.webs.GetWebResponse;
import com.microsoft.schemas.sharepoint.soap.webs.Webs;
import com.microsoft.schemas.sharepoint.soap.webs.WebsSoap;
import de.muehlencord.shared.sharepoint.api.SPContext; import de.muehlencord.shared.sharepoint.api.SPContext;
import de.muehlencord.shared.sharepoint.api.SPObject; import de.muehlencord.shared.sharepoint.api.SPObject;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import javax.xml.ws.BindingProvider;
import org.apache.commons.lang3.StringUtils;
/** /**
* *
@ -22,6 +13,7 @@ public class SPSite extends SPObject {
super(context); super(context);
} }
/*
public void getRootWeb() throws NoSuchAlgorithmException, KeyManagementException, MalformedURLException { public void getRootWeb() throws NoSuchAlgorithmException, KeyManagementException, MalformedURLException {
String rootWebUrl = StringUtils.removeEndIgnoreCase(getContext().getSiteURL().toString(), "/"); String rootWebUrl = StringUtils.removeEndIgnoreCase(getContext().getSiteURL().toString(), "/");
GetWebResponse.GetWebResult result = getWebsPort(getContext().getSiteURL()).getWeb(rootWebUrl); GetWebResponse.GetWebResult result = getWebsPort(getContext().getSiteURL()).getWeb(rootWebUrl);
@ -35,4 +27,5 @@ public class SPSite extends SPObject {
((BindingProvider) websPort).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, wsURL.toString()); ((BindingProvider) websPort).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, wsURL.toString());
return websPort; return websPort;
} }
*/
} }

View File

@ -18,7 +18,7 @@ public class NtlmAuthenticatorTest extends BaseTest {
@Ignore // Depends on available sharepoint currently @Ignore // Depends on available sharepoint currently
public void testAuthentication() throws MalformedURLException, NoSuchAlgorithmException, KeyManagementException { public void testAuthentication() throws MalformedURLException, NoSuchAlgorithmException, KeyManagementException {
SPSite instance = new SPSite(context); SPSite instance = new SPSite(context);
instance.getRootWeb(); // instance.getRootWeb();
} }
} }