Package org.newinstance.gucoach.exception

Examples of org.newinstance.gucoach.exception.ImportException


            String[] playerRecord;
            try {
                // parse player's record and fill it into an array
                playerRecord = parser.parseLine(line[0]);
            } catch (final IOException ioe) {
                throw new ImportException(ResourceLoader.getMessage(MessageId.E002.getMessageKey()), ioe);
            }

            // if first part is numeric it is actually a player
            if (StringUtils.isNumeric(playerRecord[0])) {
                convertRecordToPlayer(playerRecord);
View Full Code Here


            String[] playerHistory;
            try {
                // parse player's history and fill it into an array
                playerHistory = parser.parseLine(line[0]);
            } catch (final IOException ioe) {
                throw new ImportException(ResourceLoader.getMessage(MessageId.E002.getMessageKey()), ioe);
            }

            // if first part is numeric it is actually a player's history
            if (StringUtils.isNumeric(playerHistory[0])) {
                // use a boolean variable to stop parsing after history section
View Full Code Here

            reader = new CSVReader(inputStreamReader);
            // read all content from CSV file
            content = reader.readAll();
            if (content.isEmpty()) {
                // nothing to import
                throw new ImportException(ResourceLoader.getMessage(MessageId.E003.getMessageKey()));
            }
            fileContent.addAll(content);
        } catch (final IOException ioe) {
            throw new ImportException(ResourceLoader.getMessage(MessageId.E004.getMessageKey()), ioe);
        } finally {
            if (reader != null) {
                try {
                    reader.close();
                } catch (final IOException e) {
View Full Code Here

        final String[] firstLineInFile = fileContent.get(0);
        // data is in first cell
        final String dateLine = firstLineInFile[0];

        if (StringUtils.isBlank(dateLine)) {
            throw new ImportException(ResourceLoader.getMessage(MessageId.E005.getMessageKey()));
        } else {
            int dateStartPosition = 0;
            for (int i = 0; i < dateLine.length(); i++) {
                if (Character.isDigit(dateLine.charAt(i))) {
                    dateStartPosition = i;
                    break;
                }
            }

            // TODO this date format is valid in some countries only - maybe we have to try other formats as well
            final SimpleDateFormat df = new SimpleDateFormat(DATE_FORMAT);
            final Date date = df.parse(dateLine, new ParsePosition(dateStartPosition));
            if (date == null) {
                final String message = ResourceLoader.getMessage(MessageId.E006.getMessageKey(), dateLine.substring(dateStartPosition, dateLine.length() + 1));
                throw new ImportException(message);
            }
            // set import date for later use
            importDate = date;
        }
    }
View Full Code Here

TOP

Related Classes of org.newinstance.gucoach.exception.ImportException

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.