private void mountFiles(String path, Class<?> clazz) {
    try {
      List<Resource> list = new ArrayList<>();
      String packagePath = clazz.getPackage().getName().replace('.', '/');

      PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
      Resource[] res = resolver.getResources("classpath:" + packagePath + "/*.png");
      if (res != null) {
        list.addAll(Arrays.asList(res));
      }
      res = resolver.getResources("classpath:" + packagePath + "/*.gif");
      if (res != null) {
        list.addAll(Arrays.asList(res));
      }

      for (Resource resource : list) {
        URI uri = resource.getURI();
        File file = new File(uri.toString());
        mountResource(
            path + "/" + file.getName(), new SharedResourceReference(clazz, file.getName()));
      }
    } catch (Exception ex) {
      LoggingUtils.logUnexpectedException(LOGGER, "Couldn't mount files", ex);
    }
  }
 /** Initialize the (java.bean) PropertyDescriptors for the properties */
 private void initPropertyDescriptor() {
   for (Iterator<String> it = orderedExportedProperties.iterator(); it.hasNext(); ) {
     String propertyName = it.next();
     try {
       // we're using this specialized constructor since we want to allow properties that are
       // read-only (such as creationDate).
       // with the simpler constructor (String,Class) that would result in an Exception.
       // also note that we're using "is"+propertyName rather than get - that's the way the
       // PropertyDescriptor itself
       // does it in the constructor (String,Class) - resulting in a lookup of an is Method first
       // and then the get Method
       // this seems to be the correct standard here.
       PropertyDescriptor pd =
           new PropertyDescriptor(
               propertyName, LoggingObject.class, "is" + capitalize(propertyName), null);
       orderedExportedPropertyDescriptors.add(pd);
     } catch (IntrospectionException e) {
       log_.error(
           "initPropertyDescriptor: Could not retrieve property "
               + propertyName
               + " from LoggingObject, configuration error?",
           e);
     }
   }
 }
  @Override
  public void setUp() throws Exception {
    solo = new Solo(getInstrumentation(), getActivity());

    FlashcardActivityState state = FlashcardActivityState_.getInstance_(solo.getCurrentActivity());
    state.setBox(1);

    DatabaseOpenHelper openHelper = new DatabaseOpenHelper(solo.getCurrentActivity());
    cardDao = openHelper.getDao(Card.class);
    cardDao.queryForAll().size();
    List<List<String>> cards =
        Arrays.asList(
            Arrays.asList("111", "AAA", "1"),
            Arrays.asList("222", "BBB", "1"),
            Arrays.asList("333", "CCC", "1"),
            Arrays.asList("444", "DDD", "1"),
            Arrays.asList("555", "EEE", "1"),
            Arrays.asList("666", "FFF", "2"),
            Arrays.asList("777", "GGG", "2"),
            Arrays.asList("888", "HHH", "3"),
            Arrays.asList("999", "III", "3"));
    for (List<String> card : cards) {
      createCardForTest(card.get(0), card.get(1), Integer.valueOf(card.get(2)));
    }
  }
Example #4
0
  protected CapitalAssetSystem getCapitalAssetSystemForIndividual(
      Integer poId, PurApItem purApItem) {
    List<PurchasingCapitalAssetItem> capitalAssetItems =
        this.getPurchaseOrderService().retrieveCapitalAssetItemsForIndividual(poId);
    if (capitalAssetItems == null || capitalAssetItems.isEmpty()) {
      return null;
    }

    Integer purchaseOrderItemIdentifier = null;
    PurchaseOrderItem poi = null;
    if (purApItem instanceof PaymentRequestItem) {
      poi = ((PaymentRequestItem) purApItem).getPurchaseOrderItem();

    } else if (purApItem instanceof CreditMemoItem) {
      poi = getPurchaseOrderItemfromCreditMemoItem((CreditMemoItem) purApItem);
    }

    if (poi != null) {
      purchaseOrderItemIdentifier = poi.getItemIdentifier();
    }
    for (PurchasingCapitalAssetItem capitalAssetItem : capitalAssetItems) {
      if (capitalAssetItem.getItemIdentifier().equals(purchaseOrderItemIdentifier)) {
        return capitalAssetItem.getPurchasingCapitalAssetSystem();
      }
    }
    return null;
  }
Example #5
0
 public static void callAsynchroneMethod(
     Class clazz, String methodName, Serializable argument1, Serializable argument2) {
   List<Serializable> args = new ArrayList();
   args.add(argument1);
   args.add(argument2);
   callAsynchroneMethod(clazz, methodName, args);
 }
 /**
  * Returns either a list of all the files connected to this program or the single file that
  * represents this program exactly, if such a file exists.
  *
  * @param request
  * @param context
  * @return
  * @throws InvalidCredentialsException
  * @throws InvalidResourceException
  * @throws MethodFailedException
  */
 private List<String> findFileObjects(TranscodeRequest request, InfrastructureContext context)
     throws InvalidCredentialsException, InvalidResourceException, MethodFailedException {
   CentralWebservice doms = CentralWebserviceFactory.getServiceInstance(context);
   List<String> fileObjectPids = new ArrayList<String>();
   List<Relation> relations = doms.getRelations(request.getObjectPid());
   for (Relation relation : relations) {
     logger.debug(
         "Relation: "
             + request.getObjectPid()
             + " "
             + relation.getPredicate()
             + " "
             + relation.getObject());
     if (relation.getPredicate().equals(HAS_EXACT_FILE_RELATION)) {
       fileObjectPids = new ArrayList<String>();
       fileObjectPids.add(relation.getObject());
       request.setHasExactFile(true);
       logger.debug(
           "Program " + request.getObjectPid() + " has an exact file " + relation.getObject());
       return fileObjectPids;
     } else if (relation.getPredicate().equals(HAS_FILE_RELATION)) {
       fileObjectPids.add(relation.getObject());
     }
   }
   return fileObjectPids;
 }
  @Override
  public PortfolioSearchResult search(PortfolioSearchRequest request) {
    ArgumentChecker.notNull(request, "request");
    Collection<PortfolioDocument> docsToCheck = null;

    if ((request.getName() != null) && !RegexUtils.containsWildcard(request.getName())) {
      docsToCheck = _portfoliosByName.get(request.getName());
    } else {
      docsToCheck = _store.values();
    }
    if (docsToCheck == null) {
      docsToCheck = Collections.emptySet();
    }

    final List<PortfolioDocument> list = new ArrayList<PortfolioDocument>();
    for (PortfolioDocument doc : docsToCheck) {
      if (request.matches(doc)) {
        PortfolioDocument docToAdd = isCloneResults() ? clonePortfolioDocument(doc) : doc;
        list.add(docToAdd);
      }
    }
    final PortfolioSearchResult result = new PortfolioSearchResult();
    result.setPaging(Paging.of(request.getPagingRequest(), list));
    result.getDocuments().addAll(request.getPagingRequest().select(list));
    return result;
  }
Example #8
0
  /* input defaults to reading the Fakefile, cwd to "." */
  public void make(InputStream input, File cwd, String[] args) {
    try {
      Parser parser = parse(input, cwd);

      // filter out variable definitions
      int firstArg = 0;
      while (firstArg < args.length && args[firstArg].indexOf('=') >= 0) firstArg++;

      List<String> list = null;
      if (args.length > firstArg) {
        list = new ArrayList<String>();
        for (int i = firstArg; i < args.length; i++) list.add(args[i]);
      }
      Rule all = parser.parseRules(list);

      for (int i = 0; i < firstArg; i++) {
        int equal = args[i].indexOf('=');
        parser.setVariable(args[i].substring(0, equal), args[i].substring(equal + 1));
      }

      for (Rule rule : all.getDependenciesRecursively())
        if (rule.getVarBool("rebuild")) rule.clean(false);

      String parallel = all.getVar("parallel");
      if (parallel != null) all.makeParallel(Integer.parseInt(parallel));
      else all.make();
    } catch (FakeException e) {
      System.err.println(e);
      System.exit(1);
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(1);
    }
  }
  // Java Client for GeoNames Webservices
  private String getPhysicalPlaceOnGeonames(double lat, double lng) {
    String sPlaceName = "";
    String sGeoNameId = "";
    String hostname = "www.geonames.org";
    try {
      Process p1 = java.lang.Runtime.getRuntime().exec("ping -c 1 " + hostname);
      int returnVal = p1.waitFor();
      boolean reachable = (returnVal == 0);

      if (reachable) {
        WebService.setUserName("betaas");

        PostalCodeSearchCriteria postalCodeSearchCriteria = new PostalCodeSearchCriteria();
        postalCodeSearchCriteria.setLatitude(lat);
        postalCodeSearchCriteria.setLongitude(lng);
        List<Toponym> placeNames = WebService.findNearbyPlaceName(lat, lng);
        for (int i = 0; i < placeNames.size(); i++) {
          sGeoNameId = String.valueOf(placeNames.get(i).getGeoNameId());
          sPlaceName = "<" + PREFIX_GEONAMES + sGeoNameId + ">";
        }
      }
      //      else
      //        mLogger.info("[CM] Adaptation Context Manager, Geonames function. Service " +
      // hostname + " unavailable.");
    } catch (Exception e) {
      //      mLogger
      //          .error("[CM] Adaptation Context Manager, Geonames function. It has not been
      // executed correctly. Probably there is not Internet connection.");
    }
    return sPlaceName;
  }
Example #10
0
 public void setBlockCheck(World w, int x, int y, int z, int m, byte d, int id) {
   // List of blocks that a door cannot be placed on
   List<Integer> ids =
       Arrays.asList(
           0, 6, 8, 9, 10, 11, 18, 20, 26, 27, 28, 29, 30, 31, 32, 33, 34, 37, 38, 39, 40, 44, 46,
           50, 51, 53, 54, 55, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 75, 76,
           77, 78, 79, 81, 83, 85, 89, 92, 93, 94, 96, 101, 102, 104, 105, 106, 107, 108, 109, 111,
           113, 114, 115, 116, 117, 118, 119, 120, 122, 128, 130, 131, 132, 134, 135, 136);
   Block b = w.getBlockAt(x, y, z);
   Integer bId = Integer.valueOf(b.getTypeId());
   byte bData = b.getData();
   Statement statement = null;
   if (ids.contains(bId)) {
     b.setTypeIdAndData(m, d, true);
     // remember replaced block location, TypeId and Data so we can restore it later
     try {
       Connection connection = service.getConnection();
       statement = connection.createStatement();
       String replaced = w.getName() + ":" + x + ":" + y + ":" + z + ":" + bId + ":" + bData;
       String queryReplaced =
           "UPDATE tardis SET replaced = '" + replaced + "' WHERE tardis_id = " + id;
       statement.executeUpdate(queryReplaced);
       statement.close();
     } catch (SQLException e) {
       plugin.console.sendMessage(plugin.pluginName + "Set Replaced Block Error: " + e);
     } finally {
       try {
         statement.close();
       } catch (Exception e) {
       }
     }
   }
 }
Example #11
0
  @RequestMapping("/loadRuntimeInfo")
  @ResponseBody
  public JSONObject doLoadRuntimeInfo(HttpServletRequest request) {
    try {
      String app = request.getParameter("app");
      RuntimeMXBean mBean = JMConnManager.getRuntimeMBean(app);
      ClassLoadingMXBean cBean = JMConnManager.getClassMbean(app);
      Map<String, String> props = mBean.getSystemProperties();
      DateFormat format = DateFormat.getInstance();
      List<String> input = mBean.getInputArguments();
      Date date = new Date(mBean.getStartTime());

      TreeMap<String, Object> data = new TreeMap<String, Object>();

      data.put("apppid", mBean.getName());
      data.put("startparam", input.toString());
      data.put("starttime", format.format(date));
      data.put("classLoadedNow", cBean.getLoadedClassCount());
      data.put("classUnloadedAll", cBean.getUnloadedClassCount());
      data.put("classLoadedAll", cBean.getTotalLoadedClassCount());
      data.putAll(props);

      JSONObject json = new JSONObject(true);
      json.putAll(data);
      return json;
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
Example #12
0
 private List<Block> toBlockList(Collection<BlockVector> locs) {
   List<Block> blocks = new ArrayList<>(locs.size());
   for (BlockVector location : locs)
     blocks.add(
         world.getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ()));
   return blocks;
 }
Example #13
0
 @Override
 public void onBindViewHolder(final SimpleItemViewHolder holder, final int position) {
   holder.realBackground.setBackgroundColor(
       context.getResources().getColor(android.R.color.white));
   holder.name.setText(items.get(position).getName());
   holder.author.setText(items.get(position).getAuthor());
   Picasso.with(context).load(items.get(position).getThumb()).into(holder.target);
   holder.mainView.setOnClickListener(
       new View.OnClickListener() {
         @Override
         public void onClick(View v) {
           Snackbar.make(
                   ((Activity) context).findViewById(R.id.coordinating_wall),
                   "Wait!",
                   Snackbar.LENGTH_LONG)
               .show();
           new Thread(
                   new Runnable() {
                     @Override
                     public void run() {
                       checkForStoragePermission(position, holder);
                     }
                   })
               .start();
         }
       });
 }
Example #14
0
  public void split() throws IOException {
    List<ObjectPath> pathTable = asset.getPaths();
    TypeTree typeTree = asset.getTypeTree();

    // assets with just one object can't be split any further
    if (pathTable.size() == 1) {
      L.warning("Asset doesn't contain sub-assets!");
      return;
    }

    for (ObjectPath path : pathTable) {
      // skip filtered classes
      if (cf != null && !cf.accept(path)) {
        continue;
      }

      String className = ClassID.getNameForID(path.getClassID(), true);

      AssetFile subAsset = new AssetFile();
      subAsset.getHeader().setFormat(asset.getHeader().getFormat());

      ObjectPath subFieldPath = new ObjectPath();
      subFieldPath.setClassID1(path.getClassID1());
      subFieldPath.setClassID2(path.getClassID2());
      subFieldPath.setLength(path.getLength());
      subFieldPath.setOffset(0);
      subFieldPath.setPathID(1);
      subAsset.getPaths().add(subFieldPath);

      TypeTree subTypeTree = subAsset.getTypeTree();
      subTypeTree.setEngineVersion(typeTree.getEngineVersion());
      subTypeTree.setVersion(-2);
      subTypeTree.setFormat(typeTree.getFormat());
      subTypeTree.getFields().put(path.getClassID(), typeTree.getFields().get(path.getClassID()));

      subAsset.setDataBuffer(asset.getPathBuffer(path));

      Path subAssetDir = outputDir.resolve(className);
      if (Files.notExists(subAssetDir)) {
        Files.createDirectories(subAssetDir);
      }

      // probe asset name
      String subAssetName = getObjectName(asset, path);
      if (subAssetName != null) {
        // remove any chars that could cause troubles on various file systems
        subAssetName = FilenameSanitizer.sanitizeName(subAssetName);
      } else {
        // use numeric names
        subAssetName = String.format("%06d", path.getPathID());
      }
      subAssetName += ".asset";

      Path subAssetFile = subAssetDir.resolve(subAssetName);
      if (Files.notExists(subAssetFile)) {
        L.log(Level.INFO, "Writing {0}", subAssetFile);
        subAsset.save(subAssetFile);
      }
    }
  }
Example #15
0
  /**
   * Select a subset of all annotations within a pitch - time range.
   *
   * @param selection A selection defines a pitch-time range.
   * @return A range selection of annotations.
   */
  public List<Annotation> select(final AnnotationSelection selection) {
    final StopWatch watch = new StopWatch();
    double startTime = selection.getStartTime();
    double stopTime = selection.getStopTime();
    double startPitch = selection.getStartPitch();
    double stopPitch = selection.getStopPitch();
    double startProbability = selection.getMinProbability();
    double stopProbability = AnnotationSelection.MAX_PROBABILITY;

    double[] lowKey = {startTime, startPitch, startProbability};
    double[] upperKey = {stopTime, stopPitch, stopProbability};

    List<Annotation> selectedAnnotations = null;
    try {
      selectedAnnotations = tree.range(lowKey, upperKey);
    } catch (KeySizeException e) {
      new IllegalStateException(
          "The dimenstion of the tree is two, the dimension of the key also.");
    }
    LOG.finer(
        String.format(
            "Selected %s annotations from a KD-tree of %s annotations in %s.",
            selectedAnnotations.size(), tree.size(), watch.formattedToString()));
    return selectedAnnotations;
  }
Example #16
0
  // 保存采购量的提交方法
  public String saveyycgdmxsubmit() throws Exception {
    YycgdQueryVo yycgdQueryVo = getModel();
    // 采购单id
    Long yycgdid = yycgdQueryVo.getYycgdCustom().getId();
    // 得到页面中所有药品信息id和采购量
    List<YycgdmxCustom> yycgdmxs = yycgdQueryVo.getYycgdmxs();

    // 得到页面提交选中行的序号
    String indexs = yycgdQueryVo.getIndexs();
    String[] indexs_split = indexs.split(",");

    // 最终要处理的数据
    List<YycgdmxCustom> disposeData = new ArrayList<YycgdmxCustom>();

    // 遍历选中行的序号,根据序号从yycgdmxs 取出要处理的数据
    for (int i = 0; i < indexs_split.length; i++) {
      // 取出了序号
      int index = Integer.parseInt(indexs_split[i]);
      // 根据序号取出要处理的数据
      YycgdmxCustom yycgdmxCustom = yycgdmxs.get(index);
      disposeData.add(yycgdmxCustom);
    }
    // 保存采购药品明细
    serviceFacade.getCgdService().saveYycgdmxList(yycgdid, disposeData);
    this.setProcessResult(
        ResultUtil.createSubmitResult(ResultUtil.createSuccess(Config.MESSAGE, 906, null)));
    return "saveyycgdmxsubmit";
  }
 static {
   mustContain = new ArrayList<>();
   mustContain.add("E1M1");
   mustContain.add("E2M1");
   mustContain.add("TITLE");
   mustContain.add("MUS_E1M1");
 }
Example #18
0
  // 保存采购药品明细的发货状态
  public String savesendstate() throws Exception {
    YycgdQueryVo yycgdQueryVo = getModel();
    // 页面提交的采购单id
    Long yycgdid = yycgdQueryVo.getYycgdCustom().getId();

    // 接收页面提交所有采购药品明细的发货状态(页面显示的所有下拉框和药品信息id的hidden对象)
    List<YycgdmxCustom> yycgdmxs = yycgdQueryVo.getYycgdmxs();

    // 定义一个要处理的采购药品列表
    List<YycgdmxCustom> yycgdmxs_dispose = new ArrayList<YycgdmxCustom>();

    // 接收页面提交要处理的记录序号
    String indexs = yycgdQueryVo.getIndexs();
    String[] split = indexs.split(",");
    for (int i = 0; i < split.length; i++) {
      // 得到记录的序号
      Integer index = Integer.parseInt(split[i]);
      // 得到要处理的药品id和发货状态对象
      YycgdmxCustom yycgdmxCustom = yycgdmxs.get(index);
      // 放入要处理的列表中
      yycgdmxs_dispose.add(yycgdmxCustom);
    }
    // 只处理页面checkbox选中的记录
    serviceFacade.getCgdService().saveSendState(yycgdid, yycgdmxs_dispose);
    this.setProcessResult(
        ResultUtil.createSubmitResult(ResultUtil.createSuccess(Config.MESSAGE, 906, null)));
    return "savesendstate";
  }
  @GET
  @Path("/{reviewId}")
  @Timed(name = "view-book-by-reviewId")
  public Response viewBookReview(
      @PathParam("isbn") LongParam isbn, @PathParam("reviewId") IntParam reviewId) {

    Book book = bookRepository.getBookByISBN(isbn.get());

    ReviewDto reviewResponse = null;
    List<Review> reviewList = book.getReview();

    List<Review> tempList = new ArrayList<Review>();
    for (Review reviewObj : reviewList) {

      if (reviewObj.getId() == reviewId.get()) tempList.add(reviewObj);
    }
    reviewResponse = new ReviewDto(tempList);
    String location = "/books/" + book.getIsbn() + "/reviews/";

    HashMap<String, Object> map = new HashMap<String, Object>();

    Review review = reviewResponse.getReviewList().get(0);
    map.put("review", review);
    reviewResponse.addLink(new LinkDto("view-review", location + reviewId.get(), "GET"));
    map.put("links", reviewResponse.getLinks());
    return Response.status(200).entity(map).build();
  }
  public void validateAndCorrect() {
    if (vardAdress == null) {
      validationErrors.add("No vardAdress element found!");
      return;
    }

    HosPersonalType hosPersonal = vardAdress.getHosPersonal();
    if (hosPersonal == null) {
      validationErrors.add("No SkapadAvHosPersonal element found!");
      return;
    }

    // Check lakar id - mandatory
    if (hosPersonal.getPersonalId().getExtension() == null
        || hosPersonal.getPersonalId().getExtension().isEmpty()) {
      validationErrors.add("No personal-id found!");
    }

    // Check lakar id o.i.d.
    if (hosPersonal.getPersonalId().getRoot() == null
        || !hosPersonal.getPersonalId().getRoot().equals(HOS_PERSONAL_OID)) {
      validationErrors.add("Wrong o.i.d. for personalId! Should be " + HOS_PERSONAL_OID);
    }

    // Check lakarnamn - mandatory
    if (hosPersonal.getFullstandigtNamn() == null || hosPersonal.getFullstandigtNamn().isEmpty()) {
      validationErrors.add("No skapadAvHosPersonal fullstandigtNamn found.");
    }

    validateHosPersonalEnhet(hosPersonal.getEnhet());
  }
Example #21
0
 /*
  * This function inspects a .class file for a given .java file,
  * infers the package name and all used classes, and adds to "all"
  * the class file names of those classes used that have been found
  * in the same class path.
  */
 protected void java2classFiles(
     String java, File cwd, File buildDir, List<String> result, Set<String> all) {
   if (java.endsWith(".java")) java = java.substring(0, java.length() - 5) + ".class";
   else if (!java.endsWith(".class")) {
     if (!all.contains(java)) {
       if (buildDir == null) sortClassesAtEnd(result);
       result.add(java);
       all.add(java);
     }
     return;
   }
   byte[] buffer = Util.readFile(Util.makePath(cwd, java));
   if (buffer == null) {
     if (!java.endsWith("/package-info.class"))
       err.println("Warning: " + java + " does not exist.  Skipping...");
     return;
   }
   ByteCodeAnalyzer analyzer = new ByteCodeAnalyzer(buffer);
   String fullClass = analyzer.getPathForClass() + ".class";
   if (!java.endsWith(fullClass))
     throw new RuntimeException("Huh? " + fullClass + " is not a suffix of " + java);
   java = java.substring(0, java.length() - fullClass.length());
   for (String className : analyzer.getClassNames()) {
     String path = java + className + ".class";
     if (new File(Util.makePath(cwd, path)).exists() && !all.contains(path)) {
       result.add(path);
       all.add(path);
       java2classFiles(path, cwd, buildDir, result, all);
     }
   }
 }
  private void validateHosPersonalEnhet(EnhetType enhet) {
    if (enhet == null) {
      validationErrors.add("No enhet element found!");
      return;
    }

    // Check enhets id - mandatory
    if (enhet.getEnhetsId() == null
        || enhet.getEnhetsId().getExtension() == null
        || enhet.getEnhetsId().getExtension().isEmpty()) {
      validationErrors.add("No enhets-id found!");
    }

    // Check enhets o.i.d
    if (enhet.getEnhetsId() == null
        || enhet.getEnhetsId().getRoot() == null
        || !enhet.getEnhetsId().getRoot().equals(ENHET_OID)) {
      validationErrors.add("Wrong o.i.d. for enhetsId! Should be " + ENHET_OID);
    }

    // Check enhetsnamn - mandatory
    if (enhet.getEnhetsnamn() == null || enhet.getEnhetsnamn().length() < 1) {
      validationErrors.add("No enhetsnamn found!");
    }

    validateVardgivare(enhet.getVardgivare());
  }
Example #23
0
  @Override
  public Object visit(ASTVariableDeclarator node, Object data) {
    // Search Catch stmt nodes for variable used to store improperly created
    // throwable or exception
    try {
      if (node.hasDescendantMatchingXPath(FIND_THROWABLE_INSTANCE)) {
        String variableName = node.jjtGetChild(0).getImage(); // VariableDeclatorId
        ASTCatchStatement catchStmt = node.getFirstParentOfType(ASTCatchStatement.class);

        while (catchStmt != null) {
          List<Node> violations =
              catchStmt.findChildNodesWithXPath(
                  "//Expression/PrimaryExpression/PrimaryPrefix/Name[@Image = '"
                      + variableName
                      + "']");
          if (!violations.isEmpty()) {
            // If, after this allocation, the 'initCause' method is
            // called, and the ex passed
            // this is not a violation
            if (!useInitCause(violations.get(0), catchStmt)) {
              addViolation(data, node);
            }
          }

          // check ASTCatchStatement higher up
          catchStmt = catchStmt.getFirstParentOfType(ASTCatchStatement.class);
        }
      }
      return super.visit(node, data);
    } catch (JaxenException e) {
      // XPath is valid, this should never happens...
      throw new IllegalStateException(e);
    }
  }
Example #24
0
  public String getTransformedURL(Core core) {
    String result = getUrl();
    log.debug("URL before transformation: " + url);
    // index.jsp?param=${type}&param2=${id}&param3=${fieldname}
    Pattern p = Pattern.compile("(?!\\$\\{)([A-Za-z0-9]+?)(?:\\})", Pattern.CASE_INSENSITIVE);

    List<String> list = new ArrayList<String>();
    Matcher m = p.matcher(url);
    while (m.find()) {
      String tokenpart = m.group(1);
      log.debug("tokenpart = " + tokenpart);
      list.add(tokenpart);
    }
    log.debug("We found parameters: " + list);

    for (String param : list) {
      if ("user".equalsIgnoreCase(param)) {
        result = result.replaceAll("\\$\\{user\\}", core.getLoggedInUser().getUserName());
      }
    }

    log.debug("Returning URL: " + result);

    return result;
  }
  /**
   * Returns a CSV line for the given LoggingObject - containing all properties in the exact same
   * way as in the config file - excluding those which could not be retrieved, i.e. for which no
   * PropertyDescriptor could be created
   *
   * @param loggingObject the LoggingObject for which a CSV line should be created
   * @return the CSV line representing the given LoggingObject
   */
  public String getCSVRow(LoggingObject loggingObject, boolean anonymize, Long resourceableId) {
    List<String> loggingObjectList = new ArrayList<String>();
    for (Iterator<PropertyDescriptor> it = orderedExportedPropertyDescriptors.iterator();
        it.hasNext(); ) {
      PropertyDescriptor pd = it.next();

      String strValue = "";
      try {
        Object value = pd.getReadMethod().invoke(loggingObject, (Object[]) null);
        if (value != null) {
          strValue = String.valueOf(value);
        }
        if (anonymize && anonymizedProperties.contains(pd.getName())) {
          // do anonymization
          strValue = makeAnonymous(String.valueOf(value), resourceableId);
        }
      } catch (IllegalArgumentException e) {
        // nothing to do
      } catch (IllegalAccessException e) {
        // nothing to do
      } catch (InvocationTargetException e) {
        // nothing to do
      }
      loggingObjectList.add(strValue);
    }

    return StringHelper.formatAsCSVString(loggingObjectList);
  }
Example #26
0
  /*멤버메소드*/
  @Override
  public void actionPerformed(ActionEvent e) {
    // 버튼 객체 6개를 만들고
    if (btns.size() == 0) {
      JButton tmp = null;
      for (int i = 0; i < 6; i++) {
        tmp = new JButton();
        btns.add(tmp);
        panelSouth.add(tmp);
      }
    }

    // 6개의 랜덤숫자를 만들고
    lotto.setLotto();
    int[] arr = lotto.getLotto();
    /*
     * 디버깅 : 프로그램을 구성하는데는 필수적인 소스는 아니지만
     * 			에러발생시 에러의 원인을 파악하기 위해 붙여 둔 소스
     */
    for (int i = 0; i < arr.length; i++) {
      System.out.println(arr[i] + "\t");
    }
    // 6개의 버튼 객체에 아이콘(이미지)을 붙인다
    for (int i = 0; i < arr.length; i++) {
      btns.get(i).setIcon(getIcon(arr[i]));
    }
  }
 private List<BroadcastMetadata> getBroadcastMetadata(
     List<String> fileObjectPids, InfrastructureContext context, TranscodeRequest request)
     throws ProcessorException {
   Map<String, BroadcastMetadata> pidMap = new HashMap<String, BroadcastMetadata>();
   CentralWebservice doms = CentralWebserviceFactory.getServiceInstance(context);
   List<BroadcastMetadata> broadcastMetadataList = new ArrayList<BroadcastMetadata>();
   for (String fileObjectPid : fileObjectPids) {
     BroadcastMetadata broadcastMetadata = null;
     try {
       String broadcastMetadataXml =
           doms.getDatastreamContents(fileObjectPid, "BROADCAST_METADATA");
       logger.debug("Found file metadata '" + fileObjectPid + "' :\n" + broadcastMetadataXml);
       broadcastMetadata =
           JAXBContext.newInstance(BroadcastMetadata.class)
               .createUnmarshaller()
               .unmarshal(
                   new StreamSource(new StringReader(broadcastMetadataXml)),
                   BroadcastMetadata.class)
               .getValue();
     } catch (Exception e) {
       throw new ProcessorException(
           "Failed to get Broadcast Metadata for " + request.getObjectPid(), e);
     }
     broadcastMetadataList.add(broadcastMetadata);
     pidMap.put(fileObjectPid, broadcastMetadata);
   }
   request.setPidMap(pidMap);
   return broadcastMetadataList;
 }
Example #28
0
  /**
   * Gets the stack trace elements.
   *
   * @param stackTrace The stack trace in composite data array
   * @return The stack trace elements
   */
  private StackTraceElement[] getStackTrace(CompositeData[] stackTrace) {
    List<StackTraceElement> list = new ArrayList<StackTraceElement>();
    for (CompositeData compositeData : stackTrace) {
      Object className = compositeData.get(CLASS_NAME);
      Object fileName = compositeData.get(FILE_NAME);
      Object lineNumber = compositeData.get(LINE_NUMBER);
      Object metohdName = compositeData.get(METHOD_NAME);
      Object nativeMethod = compositeData.get(NATIVE_METHOD);

      if ((className instanceof String)
          && (className instanceof String)
          && (fileName instanceof String)
          && (lineNumber instanceof Integer)
          && (metohdName instanceof String)
          && (nativeMethod instanceof Boolean)) {
        list.add(
            new StackTraceElement(
                (String) className,
                (String) metohdName,
                (String) fileName,
                (Boolean) nativeMethod ? -2 : (Integer) lineNumber));
      }
    }
    return list.toArray(new StackTraceElement[list.size()]);
  }
Example #29
0
 public static Serializable callMethod(
     Class clazz, String methodName, Serializable argument1, Serializable argument2) {
   List<Serializable> args = new ArrayList();
   args.add(argument1);
   args.add(argument2);
   return callMethod(clazz, methodName, args);
 }
Example #30
0
  /**
   * Set Multiple system capital asset transaction type code and asset numbers.
   *
   * @param poId
   * @param purApDocs
   */
  protected void setMultipleSystemFromPurAp(
      Integer poId,
      List<PurchasingAccountsPayableDocument> purApDocs,
      String capitalAssetSystemStateCode) {
    List<CapitalAssetSystem> capitalAssetSystems =
        this.getPurchaseOrderService().retrieveCapitalAssetSystemsForMultipleSystem(poId);
    if (ObjectUtils.isNotNull(capitalAssetSystems) && !capitalAssetSystems.isEmpty()) {
      // PurAp doesn't support multiple system asset information for KFS3.0. It works as one system
      // for 3.0.
      CapitalAssetSystem capitalAssetSystem = capitalAssetSystems.get(0);
      if (ObjectUtils.isNotNull(capitalAssetSystem)) {
        String capitalAssetTransactionType = getCapitalAssetTransTypeForOneSystem(poId);
        // if modify existing asset, acquire the assets from Purap
        List<ItemCapitalAsset> purApCapitalAssets = null;
        if (PurapConstants.CapitalAssetSystemStates.MODIFY.equalsIgnoreCase(
            capitalAssetSystemStateCode)) {
          purApCapitalAssets =
              getAssetsFromItemCapitalAsset(capitalAssetSystem.getItemCapitalAssets());
        }

        // set TransactionTypeCode, itemCapitalAssets and system identifier for each item
        for (PurchasingAccountsPayableDocument purApDoc : purApDocs) {
          setItemAssetsCamsTransaction(
              capitalAssetSystem.getCapitalAssetSystemIdentifier(),
              capitalAssetTransactionType,
              purApCapitalAssets,
              purApDoc.getPurchasingAccountsPayableItemAssets());
        }
      }
    }
  }