public void makeCreator(Long userId) {
   VDCUser user = em.find(VDCUser.class, userId);
   VDCNetwork vdcNetwork = vdcNetworkService.find();
   // If the user already has a networkRole, then he is already a creator or networkAdmin,
   // so don't need to change the role.
   if (user.getNetworkRole() == null) {
     user.setNetworkRole(networkRoleService.getCreatorRole());
     mailService.sendCreatorAccountNotification(vdcNetwork.getContactEmail(), user.getUserName());
   }
 }
Exemple #2
0
  /**
   * Changes for build 16 to support scholar dataverses and display
   *
   * @author wbossons
   */
  private List<SelectItem> loadNetworkSelectItems() {
    List selectItems = new ArrayList<SelectItem>();
    List<VDCNetwork> networkList = vdcNetworkService.getVDCSubNetworks();

    if (networkList.size() > 0) {
      selectItems.add(new SelectItem(0, "<None>"));
      for (VDCNetwork vdcNetwork : networkList) {
        selectItems.add(new SelectItem(vdcNetwork.getId(), vdcNetwork.getName()));
      }
    }
    return selectItems;
  }
Exemple #3
0
  /**
   * Automatically managed component initialization. <strong>WARNING:</strong> This method is
   * automatically generated, so any user-specified code inserted here is subject to being replaced.
   */
  public void init() {
    super.init();
    HttpServletRequest request =
        (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
    Iterator iterator = request.getParameterMap().keySet().iterator();
    while (iterator.hasNext()) {
      Object key = (Object) iterator.next();
      if (key instanceof String
          && ((String) key).indexOf("dataverseType") != -1
          && !request.getParameter((String) key).equals("")) {
        this.setDataverseType(request.getParameter((String) key));
      }
    }
    // check to see if a dataverse type is in request
    VDCNetwork checkForSubnetwork = getVDCRequestBean().getCurrentVdcNetwork();
    if (!checkForSubnetwork.equals(vdcNetworkService.findRootNetwork())) {
      selectSubNetworkId = checkForSubnetwork.getId();
    } else {

      selectSubNetworkId = new Long(0);
    }
    networkSelectItems = loadNetworkSelectItems();
  }
 // ACTION METHODS
 public String save_action() {
   String forwardPage = null;
   if (getVDCRequestBean().getCurrentVDCId() == null) {
     // this is a save against the network
     VDCNetwork vdcnetwork = getVDCRequestBean().getVdcNetwork();
     vdcnetwork.setNetworkPageHeader(banner);
     vdcnetwork.setNetworkPageFooter(footer);
     vdcNetworkService.edit(vdcnetwork);
     getVDCRequestBean().getVdcNetwork().setNetworkPageHeader(banner);
     getVDCRequestBean().getVdcNetwork().setNetworkPageFooter(footer);
     forwardPage = "myNetworkOptions";
   } else {
     VDC vdc = vdcService.find(new Long(getVDCRequestBean().getCurrentVDC().getId()));
     vdc.setHeader(banner);
     vdc.setFooter(footer);
     vdc.setDisplayInFrame(displayInFrame);
     vdc.setParentSite(parentSite);
     vdcService.edit(vdc);
     getVDCRequestBean().setCurrentVDC(vdc);
     forwardPage = "myOptions";
   }
   getVDCRequestBean().setSuccessMessage("Successfully updated layout branding.");
   return forwardPage;
 }
Exemple #5
0
  public String createScholarDataverse() {
    String dataversetype = dataverseType;

    String name = (String) dataverseName.getValue();
    String alias = (String) dataverseAlias.getValue();
    String strAffiliation = (String) affiliation.getValue();
    String strShortDescription = (String) shortDescription.getValue();
    Long userId = getVDCSessionBean().getLoginBean().getUser().getId();

    if (validateClassificationCheckBoxes()) {
      vdcService.createScholarDataverse(
          userId, firstName, lastName, name, strAffiliation, alias, dataversetype);
      VDC createdScholarDataverse = vdcService.findScholarDataverseByAlias(alias);
      saveClassifications(createdScholarDataverse);

      //  add default values to the VDC table and commit/set the vdc bean props
      createdScholarDataverse.setDisplayNetworkAnnouncements(
          getVDCRequestBean().getCurrentVdcNetwork().isDisplayAnnouncements());
      createdScholarDataverse.setDisplayAnnouncements(
          getVDCRequestBean().getCurrentVdcNetwork().isDisplayVDCAnnouncements());
      // on create if description is blank uncheck display flag
      if (strShortDescription.isEmpty()) {
        createdScholarDataverse.setDisplayAnnouncements(false);
      }
      createdScholarDataverse.setAnnouncements(
          getVDCRequestBean().getCurrentVdcNetwork().getDefaultVDCAnnouncements());
      createdScholarDataverse.setDisplayNewStudies(
          getVDCRequestBean().getCurrentVdcNetwork().isDisplayVDCRecentStudies());
      createdScholarDataverse.setAboutThisDataverse(
          getVDCRequestBean().getCurrentVdcNetwork().getDefaultVDCAboutText());
      createdScholarDataverse.setContactEmail(
          getVDCSessionBean().getLoginBean().getUser().getEmail());
      createdScholarDataverse.setDvnDescription(strShortDescription);
      createdScholarDataverse.setAnnouncements(
          strShortDescription); // also set default dv home page description from the the DVN home
                                // page short description
      VDCNetwork vdcNetwork;
      if (selectSubNetworkId != null && selectSubNetworkId > 0) {
        vdcNetwork = vdcNetworkService.findById(selectSubNetworkId);
        createdScholarDataverse.setVdcNetwork(vdcNetwork);
      } else {
        vdcNetwork = vdcNetworkService.findRootNetwork();
        createdScholarDataverse.setVdcNetwork(vdcNetwork);
      }
      // Set default template to subnet's default template
      Template template = vdcNetwork.getDefaultTemplate();
      createdScholarDataverse.setDefaultTemplate(template);

      vdcService.edit(createdScholarDataverse);

      String hostUrl = PropertyUtil.getHostUrl();
      VDCUser creator =
          userService.findByUserName(getVDCSessionBean().getLoginBean().getUser().getUserName());
      String toMailAddress = getVDCSessionBean().getLoginBean().getUser().getEmail();
      String siteAddress = hostUrl + "/dvn/dv/" + createdScholarDataverse.getAlias();

      mailService.sendAddSiteNotification(toMailAddress, name, siteAddress);

      // Refresh User object in LoginBean so it contains the user's new role of VDC administrator.
      getVDCSessionBean().getLoginBean().setUser(creator);
      getVDCRenderBean().getFlash().put("successMessage", "Your new dataverse has been created!");
      return "/site/AddSiteSuccessPage?faces-redirect=true&vdcId="
          + createdScholarDataverse.getId();
    } else {
      return null;
    }
  }