private APIKeyValidationInfoDTO toDTO(
     org.wso2.carbon.apimgt.impl.dto.xsd.APIKeyValidationInfoDTO generatedDto) {
   APIKeyValidationInfoDTO dto = new APIKeyValidationInfoDTO();
   dto.setSubscriber(generatedDto.getSubscriber());
   dto.setAuthorized(generatedDto.getAuthorized());
   dto.setTier(generatedDto.getTier());
   dto.setType(generatedDto.getType());
   dto.setEndUserToken(generatedDto.getEndUserToken());
   dto.setEndUserName(generatedDto.getEndUserName());
   dto.setApplicationName(generatedDto.getApplicationName());
   dto.setEndUserName(generatedDto.getEndUserName());
   dto.setConsumerKey(generatedDto.getConsumerKey());
   // dto.setAuthorizedDomains(Arrays.asList(generatedDto.getAuthorizedDomains()));
   dto.setValidationStatus(generatedDto.getValidationStatus());
   dto.setApplicationId(generatedDto.getApplicationId());
   dto.setApplicationTier(generatedDto.getApplicationTier());
   dto.setApiPublisher(generatedDto.getApiPublisher());
   dto.setApiName(generatedDto.getApiName());
   dto.setValidityPeriod(generatedDto.getValidityPeriod());
   dto.setIssuedTime(generatedDto.getIssuedTime());
   dto.setApiTier(generatedDto.getApiTier());
   dto.setContentAware(generatedDto.getContentAware());
   dto.setScopes(
       generatedDto.getScopes() == null
           ? null
           : new HashSet<String>(Arrays.asList(generatedDto.getScopes())));
   dto.setThrottlingDataList(Arrays.asList(generatedDto.getThrottlingDataList()));
   dto.setSpikeArrestLimit(generatedDto.getSpikeArrestLimit());
   dto.setSpikeArrestUnit(generatedDto.getSpikeArrestUnit());
   dto.setSubscriberTenantDomain(generatedDto.getSubscriberTenantDomain());
   dto.setStopOnQuotaReach(generatedDto.getStopOnQuotaReach());
   return dto;
 }
Ejemplo n.º 2
0
 /**
  * @param namespacePattern - the format string to be used when constructing the namespace. this
  *     can be a fully formed namespace.
  * @param operationParam - this argument is used to determine the list of possible operation
  *     parameters
  * @param alternativeOperationParam - these arguments are treated as alternatives to
  *     <tt>operationParam</tt> (e.g., <tt>Action</tt> is an alternative to <tt>Operation</tt> ).
  */
 public BaseQueryBinding(
     final String namespacePattern, final T operationParam, final T... alternativeOperationParam) {
   super(namespacePattern);
   this.operationParam = operationParam;
   this.altOperationParams = Arrays.asList(alternativeOperationParam);
   this.possibleParams = Arrays.asList(operationParam.getDeclaringClass().getEnumConstants());
 }
Ejemplo n.º 3
0
  @Test
  public void testStrataNamesAndIdsStrataCriterions() {
    DichotomousCriterion criterion1 = new DichotomousCriterion();
    criterion1.setId(1);
    criterion1.setName("criterion1");
    criterion1.setOption1("option1");
    criterion1.setOption2("option2");
    try {
      DichotomousConstraint d1 = new DichotomousConstraint(Arrays.asList(new String[] {"option1"}));
      d1.setId(1);
      criterion1.addStrata(d1);
      DichotomousConstraint d2 = new DichotomousConstraint(Arrays.asList(new String[] {"option2"}));
      d2.setId(2);
      criterion1.addStrata(d2);
    } catch (ContraintViolatedException e) {
      fail();
    }
    DichotomousCriterion criterion2 = new DichotomousCriterion();
    criterion2.setId(2);
    criterion2.setName("criterion2");
    criterion2.setOption1("option1");
    criterion2.setOption2("option2");
    try {
      DichotomousConstraint d1 = new DichotomousConstraint(Arrays.asList(new String[] {"option1"}));
      d1.setId(1);
      criterion2.addStrata(d1);
      DichotomousConstraint d2 = new DichotomousConstraint(Arrays.asList(new String[] {"option2"}));
      d2.setId(2);
      criterion2.addStrata(d2);
    } catch (ContraintViolatedException e) {
      fail();
    }
    validTrial.addCriterion(criterion1);
    validTrial.addCriterion(criterion2);

    Pair<List<String>, List<String>> pair = validTrial.getAllStrataIdsAndNames();

    assertEquals(4, pair.first().size());
    assertEquals(4, pair.last().size());

    Collections.sort(pair.first());
    assertEquals("1_1;2_1;", pair.first().get(0));
    assertEquals("1_1;2_2;", pair.first().get(1));
    assertEquals("1_2;2_1;", pair.first().get(2));
    assertEquals("1_2;2_2;", pair.first().get(3));

    Collections.sort(pair.last());
    assertEquals("criterion1_option1;criterion2_option1;", pair.last().get(0));
    assertEquals("criterion1_option1;criterion2_option2;", pair.last().get(1));
    assertEquals("criterion1_option2;criterion2_option1;", pair.last().get(2));
    assertEquals("criterion1_option2;criterion2_option2;", pair.last().get(3));
  }
Ejemplo n.º 4
0
 @Override
 public List<PermissionSummary> acceptedPermissions() {
   return Arrays.asList(
       new PermissionSummary[] {
         new PermissionSummary("READ", "READ", PermissionAPI.PERMISSION_READ)
       });
 }
Ejemplo n.º 5
0
 @SuppressWarnings("unchecked")
 public void runAllTasks() throws TaskSystemException {
   try {
     List<String> triggerNames;
     List<Trigger> triggers = new ArrayList<Trigger>();
     String[] groupNames = scheduler.getTriggerGroupNames();
     for (String group : groupNames) {
       triggerNames = new ArrayList<String>(Arrays.asList(scheduler.getTriggerNames(group)));
       for (String triggerName : triggerNames) {
         triggers.add(scheduler.getTrigger(triggerName, group));
       }
     }
     Collections.sort(
         triggers,
         new Comparator<Trigger>() {
           @Override
           public int compare(Trigger trigger1, Trigger trigger2) {
             if (trigger1.getPriority() < trigger2.getPriority()) {
               return -1;
             } else if (trigger1.getPriority() > trigger2.getPriority()) {
               return 1;
             } else {
               return 0;
             }
           }
         });
     for (Trigger trigger : triggers) {
       scheduler.triggerJob(trigger.getJobName(), trigger.getJobGroup());
     }
   } catch (SchedulerException se) {
     throw new TaskSystemException(se);
   }
 }
  public void transferSampleBeanForDataAvailability(
      SampleBean sampleBean, HttpServletRequest request, String[] availableEntityNames) {

    if (sampleBean == null) return;

    setSampleName(sampleBean.getDomain().getName());
    setDataAvailability(sampleBean.getDataAvailabilityMetricsScore());

    this.setCaNanoLabScore(sampleBean.getCaNanoLabScore());
    this.setMincharScore(sampleBean.getMincharScore());

    setCaNanoLabScore(sampleBean.getCaNanoLabScore());
    setMincharScore(sampleBean.getMincharScore());

    SortedSet<String> ca =
        (SortedSet<String>) request.getSession().getServletContext().getAttribute("chemicalAssocs");
    setChemicalAssocs(new ArrayList<String>(ca));

    setCaNano2MINChar(
        (Map<String, String>)
            request.getSession().getServletContext().getAttribute("caNano2MINChar"));

    SortedSet<String> pc =
        (SortedSet<String>) request.getSession().getServletContext().getAttribute("physicoChars");
    setPhysicoChars(new ArrayList<String>(pc));
    SortedSet<String> iv =
        (SortedSet<String>) request.getSession().getServletContext().getAttribute("invitroChars");
    setInvitroChars(new ArrayList<String>(iv));
    SortedSet<String> invivo =
        (SortedSet<String>) request.getSession().getServletContext().getAttribute("invivoChars");
    setInvivoChars(new ArrayList<String>(invivo));

    if (availableEntityNames != null)
      this.availableEntityNames = new ArrayList<String>(Arrays.asList(availableEntityNames));

    // setSampleName(sampleBean.getDomain().getName());

    //		SortedSet<String> ca = (SortedSet<String>)
    // request.getSession().getServletContext().getAttribute("chemicalAssocs");
    //		this.chemicalAssocs = SampleUtil.getStringArrayFromSortedSet(ca);
    //				// SampleUtil.getDefaultListFromSessionByType("chemicalAssocs", request.getSession());
    //
    //
    //		this.caNano2MINChar = (Map<String, String>) request.getSession().getServletContext()
    //				.getAttribute("caNano2MINChar");
    //
    //		SortedSet<String> pc = (SortedSet<String>)
    // request.getSession().getServletContext().getAttribute("physicoChars");
    //		this.physicoChars = SampleUtil.getStringArrayFromSortedSet(pc);
    //		SortedSet<String> iv = (SortedSet<String>)
    // request.getSession().getServletContext().getAttribute("invitroChars");
    //		this.invitroChars = SampleUtil.getStringArrayFromSortedSet(iv);
    //		SortedSet<String> invivo = (SortedSet<String>)
    // request.getSession().getServletContext().getAttribute("invivoChars");
    //		this.invivoChars = SampleUtil.getStringArrayFromSortedSet(invivo);
    //

  }
Ejemplo n.º 7
0
  @Override
  public List<DictionaryData> findDictValue(String columnValue) throws Exception {

    Dictionary dictionary =
        (Dictionary) this.findByColumn(Dictionary.class.getName(), "code", columnValue).get(0);
    Set<DictionaryData> dictionaryDatas = dictionary.getDatas();
    List<DictionaryData> list =
        new ArrayList<DictionaryData>(Arrays.asList(dictionaryDatas.toArray()));
    // 对list排序,
    PropertyComparator.sort(list, new MutableSortDefinition("id", false, true));
    return list;
  }
  private URITemplate toTemplates(org.wso2.carbon.apimgt.api.model.xsd.URITemplate dto) {
    URITemplate template = new URITemplate();
    template.setAuthType(dto.getAuthType());
    template.setHTTPVerb(dto.getHTTPVerb());
    template.setResourceSandboxURI(dto.getResourceSandboxURI());
    template.setUriTemplate(dto.getUriTemplate());
    template.setThrottlingTier(dto.getThrottlingTier());

    ConditionGroupDTO[] xsdConditionGroups = dto.getConditionGroups();
    org.wso2.carbon.apimgt.api.dto.ConditionGroupDTO[] conditionGroups =
        new org.wso2.carbon.apimgt.api.dto.ConditionGroupDTO[xsdConditionGroups.length];

    for (short groupCounter = 0; groupCounter < xsdConditionGroups.length; groupCounter++) {
      org.wso2.carbon.apimgt.api.dto.ConditionGroupDTO conditionGroup =
          new org.wso2.carbon.apimgt.api.dto.ConditionGroupDTO();
      ConditionGroupDTO xsdConditionGroup = xsdConditionGroups[groupCounter];

      // Have to check nullity explicitly here because, in certain cases, length becomes 1 even when
      // there are
      // no elements in the array.
      if (xsdConditionGroup != null) {
        conditionGroup.setConditionGroupId(xsdConditionGroup.getConditionGroupId());
        ConditionDTO[] xsdConditions = xsdConditionGroup.getConditions();

        if (xsdConditions != null) {
          org.wso2.carbon.apimgt.api.dto.ConditionDTO[] conditions =
              new org.wso2.carbon.apimgt.api.dto.ConditionDTO[xsdConditions.length];
          for (short conditionCounter = 0;
              conditionCounter < xsdConditions.length;
              conditionCounter++) {

            ConditionDTO xsdCondition = xsdConditions[conditionCounter];
            if (xsdCondition != null) {
              org.wso2.carbon.apimgt.api.dto.ConditionDTO condition =
                  new org.wso2.carbon.apimgt.api.dto.ConditionDTO();
              condition.setConditionName(xsdCondition.getConditionName());
              condition.setConditionType(xsdCondition.getConditionType());
              condition.setConditionValue(xsdCondition.getConditionValue());
              conditions[conditionCounter] = condition;
            }
          }
          conditionGroup.setConditions(conditions);
        }
        conditionGroups[groupCounter] = conditionGroup;
      }
    }
    template.setConditionGroups(conditionGroups);
    template.setThrottlingConditions((Arrays.asList(dto.getThrottlingConditions())));
    return template;
  }
  @Test
  public void testExecuteForResult() throws Exception {

    resourceService = Mockito.mock(ResourceService.class);
    responseGenerator = Mockito.mock(ResponseGenerator.class);

    addClusterCmd._resourceService = resourceService;
    addClusterCmd._responseGenerator = responseGenerator;

    Cluster cluster = Mockito.mock(Cluster.class);
    Cluster[] clusterArray = new Cluster[] {cluster};

    Mockito.when(resourceService.discoverCluster(addClusterCmd))
        .thenReturn(Arrays.asList(clusterArray));

    addClusterCmd.execute();
  }
Ejemplo n.º 10
0
 /**
  * 拆分到汇兑损益应付单的表体(3条,4/4/2)
  *
  * @param listF
  * @param objSYF
  * @return
  */
 private List<ExchangeSyfBVO> splitToSyfBvos(Object[] objSYF, Object[] objF)
     throws BusinessException {
   ExchangeSyfBVO[] bvos = new ExchangeSyfBVO[3];
   int mainBill = 1; // 主
   int assistBill = 2; // 辅
   if ("PP".equals(objF[12]) || "月结".equals(objF[12])) {
     // 挂在业务员
     bvos[0] = SplitToSyfStartBVO(objF, assistBill);
     bvos[1] = SplitToSyfDesBVO(objF, assistBill);
     bvos[2] = SplitToSellmanBVO(objF, mainBill);
   } else {
     // 挂在目的地
     bvos[0] = SplitToSyfStartBVO(objF, assistBill);
     bvos[1] = SplitToSyfDesBVO(objF, mainBill);
     bvos[2] = SplitToSellmanBVO(objF, assistBill);
   }
   List<ExchangeSyfBVO> list = Arrays.asList(bvos);
   return list;
 }
  /**
   * Checks whether all the elements in the idsAccessing array are found in the idsAllowed
   * Collection
   *
   * @param idsAccessing the ids the user is trying to access
   * @param idsAllowed the ids the user is allowed to access
   * @return whether all the elements are in the Collection
   */
  private boolean elementsInCollection(String[] idsAccessing, Collection<Workgroup> idsAllowed) {
    // convert the accessing array to a list
    List<String> idsAccessingList = Arrays.asList(idsAccessing);

    // convert the allowed Collection to a list
    List<String> idsAllowedList = new ArrayList<String>();

    // obtain an iterator for the Collection
    Iterator<Workgroup> idsAllowedIter = idsAllowed.iterator();

    // loop through all the Workgroups in the Collection
    while (idsAllowedIter.hasNext()) {
      // obtain the workgroup id from the Workgroup
      String idAllowed = idsAllowedIter.next().getId().toString();

      // add the workgroup id string to the list of allowed ids
      idsAllowedList.add(idAllowed);
    }

    // see if all the elements in the accessing list are in the allowed list
    return idsAllowedList.containsAll(idsAccessingList);
  }