Esempio n. 1
0
  /**
   * Get NOS Details
   *
   * @param objectKey
   * @return
   */
  @Deprecated /*deprecated - changed to get nos detail by build request key and device*/
  @RequestMapping(value = "/rest/getnosinfo", method = RequestMethod.GET)
  public NOSInfo getNOSDetails(
      @RequestParam("series") String seriesName,
      @RequestParam("nos") String nosName,
      @RequestParam("dev") String deviceName) {
    try {
      NOSSeries series = seriesDAO.getByName(seriesName);
      if (series == null) return null;
      Artifact a = artDao.getByNameAndSeries(nosName, series.getId());
      if (a == null) return null;
      Device device = deviceDAO.getByName(deviceName);
      if (device == null) return null;
      ArtifactInfo artifactInfo =
          artifactInfoDAO.getByDeviceIdArtifactId(device.getId(), a.getId());
      if (artifactInfo == null) return null;
      SysVerInfo sysVerInfo = new SysVerInfo();
      sysVerInfo.setSys(artifactInfo.getSysInfo());
      sysVerInfo.setVer(artifactInfo.getVerInfo());
      BuildRequest history = historyDAO.getById(a.getBuildRequestId());
      NOSInfo n = new NOSInfo();
      n.setId(a.getId());
      n.setBmt(a.getBmtNumber());
      n.setBuildno(a.getBuildNumber());
      n.setCategory(series.getCategory());
      n.setDump(a.getAttachedDumpFile());
      n.setFilesize(a.getFileSize());
      n.setHash(a.getFileHash());
      n.setLocation(a.getFileLocation());
      n.setMajor(a.getVersionMajor());
      n.setMinor(a.getVersionMinor());
      n.setName(a.getFileName());
      n.setOsInfo(Utils.toJson(sysVerInfo));
      n.setResized(a.getIsResized());
      n.setType(a.getType());
      if (history != null) {
        n.setSrcRev(history.getSourceRev());
        n.setSrcUrl(history.getSourceUrl());
        if (requestMap.contains(history.getRequestKey()))
          requestMap.remove(history.getRequestKey());
      }

      return n;
    } catch (Exception e) {
      logger.error("Error in NosRepoRestController.getNOSDetails(): ", e);
    }
    return null;
  }
Esempio n. 2
0
  @RequestMapping(
      value = "/ajax/cloneNosSeries",
      method = RequestMethod.POST,
      params = {"nosSeries", "newName"})
  @ResponseBody
  public boolean cloneNosSeries(
      @RequestParam("nosSeries") String nosSeries,
      @RequestParam("newName") String newName,
      HttpServletRequest request) {
    try {
      Principal p = (Principal) request.getSession().getAttribute(Constant.SESSION_KEY_USER);
      if (p == null) {
        return false;
      }
      if (newName == "") {
        return false;
      }
      List<NOSSeries> listNOSSeries = nosSeriesDAO.getAll();
      for (NOSSeries existed : listNOSSeries) {
        String name = existed.getSeriesName();
        if (name.equals(nosSeries)) {
          return false;
        } else {
          NOSSeries newSeries = new NOSSeries();
          NOSSeries currentSeries = nosSeriesDAO.getByName(nosSeries);

          newSeries.setSeriesName(newName);
          String currentCategory = currentSeries.getCategory();
          if (StringUtils.isBlank(currentCategory)) {
            newSeries.setCategory("");
          } else {
            newSeries.setCategory(currentCategory);
          }
          String currentDescript = currentSeries.getDescription();
          if (StringUtils.isBlank(currentDescript)) {
            newSeries.setDescription("");
          } else {
            newSeries.setDescription(currentDescript);
          }
          String ftpDefault = currentSeries.getFtpDefaultLocation();
          if (StringUtils.isBlank(ftpDefault)) {
            newSeries.setFtpDefaultLocation("");
          } else {
            newSeries.setFtpDefaultLocation(ftpDefault);
          }
          String curNosName = currentSeries.getNamePattern();
          if (StringUtils.isBlank(curNosName)) {
            newSeries.setNamePattern("");
          } else {
            newSeries.setNamePattern(curNosName);
          }
          String defaultLocation = currentSeries.getOutputDefaultLocation();
          if (StringUtils.isBlank(defaultLocation)) {
            newSeries.setOutputDefaultLocation("");
          } else {
            newSeries.setOutputDefaultLocation(defaultLocation);
          }
          String curDefaultNos = currentSeries.getOutputDefaultNamePattern();
          if (StringUtils.isBlank(curDefaultNos)) {
            newSeries.setOutputDefaultNamePattern("");
          } else {
            newSeries.setOutputDefaultNamePattern(curDefaultNos);
          }
          String[] curStakehoders = currentSeries.getStakeholders();
          if (curStakehoders.length <= 0) {
            newSeries.setStakeholders(null);
          } else {
            newSeries.setStakeholders(curStakehoders);
          }
          ChangedContent[] curChangeContent = currentSeries.getMakeRules();
          if (curChangeContent.length <= 0) {
            newSeries.setMakeRules(null);
          } else {
            newSeries.setMakeRules(curChangeContent);
          }
          long newSeriesId = nosSeriesDAO.add(newSeries);
          List<SeriesBuildServer> listBuildServer =
              seriesBuildServerDAO.getAllBuildServer(currentSeries.getId());
          List<SeriesBuildServer> newListSBS = new ArrayList<SeriesBuildServer>();
          SeriesBuildServer newSBS = new SeriesBuildServer();
          for (SeriesBuildServer current : listBuildServer) {
            newSBS.setBuildServerId(current.getBuildServerId());
            newSBS.setSeriesId(newSeriesId);
            seriesBuildServerDAO.add(newSBS);
            newListSBS.add(newSBS);
          }
          List<SeriesCapability> listSC = seriesCapabilityDao.getBySeriesId(currentSeries.getId());
          List<SeriesCapability> newListSC = new ArrayList<SeriesCapability>();
          SeriesCapability newSC = new SeriesCapability();
          for (SeriesCapability seriesCapability : listSC) {
            newSC.setContractId(seriesCapability.getContractId());
            newSC.setDeviceId(seriesCapability.getDeviceId());
            newSC.setSeriesId(newSeriesId);
            seriesCapabilityDao.add(newSC);
            newListSC.add(newSC);
          }
          return true;
        }
      }
    } catch (Exception e) {
      logger.warn("MyNOSSeriesController.cloneNosSeries() " + e.getMessage());
    }
    return false;
  }