converted row limit to integer value

This commit is contained in:
jomu
2015-02-10 08:12:58 +00:00
parent 59f71fcbda
commit b0c77c8fd0
3 changed files with 46 additions and 22 deletions

View File

@ -64,13 +64,13 @@ public class SPList extends SPJaxbObject<List> {
}
/* *** queries *** */
public java.util.List<java.util.List<String>> getListItems(java.util.List<String> listColumnNames, String rowLimit) throws NoSuchAlgorithmException,
public java.util.List<java.util.List<String>> getListItems(java.util.List<String> listColumnNames, int rowLimit) throws NoSuchAlgorithmException,
KeyManagementException, JAXBException, MalformedURLException,
SAXException, ParserConfigurationException, IOException {
return getListItems(listColumnNames, rowLimit, null);
}
public java.util.List<java.util.List<String>> getListItems(java.util.List<String> listColumnNames, String rowLimit, String queryString) throws
public java.util.List<java.util.List<String>> getListItems(java.util.List<String> listColumnNames, int rowLimit, String queryString) throws
NoSuchAlgorithmException, KeyManagementException, JAXBException, MalformedURLException,
SAXException, ParserConfigurationException, IOException {
@ -85,9 +85,10 @@ public class SPList extends SPJaxbObject<List> {
}
QueryOptions queryOptions = new QueryOptions();
String webId = null;
String rowLimitString = Integer.toString(rowLimit);
GetListItemsResponse.GetListItemsResult result = getListsPort().
getListItems(getValue().name, viewName, query, viewFields, rowLimit, queryOptions, webId);
getListItems(getValue().name, viewName, query, viewFields, rowLimitString, queryOptions, webId);
java.util.List<java.util.List<String>> returnList = new LinkedList<>();
if (result != null && result.getContent() != null) {
@ -187,7 +188,7 @@ public class SPList extends SPJaxbObject<List> {
}
/* *** information & tools *** */
public Map<String, String> getLookupValueMap(String value, String rowLimit) throws NoSuchAlgorithmException,
public Map<String, String> getLookupValueMap(String value, int rowLimit) throws NoSuchAlgorithmException,
KeyManagementException, JAXBException, MalformedURLException, SAXException, ParserConfigurationException, IOException {
// get list values from sharepoint

View File

@ -50,7 +50,12 @@ public class SPUserGroup extends SPObject {
if (user == null) {
throw new SAXException("User not found");
}
if (userLoginName.startsWith("i:0#.w|")) {
getUserGroupPort().removeUserFromGroup(groupName, user.getUserLoginName());
} else {
getUserGroupPort().removeUserFromGroup(groupName, "i:0#.w|" + user.getUserLoginName());
}
}
public boolean isUserMemberOfGroup(String userLoginName, String groupName) throws NoSuchAlgorithmException, KeyManagementException, MalformedURLException {
@ -78,6 +83,23 @@ public class SPUserGroup extends SPObject {
}
}
public SPUsers getUsersFromGroup(String groupName) throws NoSuchAlgorithmException, KeyManagementException, MalformedURLException, JAXBException, SAXException {
GetUserCollectionFromGroupResponse.GetUserCollectionFromGroupResult result = getUserGroupPort().getUserCollectionFromGroup(groupName);
if ((result != null) && (result.getContent() != null) && (!result.getContent().isEmpty())) {
Object value = result.getContent().get(0);
if (value instanceof Element) {
Element rootElement = (Element) value;
SPUsers users = new SPUsers(getContext());
String usersString = SPUsers.xmlToString(rootElement.getFirstChild());
users.setValue(usersString);
return users;
}
}
return null;
}
public String getUserId(String userLoginName) throws NoSuchAlgorithmException, KeyManagementException, MalformedURLException, JAXBException, SAXException {
SPUser user = getUser(userLoginName);
if (user == null) {
@ -96,6 +118,7 @@ public class SPUserGroup extends SPObject {
}
}
// 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,
NoSuchAlgorithmException, KeyManagementException {

View File

@ -45,7 +45,7 @@ public class SPListTest extends BaseTest {
java.util.List<String> columns = new ArrayList<>();
columns.add("Title");
columns.add("ID");
java.util.List<java.util.List<String>> countryCodes = list.getListItems(columns, "300");
java.util.List<java.util.List<String>> countryCodes = list.getListItems(columns, 300);
Map<String, String> data = new HashMap<>();
data.put("Title", "Test");
@ -101,10 +101,10 @@ public class SPListTest extends BaseTest {
// columns.add("CountryCode");
columns.add("Title");
columns.add("ID");
java.util.List<java.util.List<String>> smallList = list.getListItems(columns, "30");
java.util.List<java.util.List<String>> smallList = list.getListItems(columns, 30);
assertNotNull(smallList);
assertEquals("Size smallList", 30, smallList.size());
java.util.List<java.util.List<String>> bigList = list.getListItems(columns, "300");
java.util.List<java.util.List<String>> bigList = list.getListItems(columns, 300);
assertNotNull(bigList);
assertEquals("Size bigList", 249, bigList.size());
}
@ -125,7 +125,7 @@ public class SPListTest extends BaseTest {
+ "<Value Type=\"Text\">DE</Value>"
+ "</Eq></Where></Query>";
java.util.List<java.util.List<String>> smallList = list.getListItems(columns, "30",queryString);
java.util.List<java.util.List<String>> smallList = list.getListItems(columns, 30, queryString);
// the list contains more than one item but title is a unique value, so it can only
// return one row if filtered to one country
assertNotNull(smallList);
@ -138,7 +138,7 @@ public class SPListTest extends BaseTest {
public void testGetLookupValueMap() throws Exception {
SPLists instance = new SPLists(context);
SPList list = instance.getSpListByTitle("Questionnaire_Countries");
Map<String, String> lookupValues = list.getLookupValueMap("Title", "0");
Map<String, String> lookupValues = list.getLookupValueMap("Title", 0);
System.out.println(lookupValues);
}