示例#1
0
  @Override
  public void computeAccess(
      IAccessContextId contextId, Collection<Object> objectsToCheck, AccessData accessData)
      throws OseeCoreException {
    Conditions.checkNotNull(contextId, "contextId");
    Conditions.checkNotNull(objectsToCheck, "objectsToCheck");
    Conditions.checkNotNull(accessData, "accessData");

    OseeDsl oseeDsl = dslProvider.getDsl();
    Conditions.checkNotNull(oseeDsl, "oseeDsl", "dsl provider returned null");

    Collection<AccessContext> contexts = oseeDsl.getAccessDeclarations();
    AccessContext context = interpreter.getContext(contexts, contextId);
    Conditions.checkNotNull(
        context,
        "interpreted accessContext",
        "No matching access context was found in access dsl for [%s]",
        contextId);

    for (Object objectToCheck : objectsToCheck) {
      List<AccessDetail<?>> accessDetail = new LinkedList<>();
      AccessDetailCollector collector = new AccessDataCollector(accessDetail);
      interpreter.computeAccessDetails(collector, context, objectToCheck);
      accessData.addAll(objectToCheck, accessDetail);
    }
  }
示例#2
0
  public static Job createWorkingBranch(
      final TeamWorkFlowArtifact teamArt, final TransactionRecord parentTransactionId, boolean pend)
      throws OseeCoreException {
    final String branchName =
        Strings.truncate(TeamWorkFlowManager.getBranchName(teamArt), 195, true);
    Conditions.checkNotNull(teamArt, "Parent Team Workflow");
    Conditions.checkNotNull(parentTransactionId, "Parent Branch");

    IExceptionableRunnable runnable =
        new IExceptionableRunnable() {

          @Override
          public IStatus run(IProgressMonitor monitor) throws OseeCoreException {
            teamArt.setWorkingBranchCreationInProgress(true);
            BranchManager.createWorkingBranch(parentTransactionId, branchName, teamArt);
            teamArt.setWorkingBranchCreationInProgress(false);
            performPostBranchCreationTasks(teamArt);
            return Status.OK_STATUS;
          }
        };

    //            Jobs.runInJob("Create Branch", runnable, Activator.class, Activator.PLUGIN_ID);
    Job job =
        Jobs.startJob(
            new CatchAndReleaseJob("Create Branch", runnable, Activator.class, Activator.PLUGIN_ID),
            true);
    if (pend) {
      try {
        job.join();
      } catch (InterruptedException ex) {
        throw new OseeWrappedException(ex);
      }
    }
    return job;
  }
示例#3
0
 public static Job createWorkingBranch_Create(
     final TeamWorkFlowArtifact teamArt, final IOseeBranch parentBranch, boolean pend)
     throws OseeCoreException {
   Conditions.checkNotNull(teamArt, "Parent Team Workflow");
   Conditions.checkNotNull(parentBranch, "Parent Branch");
   TransactionRecord parentTransactionId = TransactionManager.getHeadTransaction(parentBranch);
   return createWorkingBranch(teamArt, parentTransactionId, pend);
 }
示例#4
0
  private static <K, V> Cache<K, V> newCache(int cacheMaxSize, long cacheEvictTimeoutMillis) {
    Conditions.checkExpressionFailOnTrue(
        cacheMaxSize <= 0, "Token Cache max size must be greater than 0");
    Conditions.checkExpressionFailOnTrue(
        cacheEvictTimeoutMillis > MAX_TOKEN_CACHE_EVICT_TIMEOUT_MILLIS,
        "Token cache evict timeout exceeds max - [%s]",
        Lib.asTimeString(MAX_TOKEN_CACHE_EVICT_TIMEOUT_MILLIS));
    Conditions.checkExpressionFailOnTrue(
        cacheEvictTimeoutMillis <= 0, "Token cache evict timeout must be greater than 0");

    return CacheBuilder.newBuilder() //
        .maximumSize(cacheMaxSize) //
        .expireAfterWrite(cacheEvictTimeoutMillis, TimeUnit.MILLISECONDS) //
        .build();
  }
  /**
   * @param branchGuid -- the GUID of the branch to apply the test to
   * @param selectedTypes -- a list of the Low level Artifact types that will be used for the report
   * @return -- An Excel sheet (in XML format) containing the two reports
   */
  @GET
  @Produces(MediaType.APPLICATION_XML)
  public Response getLowHighReqReport(
      @QueryParam("branch") long branchUuid, @QueryParam("selected_types") String selectedTypes) {
    Conditions.checkNotNull(branchUuid, "branch query param");
    Conditions.checkNotNull(selectedTypes, "selected_types query param");

    StreamingOutput streamingOutput =
        new PublishLowHighReqStreamingOutput(logger, orcsApi, branchUuid, selectedTypes);
    String fileName = "Requirement_Trace_Report.xml";

    ResponseBuilder builder = Response.ok(streamingOutput);
    builder.header("Content-Disposition", "attachment; filename=" + fileName);
    return builder.build();
  }
示例#6
0
    @Override
    public List<IOseeBranch> call() throws Exception {
      Collection<BranchReadable> branchesToPurge = getBranchesToPurge();

      Conditions.checkNotNull(branchesToPurge, "branchesToPurge");
      if (branchesToPurge.isEmpty()) {
        console.writeln("no branches matched specified criteria");
      } else {
        List<BranchReadable> orderedBranches =
            BranchUtil.orderByParentReadable(queryFactory, branchesToPurge);

        for (IOseeBranch toPurge : orderedBranches) {
          console.writeln(
              "Branch [%s] guid [%s] will be purged!", toPurge.getName(), toPurge.getGuid());
        }

        List<IOseeBranch> purged = new LinkedList<IOseeBranch>();
        if (runPurge) {
          int size = orderedBranches.size();
          int count = 0;
          for (IOseeBranch aBranch : orderedBranches) {
            console.writeln("Purging Branch [%s of %s]: [%s]", ++count, size, aBranch);
            Callable<List<IOseeBranch>> callable = orcsBranch.purgeBranch(aBranch, false);
            purged.addAll(callable.call());
          }
        }
        return purged;
      }
      return null;
    }
  private void processSoftwareRequirement(ArtifactReadable softwareRequirement, String criticality)
      throws IOException {
    writer.writeCell(
        softwareRequirement.getName(), SafetyReportGenerator.SOFTWARE_REQUIREMENT_INDEX);
    String softwareRequirementDAL =
        writeCriticalityWithDesignCheck(
            softwareRequirement,
            criticality,
            CoreRelationTypes.Requirement_Trace__Higher_Level,
            CoreAttributeTypes.DevelopmentAssuranceLevel);

    writer.writeCell(
        calculateBoeingEquivalentSWQualLevel(
            softwareRequirementDAL,
            softwareRequirement.getAttributeCount(CoreAttributeTypes.Partition)));
    writer.writeCell(functionalCategory);

    writer.writeCell(
        Collections.toString(
            ",", getAttributesToStringList(softwareRequirement, CoreAttributeTypes.Partition)));

    writer.writeCell(
        safetyReport.getComponentUtil().getQualifiedComponentNames(softwareRequirement));
    Collection<String> codeUnits =
        safetyReport.getRequirementToCodeUnitsValues(softwareRequirement);

    if (Conditions.hasValues(codeUnits)) {
      for (String codeUnit : codeUnits) {
        writer.writeCell(codeUnit, SafetyReportGenerator.CODE_UNIT_INDEX);
        writer.endRow();
      }
    } else {
      writer.endRow();
    }
  }
示例#8
0
 public QueryBuilder build(QueryFactory queryFactory, SearchRequest params)
     throws OseeCoreException {
   Conditions.checkNotNull(queryFactory, "queryFactory");
   Conditions.checkNotNull(params, "params");
   IOseeBranch searchBranch = TokenFactory.createBranch(params.getBranchUuid(), "searchBranch");
   QueryBuilder builder = queryFactory.fromBranch(searchBranch);
   List<Predicate> predicates = params.getPredicates();
   if (predicates != null) {
     for (Predicate predicate : predicates) {
       SearchMethod method = predicate.getType();
       PredicateHandler handler = handlers.get(method);
       if (handler != null) {
         builder = handler.handle(builder, predicate);
       }
     }
   }
   return builder;
 }
示例#9
0
 @Override
 public IAtsVersion store(IAtsVersion version, IAtsTeamDefinition teamDef) {
   Conditions.checkNotNull(version, "version");
   Conditions.checkNotNull(teamDef, "teamDef");
   Conditions.checkNotNull(teamDef.getStoreObject(), "teamDef storeObject");
   IAtsVersion result = version;
   if (version.getStoreObject() == null) {
     Artifact verArt = cacheProvider.get().getArtifact(version);
     if (verArt == null) {
       AtsChangeSet changes = new AtsChangeSet("Create " + version);
       VersionArtifactWriter writer = new VersionArtifactWriter();
       verArt = writer.store(version, cacheProvider.get(), changes);
       changes.relate(teamDef, AtsRelationTypes.TeamDefinitionToVersion_Version, verArt);
       version.setStoreObject(verArt);
       changes.execute();
     }
   }
   return result;
 }
示例#10
0
  @Override
  public ArtifactData create(IOseeBranch branch, IArtifactType token, String guid, long uuid)
      throws OseeCoreException {
    Conditions.checkNotNull(branch, "branch");

    Conditions.checkExpressionFailOnTrue(
        artifactCache.isAbstract(token), "Cannot create an instance of abstract type [%s]", token);

    String guidToSet = idFactory.getUniqueGuid(guid);

    Conditions.checkExpressionFailOnTrue(
        !GUID.isValid(guidToSet),
        "Invalid guid [%s] during artifact creation [type: %s]",
        guidToSet,
        token);

    VersionData version = objectFactory.createDefaultVersionData();
    version.setBranchId(branch.getUuid());

    ModificationType modType = RelationalConstants.DEFAULT_MODIFICATION_TYPE;
    ArtifactData artifactData =
        objectFactory.createArtifactData(version, (int) uuid, token, modType, guidToSet);
    return artifactData;
  }
示例#11
0
  @Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws IOException {
    try {
      Long branchUuid = null;
      String artifactGuid = request.getParameter(GUID_KEY);
      String branchName = request.getParameter(BRANCH_NAME_KEY);
      String branchGuid = request.getParameter(BRANCH_GUID_KEY);
      if (branchGuid != null) {
        getLogger()
            .warn(
                "Request with branch guid instead of uuid [%s]",
                request.getRequestURL().append('?').append(request.getQueryString()));
        branchUuid = extractBranchUuid(branchGuid);
      } else {
        branchUuid = Long.parseLong(request.getParameter(BRANCH_UUID_KEY));
      }

      String uri = null;
      BranchQuery query = orcs.getQueryFactory(null).branchQuery();
      if (branchName != null) {
        query.andNameEquals(branchName);
      } else if (branchUuid != null) {
        query.andUuids(branchUuid);
      }
      BranchReadable branch = query.getResults().getExactlyOne();
      Conditions.checkNotNull(branch, "branch", "Unable to determine branch");
      uri = ArtifactUtil.getUri(jdbcClient, artifactGuid, branch);
      handleArtifactUri(resourceManager, request.getQueryString(), uri, response);
    } catch (NumberFormatException ex) {
      handleError(
          response,
          HttpServletResponse.SC_BAD_REQUEST,
          String.format("Invalid Branch Id: [%s]", request.getQueryString()),
          ex);
    } catch (Exception ex) {
      handleError(
          response,
          HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
          String.format("Unable to acquire resource: [%s]", request.getQueryString()),
          ex);
    } finally {
      response.flushBuffer();
    }
  }
示例#12
0
 public static String toStringWithId(Identifiable<String> obj) {
   Conditions.checkNotNull(obj, "object");
   return String.format("[%s][%s]", obj.getGuid(), obj.getName());
 }
示例#13
0
 public boolean isValid() {
   return Conditions.notNull(destinationArtifact, sourceFile, extractor)
       && (extractor.isDelegateRequired() ? extractor.hasDelegate() : true);
 }
示例#14
0
 public static CoverageUnit createCodeUnit(
     URL url, ICoverageUnitFileContentsProvider fileContentsProvider) throws OseeCoreException {
   Conditions.checkNotNull(url, "url", "Valid filename must be specified");
   InputStream inputStream = null;
   CoverageUnit fileCoverageUnit = null;
   try {
     inputStream = url.openStream();
     Conditions.checkNotNull(inputStream, "input stream", "File doesn't exist [%s]", url);
     // Store file as CoverageUnit
     File file = new File(url.getFile());
     String filename = file.getCanonicalFile().getName();
     fileCoverageUnit =
         CoverageUnitFactory.createCoverageUnit(
             null, filename, url.getFile(), fileContentsProvider);
     String fileStr = Lib.inputStreamToString(inputStream);
     Matcher m = packagePattern.matcher(fileStr);
     if (m.find()) {
       fileCoverageUnit.setNamespace(m.group(1));
     } else {
       throw new OseeArgumentException("Can't find package for [%s]", url);
     }
     fileCoverageUnit.setFileContents(fileStr);
     CoverageUnit coverageUnit = null;
     int lineNum = 0;
     for (String line : fileStr.split("(\r\n|\n)")) {
       if (line.contains("IGNORE")) {
         continue;
       }
       lineNum++;
       // Determine if method; store as CoverageUnit
       m = methodPattern.matcher(line);
       if (m.find()) {
         String name = m.group(3);
         coverageUnit =
             CoverageUnitFactory.createCoverageUnit(
                 fileCoverageUnit, name, "Line " + lineNum, fileContentsProvider);
         // Note: CoverageUnit's orderNumber is set by executeLine match below
         fileCoverageUnit.addCoverageUnit(coverageUnit);
         // Duplicate this method as error case for importing
         if (filename.contains("AuxPowerUnit2") && name.equals("clear")) {
           CoverageUnit duplicateCoverageUnit =
               CoverageUnitFactory.createCoverageUnit(
                   fileCoverageUnit, name, "Line " + lineNum, fileContentsProvider);
           duplicateCoverageUnit.setOrderNumber("2");
           fileCoverageUnit.addCoverageUnit(duplicateCoverageUnit);
           CoverageItem item =
               new CoverageItem(duplicateCoverageUnit, CoverageOptionManager.Not_Covered, "1");
           item.setName("return super.getColumn(index)");
           duplicateCoverageUnit.addCoverageItem(item);
         }
       }
       // Determine if executable coverage line; store as CoverageItem
       m = executeLine.matcher(line);
       if (m.find()) {
         String lineText = m.group(1);
         String methodNum = m.group(2);
         String executeNum = m.group(3);
         String testUnits = m.group(4);
         boolean covered = !testUnits.equals("n");
         CoverageItem coverageItem =
             new CoverageItem(
                 coverageUnit,
                 covered ? CoverageOptionManager.Test_Unit : CoverageOptionManager.Not_Covered,
                 executeNum);
         coverageUnit.setOrderNumber(methodNum);
         coverageItem.setName(lineText);
         coverageItem.setOrderNumber(executeNum);
         coverageUnit.addCoverageItem(coverageItem);
         if (covered) {
           for (String testUnitName : testUnits.split("\\|")) {
             coverageItem.addTestUnitName(testUnitName);
           }
         }
       }
     }
   } catch (IOException ex) {
     OseeExceptions.wrapAndThrow(ex);
   }
   return fileCoverageUnit;
 }
示例#15
0
  public List<CpaDecision> load() {
    List<CpaDecision> decisions = new ArrayList<CpaDecision>();
    QueryBuilder queryBuilder =
        atsServer
            .getQuery()
            .andTypeEquals(AtsArtifactTypes.TeamWorkflow)
            .and(AtsAttributeTypes.ApplicabilityWorkflow, "true");
    if (Strings.isValid(programUuid)) {
      queryBuilder.and(AtsAttributeTypes.ProgramUuid, programUuid);
    }
    if (Conditions.hasValues(uuids)) {
      queryBuilder.and(AtsAttributeTypes.AtsId, uuids);
    }
    if (open != null) {
      queryBuilder.and(
          AtsAttributeTypes.CurrentStateType,
          (open ? StateType.Working.name() : StateType.Completed.name()));
    }
    HashCollection<String, CpaDecision> origPcrIdToDecision =
        new HashCollection<String, CpaDecision>();
    String pcrToolId = null;
    ElapsedTime time = new ElapsedTime("load cpa workflows");
    ResultSet<ArtifactReadable> results = queryBuilder.getResults();
    time.end(Units.SEC);
    time = new ElapsedTime("process cpa workflows");
    for (ArtifactReadable art : results) {
      IAtsTeamWorkflow teamWf = atsServer.getWorkItemFactory().getTeamWf(art);
      CpaDecision decision = CpaFactory.getDecision(teamWf, null);
      decision.setApplicability(
          art.getSoleAttributeValue(AtsAttributeTypes.ApplicableToProgram, ""));
      decision.setRationale(art.getSoleAttributeValue(AtsAttributeTypes.Rationale, ""));
      String pcrToolIdValue = art.getSoleAttributeValue(AtsAttributeTypes.PcrToolId, "");
      if (pcrToolId == null) {
        pcrToolId = pcrToolIdValue;
      }
      decision.setPcrSystem(pcrToolIdValue);
      boolean completed =
          art.getSoleAttributeValue(AtsAttributeTypes.CurrentStateType, "")
              .equals(StateType.Completed.name());
      decision.setComplete(completed);
      decision.setAssignees(teamWf.getStateMgr().getAssigneesStr());
      if (completed) {
        decision.setCompletedBy(teamWf.getCompletedBy().getName());
        decision.setCompletedDate(DateUtil.getMMDDYY(teamWf.getCompletedDate()));
      }

      // set location of decision workflow
      decision.setDecisionLocation(
          CpaUtil.getCpaPath(atsServer).path(teamWf.getAtsId()).build().toString());

      // set location of originating pcr
      String origPcrId = art.getSoleAttributeValue(AtsAttributeTypes.OriginatingPcrId);
      origPcrIdToDecision.put(origPcrId, decision);
      decision.setOrigPcrLocation(
          CpaUtil.getCpaPath(atsServer)
              .path(origPcrId)
              .queryParam("pcrSystem", decision.getPcrSystem())
              .build()
              .toString());

      // set location of duplicated pcr (if any)
      String duplicatedPcrId = art.getSoleAttributeValue(AtsAttributeTypes.DuplicatedPcrId, null);
      if (Strings.isValid(duplicatedPcrId)) {
        String duplicatedLocation =
            CpaUtil.getCpaPath(atsServer)
                .path(duplicatedPcrId)
                .queryParam("pcrSystem", decision.getPcrSystem())
                .build()
                .toString();
        decision.setDuplicatedPcrLocation(duplicatedLocation);
        decision.setDuplicatedPcrId(duplicatedPcrId);
      }

      decisions.add(decision);
    }
    time.end();

    time = new ElapsedTime("load issues");
    IAtsCpaService service = cpaRegistry.getServiceById(pcrToolId);
    for (Entry<String, CpaPcr> entry :
        service.getPcrsByIds(origPcrIdToDecision.keySet()).entrySet()) {
      for (CpaDecision decision : origPcrIdToDecision.getValues(entry.getKey())) {
        decision.setOriginatingPcr(entry.getValue());
      }
    }
    time.end();

    return decisions;
  }
 public AttributeNotExistsSearch(IAttributeType attributeType) {
   Conditions.checkNotNull(attributeType, "attributeType");
   this.attributeType = attributeType;
 }
示例#17
0
 public static String toStringWithId(IAtsObject obj) {
   Conditions.checkNotNull(obj, "object");
   return String.format("[%s][%s]", obj.getUuid(), obj.getName());
 }