converted row limit to integer value
This commit is contained in:
@ -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
|
||||
|
||||
@ -50,7 +50,12 @@ public class SPUserGroup extends SPObject {
|
||||
if (user == null) {
|
||||
throw new SAXException("User not found");
|
||||
}
|
||||
getUserGroupPort().removeUserFromGroup(groupName, user.getUserLoginName());
|
||||
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,24 +118,25 @@ 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 {
|
||||
|
||||
String xml = "<Users><User Email=\"" + emailAddress + "\"/></Users>";
|
||||
EmailXml emailXml = new GetUserLoginFromEmail.EmailXml();
|
||||
EmailXml emailXml = new GetUserLoginFromEmail.EmailXml();
|
||||
emailXml.getContent().add(SPJaxbObject.createSharePointCAMLNode(xml));
|
||||
// Node userNode = user.createSharePointCAMLNode();
|
||||
GetUserLoginFromEmailResponse.GetUserLoginFromEmailResult result = getUserGroupPort().getUserLoginFromEmail(emailXml);
|
||||
if ((result != null) && (!result.getContent().isEmpty())) {
|
||||
Object content = result.getContent().get(0);
|
||||
if (content instanceof Element) {
|
||||
Element rootElement = (Element) content;
|
||||
Element rootElement = (Element) content;
|
||||
SPUser user = new SPUser(getContext());
|
||||
user.setValue(SPJaxbObject.xmlToString(rootElement.getFirstChild()));
|
||||
return user;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -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");
|
||||
@ -65,7 +65,7 @@ public class SPListTest extends BaseTest {
|
||||
SPList list = instance.getSpListByTitle("Questionnaire");
|
||||
assertNotNull(list);
|
||||
String listName = list.getListName();
|
||||
assertEquals ("Listname", "{4728157C-CFA4-447E-8863-170133FDC351}", listName);
|
||||
assertEquals("Listname", "{4728157C-CFA4-447E-8863-170133FDC351}", listName);
|
||||
|
||||
Map<String, String> data = new HashMap<>();
|
||||
data.put(list.getColumnNameByDisplayName("Country"), "357;#DE");
|
||||
@ -101,44 +101,44 @@ 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());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Ignore // Depends on available sharepoint currently
|
||||
public void testGetListItemsQuery() throws Exception {
|
||||
SPLists instance = new SPLists(context);
|
||||
SPList list = instance.getSpListByTitle("Questionnaire_Countries");
|
||||
assertNotNull(list);
|
||||
java.util.List<String> columns = new ArrayList<>();
|
||||
java.util.List<String> columns = new ArrayList<>();
|
||||
columns.add("Title");
|
||||
columns.add("ID");
|
||||
|
||||
|
||||
// create query
|
||||
String queryString = "<Query><Where><Eq>"
|
||||
+ "<FieldRef Name=\"Title\" />"
|
||||
+ "<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);
|
||||
assertEquals("Size smallList", 1, smallList.size());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore // Depends on available sharepoint currently
|
||||
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);
|
||||
|
||||
}
|
||||
@ -148,14 +148,14 @@ public class SPListTest extends BaseTest {
|
||||
public void testGetColumnNameByDisplayName() throws Exception {
|
||||
SPLists instance = new SPLists(context);
|
||||
SPList list = instance.getSpListByTitle("Questionnaire");
|
||||
assertEquals ("Displayname of Current OS", "Current_x0020_OS", list.getColumnNameByDisplayName("Current OS"));
|
||||
assertEquals("Displayname of Current OS", "Current_x0020_OS", list.getColumnNameByDisplayName("Current OS"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Ignore // Depends on available sharepoint currently
|
||||
public void testGetItemCount() throws Exception {
|
||||
SPLists instance = new SPLists(context);
|
||||
SPList list = instance.getSpListByTitle("Questionnaire");
|
||||
assertTrue (list.getItemCount() > 0);
|
||||
assertTrue(list.getItemCount() > 0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user