Package org.apache.flex.utilities.converter.exceptions

Examples of org.apache.flex.utilities.converter.exceptions.ConverterException


     * @throws ConverterException
     */
    @Override
    protected void processDirectory() throws ConverterException {
        if(!rootSourceDirectory.exists() || !rootSourceDirectory.isDirectory()) {
            throw new ConverterException("Flash SDK directory '" + rootSourceDirectory.getPath() + "' is invalid.");
        }

        generateRuntimeArtifacts();
        generateFrameworkArtifacts();
    }
View Full Code Here


                if(new File(lnxDirectory, "flashplayer.tar.gz").exists()) {
                    flashPlayerBinary = new File(lnxDirectory, "flashplayer.tar.gz");
                } else if(new File(lnxDirectory, "flashplayerdebugger.tar.gz").exists()) {
                    flashPlayerBinary = new File(lnxDirectory, "flashplayerdebugger.tar.gz");
                } else {
                    throw new ConverterException("Couldn't find player archive.");
                }

                // Decompress the archive.
                // First unzip it.
                final FileInputStream fin;
                try {
                    fin = new FileInputStream(flashPlayerBinary);
                    final BufferedInputStream in = new BufferedInputStream(fin);
                    final File tempTarFile = File.createTempFile("flex-sdk-linux-flashplayer-binary-" + version, ".tar");
                    final FileOutputStream out = new FileOutputStream(tempTarFile);
                    final GzipCompressorInputStream gzIn = new GzipCompressorInputStream(in);
                    final byte[] buffer = new byte[1024];
                    int n;
                    while (-1 != (n = gzIn.read(buffer))) {
                        out.write(buffer, 0, n);
                    }
                    out.close();
                    gzIn.close();

                    // Then untar it.
                    File uncompressedBinary = null;
                    final FileInputStream tarFileInputStream = new FileInputStream(tempTarFile);
                    final TarArchiveInputStream tarArchiveInputStream = new TarArchiveInputStream(tarFileInputStream);
                    ArchiveEntry entry;
                    while((entry = tarArchiveInputStream.getNextEntry()) != null) {
                        if("flashplayer".equals(entry.getName())) {
                            uncompressedBinary = File.createTempFile("flex-sdk-linux-flashplayer-binary-" + version, ".uexe");
                            final FileOutputStream uncompressedBinaryOutputStream = new FileOutputStream(uncompressedBinary);
                            while(-1 != (n = tarArchiveInputStream.read(buffer))) {
                                uncompressedBinaryOutputStream.write(buffer, 0, n);
                            }
                            uncompressedBinaryOutputStream.close();
                        } else if("flashplayerdebugger".equals(entry.getName())) {
                            uncompressedBinary = File.createTempFile("flex-sdk-linux-flashplayer-binary-" + version, ".uexe");
                            final FileOutputStream uncompressedBinaryOutputStream = new FileOutputStream(uncompressedBinary);
                            while(-1 != (n = tarArchiveInputStream.read(buffer))) {
                                uncompressedBinaryOutputStream.write(buffer, 0, n);
                            }
                            uncompressedBinaryOutputStream.close();
                        }
                    }
                    tarFileInputStream.close();

                    // If a binary exists, copy it to the target and create a pom for it.
                    if (uncompressedBinary != null) {
                        playerArtifact.addBinaryArtifact("linux", flashPlayerBinary);
                    }
                } catch (FileNotFoundException e) {
                    throw new ConverterException("Error processing the linux player tar file", e);
                } catch (IOException e) {
                    throw new ConverterException("Error processing the linux player tar file", e);
                }
            }

            // Write this artifact to file.
            writeArtifact(playerArtifact);
View Full Code Here

     */
    protected void generateFrameworkArtifacts() throws ConverterException {
        // Create a list of all libs that should belong to the Flash SDK runtime.
        final File directory = new File(rootSourceDirectory, "frameworks.libs.player".replace(".", File.separator));
        if (!directory.exists() || !directory.isDirectory()) {
            throw new ConverterException("Runtime directory does not exist.");
        }
        final List<File> playerVersions = new ArrayList<File>();
        final File[] versions = directory.listFiles();
        if((versions != null) && (versions.length > 0)) {
            playerVersions.addAll(Arrays.asList(versions));
View Full Code Here

    private VelocityEngine velocityEngine;

    protected BaseConverter(File rootSourceDirectory, File rootTargetDirectory) throws ConverterException {
        if(rootSourceDirectory == null) {
            throw new ConverterException("Air SDK directory is null.");
        }
        if(rootTargetDirectory == null) {
            throw new ConverterException("Target directory is null.");
        }

        this.rootSourceDirectory = rootSourceDirectory;
        this.rootTargetDirectory = rootTargetDirectory;

        try {
            // Load some initial properties from the classpath.
            final Properties properties = new Properties();
            final InputStream propertyInputStream =
                  getClass().getClassLoader().getResourceAsStream("velocity.properties");
            if(propertyInputStream != null) {
                properties.load(propertyInputStream);
            }

            // Instantiate the engine that will be used for every generation.
            velocityEngine = new VelocityEngine(properties);
        } catch (Exception e) {
            throw new ConverterException("Error initializing the velocity template engine.", e);
        }
    }
View Full Code Here

                    //noinspection ThrowFromFinallyBlock
                    throw new RuntimeException("Unable to close input stream for MD5 calculation", e);
                }
            }
        } catch (NoSuchAlgorithmException e) {
            throw new ConverterException("Error calculating checksum of file '" + jarFile.getPath() + "'", e);
        } catch (FileNotFoundException e) {
            throw new ConverterException("Error calculating checksum of file '" + jarFile.getPath() + "'", e);
        }
    }
View Full Code Here

                            " more than one result was returned by query: " + queryUrl);
                }
            }
            return null;
        } catch(IOException e) {
            throw new ConverterException("Error processing Metadata for checksum: '" + checksum + "'", e);
        } catch (JSONException e) {
            throw new ConverterException("Error processing Metadata for checksum: '" + checksum + "'", e);
        }
    }
View Full Code Here

            }

            in.close();
            out.close();
        } catch(IOException e) {
            throw new ConverterException("Error copying file from '" + source.getPath() +
                    "' to '" + target.getPath() + "'", e);
        }
    }
View Full Code Here

            if(velocityEngine.resourceExists("templates/" + metadata.getPackaging() + ".vm")) {
               templateName = "templates/" + metadata.getPackaging() + ".vm";
            } else if(velocityEngine.resourceExists("templates/default.vm")) {
               templateName = "templates/default.vm";
            } else {
               throw new ConverterException("No template found for generating pom output.");
            }

            // Prepare an output stream to which the output can be generated.
            FileWriter writer = null;
            try {
                if(!outputFile.getParentFile().exists()) {
                    if(!outputFile.getParentFile().mkdirs()) {
                        throw new ConverterException("Could not create template output directory.");
                    }
                }

                writer = new FileWriter(outputFile);

                // Have velocity generate the output for the template.
                velocityEngine.mergeTemplate(templateName, "utf-8", velocityContext, writer);
            } finally {
                if(writer != null) {
                    writer.close();
                }
            }
        } catch (Exception e) {
            throw new ConverterException("Error generating template output.", e);
        }
    }
View Full Code Here

            final ZipOutputStream out = new ZipOutputStream(new FileOutputStream(targetFile));
            out.putNextEntry(new ZipEntry("dummy"));
            out.closeEntry();
            out.close();
        } catch (IOException e) {
            throw new ConverterException("Error generating dummy resouce bundle.");
        }
    }
View Full Code Here

            for (final File file : zipInputFiles) {
                addFileToZip(zipOutputStream, file, rootDir);
            }
            zipOutputStream.close();
        } catch(IOException e) {
            throw new ConverterException("Error generating " + targetFile.getName() + " zip.", e);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.flex.utilities.converter.exceptions.ConverterException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.