public void createWorkspaceWithTags(
      String workspaceName, String description, String username, String origin, String tags) {
    Assert.notNull(workspaceName);
    Assert.notNull(username);
    if (checkNameAvailability(workspaceName, username)) {
      Workspace ws = new Workspace();
      ws.setDownloads(0);
      ws.setDescription(description);
      ws.setLastMod(Calendar.getInstance().getTime());
      ws.setLaunches(0);
      ws.setWsVersion(1);
      ws.setName(workspaceName);
      UserAccount ua = uar.findByUsername(username);
      Researcher rese = researcherRepository.findByUserAccountId(ua.getId());
      ws.setOwner(rese);

      String[] array = tags.split("\\s+");
      Collection<Tag> wsTags = new ArrayList<>();

      for (String a : array) {
        if (a.length() > 1) {
          if (tagRepository.findByName(a) != null) wsTags.add(tagRepository.findByName(a));
          else {
            Tag newTag = new Tag();
            newTag.setName(a);
            wsTags.add(tagRepository.save(newTag));
          }
        }
      }
      ws.setWorkspaceTags(wsTags);

      workspaceRepository.saveAndFlush(ws);
    }
  }
 public void updateDownloas(Workspace w) {
   int d = w.getDownloads() + 1;
   w.setDownloads(d);
   if (w.getOrigin() != null) {
     updateDownloas(w.getOrigin());
   }
   workspaceRepository.saveAndFlush(w);
 }
 public void updateDownloads(String workspaceName, String username) {
   if (username.equals(DEMO_MASTER) || !username.startsWith("demo")) {
     Workspace ws = findByNameAndOwner(workspaceName, username);
     int d = ws.getDownloads() + 1;
     ws.setDownloads(d);
     if (ws.getOrigin() != null) {
       updateDownloads(
           ws.getOrigin().getName(), ws.getOrigin().getOwner().getUserAccount().getUsername());
     }
     workspaceRepository.saveAndFlush(ws);
   }
 }
  public void createWorkspace(String workspaceName, String username, String origin) {
    Assert.notNull(workspaceName);
    Assert.notNull(username);
    if (checkNameAvailability(workspaceName, username)) {
      Workspace ws = new Workspace();
      ws.setDownloads(0);
      ws.setDescription("");
      ws.setLastMod(Calendar.getInstance().getTime());
      ws.setLaunches(0);
      ws.setWsVersion(1);
      ws.setName(workspaceName);
      UserAccount ua = uar.findByUsername(username);
      Researcher rese = researcherRepository.findByUserAccountId(ua.getId());
      ws.setOwner(rese);
      if (origin != null) {
        ws.setOrigin(workspaceRepository.findById(Integer.valueOf(origin)));
        ws.setDescription(workspaceRepository.findById(Integer.valueOf(origin)).getDescription());

        if (username.startsWith("demo")) updateLaunches(workspaceName, DEMO_MASTER);
      }
      workspaceRepository.saveAndFlush(ws);
    }
  }