コード例 #1
0
  @Override
  @Transactional
  public void addNewAlias(Application application, String alias)
      throws ServiceException, CheckException {

    logger.info("ALIAS VALUE IN addNewAlias : " + alias);

    if (checkAliasIfExists(alias)) {
      throw new CheckException(
          "This alias is already used by another application on this CloudUnit instance");
    }

    alias = alias.toLowerCase();
    if (alias.startsWith("https://") || alias.startsWith("http://") || alias.startsWith("ftp://")) {
      alias = alias.substring(alias.lastIndexOf("//") + 2, alias.length());
    }

    if (!StringUtils.isAlphanumeric(alias)) {
      throw new CheckException(
          "This alias must be alphanumeric. Please remove all other characters");
    }

    try {
      Server server = application.getServers().get(0);
      application.getAliases().add(alias);
      hipacheRedisUtils.writeNewAlias(alias, application, server.getServerAction().getServerPort());
      applicationDAO.save(application);

    } catch (DataAccessException e) {
      throw new ServiceException(e.getLocalizedMessage(), e);
    }
  }
コード例 #2
0
 @Override
 public boolean incrementToken() throws IOException {
   while (input.incrementToken()) {
     String term = new String(termAttribute.buffer(), 0, termAttribute.length());
     if (StringUtils.isAlphanumeric(term)) {
       return true;
     }
   }
   return false;
 }
コード例 #3
0
ファイル: TestDataLoader.java プロジェクト: hawking81/kfs
  public static void main(String[] args) {
    TestDataLoader testDataLoader = new TestDataLoader();
    Date groupCreationDate = new Date(0);

    if (ArrayUtils.isEmpty(args) || args.length < 2) {
      System.out.println("The program requires at least two arguments.");
      return;
    }

    if (!StringUtils.isAlphanumeric(args[0])) {
      System.out.println("The first argument should be a number.");
      return;
    }

    for (int numOfRound = Integer.parseInt(args[0]); numOfRound > 0; numOfRound--) {
      if (ArrayUtils.contains(args, "poster")) {
        OriginEntryGroup group = new OriginEntryGroup();
        group.setSourceCode(LABOR_SCRUBBER_VALID);
        group.setValid(true);
        group.setScrub(false);
        group.setProcess(true);
        group.setDate(groupCreationDate);
        int numOfData = testDataLoader.loadTransactionIntoOriginEntryTable(group);
        System.out.println("Number of Origin Entries for Poster = " + numOfData);
      }

      if (ArrayUtils.contains(args, "scrubber")) {
        OriginEntryGroup group = new OriginEntryGroup();
        group.setSourceCode(LABOR_BACKUP);
        group.setValid(true);
        group.setScrub(true);
        group.setProcess(true);
        group.setDate(groupCreationDate);
        int numOfData = testDataLoader.loadTransactionIntoOriginEntryTable(group);
        System.out.println("Number of Origin Entries for Scrubber = " + numOfData);
      }

      if (ArrayUtils.contains(args, "pending")) {
        int numOfData = testDataLoader.loadTransactionIntoPendingEntryTable();
        System.out.println("Number of Pending Entries = " + numOfData);
      }

      if (ArrayUtils.contains(args, "glentry")) {
        int numOfData = testDataLoader.loadTransactionIntoGLEntryTable();
        System.out.println("Number of Labor GL Entries = " + numOfData);
      }
    }
    System.exit(0);
  }
コード例 #4
0
    /**
     * @param indexWriter
     * @param orderList
     */
    protected void writeIndex(final TableWriter indexWriter, final Vector<TableWriter> orderList) {
      orderList.remove(sortByTblWriter);
      orderList.insertElementAt(sortByTblWriter, 1);

      HashSet<String> alphaSet = new HashSet<String>();
      for (TableWriter tblWr : orderList) {
        String titleLetter = tblWr.getTitle().substring(0, 1).toUpperCase().trim();
        if (!titleLetter.isEmpty()) {
          alphaSet.add(titleLetter);
        }
      }
      Vector<String> alphaList = new Vector<String>(alphaSet);
      Collections.sort(alphaList);

      int i = 0;
      for (String alpha : alphaList) {
        if (StringUtils.isAlphanumeric(alpha)) {
          if (i > 0) indexWriter.append(", ");
          indexWriter.print("<a href=\"#" + alpha + "\">" + alpha + "</a>");
        }
        i++;
      }
      indexWriter.println("<BR><BR>");

      String alphaAnchor = "";
      indexWriter.startTable();
      for (TableWriter tblWr : orderList) {
        System.out.println(tblWr.getTitle());

        String alpha = tblWr.getTitle().substring(0, 1).toUpperCase();
        if (!alpha.equals(" ") && !alpha.equals(alphaAnchor)) {
          indexWriter.print("<a name=\"" + alpha + "\"></a><H3>" + alpha + "</H3>");
          alphaAnchor = alpha;
        }

        try {
          String title = tblWr == sortByTblWriter ? "Rankings" : tblInstHash.get(tblWr).getTitle();
          indexWriter.log(
              "<A href=\"" + FilenameUtils.getName(tblWr.getFileName()) + "\">" + title + "</A>");
          tblWr.close();

        } catch (Exception ex) {
          ex.printStackTrace();
        }
      }
      indexWriter.endTable();
    }
コード例 #5
0
  private String getSolidFireVolumeName(String strCloudStackVolumeName) {
    final String specialChar = "-";

    StringBuilder strSolidFireVolumeName = new StringBuilder();

    for (int i = 0; i < strCloudStackVolumeName.length(); i++) {
      String strChar = strCloudStackVolumeName.substring(i, i + 1);

      if (StringUtils.isAlphanumeric(strChar)) {
        strSolidFireVolumeName.append(strChar);
      } else {
        strSolidFireVolumeName.append(specialChar);
      }
    }

    return strSolidFireVolumeName.toString();
  }
コード例 #6
0
ファイル: StringUtil.java プロジェクト: artyama/myspris
 public static boolean isAlphanumeric(String str) {
   return org.apache.commons.lang.StringUtils.isAlphanumeric(str);
 }
コード例 #7
0
 public static boolean isValid(String pluginKey) {
   return StringUtils.isNotBlank(pluginKey) && StringUtils.isAlphanumeric(pluginKey);
 }
コード例 #8
0
  /* (non-Javadoc)
   * @see org.ebayopensource.turmeric.eclipse.ui.wizards.pages.AbstractElementManagementWizardPage#dialogChanged()
   */
  @Override
  public boolean dialogChanged() {
    if (super.dialogChanged() == false) return false;

    boolean addButtonEnabled = true;
    if (getPreviousPage() instanceof ComplexTypeCCWizardGeneralPage) {
      final ComplexTypeCCWizardGeneralPage ccPage =
          (ComplexTypeCCWizardGeneralPage) getPreviousPage();
      if (ccPage.getRawBaseType() == null
          || StringUtils.isBlank(ccPage.getRawBaseType().toString())) {
        updatePageStatus(
            null,
            EclipseMessageUtils.createStatus(
                "The extension type of the previous page need to be selected in order to add elements",
                IStatus.WARNING));
        addButtonEnabled = false;
      }
    }

    if (super.typesViewer != null) {
      super.typesViewer.setAddButtonsEnabled(addButtonEnabled);

      if (addButtonEnabled == false) return false;
    }

    final Set<String> elementNames = new HashSet<String>();
    for (final IParameterElement elementModel : elements) {
      if (elementModel instanceof ElementTableModel) {
        final String elementValue = ((ElementTableModel) elementModel).getElementName();
        final int minOccursValue = ((ElementTableModel) elementModel).getMinOccurs();
        final int maxOccursValue = ((ElementTableModel) elementModel).getMaxOccurs();
        if (!StringUtils.isAlphanumeric(elementValue)) {
          updateStatus(super.typesViewer.getControl(), "Element name should be alphanumeric");
          return false;
        }
        if (minOccursValue < 0) {
          updateStatus(super.typesViewer.getControl(), "The min occurs must be greater than zero");
          return false;
        }
        if (maxOccursValue != -1) {
          if (maxOccursValue >= 0 && minOccursValue > maxOccursValue) {
            updateStatus(
                super.typesViewer.getControl(),
                "The min occurs "
                    + minOccursValue
                    + " cannot be greater than max occurs "
                    + maxOccursValue);
            return false;
          }
        }
        if (elementNames.contains(elementValue)) {
          updateStatus(super.typesViewer.getControl(), "Duplicate element name - " + elementValue);
          return false;
        } else {
          updateStatus(null);
        }
        elementNames.add(elementValue);
      }
    }
    return true;
  }
コード例 #9
0
  /** Command "/sketchmap create [MAP-NAME] [URL]" * */
  @Override
  public void onCommand(CommandSender sender, String[] args, String prefix) {

    if (!(sender instanceof Player)) {
      sender.sendMessage(ChatColor.RED + prefix + "This command cannot be used from the Console.");
      return;
    }

    Player player = (Player) sender;

    if (args.length < 3) {
      player.sendMessage(
          ChatColor.RED + prefix + "Error in Command Syntax. Try, \"" + getSyntax() + "\"");
      return;
    }

    if (args[1].length() < 3 || args[1].length() > 16) {
      player.sendMessage(ChatColor.RED + prefix + "Map ID must be between 3 - 16 Characters");
      return;
    }

    if (!StringUtils.isAlphanumeric(args[1].replace("_", "").replace("-", ""))) {
      player.sendMessage(ChatColor.RED + prefix + "Map ID must be Alphanumeric");
      return;
    }

    if (SketchMapAPI.getMapByID(args[1]) != null) {
      if (SketchMapAPI.getMapByID(args[1]).isPublicProtected()) {
        player.sendMessage(
            ChatColor.RED
                + prefix
                + "An External Plugin has reserved "
                + "that Map ID. Try a different Map ID");
        return;
      }

      player.sendMessage(ChatColor.RED + prefix + "A map by that id already exists.");
      return;
    }

    URL url = null;
    try {
      url = new URL(args[2]);
    } catch (MalformedURLException ex) {
      player.sendMessage(ChatColor.RED + prefix + "Unable to load image. URL appears invalid");
      return;
    }

    Integer xPanes = null;
    Integer yPanes = null;

    if (args.length > 3) {
      String[] split = args[3].split(":");
      if (split.length != 2) {
        player.sendMessage(
            ChatColor.RED
                + prefix
                + "Cannot resize image invalid resize arguments set. "
                + getSyntax());
        return;
      }

      try {
        xPanes = Integer.parseInt(split[0]);
        yPanes = Integer.parseInt(split[1]);

      } catch (Exception ex) {
        player.sendMessage(
            ChatColor.RED
                + prefix
                + "Cannot resize image invalid resize arguments set. "
                + getSyntax());
        return;
      }

      if (xPanes < 1 || yPanes < 1) {
        player.sendMessage(
            ChatColor.RED + prefix + "Resize image arguments must be positive. " + getSyntax());
        return;
      }
    }

    try {
      player.sendMessage(ChatColor.AQUA + prefix + "Downloading Image");
      BufferedImage image = ImageIO.read(url);

      player.sendMessage(ChatColor.AQUA + prefix + "Processing Image");

      String ext = url.getFile().substring(url.getFile().length() - 3);
      BaseFormat format = BaseFormat.fromExtension(ext);

      if (format == null) {
        player.sendMessage(
            ChatColor.RED
                + prefix
                + "Sorry, Only JPEG and PNG are supported at this moment. "
                + "But animated Maps will be coming soon.");
        return;
      }

      if (args.length == 3) {

        int imageX = image.getWidth();
        int imageY = image.getHeight();

        while (imageX % 128 != 0) {
          imageX++;
        }

        while (imageY % 128 != 0) {
          imageY++;
        }

        xPanes = imageX / 128;
        yPanes = imageY / 128;
      }

      new SketchMap(image, args[1], xPanes, yPanes, false, format);

      player.sendMessage(
          ChatColor.GREEN
              + prefix
              + "Map \""
              + ChatColor.GOLD
              + args[1]
              + ChatColor.GREEN
              + "\" Created! "
              + ChatColor.GOLD
              + "Use \"/sketchmap get "
              + args[1]
              + "\""
              + " to get this map as map items.");

      player.sendMessage(
          ChatColor.AQUA
              + " Or use \""
              + ChatColor.GOLD
              + "/sketchmap place "
              + args[1]
              + ChatColor.AQUA
              + "\" to place it directly onto a wall.");

    } catch (IOException e) {
      player.sendMessage(
          ChatColor.RED
              + prefix
              + "Unable to load/find image at URL."
              + " If you think this is a error try uploading this image @ imgur.com.");
      return;
    }
  }
コード例 #10
0
ファイル: IndexImpl.java プロジェクト: ryanlfoster/force-cq
 @Override
 public boolean isValidIndexKey(String key) {
   return StringUtils.isAlphanumeric(key);
 }