Ejemplo n.º 1
0
 @Override
 public String send(Tenant tenant, Map<String, String> params, String interfce) {
   switch (params.get("action")) {
     case "upload":
       List<YSpecification> specifications;
       try {
         specifications = YMarshal.unmarshalSpecifications(params.get("specXML"));
       } catch (YSyntaxException e) {
         return SchedulerUtils.failure("Inappropriate specification");
       }
       YSpecification spec = specifications.get(0);
       Spec s = new Spec(tenant, spec.getID(), spec.getSpecVersion(), spec.getURI());
       specRepo.save(s);
       break;
     case "unload":
       Spec unspec = specRepo.findOne(params.get("specidentifier"));
       if (unspec == null || !unspec.getOwner().equals(tenant)) {
         return SchedulerUtils.failure("no such specification");
       }
       specRepo.delete(unspec);
       break;
     case "createAccount":
       String password;
       try {
         password = PasswordEncryptor.encrypt(params.get(("password")));
       } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {
         e.printStackTrace();
         return e.getMessage();
       }
       User user = new User(params.get("userid"), password, tenant);
       userRepo.save(user);
       break;
     case "deleteAccount":
       userRepo.delete(params.get("userid"));
       break;
     case "updateAccount":
       User user1 = userRepo.findByUserName(params.get("userid"));
       user1.setPassword(params.get("password"));
       user1.setPassword(params.get("doco"));
       userRepo.save(user1);
       break;
   }
   return allEngineInTenant.send(tenant, params, interfce);
 }
Ejemplo n.º 2
0
 /**
  * Connects an external entity to the document store
  *
  * @param userID the userid
  * @param password the corresponding password
  * @return a sessionHandle if successful, or a failure message if not
  * @throws IOException if the service can't be reached
  */
 public String connect(String userID, String password) throws IOException {
   byte[] bytes = toByteArray("connect", "", userID, PasswordEncryptor.encrypt(password, null));
   String result = executePost(bytes).toString("UTF-8");
   return (successful(result)) ? stripOuterElement(result) : result;
 }