예제 #1
0
 @Override
 public int getLatestSCTMBuildnumber(String productName, String version) throws SCTMException {
   try {
     String[] builds = adminService.getBuilds(sessionId, productName, version);
     int latestBuildnumber = -1;
     for (String bn : builds) {
       int buildnumber = 0;
       try {
         buildnumber = Integer.parseInt(bn);
         if (buildnumber > latestBuildnumber) latestBuildnumber = buildnumber;
       } catch (NumberFormatException e) {
         LOGGER.warning(
             MessageFormat.format(
                 "Build number ({0}) is not a number. Ignoring it.", buildnumber));
       }
     }
     return latestBuildnumber;
   } catch (RemoteException e) {
     if (handleLostSessionException(e)) return getLatestSCTMBuildnumber(productName, version);
     LOGGER.log(Level.SEVERE, e.getMessage(), e);
     throw new SCTMException(
         MessageFormat.format(
             Messages.getString("SCTMService.err.commonFatalError"),
             e.getMessage())); // $NON-NLS-1$
   }
 }
예제 #2
0
  public SCTMService(String serviceURL, String user, String pwd, int projectId)
      throws SCTMException {
    try {
      this.user = user;
      this.pwd = pwd;
      this.projectId = projectId;

      systemService =
          new SystemServiceServiceLocator()
              .getsccsystem(new URL(serviceURL + "/sccsystem?wsdl")); // $NON-NLS-1$
      execService =
          new ExecutionWebServiceServiceLocator()
              .gettmexecution(new URL(serviceURL + "/tmexecution?wsdl")); // $NON-NLS-1$
      adminService =
          new MainEntitiesServiceLocator()
              .getsccentities(new URL(serviceURL + "/sccentities?wsdl"));
      planningService =
          new PlanningServiceServiceLocator()
              .gettmplanning(new URL(serviceURL + "/tmplanning?wsdl"));
      performerService =
          new PerformerServiceServiceLocator()
              .gettmperformer(new URL(serviceURL + "/tmperformer?wsdl"));
      serviceExchangeURL =
          String.format("%sExchange?hid=%s&sid=%s&rfid=%s", serviceURL, "SilkPerformer");

      logon();
      this.execDefIdToNode = new HashMap<Integer, ExecutionNode>();
    } catch (MalformedURLException e) {
      LOGGER.log(Level.SEVERE, e.getMessage(), e);
      throw new SCTMException(Messages.getString("SCTMService.err.serviceUrlWrong")); // $NON-NLS-1$
    } catch (ServiceException e) {
      LOGGER.log(Level.SEVERE, e.getMessage(), e);
      throw new SCTMException(
          MessageFormat.format(
              Messages.getString("SCTMService.err.urlOrServiceBroken"), serviceURL)); // $NON-NLS-1$
    } catch (RemoteException e) {
      LOGGER.log(Level.SEVERE, e.getMessage(), e);
      throw new SCTMException(
          MessageFormat.format(
              Messages.getString("SCTMService.err.commonFatalError"),
              e.getMessage())); // $NON-NLS-1$
    }
  }
예제 #3
0
 private boolean handleLostSessionException(RemoteException e) throws SCTMException {
   if (lostSessionExceptionThrown(e) && logonRetryCount < MAX_LOGONRETRYCOUNT) { // $NON-NLS-1$
     logonRetryCount++;
     LOGGER.warning(Messages.getString("SCTMService.warn.SessionLostReconnect")); // $NON-NLS-1$
     try {
       logon();
       return true;
     } catch (RemoteException e1) {
       LOGGER.log(Level.SEVERE, e.getMessage(), e);
       if (e.getMessage().contains("Not logged in")) // $NON-NLS-1$
       throw new SCTMException(Messages.getString("SCTMService.err.accessDenied")); // $NON-NLS-1$
       else
         throw new SCTMException(
             MessageFormat.format(
                 Messages.getString("SCTMService.err.commonFatalError"),
                 e.getMessage())); // $NON-NLS-1$
     }
   }
   return false;
 }
예제 #4
0
 /* (non-Javadoc)
  * @see hudson.plugins.sctmexecutor.service.ISCTMService#getExecutionResult(com.borland.tm.webservices.tmexecution.ExecutionHandle)
  */
 public ExecutionResult getExecutionResult(ExecutionHandle handle) throws SCTMException {
   try {
     return execService.getExecutionResult(this.sessionId, handle);
   } catch (RemoteException e) {
     if (handleLostSessionException(e)) return getExecutionResult(handle);
     LOGGER.log(Level.SEVERE, e.getMessage(), e);
     throw new SCTMException(
         MessageFormat.format(
             Messages.getString("SCTMService.err.commonFatalError"),
             e.getMessage())); // $NON-NLS-1$
   }
 }
예제 #5
0
 /* (non-Javadoc)
  * @see hudson.plugins.sctmexecutor.service.ISCTMService#isFinished(com.borland.tm.webservices.tmexecution.ExecutionHandle)
  */
 public boolean isFinished(ExecutionHandle handle) throws SCTMException {
   try {
     return execService.getStateOfExecution(sessionId, handle) < 0;
   } catch (RemoteException e) {
     if (handleLostSessionException(e)) return isFinished(handle);
     LOGGER.log(Level.SEVERE, e.getMessage(), e);
     throw new SCTMException(
         MessageFormat.format(
             Messages.getString("SCTMService.err.commonFatalError"),
             e.getMessage())); // $NON-NLS-1$
   }
 }
예제 #6
0
 @Override
 public String getProductName(int nodeId) throws SCTMException {
   try {
     return getProductName(getExecDefNode(nodeId));
   } catch (RemoteException e) {
     if (handleLostSessionException(e)) return getProductName(nodeId);
     LOGGER.log(Level.SEVERE, e.getMessage(), e);
     throw new SCTMException(
         MessageFormat.format(
             Messages.getString("SCTMService.err.commonFatalError"),
             e.getMessage())); // $NON-NLS-1$
   }
 }
예제 #7
0
 @Override
 public SPNamedEntity[] getResultFiles(int testDefRunId) throws SCTMException {
   try {
     return performerService.getExecutionFiles(sessionId, testDefRunId);
   } catch (RemoteException e) {
     if (handleLostSessionException(e)) return getResultFiles(testDefRunId);
     LOGGER.log(Level.SEVERE, e.getMessage(), e);
     throw new SCTMException(
         MessageFormat.format(
             Messages.getString("SCTMService.err.commonFatalError"),
             e.getMessage())); // $NON-NLS-1$
   }
 }
예제 #8
0
 /* (non-Javadoc)
  * @see hudson.plugins.sctmexecutor.service.ISCTMService#start(int)
  */
 public Collection<ExecutionHandle> start(int executionId) throws SCTMException {
   try {
     ExecutionHandle[] handles = execService.startExecution(this.sessionId, executionId);
     logonRetryCount = 0;
     return convertToList(handles);
   } catch (RemoteException e) {
     if (handleLostSessionException(e)) return start(executionId);
     LOGGER.log(Level.WARNING, e.getMessage(), e);
     throw new SCTMException(
         MessageFormat.format(
             Messages.getString("SCTMService.err.commonFatalError"), e.getMessage()));
   }
 }
예제 #9
0
 @Override
 public String getExecDefinitionName(int execDefId) throws SCTMException {
   try {
     ExecutionNode node = getExecDefNode(execDefId);
     return getExecutionNodePropertyValue(node, "PROP_NAME");
   } catch (RemoteException e) {
     if (handleLostSessionException(e)) return getExecDefinitionName(execDefId);
     LOGGER.log(Level.SEVERE, e.getMessage(), e);
     throw new SCTMException(
         MessageFormat.format(
             Messages.getString("SCTMService.err.commonFatalError"),
             e.getMessage())); // $NON-NLS-1$
   }
 }
예제 #10
0
 @Override
 public Collection<String> getAllVersions(int execDefId) throws SCTMException {
   String[] versions = new String[0];
   try {
     ExecutionNode node = getExecDefNode(execDefId);
     versions = adminService.getVersions(execDefId, getProductName(node));
   } catch (RemoteException e) {
     if (handleLostSessionException(e)) return getAllVersions(execDefId);
     LOGGER.log(Level.SEVERE, e.getMessage(), e);
     throw new SCTMException(
         MessageFormat.format(
             Messages.getString("SCTMService.err.commonFatalError"),
             e.getMessage())); // $NON-NLS-1$
   }
   return toList(versions);
 }
예제 #11
0
 /* (non-Javadoc)
  * @see hudson.plugins.sctmexecutor.service.ISCTMService#start(int, java.lang.String)
  */
 public Collection<ExecutionHandle> start(int executionId, String buildNumber)
     throws SCTMException {
   try {
     ExecutionHandle[] handles =
         execService.startExecution(this.sessionId, executionId, buildNumber, 1, null);
     return convertToList(handles);
   } catch (RemoteException e) {
     if (handleLostSessionException(e)) {
       return start(executionId, buildNumber);
     }
     LOGGER.log(Level.WARNING, e.getMessage(), e);
     throw new SCTMException(
         MessageFormat.format(
             Messages.getString("SCTMService.err.commonFatalError"),
             e.getMessage())); // $NON-NLS-1$
   }
 }
예제 #12
0
 @Override
 public boolean buildNumberExists(String productName, String version, int buildNumber)
     throws SCTMException {
   try {
     String[] builds = adminService.getBuilds(sessionId, productName, version);
     String value = String.valueOf(buildNumber);
     for (String build : builds) {
       if (value.equals(build)) return true;
     }
     return false;
   } catch (RemoteException e) {
     if (handleLostSessionException(e))
       return buildNumberExists(productName, version, buildNumber);
     LOGGER.log(Level.SEVERE, e.getMessage(), e);
     throw new SCTMException(
         MessageFormat.format(
             Messages.getString("SCTMService.err.commonFatalError"),
             e.getMessage())); // $NON-NLS-1$
   }
 }
예제 #13
0
 @Override
 public boolean addBuildNumber(String productName, String version, int buildNumber)
     throws SCTMException {
   try {
     return adminService.addBuild(
         sessionId,
         productName,
         version,
         String.valueOf(buildNumber),
         "build number generated by hudson continuous integration system",
         true);
   } catch (RemoteException e) {
     if (handleLostSessionException(e)) addBuildNumber(productName, version, buildNumber);
     LOGGER.log(Level.SEVERE, e.getMessage(), e);
     throw new SCTMException(
         MessageFormat.format(
             Messages.getString("SCTMService.err.commonFatalError"),
             e.getMessage())); // $NON-NLS-1$
   }
 }