Example usage for java.io FileNotFoundException getClass

List of usage examples for java.io FileNotFoundException getClass

Introduction

In this page you can find the example usage for java.io FileNotFoundException getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:de.zweipunktfuenf.crypdroid.activities.ActionChooserActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case REQUEST_SAVE:
        if (RESULT_OK == resultCode) {
            File file;/* w ww.  j  a  v a2s  . c o m*/
            {// find unique filename
                String dir = (String) data.getExtras().getSerializable(FileviewActivity.EXTRA_SELECTED_FILE)
                        + "/";

                //               String fname = (null == filename || filename.isEmpty())
                //                  ? "" + System.currentTimeMillis()
                //                  + (mode == MODE_PLAIN ? ".txt" : "")
                //                  : filename;
                String fname = data.getExtras().getString(FileviewActivity.EXTRA_FILENAME);

                String[] parts = fname.split("\\.(?=[^\\.]+$)");
                String fn = parts[0];
                String ext = parts.length == 2 ? parts[1] : "";

                String test = fn + (ext.isEmpty() ? "" : ("." + ext));
                file = new File(dir + "/" + test);

                int i = 1;
                while (file.exists()) {
                    test = fn + "(" + ++i + ")" + (ext.isEmpty() ? "" : ("." + ext));
                    file = new File(dir + "/" + test);
                }
            }

            FileInputStream fis = null;
            FileOutputStream fos = null;
            try {
                file.createNewFile();
                fos = new FileOutputStream(file);
                fis = openFileInput(CrypdroidActivity.FILE_TEMP_OUT);

                int n;
                byte[] buffer = new byte[1024];
                while (-1 < (n = fis.read(buffer)))
                    fos.write(buffer, 0, n);

                Toast.makeText(this, R.string.file_saved, Toast.LENGTH_LONG).show();

            } catch (FileNotFoundException e) {
                Toast.makeText(this, R.string.error_internal, Toast.LENGTH_LONG).show();
                Log.e("ActionChooserActivity#onActivityResult", "" + e.getClass(), e);
            } catch (IOException e) {
                Toast.makeText(this, R.string.error_internal, Toast.LENGTH_LONG).show();
                Log.e("ActionChooserActivity#onActivityResult", "" + e.getClass(), e);
            } finally {
                if (null != fis)
                    try {
                        fis.close();
                    } catch (IOException e) {
                        Log.d("ActionChooserActivity#onActivityResult", "error while closing internal_out", e);
                    }
                if (null != fos)
                    try {
                        fos.close();
                    } catch (IOException e) {
                        Log.d("ActionChooserActivity#onActivityResult", "error while closing file output", e);
                    }
            }
        }
        break;
    default:
        super.onActivityResult(requestCode, resultCode, data);
    }
}

From source file:pcgen.core.Names.java

private void parseFile(final File aSourceFile) {
    String currentLine = "";

    BufferedReader br = null;/*from  w  w w  .j  a  v a2  s  .co  m*/

    int lineNumber = 0;

    try {
        String currentSyllable = null;

        boolean canWrite = true;
        boolean inRulesSection = false;

        br = new BufferedReader(new InputStreamReader(new FileInputStream(aSourceFile)));

        while ((currentLine = br.readLine()) != null) {
            ++lineNumber;

            if (((currentLine.length() > 0) && (currentLine.charAt(0) == '#')) || currentLine.startsWith("//")
                    || "".equals(currentLine.trim())) {
                continue;
            }

            if (currentLine.startsWith("[/PRE]")) {
                canWrite = true;
            }

            if (currentLine.startsWith("[PRE") && (currentLine.indexOf(':') >= 0)) {
                final StringTokenizer tabTok = new StringTokenizer(
                        currentLine.substring(1, currentLine.length() - 1), "\t", false);
                final List<String> aList = new ArrayList<String>();

                while (tabTok.hasMoreTokens()) {
                    aList.add(tabTok.nextToken());
                }
                List<Prerequisite> prereqs = new ArrayList<Prerequisite>();
                try {
                    PreParserFactory factory = PreParserFactory.getInstance();
                    prereqs = factory.parse(aList);
                } catch (PersistenceLayerException ple) {
                    // Do nothing
                }
                canWrite = PrereqHandler.passesAll(prereqs, pc, null);
                continue;
            }

            if (!canWrite) {
                if ((currentLine.length() > 0) && (currentLine.charAt(0) == '[')) {
                    System.err.println(
                            "Line #" + Integer.toString(lineNumber) + " prereqs not met: " + currentLine);
                }
                continue;
            }

            if (currentLine.startsWith("[RULES]")) {
                inRulesSection = true;

                continue;
            }

            if ((currentLine.length() > 0) && (currentLine.charAt(0) == '[')) {
                inRulesSection = false;
            }

            if (inRulesSection) {
                ruleDefinitions.add(currentLine);

                continue;
            }

            //This is where the syllable types are saved to sylRuleList and the list themselves
            //are read into a corresponding list.
            if (((currentLine.length() > 0) && (currentLine.charAt(0) == '[')) && currentLine.endsWith("]")) {
                currentSyllable = currentLine;
                allTheSyllablesForEachRule.put(currentLine, new ArrayList<String>());

                continue;
            }

            // if we make it here, then we actually have a syllable fragment in hand.
            allTheSyllablesForEachRule.get(currentSyllable).add(currentLine);
        }
    } catch (FileNotFoundException exception) {
        if (!"pcgen.ini".equals(aSourceFile.getName())) {
            Logging.errorPrint("ERROR:" + aSourceFile.getName() + " error " + currentLine + " Exception type:"
                    + exception.getClass().getName() + " Message:" + exception.getMessage(), exception);
        }
    } catch (IOException exception) {
        if (!("pcgen.ini".equals(aSourceFile.getName()))) {
            Logging.errorPrint("ERROR:" + aSourceFile.getName() + " error " + currentLine + " Exception type:"
                    + exception.getClass().getName() + " Message:" + exception.getMessage(), exception);
        }
    } finally {
        if (br != null) {
            try {
                br.close();
            } catch (IOException ignore) {
                Logging.errorPrint("Couldn't close the reader for " + aSourceFile.getName(), ignore);
            }
        }
    }
}

From source file:biz.wiz.android.wallet.WalletApplication.java

private void loadWalletFromProtobuf() {
    if (walletFile.exists()) {
        final long start = System.currentTimeMillis();

        FileInputStream walletStream = null;

        try {//w  w w . j  ava 2 s  .  c  o m
            walletStream = new FileInputStream(walletFile);

            wallet = new WalletProtobufSerializer().readWallet(walletStream);

            if (!wallet.getParams().equals(Constants.NETWORK_PARAMETERS))
                throw new UnreadableWalletException(
                        "bad wallet network parameters: " + wallet.getParams().getId());

            log.info("wallet loaded from: '" + walletFile + "', took " + (System.currentTimeMillis() - start)
                    + "ms");
        } catch (final FileNotFoundException x) {
            log.error("problem loading wallet", x);

            Toast.makeText(WalletApplication.this, x.getClass().getName(), Toast.LENGTH_LONG).show();

            wallet = restoreWalletFromBackup();
        } catch (final UnreadableWalletException x) {
            log.error("problem loading wallet", x);

            Toast.makeText(WalletApplication.this, x.getClass().getName(), Toast.LENGTH_LONG).show();

            wallet = restoreWalletFromBackup();
        } finally {
            if (walletStream != null) {
                try {
                    walletStream.close();
                } catch (final IOException x) {
                    // swallow
                }
            }
        }

        if (!wallet.isConsistent()) {
            Toast.makeText(this, "inconsistent wallet: " + walletFile, Toast.LENGTH_LONG).show();

            wallet = restoreWalletFromBackup();
        }

        if (!wallet.getParams().equals(Constants.NETWORK_PARAMETERS))
            throw new Error("bad wallet network parameters: " + wallet.getParams().getId());
    } else {
        wallet = new Wallet(Constants.NETWORK_PARAMETERS);

        // log.info("wallet bip32 seed is " + wallet.getKeyChainSeed().getMnemonicCode());

        backupWallet();

        config.armBackupReminder();

        log.info("new wallet created");
    }
}

From source file:com.aol.advertising.qiao.emitter.KafkaEmitter.java

private Properties loadProperties(File file) {
    if (!file.exists())
        return null;

    Properties props = new Properties();

    FileReader reader;//from   ww w  .j a va 2  s.com
    try {
        reader = new FileReader(file);
        props.load(reader);
        return props;
    } catch (FileNotFoundException e) {
        logger.warn("File not found: " + file.getName());
    } catch (IOException e) {
        logger.warn("failed loading property file " + file.getName() + " => " + e.getClass().getSimpleName()
                + ": " + e.getMessage());
    }

    return null;
}

From source file:org.hopestarter.wallet.WalletApplication.java

private void loadWalletFromProtobuf() {
    if (mWalletFile.exists()) {
        final long start = System.currentTimeMillis();

        FileInputStream walletStream = null;

        try {//from  ww  w . ja  v a 2  s  .com
            walletStream = new FileInputStream(mWalletFile);

            mWallet = new WalletProtobufSerializer().readWallet(walletStream);

            if (!mWallet.getParams().equals(Constants.NETWORK_PARAMETERS))
                throw new UnreadableWalletException(
                        "bad wallet network parameters: " + mWallet.getParams().getId());

            log.info("wallet loaded from: '" + mWalletFile + "', took " + (System.currentTimeMillis() - start)
                    + "ms");
        } catch (final FileNotFoundException x) {
            log.error("problem loading wallet", x);

            Toast.makeText(WalletApplication.this, x.getClass().getName(), Toast.LENGTH_LONG).show();

            mWallet = restoreWalletFromBackup();
        } catch (final UnreadableWalletException x) {
            log.error("problem loading wallet", x);

            Toast.makeText(WalletApplication.this, x.getClass().getName(), Toast.LENGTH_LONG).show();

            mWallet = restoreWalletFromBackup();
        } finally {
            if (walletStream != null) {
                try {
                    walletStream.close();
                } catch (final IOException x) {
                    // swallow
                }
            }
        }

        if (!mWallet.isConsistent()) {
            Toast.makeText(this, "inconsistent wallet: " + mWalletFile, Toast.LENGTH_LONG).show();

            mWallet = restoreWalletFromBackup();
        }

        if (!mWallet.getParams().equals(Constants.NETWORK_PARAMETERS))
            throw new Error("bad wallet network parameters: " + mWallet.getParams().getId());
    } else {
        mWallet = new Wallet(Constants.NETWORK_PARAMETERS);

        backupWallet();

        mConfig.armBackupReminder();

        log.info("new wallet created");
    }
}

From source file:com.matthewmitchell.peercoin_android_wallet.WalletApplication.java

private void loadWalletFromProtobuf() {
    if (walletFile.exists()) {
        final long start = System.currentTimeMillis();

        FileInputStream walletStream = null;

        try {//from w w w.  j a  v  a2  s  .  c om
            walletStream = new FileInputStream(walletFile);

            wallet = new WalletProtobufSerializer().readWallet(walletStream);

            if (!wallet.getParams().equals(Constants.NETWORK_PARAMETERS))
                throw new UnreadableWalletException(
                        "bad wallet network parameters: " + wallet.getParams().getId());

            log.info("wallet loaded from: '" + walletFile + "', took " + (System.currentTimeMillis() - start)
                    + "ms");
        } catch (final FileNotFoundException x) {
            log.error("problem loading wallet", x);

            Toast.makeText(WalletApplication.this, x.getClass().getName(), Toast.LENGTH_LONG).show();

            wallet = restoreWalletFromBackup();
        } catch (final UnreadableWalletException x) {
            log.error("problem loading wallet", x);

            Toast.makeText(WalletApplication.this, x.getClass().getName(), Toast.LENGTH_LONG).show();

            wallet = restoreWalletFromBackup();
        } finally {
            if (walletStream != null) {
                try {
                    walletStream.close();
                } catch (final IOException x) {
                    // swallow
                }
            }
        }

        if (!wallet.isConsistent()) {
            Toast.makeText(this, "inconsistent wallet: " + walletFile, Toast.LENGTH_LONG).show();

            wallet = restoreWalletFromBackup();
        }

        if (!wallet.getParams().equals(Constants.NETWORK_PARAMETERS))
            throw new Error("bad wallet network parameters: " + wallet.getParams().getId());
    } else {
        wallet = new Wallet(Constants.NETWORK_PARAMETERS);

        backupWallet();

        config.armBackupReminder();

        log.info("new wallet created");
    }
}

From source file:org.multibit.file.FileHandler.java

public static void writeUserPreferences(BitcoinController bitcoinController) {
    final Controller controller = bitcoinController;
    // Save all the wallets' filenames in the user preferences.
    if (bitcoinController.getModel().getPerWalletModelDataList() != null) {
        List<WalletData> perWalletModelDataList = bitcoinController.getModel().getPerWalletModelDataList();

        List<String> orderList = new ArrayList<String>();
        List<String> earlyList = new ArrayList<String>();
        List<String> protobuf3List = new ArrayList<String>();

        for (WalletData perWalletModelData : perWalletModelDataList) {
            // Check if this is the initial empty WalletData
            if ("".equals(perWalletModelData.getWalletFilename())
                    || perWalletModelData.getWalletFilename() == null
                    || perWalletModelData.getWalletInfo() == null) {
                continue;
            }/* w w w  .  j  a  v  a2s .  c  o  m*/

            // Do not save deleted wallets
            if (perWalletModelData.getWalletInfo().isDeleted()) {
                log.debug("Not writing out info about wallet '" + perWalletModelData.getWalletFilename()
                        + "' as it has been deleted");
                continue;
            }

            if (!orderList.contains(perWalletModelData.getWalletFilename())) {
                orderList.add(perWalletModelData.getWalletFilename());
            }

            if (perWalletModelData.getWalletInfo()
                    .getWalletVersion() == MultiBitWalletVersion.PROTOBUF_ENCRYPTED) {
                if (!protobuf3List.contains(perWalletModelData.getWalletFilename())) {
                    protobuf3List.add(perWalletModelData.getWalletFilename());
                }
            } else if (perWalletModelData.getWalletInfo().getWalletVersion() == null
                    || perWalletModelData.getWalletInfo().getWalletVersion() == MultiBitWalletVersion.SERIALIZED
                    || perWalletModelData.getWalletInfo()
                            .getWalletVersion() == MultiBitWalletVersion.PROTOBUF) {
                if (!earlyList.contains(perWalletModelData.getWalletFilename())) {
                    earlyList.add(perWalletModelData.getWalletFilename());
                }
            }
        }

        int orderCount = 1;
        for (String walletFilename : orderList) {
            controller.getModel().setUserPreference(BitcoinModel.WALLET_ORDER_PREFIX + orderCount,
                    walletFilename);
            orderCount++;
        }
        controller.getModel().setUserPreference(BitcoinModel.WALLET_ORDER_TOTAL, "" + orderList.size());

        int earlyCount = 1;
        for (String walletFilename : earlyList) {
            controller.getModel().setUserPreference(BitcoinModel.EARLY_WALLET_FILENAME_PREFIX + earlyCount,
                    walletFilename);
            earlyCount++;
        }
        controller.getModel().setUserPreference(BitcoinModel.NUMBER_OF_EARLY_WALLETS, "" + earlyList.size());

        int protobuf3Count = 1;
        for (String walletFilename : protobuf3List) {
            controller.getModel().setUserPreference(
                    BitcoinModel.PROTOBUF3_WALLET_FILENAME_PREFIX + protobuf3Count, walletFilename);
            protobuf3Count++;
        }
        controller.getModel().setUserPreference(BitcoinModel.NUMBER_OF_PROTOBUF3_WALLETS,
                "" + protobuf3List.size());
        controller.getModel().setUserPreference(BitcoinModel.ACTIVE_WALLET_FILENAME,
                bitcoinController.getModel().getActiveWalletFilename());
    }

    Properties userPreferences = controller.getModel().getAllUserPreferences();

    // If the view is marked as also requiring a backwards compatible
    // numeric field write that.
    @SuppressWarnings("deprecation")
    int currentViewNumericFormat = View.toOldViewNumeric(controller.getCurrentView());
    if (currentViewNumericFormat != 0) {
        userPreferences.put(CoreModel.SELECTED_VIEW, "" + currentViewNumericFormat);
    } else {
        // Make sure the old numeric value for a view is not in the user
        // properties.
        userPreferences.remove(CoreModel.SELECTED_VIEW);
    }
    // Write the user preference properties.
    OutputStream outputStream = null;
    try {
        String userPropertiesFilename;
        if ("".equals(controller.getApplicationDataDirectoryLocator().getApplicationDataDirectory())) {
            userPropertiesFilename = USER_PROPERTIES_FILE_NAME;
        } else {
            userPropertiesFilename = controller.getApplicationDataDirectoryLocator()
                    .getApplicationDataDirectory() + File.separator + USER_PROPERTIES_FILE_NAME;
        }

        outputStream = new FileOutputStream(userPropertiesFilename);
        BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(outputStream);
        OutputStreamWriter outputStreamWriter = new OutputStreamWriter(bufferedOutputStream, "UTF8");
        userPreferences.store(outputStreamWriter, USER_PROPERTIES_HEADER_TEXT);
    } catch (FileNotFoundException e) {
        log.error(e.getMessage(), e);
    } catch (IOException e) {
        log.error(e.getMessage(), e);
    } finally {
        if (outputStream != null) {
            try {
                outputStream.flush();
                outputStream.close();
            } catch (IOException e) {
                log.error(e.getClass().getCanonicalName() + " " + e.getMessage());
            } finally {
                outputStream = null;
            }
        }
    }
}

From source file:org.apache.archiva.common.filelock.DefaultFileLockManager.java

@Override
public Lock readFileLock(File file) throws FileLockException, FileLockTimeoutException {
    if (skipLocking) {
        return new Lock(file);

    }/*from w  w  w  .  j  a  v a 2s  .c om*/
    StopWatch stopWatch = new StopWatch();
    boolean acquired = false;
    mkdirs(file.getParentFile());

    Lock lock = null;

    stopWatch.start();

    while (!acquired) {

        if (timeout > 0) {
            long delta = stopWatch.getTime();
            log.debug("delta {}, timeout {}", delta, timeout);
            if (delta > timeout) {
                log.warn("Cannot acquire read lock within {} millis. Will skip the file: {}", timeout, file);
                // we could not get the lock within the timeout period, so  throw  FileLockTimeoutException
                throw new FileLockTimeoutException();
            }
        }

        Lock current = lockFiles.get(file);

        if (current != null) {
            log.debug("read lock file exist continue wait");
            continue;
        }

        try {
            lock = new Lock(file, false);
            createNewFileQuietly(file);
            lock.openLock(false, timeout > 0);
            acquired = true;
        } catch (FileNotFoundException e) {
            // can happen if an other thread has deleted the file
            // close RandomAccessFile!!!
            if (lock != null) {
                closeQuietly(lock.getRandomAccessFile());
            }
            log.debug("read Lock skip: {} try to create file", e.getMessage());
            createNewFileQuietly(file);
        } catch (IOException e) {
            throw new FileLockException(e.getMessage(), e);
        } catch (IllegalStateException e) {
            log.debug("openLock {}:{}", e.getClass(), e.getMessage());
        }
    }
    Lock current = lockFiles.putIfAbsent(file, lock);
    if (current != null) {
        lock = current;
    }
    return lock;

}

From source file:org.apache.archiva.common.filelock.DefaultFileLockManager.java

@Override
public Lock writeFileLock(File file) throws FileLockException, FileLockTimeoutException {
    if (skipLocking) {
        return new Lock(file);
    }/*from w w w  . jav a  2  s  . c o m*/

    mkdirs(file.getParentFile());

    StopWatch stopWatch = new StopWatch();
    boolean acquired = false;

    Lock lock = null;

    stopWatch.start();

    while (!acquired) {

        if (timeout > 0) {
            long delta = stopWatch.getTime();
            log.debug("delta {}, timeout {}", delta, timeout);
            if (delta > timeout) {
                log.warn("Cannot acquire read lock within {} millis. Will skip the file: {}", timeout, file);
                // we could not get the lock within the timeout period, so throw FileLockTimeoutException
                throw new FileLockTimeoutException();
            }
        }

        Lock current = lockFiles.get(file);

        try {

            if (current != null) {
                log.debug("write lock file exist continue wait");

                continue;
            }
            lock = new Lock(file, true);
            createNewFileQuietly(file);
            lock.openLock(true, timeout > 0);
            acquired = true;
        } catch (FileNotFoundException e) {
            // can happen if an other thread has deleted the file
            // close RandomAccessFile!!!
            if (lock != null) {
                closeQuietly(lock.getRandomAccessFile());
            }
            log.debug("write Lock skip: {} try to create file", e.getMessage());
            createNewFileQuietly(file);
        } catch (IOException e) {
            throw new FileLockException(e.getMessage(), e);
        } catch (IllegalStateException e) {
            log.debug("openLock {}:{}", e.getClass(), e.getMessage());
        }
    }

    Lock current = lockFiles.putIfAbsent(file, lock);
    if (current != null) {
        lock = current;
    }

    return lock;

}

From source file:org.sakaiproject.profile2.conversion.ProfileConverter.java

/**
 * Import profiles from the given CSV file
 * //from   ww w . ja va 2s .co  m
 * <p>The CSV file may contain any of the following headings, in any order:
 *  
 *  <ul>
 *  <li>eid</li>
 *  <li>nickname</li>
 *  <li>position</li>
 *  <li>department</li>
 *  <li>school</li>
 *  <li>room</li>
 *  <li>web site</li>
 *  <li>work phone</li>
 *  <li>home phone</li>
 *  <li>mobile phone</li>
 *  <li>fax</li>
 *  <li>books</li>
 *  <li>tv</li>
 *  <li>movies</li>
 *  <li>quotes</li>
 *  <li>summary</li>
 *  <li>course</li>
 *  <li>subjects</li>
 *  <li>staff profile</li>
 *  <li>uni profile url</li>
 *  <li>academic profile url</li>
 *  <li>publications</li>
 *  <li>official image url</li>
 *  </ul>
 * 
 * <p>Column headings must match EXACTLY the list above. They do not need to be in the same order, or even all present.
 * 
 * <p>Fields must be comma separated and each field surrounded with double quotes. There must be no spaces between fields.
 * 
 * <p>Only users that do not currently have a profile will be imported.
 * 
 * @param path   path to CSV file on the server
 */
public void importProfiles(String path) {

    if (StringUtils.isBlank(path)) {
        log.warn("Profile2 importer: invalid path to CSV file. Aborting.");
        return;
    }

    HeaderColumnNameTranslateMappingStrategy<ImportableUserProfile> strat = new HeaderColumnNameTranslateMappingStrategy<ImportableUserProfile>();
    strat.setType(ImportableUserProfile.class);

    //map the column headers to the field names in the UserProfile class
    //this mapping is not exhaustive and can be added to at any time since we are mapping
    //on column name not position
    Map<String, String> map = new HashMap<String, String>();
    map.put("eid", "eid");
    map.put("nickname", "nickname");
    map.put("position", "position");
    map.put("department", "department");
    map.put("school", "school");
    map.put("room", "room");
    map.put("web site", "homepage");
    map.put("work phone", "workphone");
    map.put("home phone", "homephone");
    map.put("mobile phone", "mobilephone");
    map.put("fax", "facsimile");
    map.put("books", "favouriteBooks");
    map.put("tv", "favouriteTvShows");
    map.put("movies", "favouriteMovies");
    map.put("quotes", "favouriteQuotes");
    map.put("summary", "personalSummary");
    map.put("course", "course");
    map.put("subjects", "subjects");
    map.put("staff profile", "staffProfile");
    map.put("uni profile url", "universityProfileUrl");
    map.put("academic profile url", "academicProfileUrl");
    map.put("publications", "publications");
    map.put("official image url", "officialImageUrl");

    strat.setColumnMapping(map);

    CsvToBean<ImportableUserProfile> csv = new CsvToBean<ImportableUserProfile>();
    List<ImportableUserProfile> list = new ArrayList<ImportableUserProfile>();
    try {
        list = csv.parse(strat, new CSVReader(new FileReader(path)));
    } catch (FileNotFoundException fnfe) {
        log.error("Profile2 importer: Couldn't find file: " + fnfe.getClass() + " : " + fnfe.getMessage());
    }

    //setup a security advisor so we can save profiles
    SecurityAdvisor securityAdvisor = new SecurityAdvisor() {
        public SecurityAdvice isAllowed(String userId, String function, String reference) {
            return SecurityAdvice.ALLOWED;
        }
    };
    enableSecurityAdvisor(securityAdvisor);

    //process each
    for (ImportableUserProfile profile : list) {

        log.info("Processing user: " + profile.getEid());

        //get uuid
        String uuid = sakaiProxy.getUserIdForEid(profile.getEid());
        if (StringUtils.isBlank(uuid)) {
            log.error("Invalid user: " + profile.getEid() + ". Skipping...");
            continue;
        }

        profile.setUserUuid(uuid);

        //check if user already has a profile. Skip if so.
        if (hasPersistentProfile(uuid)) {
            log.warn("User: " + profile.getEid() + " already has a profile. Skipping...");
            continue;
        }

        //persist user profile
        try {
            SakaiPerson sp = transformUserProfileToSakaiPerson(profile);

            if (sp == null) {
                //already logged
                continue;
            }

            if (sakaiProxy.updateSakaiPerson(sp)) {
                log.info("Profile saved for user: " + profile.getEid());
            } else {
                log.error("Couldn't save profile for user: " + profile.getEid());
                continue;
            }
        } catch (ProfileNotDefinedException pnde) {
            //already logged
            continue;
        }

        //add/update official image, if supplied in the CSV
        if (StringUtils.isNotBlank(profile.getOfficialImageUrl())) {
            if (imageLogic.saveOfficialImageUrl(uuid, profile.getOfficialImageUrl())) {
                log.info("Official image saved for user: " + profile.getEid());
            } else {
                log.error("Couldn't save official image for user: " + profile.getEid());
            }
        }
    }
    disableSecurityAdvisor(securityAdvisor);

}