Exemplo n.º 1
0
  public static void getBackupSummary(String id, String bkpId) throws Exception {

    SalesforceOrg org = dbUtils.findOrganizationById(id);
    for (Backup bkp : dbUtils.backupsForOrg(org.getOrgId())) {
      if (bkpId.equalsIgnoreCase((bkp.getId()))) {
        JedisPool pool = null;
        Jedis jedis = null;
        try {

          pool = poolFactory.getPool();
          jedis = pool.getResource();

          response.setContentTypeIfNotSet("application/json");
          ObjectMapper objectMapper = new ObjectMapper();
          objectMapper.setSerializationInclusion(Inclusion.NON_NULL);
          renderJSON(
              objectMapper.writeValueAsString(
                  DifferenceUtils.summarizeDifferences(
                      jedis.hget(bkp.getGitVersion(), "changes"))));
        } finally {
          if (pool != null && jedis != null) {
            pool.returnResource(jedis);
          }
        }
        break;
      }
    }
    renderJSON("{}");
  }
Exemplo n.º 2
0
  public static void getBackup(String id) throws Exception {
    SalesforceOrg org = dbUtils.findOrganizationById(id);
    User usr = dbUtils.findUserById(org.getDotVersionOwner());
    renderArgs.put("metadataElements", metadataElements);
    List<Backup> backups = dbUtils.backupsForOrg(org.getOrgId());

    renderTemplate("Salesforce/backup.html", usr, org, backups, metadataElements);
  }
Exemplo n.º 3
0
  // Create new Backup
  public static void backup(String id) throws Exception {
    User usr = dbUtils.findUser(session.get("username"));

    SalesforceOrg org = null;
    for (SalesforceOrg myOrg : usr.getSalesforceOrgs()) {
      if (myOrg.getId().equalsIgnoreCase(id)) {
        org = myOrg;
        break;
      }
    }
    renderArgs.put("metadataElements", metadataElements);

    String logoutUrl = org.getApiEndpoint() + "/secur/logout.jsp";
    render(usr, org, metadataElements, logoutUrl);
  }
Exemplo n.º 4
0
  public static void backups() throws Exception {

    String username = session.get("username");
    User usr = dbUtils.findUser(username);

    renderArgs.put("metadataElements", metadataElements);

    SalesforceOrg org = null;
    for (SalesforceOrg myOrg : usr.getSalesforceOrgs()) {
      if (myOrg.getId().equalsIgnoreCase(session.get("org_id"))) {
        org = myOrg;
        break;
      }
    }

    String logoutUrl = org.getApiEndpoint() + "/secur/logout.jsp";
    session.remove("force_auth");
    render(usr, logoutUrl);
  }
Exemplo n.º 5
0
 public static void scheduleBackupNow(String id) throws Exception {
   SalesforceOrg org = dbUtils.findOrganizationById(id);
   org.setLastBackupStatus("Scheduled");
   dbUtils.upsert(org);
   JedisPool pool = null;
   Jedis jedis = null;
   try {
     pool = poolFactory.getPool();
     jedis = pool.getResource();
     ObjectMapper mapper = new ObjectMapper(); // can reuse, share globally
     mapper.setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL);
     String msgJson = mapper.writeValueAsString(org);
     jedis.rpush(DotVersionConstants.BACKUP_QUEUE_NAME, msgJson);
   } finally {
     if (pool != null && jedis != null) {
       pool.returnResource(jedis);
     }
   }
   backups();
 }