Exemplo n.º 1
0
 private void loadCurrentProjectSpineAnimations(String path, String curResolution) {
   spineAnimAtlases.clear();
   FileHandle sourceDir = new FileHandle(path + "orig/spine-animations");
   for (FileHandle entry : sourceDir.list()) {
     if (entry.file().isDirectory()) {
       String animName = FilenameUtils.removeExtension(entry.file().getName());
       TextureAtlas atlas =
           new TextureAtlas(
               Gdx.files.internal(
                   path
                       + curResolution
                       + "/spine-animations/"
                       + File.separator
                       + animName
                       + File.separator
                       + animName
                       + ".atlas"));
       FileHandle animJsonFile =
           Gdx.files.internal(
               entry.file().getAbsolutePath() + File.separator + animName + ".json");
       SpineAnimData data = new SpineAnimData();
       data.atlas = atlas;
       data.jsonFile = animJsonFile;
       data.animName = animName;
       spineAnimAtlases.put(animName, data);
     }
   }
 }
Exemplo n.º 2
0
  public static boolean isValidFileName(String fileName) {
    if (StringUtils.isBlank(fileName)) {
      return false;
    }

    for (String blacklistChar : PropsValues.SYNC_FILE_BLACKLIST_CHARS) {
      if (fileName.contains(blacklistChar)) {
        return false;
      }
    }

    for (String blacklistLastChar : PropsValues.SYNC_FILE_BLACKLIST_CHARS_LAST) {

      if (blacklistLastChar.startsWith("\\u")) {
        blacklistLastChar = StringEscapeUtils.unescapeJava(blacklistLastChar);
      }

      if (fileName.endsWith(blacklistLastChar)) {
        return false;
      }
    }

    String nameWithoutExtension = FilenameUtils.removeExtension(fileName);

    for (String blacklistName : PropsValues.SYNC_FILE_BLACKLIST_NAMES) {
      if (nameWithoutExtension.equalsIgnoreCase(blacklistName)) {
        return false;
      }
    }

    return true;
  }
 @Override
 public String getName() {
   if (propertiesFile != null) {
     return FilenameUtils.removeExtension(propertiesFile.getFileName().toString());
   }
   return null;
 }
Exemplo n.º 4
0
 /**
  * A method to set the output file name to a series of numbered files, using a pattern like:
  *
  * <p>fileName = String.format("%s_%03d.%s", fName, fNumber, ext);
  *
  * <p>When fName includes an extension, it is first removed and saved into ext.
  *
  * @param fName a file path + name (with or without an extension).
  */
 private static void createOutputStream(String fName) throws Exception {
   fName = FilenameUtils.normalize(fName);
   String name = FilenameUtils.removeExtension(fName);
   String ext = FilenameUtils.getExtension(fName);
   if (oSerializeFormat.equals("turtle")) {
     ext = "ttl";
   } else if (oSerializeFormat.equals("Ntriples")) {
     ext = "nt";
   } else if (ext.equals("")) {
     ext = "txt";
   }
   fName = String.format("%s_%03d.%s", name, ++oFileNumber, ext);
   oFile = new File(fName);
   try {
     oStream.close();
     oStream = new PrintStream(new FileOutputStream(oFile));
     if (oSerializeFormat.equals("turtle")) {
       oStream.println(SparqlPrefixes.ttlMappingPrefix());
       oStream.println();
       if (oFileNumber == 1) {
         oStream.println(loomInfo.ttlSignature());
         oStream.println();
       }
     }
   } catch (Exception e) {
     log.fatal("Cannot create output file stream: {}", oFile.getAbsolutePath());
     throw e;
   }
 }
Exemplo n.º 5
0
  protected Rule(AppEnv env, File docFile) throws RuleException {
    try {
      this.env = env;
      DocumentBuilderFactory pageFactory = DocumentBuilderFactory.newInstance();
      DocumentBuilder pageBuilder = pageFactory.newDocumentBuilder();
      Document xmlFileDoc = pageBuilder.parse(docFile.toString());
      doc = xmlFileDoc;
      filePath = docFile.getAbsolutePath();
      parentDirPath = docFile.getParentFile().getAbsolutePath();
      scriptDirPath =
          "rule"
              + File.separator
              + env.appName
              + File.separator
              + "Resources"
              + File.separator
              + "scripts";
      id = XMLUtil.getTextContent(doc, "/rule/@id", true);
      if (id.equals("")) {
        id = FilenameUtils.removeExtension(docFile.getName());
      }
      AppEnv.logger.debugLogEntry("Load rule: " + this.getClass().getSimpleName() + ", id=" + id);
      if (XMLUtil.getTextContent(doc, "/rule/@mode").equalsIgnoreCase("off")) {
        isOn = RunMode.OFF;
        isValid = false;
      }

      if (XMLUtil.getTextContent(doc, "/rule/@anonymous").equalsIgnoreCase("on")) {
        allowAnonymousAccess = true;
      }

      if (XMLUtil.getTextContent(doc, "/rule/@security").equalsIgnoreCase("on")) {
        isSecured = true;
      }

      description = XMLUtil.getTextContent(doc, "/rule/description");

      NodeList captionList = XMLUtil.getNodeList(doc, "/rule/caption");
      for (int i = 0; i < captionList.getLength(); i++) {
        Caption c = new Caption(captionList.item(i));
        if (c.isOn == RunMode.ON) {
          captions.add(c);
        }
      }

    } catch (SAXParseException spe) {
      AppEnv.logger.errorLogEntry("XML-file structure error (" + docFile.getAbsolutePath() + ")");
      AppEnv.logger.errorLogEntry(spe);
    } catch (FileNotFoundException e) {
      throw new RuleException("Rule \"" + docFile.getAbsolutePath() + "\" has not found");
    } catch (ParserConfigurationException e) {
      AppEnv.logger.errorLogEntry(e);
    } catch (IOException e) {
      AppEnv.logger.errorLogEntry(e);
    } catch (SAXException se) {
      AppEnv.logger.errorLogEntry(se);
    }
  }
 public static String getFilenameWOExtension(String filename) {
   String fileNameWOExt = null;
   if (FilenameUtils.indexOfExtension(filename) == -1) {
     fileNameWOExt = filename;
   } else {
     fileNameWOExt = FilenameUtils.removeExtension(filename);
   }
   return fileNameWOExt;
 }
Exemplo n.º 7
0
 // returns the movie file path without anything like CD1, Disc A, etc and also gets rid of the
 // file extension
 // Example: MyMovie ABC-123 CD1.avi returns MyMovie ABC-123
 // Example2: MyMovie ABC-123.avi returns MyMovie ABC-123
 public static String getUnstackedMovieName(File file) {
   String fileName = file.toString();
   fileName =
       replaceLast(
           fileName,
           file.getName(),
           SiteParsingProfile.stripDiscNumber(FilenameUtils.removeExtension(file.getName())));
   return fileName;
 }
  public static ResponseState saveMapping(
      MappingScriptProxy mappings, TransformationUI transformationUI, String oldTransId) {
    //        System.out.println("SERVER - Save Mapping: "+mappings.getID());
    //        System.out.println("SERVER - Target ID: "+mappings.getTargetModel().getID());
    //        System.out.println("SERVER - Source ID: "+mappings.getSourceModel().getID());
    ResponseState response;

    try {
      // 00 validate transformation
      response =
          validateTransformation(
              transformationUI.getIdentifier(),
              FilenameUtils.removeExtension(transformationUI.getXslFilePath()),
              oldTransId);
      if (response != ResponseState.SUCCESS) return response;
      //            System.out.println("SERVER - The transformation is valid");

      // Setup stuff for file writing
      URL tmpUrl = new URL(transformationUI.getSourceSchema());
      XMLSchema source = getXSDSchema(tmpUrl);
      tmpUrl = new URL(transformationUI.getDestSchema());
      XMLSchema target = getXSDSchema(tmpUrl);
      MappingFactory factory = new MappingFactoryImpl(ModelUtils.getRegistry());
      MappingScript script = new UI2MappingAdapter(factory, source, target).adapt(mappings);

      //  1st STEP - create the xmap file
      String fileName = FilenameUtils.removeExtension(transformationUI.getXslFilePath());
      createXmapFile(fileName, script);

      // 2nd STEP - Create the xsl file
      createXslFile(fileName, script);

      // 3rd STEP - Register transformation in the mdr
      response = saveTransformationMDR(transformationUI, oldTransId);
      // System.out.println("SERVER - EDITABLE: "+transformationUI.isEditable());
    } catch (Exception e) {
      e.printStackTrace();
      response = ResponseState.ERROR;
    }

    return response;
  }
Exemplo n.º 9
0
  private boolean isExistsOnUI(ZipFile zipFile, ContentsTableFrame table)
      throws ZipException, IOException {
    boolean result = true;
    Enumeration<? extends ZipEntry> entries = zipFile.entries();
    while (entries.hasMoreElements()) {
      ZipEntry inputEntry = (ZipEntry) entries.nextElement();

      result &= table.isContentPresentInTable(FilenameUtils.removeExtension(inputEntry.getName()));
    }
    zipFile.close();
    return result;
  }
  @RequestMapping(value = "/{contentId}.htm")
  public String contentInfo(
      @PathVariable Long contentId, ModelMap modelMap, HttpServletRequest request) {
    Site site = (Site) request.getSession().getAttribute(SystemConstant.FRONT_SITE_SESSION_KEY);
    Content content = contentService.findOne(contentId);

    modelMap.addAttribute("content", content);

    String contpl =
        FilenameUtils.removeExtension(
            SystemUtils.formatUri(content.getColumn().getColumnType().getContenttpl()));
    return site.getThemeName() + "/" + contpl;
  }
Exemplo n.º 11
0
  private TextureRegion getCachedGfxRegion(TextureRegionAsset asset) {
    String relativePath = asset.getPath();
    String regionName = FileUtils.removeFirstSeparator(FilenameUtils.removeExtension(relativePath));

    TextureRegion region = regions.get(regionName);

    if (region == null) {
      if (cache != null) region = cache.findRegion(regionName);
      if (region == null) region = new TextureRegion(loadingRegion);
      regions.put(relativePath, region);
    }

    return region;
  }
Exemplo n.º 12
0
 @Override
 public boolean register(String path) {
   String id = FilenameUtils.removeExtension(new File(path).getName());
   Audio audio = null;
   try {
     audio = new Audio(path);
   } catch (FileNotFoundException e) {
     e.printStackTrace();
     return false;
   }
   idToAudioMap.put(id, audio);
   Log.println(LOW_DEBUG, id + " Audio Loaded Successfully");
   return true;
 }
Exemplo n.º 13
0
 private void loadCurrentProjectSpriteAnimations(String path, String curResolution) {
   spriteAnimAtlases.clear();
   FileHandle sourceDir = new FileHandle(path + curResolution + "/sprite-animations");
   for (FileHandle entry : sourceDir.list()) {
     if (entry.file().isDirectory()) {
       String animName = FilenameUtils.removeExtension(entry.file().getName());
       TextureAtlas atlas =
           new TextureAtlas(
               Gdx.files.internal(
                   entry.file().getAbsolutePath() + File.separator + animName + ".atlas"));
       spriteAnimAtlases.put(animName, atlas);
     }
   }
 }
Exemplo n.º 14
0
  protected String getScriptUrl(
      ScriptFactory scriptFactory,
      SiteContext siteContext,
      HttpServletRequest request,
      String serviceUrl) {
    String baseUrl =
        UrlUtils.appendUrl(
            siteContext.getRestScriptsPath(), FilenameUtils.removeExtension(serviceUrl));

    return String.format(
        SCRIPT_URL_FORMAT,
        baseUrl,
        request.getMethod().toLowerCase(),
        scriptFactory.getScriptFileExtension());
  }
Exemplo n.º 15
0
  public int retrievePageCount(File source) {

    File target =
        new File(
            System.getProperty("java.io.tmpdir"),
            FilenameUtils.removeExtension(source.getName()) + ".pdf");

    Map<String, Object> args = newHashMap();
    args.put("source", source);
    args.put("targetDir", target.getParentFile());

    CommandLine cmd = new CommandLine("loffice");
    cmd.addArgument("--headless");
    cmd.addArgument("--convert-to");
    cmd.addArgument("pdf");
    cmd.addArgument("--outdir");
    cmd.addArgument("${targetDir}");
    cmd.addArgument("${source}");
    cmd.setSubstitutionMap(args);

    try {
      DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();

      ExecuteWatchdog watchdog = new ExecuteWatchdog(10L * 1000L);
      executor.setWatchdog(watchdog);
      logger.trace("About to execute command {}", cmd.toString());
      executor.execute(cmd, resultHandler);

      resultHandler.waitFor();
      final int exitValue = resultHandler.getExitValue();

      if (exitValue != 0) {
        logger.error(
            "Unable to convert Microsoft Word file {} to PDF. Exit code = {}",
            source.getAbsolutePath(),
            exitValue);
        return -1;
      }
      final int pageCount = pdfDocumentInspector.retrievePageCount(target);
      deleteFileIfNeeded(target);
      return pageCount;

    } catch (IOException | InterruptedException e) {
      logger.error("Unable to create a PDF from {}", source.getAbsolutePath(), e);
      deleteFileIfNeeded(target);
      return -1;
    }
  }
Exemplo n.º 16
0
  /**
   * Write a PDF character sheet for the character to the output file. The character sheet will be
   * built according to the template file. If the output file exists it will be overwritten.
   *
   * @param character The already loaded character to be output.
   * @param outFile The file to which the character sheet is to be written.
   * @param templateFile The file that has the export template definition.
   * @return true if the export was successful, false if it failed in some way.
   */
  public static boolean exportCharacterToPDF(
      CharacterFacade character, File outFile, File templateFile) {

    String templateExtension = FilenameUtils.getExtension(templateFile.getName());

    boolean isTransformTemplate =
        "xslt".equalsIgnoreCase(templateExtension) || "xsl".equalsIgnoreCase(templateExtension);

    boolean useTempFile =
        PCGenSettings.OPTIONS_CONTEXT.initBoolean(
            PCGenSettings.OPTION_GENERATE_TEMP_FILE_WITH_PDF, false);
    String outFileName = FilenameUtils.removeExtension(outFile.getAbsolutePath());
    File tempFile =
        isTransformTemplate ? new File(outFileName + ".xml") : new File(outFileName + ".fo");
    try (BufferedOutputStream fileStream = new BufferedOutputStream(new FileOutputStream(outFile));
        ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();
        OutputStream exportOutput =
            useTempFile
                // Output to both the byte stream and to the temp file.
                ? new TeeOutputStream(byteOutputStream, new FileOutputStream(tempFile))
                : byteOutputStream) {
      FopTask task;
      if (isTransformTemplate) {
        exportCharacter(character, exportOutput);
        ByteArrayInputStream inputStream = new ByteArrayInputStream(byteOutputStream.toByteArray());
        task = FopTask.newFopTask(inputStream, templateFile, fileStream);
      } else {
        exportCharacter(character, templateFile, exportOutput);
        ByteArrayInputStream inputStream = new ByteArrayInputStream(byteOutputStream.toByteArray());
        task = FopTask.newFopTask(inputStream, null, fileStream);
      }
      character.setDefaultOutputSheet(true, templateFile);
      task.run();
      if (StringUtils.isNotBlank(task.getErrorMessages())) {
        Logging.errorPrint(
            "BatchExporter.exportCharacterToPDF failed: " //$NON-NLS-1$
                + task.getErrorMessages());
        return false;
      }
    } catch (IOException e) {
      Logging.errorPrint("BatchExporter.exportCharacterToPDF failed", e); // $NON-NLS-1$
      return false;
    } catch (ExportException e) {
      Logging.errorPrint("BatchExporter.exportCharacterToPDF failed", e); // $NON-NLS-1$
      return false;
    }
    return true;
  }
Exemplo n.º 17
0
  /**
   * Deserialize the specified file and attempt to set the class level variable with the file name
   * to it.
   *
   * @param varFile The serialized variable file
   * @throws IOException
   * @throws ClassNotFoundException
   * @throws IllegalAccessException
   * @throws IllegalArgumentException
   */
  @SuppressWarnings({"unchecked", "resource"})
  private <T> void setVariable(File varFile)
      throws ClassNotFoundException, IOException, IllegalArgumentException, IllegalAccessException {
    try {
      String varName = FilenameUtils.removeExtension(varFile.getName());
      Field field = ServerData.class.getDeclaredField(varName);
      ObjectInputStream in = new ObjectInputStream(new FileInputStream(varFile));
      T variable = (T) in.readObject();

      field.set(this, variable);
      in.close();
    } catch (NoSuchFieldException e) {
      e.printStackTrace();
      return;
    }
  }
 // Create a file by append uploadId to filePath with "_" separator
 private void createUploadResource(String filePath, String uploadId) throws IOException {
   String tempPath =
       FilenameUtils.removeExtension(filePath)
           + "_"
           + uploadId
           + "."
           + FilenameUtils.getExtension(filePath);
   tempPath = tempPath.replaceAll("^/", "");
   tempPath = FilenameUtils.concat(tmpUploadFolder.dir().getCanonicalPath(), tempPath);
   try {
     new File(tempPath).getParentFile().mkdirs();
     new File(tempPath).createNewFile();
   } catch (IOException e) {
     throw new IllegalStateException("Unable to create upload resource");
   }
 }
Exemplo n.º 19
0
  public QualimapJob(File bam, File qualimapReport, GlobalConfiguration gc, String hostNameArg)
      throws IOException {
    super(FilenameUtils.removeExtension(bam.getAbsolutePath()) + "_qualimap.sh");
    this.bam = bam;
    this.qualimapReport = qualimapReport;
    this.gc = gc;

    sgeName = "qualimap_" + bam.getName();

    hostName = hostNameArg;
    this.sgeThreads = 8;

    sgeThreads = gc.getQualimapSGEThreads();

    addCommands();
    close();
  }
 /**
  * Return supportFiles (if found) for the specified file
  *
  * @param filePath
  * @return
  */
 public List<File> getSupportFiles(String filePath) {
   List<File> supportFiles = null;
   String parent = FilenameUtils.getFullPath(filePath);
   String mainName = FilenameUtils.getName(filePath);
   String baseName = FilenameUtils.removeExtension(mainName);
   for (String extension : supportingExtensions) {
     String newFilePath = parent + baseName + extension;
     File file = new File(newFilePath);
     if (file.exists()) {
       if (supportFiles == null) {
         supportFiles = new ArrayList<File>();
       }
       supportFiles.add(file);
     }
   }
   return supportFiles;
 }
 private boolean saveAttachment() {
   String filename = JSFUtils.getRequestParameter("filename");
   String diskFileName =
       this.attachmentService.fileNameProcess(FilenameUtils.removeExtension(filename));
   diskFileName = this.attachmentService.replaceFile(filename, diskFileName);
   this.attachment.setFilename(filename);
   this.attachment.setDiskFilename(diskFileName);
   this.attachment.setContainerId(this.userStory.getUserStoryId());
   this.attachment.setContainerType(Attachment.USERSTORY_ATTACHMENT);
   if (this.attachment.getContainerId() == null) {
     this.attachment.setTemp(true);
   } else {
     this.attachment.setTemp(false);
   }
   this.attachment.setCreatedOn(new Date());
   this.attachment.setAuthor(this.utils.getLoggedInMember());
   return this.attachmentService.save(this.attachment);
 }
  protected void updateUrl(Page page, Pager pager) {
    String url = page.getDecodedUrl();
    int pageNumber = pager.getPageNumber();

    if (url.endsWith("/")) {
      // /a/b/c/name/ --> /a/b/c/name/page/2/
      url += "page/" + pageNumber + "/";
    } else {
      //  /a/b/c/name.html --> /a/b/c/name-p2.html
      url =
          FilenameUtils.removeExtension(url)
              + "-p"
              + pageNumber
              + "."
              + FilenameUtils.getExtension(url);
    }
    page.setUrl(url);
  }
 /**
  * Command line interface to the vocal tract linear scaler effect.
  *
  * @param args the command line arguments. Exactly two arguments are expected: (1) the factor by
  *     which to scale the vocal tract (between 0.25 = very long and 4.0 = very short vocal tract);
  *     (2) the filename of the wav file to modify. Will produce a file basename_factor.wav, where
  *     basename is the filename without the extension.
  * @throws Exception if processing fails for some reason.
  */
 public static void main(String[] args) throws Exception {
   if (args.length != 2) {
     System.err.println(
         "Usage: java " + VocalTractLinearScalerEffect.class.getName() + " <factor> <filename>");
     System.exit(1);
   }
   float factor = Float.parseFloat(args[0]);
   String filename = args[1];
   AudioDoubleDataSource input =
       new AudioDoubleDataSource(AudioSystem.getAudioInputStream(new File(filename)));
   AudioFormat format = input.getAudioFormat();
   VocalTractLinearScalerEffect effect =
       new VocalTractLinearScalerEffect((int) format.getSampleRate());
   DoubleDataSource output = effect.apply(input, "amount:" + factor);
   DDSAudioInputStream audioOut = new DDSAudioInputStream(output, format);
   String outFilename = FilenameUtils.removeExtension(filename) + "_" + factor + ".wav";
   AudioSystem.write(audioOut, AudioFileFormat.Type.WAVE, new File(outFilename));
   System.out.println("Created file " + outFilename);
 }
 /**
  * Create a new, read-only temporary file.
  *
  * @param file Original file that you need a copy of
  * @param newExtension The extension that the new file should have
  * @return File (read-only)
  * @throws IOException
  */
 public File createTempfileCopy(File file, String newExtension) throws IOException {
   File destFile = files.get(file);
   if (destFile == null) {
     destFile = File.createTempFile("temp", "." + newExtension);
     createNewCopy(file, destFile);
     destFile.setWritable(false, false);
   } else {
     String newFilename =
         FilenameUtils.removeExtension(destFile.getAbsolutePath()) + "." + newExtension;
     File newFile = new File(newFilename);
     boolean renameSucces = destFile.renameTo(newFile);
     if (!renameSucces) {
       createNewCopy(file, newFile);
     }
     files.put(file, newFile);
     destFile = newFile;
   }
   return destFile;
 }
Exemplo n.º 25
0
  public static void loadItem(File file) {
    String itemName = FilenameUtils.removeExtension(file.getName());

    XmlItemStack item = null;
    try {
      item = serializer.read(XmlItemStack.class, file);
    } catch (Exception e) {
      e.printStackTrace();
    }

    if (item == null) {
      return;
    }

    items.put(itemName, item.getItemStack());
    Chat.debug(
        String.format(
            "Loaded item %s",
            StringUtil.joinString(Messages.itemInfo(item.getItemStack()), "\n", 0)));
  }
Exemplo n.º 26
0
  /**
   * Write a PDF party sheet for the characters in the party to the output file. The party sheet
   * will be built according to the template file. If the output file exists it will be overwritten.
   *
   * @param party The already loaded party of characters to be output.
   * @param outFile The file to which the party sheet is to be written.
   * @param templateFile The file that has the export template definition.
   * @return true if the export was successful, false if it failed in some way.
   */
  public static boolean exportPartyToPDF(PartyFacade party, File outFile, File templateFile) {
    // We want the non pdf extension here for the intermediate file.
    String templateExtension = ExportUtilities.getOutputExtension(templateFile.getName(), false);
    boolean isTransformTemplate =
        "xslt".equalsIgnoreCase(templateExtension) || "xsl".equalsIgnoreCase(templateExtension);

    boolean useTempFile =
        PCGenSettings.OPTIONS_CONTEXT.initBoolean(
            PCGenSettings.OPTION_GENERATE_TEMP_FILE_WITH_PDF, false);
    String outFileName = FilenameUtils.removeExtension(outFile.getAbsolutePath());
    File tempFile =
        isTransformTemplate ? new File(outFileName + ".xml") : new File(outFileName + ".fo");
    try (BufferedOutputStream fileStream = new BufferedOutputStream(new FileOutputStream(outFile));
        ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();
        OutputStream exportOutput =
            useTempFile
                // Output to both the byte stream and to the temp file.
                ? new TeeOutputStream(byteOutputStream, new FileOutputStream(tempFile))
                : byteOutputStream) {
      FopTask task;
      if (isTransformTemplate) {
        exportParty(party, exportOutput);
        ByteArrayInputStream inputStream = new ByteArrayInputStream(byteOutputStream.toByteArray());
        task = FopTask.newFopTask(inputStream, templateFile, fileStream);
      } else {
        SettingsHandler.setSelectedPartyPDFOutputSheet(templateFile.getAbsolutePath());

        exportParty(party, templateFile, exportOutput);
        ByteArrayInputStream inputStream = new ByteArrayInputStream(byteOutputStream.toByteArray());
        task = FopTask.newFopTask(inputStream, null, fileStream);
      }
      task.run();
    } catch (IOException e) {
      Logging.errorPrint("BatchExporter.exportPartyToPDF failed", e);
      return false;
    } catch (ExportException e) {
      Logging.errorPrint("BatchExporter.exportPartyToPDF failed", e);
      return false;
    }
    return true;
  }
Exemplo n.º 27
0
  public void process() {
    File inFolder = new File(vectorFolder);
    if (!inFolder.isDirectory()) {
      System.out.println("In should be a folder: " + vectorFolder);
      return;
    }
    boolean clusterSaved = false;
    this.invertedFixedClases = loadFixedClasses(fixedClassesFile);
    if (!histogram) {
      Map<String, List<String>> sectors = loadStockSectors(sectorFile);
      sectorToClazz = convertSectorsToClazz(sectors);
      if (!clusterSaved) {
        changeClassLabels();
        clusterSaved = true;
      }
      for (Map.Entry<String, Integer> entry : sectorToClazz.entrySet()) {
        System.out.println(entry.getKey() + " : " + entry.getValue());
      }
    }

    for (File inFile : inFolder.listFiles()) {
      String fileName = inFile.getName();
      String fileNameWithOutExt = FilenameUtils.removeExtension(fileName);
      if (histogram) {
        sectorToClazz.clear();
        invertedSectors.clear();

        Map<String, List<String>> sectors =
            loadHistoSectors(sectorFile + "/" + fileNameWithOutExt + ".csv");
        sectorToClazz = convertSectorsToClazz(sectors);
        if (!clusterSaved) {
          changeClassLabels();
          clusterSaved = true;
        }
        for (Map.Entry<String, Integer> entry : sectorToClazz.entrySet()) {
          System.out.println(entry.getKey() + " : " + entry.getValue());
        }
      }
      processFile(fileNameWithOutExt);
    }
  }
  private boolean addAttachment() {
    try {
      this.attachment = new Attachment();

      String filename = JSFUtils.getRequestParameter("filename");
      String diskFileName =
          this.attachmentService.fileNameProcess(FilenameUtils.removeExtension(filename));
      diskFileName = this.attachmentService.replaceFile(filename, diskFileName);

      this.attachment.setFilename(filename);
      this.attachment.setDiskFilename(diskFileName);
      this.attachment.setContainerType(Attachment.USERSTORY_ATTACHMENT);
      this.attachment.setTemp(true);
      this.attachment.setCreatedOn(new Date());
      this.attachment.setAuthor(this.utils.getLoggedInMember());
      return true;
    } catch (Exception exception) {
      LOGGER.error("addAttachment at sprintBacklog " + exception);
      return false;
    }
  }
Exemplo n.º 29
0
  /** Upload attachment file for issue */
  public void uploadFile() {
    String filename = JSFUtils.getRequestParameter("filename");
    String diskFileName =
        this.attachmentService.fileNameProcess(FilenameUtils.removeExtension(filename));
    diskFileName = this.attachmentService.replaceFile(filename, diskFileName);
    attachment = new Attachment();
    attachment.setFilename(filename);
    attachment.setDiskFilename(diskFileName);
    attachment.setContainerId(issue.getIssueId());
    attachment.setContainerType(Attachment.ISSUE_ATTACHMENT);
    // add files of Issue in user story for easy to handle.
    if (issue.getUserStory() != null) {
      attachment.setContainerId(issue.getUserStory().getUserStoryId());
      attachment.setContainerType(Attachment.USERSTORY_ATTACHMENT);
    }

    attachment.setTemp(false);
    attachment.setCreatedOn(new Date());
    attachment.setAuthor(utils.getLoggedInMember());
    attachmentService.save(attachment);
    Attachment newAttachment = attachmentService.findAttachmentById(attachment.getAttachmentId());

    if (attachmentNotAddList == null) {
      attachmentNotAddList = new ArrayList<Attachment>();
    }

    if (newAttachment.getContainerId() != null) {
      attachment.setTemp(false);
      attachmentService.moveAttachmentFile(attachment, projectId);
    } else {
      attachment.setTemp(true);
      attachmentNotAddList.add(newAttachment);
    }

    attachmentListByIssue = attachmentService.findAttachmentByIssue(issue);
    if (issue.getUserStory() != null) {
      attachmentListByIssue.addAll(
          attachmentService.findAttachmentByUserStory(issue.getUserStory()));
    }
  }
Exemplo n.º 30
0
  private void reloadCache() {
    if (cacheFile.exists()) {
      TextureAtlas oldCache = null;

      if (cache != null) oldCache = cache;

      cache = new TextureAtlas(cacheFile);

      for (Entry<String, TextureRegion> e : regions.entries()) {
        String path = FileUtils.removeFirstSeparator(FilenameUtils.removeExtension(e.key));
        TextureRegion region = e.value;
        TextureRegion newRegion = cache.findRegion(path);
        if (newRegion == null) region.setRegion(missingRegion);
        else region.setRegion(newRegion);
      }

      disposeCacheLater(oldCache);

      App.eventBus.post(new ResourceReloadedEvent(ResourceReloadedEvent.RESOURCE_TEXTURES));
    } else
      Log.error(
          "Texture cache not ready, probably they aren't any textures in project or packer failed");
  }