Changeset 1219 for trunk/src


Ignore:
Timestamp:
01/30/19 13:03:55 (5 years ago)
Author:
bln4
Message:

FrameIO.java -> Altercation of how frames are discovered during loading process to be more formal. This will likely evolve further.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/gui/FrameIO.java

    r1200 r1219  
    3737import java.util.HashMap;
    3838import java.util.LinkedList;
     39import java.util.List;
    3940
    4041import org.expeditee.actions.Actions;
    4142import org.expeditee.agents.ExistingFramesetException;
    42 import org.expeditee.auth.io.EncryptedExpReader;
    43 import org.expeditee.auth.io.EncryptedExpWriter;
     43import org.expeditee.auth.Authenticator;
     44import org.expeditee.auth.EncryptedExpReader;
     45import org.expeditee.auth.EncryptedProfileExpWriter;
     46import org.expeditee.auth.gui.MailBay;
    4447import org.expeditee.io.Conversion;
    4548import org.expeditee.io.ExpReader;
     
    193196        }
    194197       
    195         public static String FRAMESET_CONSULT_PATH = null;
    196 
    197198        public static Frame LoadFrame(String frameName) {
    198                 return LoadFrame(frameName, FRAMESET_CONSULT_PATH, false);
     199                return LoadFrame(frameName, null, false);
    199200        }
    200201
     
    203204        }
    204205
    205         public static Frame LoadFrame(String frameName, String path, boolean ignoreAnnotations)
    206         {
     206        public static Frame LoadFrame(String frameName, String path, boolean ignoreAnnotations) {
    207207                if (!isValidFrameName(frameName)) {
    208208                        return null;
     
    261261                                Logger.Log(Logger.SYSTEM, Logger.LOAD, "Clearing " + frameName
    262262                                                + " from cache.");
    263                                 Frame frame = _Cache.get(frameNameLower);
    264263                                _Cache.remove(frameNameLower);                         
    265264                        }
     
    293292                        loaded = LoadKnowPath(knownPath, framename);
    294293                } else {
    295 
    296                         for (String path : FolderSettings.FrameDirs.get()) {
     294                        List<String> directoriesToSearch = FolderSettings.FrameDirs.get();
     295                       
     296                        if (UserSettings.Authenticated.get()) {
     297                                // if we are running Expeditee Authenticated, consult user profile as location for framesets first
     298                                String profilePath = FrameIO.PROFILE_PATH + UserSettings.UserName.get() + File.separator;
     299                                directoriesToSearch.add(0, profilePath);
     300                        }
     301                       
     302                        for (String path : directoriesToSearch) {
    297303                                loaded = LoadKnowPath(path, framename);
    298304                                if (loaded != null) {
     
    448454                                }
    449455                        }
     456                        reader.close();
    450457                } catch (FileNotFoundException e) {
    451458                        e.printStackTrace();
     
    468475                        if (fullPath.endsWith(ExpReader.EXTENTION)) {
    469476                                if (EncryptedExpReader.isEncryptedExpediteeFile(fullPath)) {
    470                                         reader = new EncryptedExpReader(frameName);
     477                                        final boolean isProfile = frameName.startsWith(UserSettings.UserName.get());
     478                                        reader = new EncryptedExpReader(frameName, isProfile);
    471479                                } else {
    472480                                        reader = new ExpReader(frameName);
     
    941949        public static String SaveFrame(Frame toSave, boolean inc,
    942950                        boolean checkBackup) {
     951               
     952                if (toSave.getName().startsWith("ExpediteeMail")) {
     953                        System.err.println();
     954                }
    943955
    944956                // TODO When loading a frame maybe append onto the event history too-
     
    9941006                        // if its a new frame or an existing Exp frame...
    9951007                        if (fullPath == null || fullPath.endsWith(ExpReader.EXTENTION)) {
    996                                 //writer = new ExpWriter();
    997                                 writer = new ExpWriter();//new EncryptedExpWriter();
    998                                 savedVersion = ExpReader.getVersion(fullPath);
     1008                                //Frame currentFrame = DisplayController.getCurrentFrame();
     1009                                if (UserSettings.Authenticated.get() &&
     1010                                                toSave.getName().startsWith(UserSettings.UserName.get()) &&
     1011                                                toSave.getNumber() != Authenticator.PUBLIC_KEY_FRAME) {
     1012                                        writer = new EncryptedProfileExpWriter();
     1013                                        savedVersion = EncryptedExpReader.getVersion(fullPath);
     1014                                } else {
     1015                                        writer = new ExpWriter();
     1016                                        savedVersion = ExpReader.getVersion(fullPath);
     1017                                }
    9991018                        } else {
    10001019                                writer = new KMSWriter();
     
    10161035
    10171036                        // Check if we are trying to save an out of date version
    1018                         if (savedVersion > toSave.getVersion()
    1019                                         && !toSave.getFramesetName().equalsIgnoreCase(
    1020                                                         MessageBay.MESSAGES_FRAMESET_NAME)) {
     1037                        String framesetName = toSave.getFramesetName();
     1038                        boolean isBayFrameset =
     1039                                        framesetName.equalsIgnoreCase(MessageBay.MESSAGES_FRAMESET_NAME) ||
     1040                                        framesetName.equalsIgnoreCase(MailBay.EXPEDITEE_MAIL_FRAMESET_NAME);
     1041                        if (savedVersion > toSave.getVersion() && !isBayFrameset) {
    10211042                                // remove this frame from the cache if it is there
    10221043                                // This will make sure links to the original are set correctly
     
    11461167               
    11471168                String sf = SaveFrame(toSave, inc, checkBackup);               
    1148                 String originalFrameName = toSave.getFramesetName();
    1149                 //System.out.println(originalFrameName + " : " + toSave.getPath());
    11501169                String fullPath = getFrameFullPathName(toSave.getPath(), toSave
    11511170                                .getName());
Note: See TracChangeset for help on using the changeset viewer.