Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void setPersonOnNotAllowedViaUserUUID(String UUUID) throws Exception, XmlRpcException{
- final String url = "http://10.3.50.48:8069",
- db = "KassaGroepC",
- username ="ricardo.mayorga.mera@student.ehb.be",
- password = "opiq188";
- final XmlRpcClient client = new XmlRpcClient();
- final XmlRpcClientConfigImpl common_config = new XmlRpcClientConfigImpl();
- common_config.setServerURL(
- new URL(String.format("%s/xmlrpc/2/common", url)));
- int uid = (int) client.execute(common_config,"authenticate",Arrays.asList(db,username, password, Collections.emptyMap()));
- final XmlRpcClient models = new XmlRpcClient() {
- {
- setConfig (new XmlRpcClientConfigImpl() {
- {
- setServerURL(new URL (String.format("%s/xmlrpc/2/object", url)));
- }
- });
- }
- };
- //search and read
- final java.util.List<Object> xuuid= Arrays.asList((Object[])models.execute("execute_kw", Arrays.asList(
- db, uid, password,
- "res.partner", "search",
- Arrays.asList(Arrays.asList(
- Arrays.asList("x_uuid", "=", UUUID))))));
- if (xuuid != null && !xuuid.isEmpty()){
- //System.out.print("userid: " + userid + " is not empty \n");
- System.out.println("Person found for UUID: " + UUUID + ":");
- System.out.println("User before function: ");
- final java.util.List<Object> fields = Arrays.asList((Object[])models.execute
- ("execute_kw",Arrays.asList(db,uid,password,"res.partner","read",Arrays.asList(xuuid),
- new HashMap()
- {{put("fields",Arrays.asList("x_uuid","Bezoeker","name","street","email","x_isactive","x_isallowed","version","timestamp"));}})));
- System.out.println(fields);
- models.execute("execute_kw", Arrays.asList(
- db, uid, password,
- "res.partner", "write",
- Arrays.asList(
- Arrays.asList(UUUID),
- new HashMap() {{ put("x_isallowed", false); }}
- )
- ));
- System.out.println("set user to not allowed");
- // get record name after having changed it
- Arrays.asList((Object[])models.execute("execute_kw", Arrays.asList(
- db, uid, password,
- "res.partner", "name_get",
- Arrays.asList(Arrays.asList(UUUID))
- )));
- final java.util.List<Object> fields1 = Arrays.asList((Object[])models.execute
- ("execute_kw",Arrays.asList(db,uid,password,"res.partner","read",Arrays.asList(xuuid),
- new HashMap()
- {{put("fields",Arrays.asList("x_uuid","Bezoeker","name","street","email","x_isactive","x_isallowed","version","timestamp"));}})));
- System.out.println(fields1);
- message msg = new message();
- //hier de message die moet doorgestuurd worden
- //values van de persoon opvragen die zijn allowed op false moet gezet worden
- //momenteel hardcoded message
- newPerson p = new newPerson("x_uuid","Bezoeker","TESTMESSAGE " + userid + " TEST","De program manager","zijn adress","testmail@verbeeck.be",true,false,1,UUIDHelper.getCurrentDate());
- XStream x = new XStream();
- x.alias("message",message.class);
- msg.setBody(p);
- msg.setMessageType("newPerson");
- x.alias("newPerson", newPerson.class);
- String toSend=x.toXML(msg);
- Sender.Send(toSend);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement