public void deleteReferences(String workspaceName, String username) {

    Assert.notNull(workspaceName);
    Assert.notNull(username);

    Collection<Workspace> demos = findByDemoPrincipal();

    for (Workspace demo : demos) {
      if (demo.getOrigin() != null && demo.getOrigin().getName().equals(workspaceName)) {
        demo.setOrigin(null);
        workspaceRepository.saveAndFlush(demo);
      }
    }
  }
  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);
    }
  }