@Test public void testFind() { assertNotNull(new SecurityApplicationGroupSupportDirectoryFinder().find()); assertEquals("~/Library/Group Containers/G69SCX94XU.duck/Library/Application Support/duck", new SecurityApplicationGroupSupportDirectoryFinder().find().getAbbreviatedPath()); }
@Override public Local find() { final NSFileManager manager = NSFileManager.defaultManager(); if(manager.respondsToSelector(Foundation.selector("containerURLForSecurityApplicationGroupIdentifier:"))) { final NSURL group = manager .containerURLForSecurityApplicationGroupIdentifier(identifier); if(null == group) { log.warn("Missing com.apple.security.application-groups in sandbox entitlements"); } else { final String application = PreferencesFactory.get().getProperty("application.datafolder.name"); final Local folder = new FinderLocal(String.format("%s/Library/Application Support", group.path()), application); try { final Local previous = new ApplicationSupportDirectoryFinder().find(); if(previous.exists()) { log.warn(String.format("Migrate application support folder from %s to %s", previous, folder)); try { FileUtils.copyDirectory(new File(previous.getAbsolute()), new File(folder.getAbsolute())); log.warn(String.format("Move application support folder %s to Trash", previous)); try { final Trash trash = LocalTrashFactory.get(); trash.trash(previous); final Symlink symlink = LocalSymlinkFactory.get(); symlink.symlink(previous, folder.getAbsolute()); } catch(LocalAccessDeniedException e) { log.warn(String.format("Failure cleaning up previous application support directory. %s", e.getMessage())); } } catch(IOException e) { log.warn(String.format("Failure migrating %s to security application group directory %s. %s", previous, folder, e.getMessage())); } } else { log.debug(String.format("No previous application support folder found in %s", previous)); } return folder; } catch(AccessDeniedException e) { log.warn(String.format("Failure creating security application group directory. %s", e.getMessage())); } } } log.warn("Missing support for security application groups. Default to application support directory"); return new ApplicationSupportDirectoryFinder().find(); }
SecurityApplicationGroupSupportDirectoryFinder implements SupportDirectoryFinder { @Override public Local find() { final NSFileManager manager = NSFileManager.defaultManager(); if(manager.respondsToSelector(Foundation.selector("containerURLForSecurityApplicationGroupIdentifier:"))) { final NSURL group = manager .containerURLForSecurityApplicationGroupIdentifier(identifier); if(null == group) { log.warn("Missing com.apple.security.application-groups in sandbox entitlements"); } else { final String application = PreferencesFactory.get().getProperty("application.datafolder.name"); final Local folder = new FinderLocal(String.format("%s/Library/Application Support", group.path()), application); try { final Local previous = new ApplicationSupportDirectoryFinder().find(); if(previous.exists()) { log.warn(String.format("Migrate application support folder from %s to %s", previous, folder)); try { FileUtils.copyDirectory(new File(previous.getAbsolute()), new File(folder.getAbsolute())); log.warn(String.format("Move application support folder %s to Trash", previous)); try { final Trash trash = LocalTrashFactory.get(); trash.trash(previous); final Symlink symlink = LocalSymlinkFactory.get(); symlink.symlink(previous, folder.getAbsolute()); } catch(LocalAccessDeniedException e) { log.warn(String.format("Failure cleaning up previous application support directory. %s", e.getMessage())); } } catch(IOException e) { log.warn(String.format("Failure migrating %s to security application group directory %s. %s", previous, folder, e.getMessage())); } } else { log.debug(String.format("No previous application support folder found in %s", previous)); } return folder; } catch(AccessDeniedException e) { log.warn(String.format("Failure creating security application group directory. %s", e.getMessage())); } } } log.warn("Missing support for security application groups. Default to application support directory"); return new ApplicationSupportDirectoryFinder().find(); } }
SecurityApplicationGroupSupportDirectoryFinder implements SupportDirectoryFinder { @Override public Local find() { final NSFileManager manager = NSFileManager.defaultManager(); if(manager.respondsToSelector(Foundation.selector("containerURLForSecurityApplicationGroupIdentifier:"))) { final NSURL group = manager .containerURLForSecurityApplicationGroupIdentifier(identifier); if(null == group) { log.warn("Missing com.apple.security.application-groups in sandbox entitlements"); } else { final String application = PreferencesFactory.get().getProperty("application.datafolder.name"); final Local folder = new FinderLocal(String.format("%s/Library/Application Support", group.path()), application); try { final Local previous = new ApplicationSupportDirectoryFinder().find(); if(previous.exists()) { log.warn(String.format("Migrate application support folder from %s to %s", previous, folder)); try { FileUtils.copyDirectory(new File(previous.getAbsolute()), new File(folder.getAbsolute())); log.warn(String.format("Move application support folder %s to Trash", previous)); try { final Trash trash = LocalTrashFactory.get(); trash.trash(previous); final Symlink symlink = LocalSymlinkFactory.get(); symlink.symlink(previous, folder.getAbsolute()); } catch(LocalAccessDeniedException e) { log.warn(String.format("Failure cleaning up previous application support directory. %s", e.getMessage())); } } catch(IOException e) { log.warn(String.format("Failure migrating %s to security application group directory %s. %s", previous, folder, e.getMessage())); } } else { log.debug(String.format("No previous application support folder found in %s", previous)); } return folder; } catch(AccessDeniedException e) { log.warn(String.format("Failure creating security application group directory. %s", e.getMessage())); } } } log.warn("Missing support for security application groups. Default to application support directory"); return new ApplicationSupportDirectoryFinder().find(); } SecurityApplicationGroupSupportDirectoryFinder();  SecurityApplicationGroupSupportDirectoryFinder(final String identifier); }
SecurityApplicationGroupSupportDirectoryFinder implements SupportDirectoryFinder { @Override public Local find() { final NSFileManager manager = NSFileManager.defaultManager(); if(manager.respondsToSelector(Foundation.selector("containerURLForSecurityApplicationGroupIdentifier:"))) { final NSURL group = manager .containerURLForSecurityApplicationGroupIdentifier(identifier); if(null == group) { log.warn("Missing com.apple.security.application-groups in sandbox entitlements"); } else { final String application = PreferencesFactory.get().getProperty("application.datafolder.name"); final Local folder = new FinderLocal(String.format("%s/Library/Application Support", group.path()), application); try { final Local previous = new ApplicationSupportDirectoryFinder().find(); if(previous.exists()) { log.warn(String.format("Migrate application support folder from %s to %s", previous, folder)); try { FileUtils.copyDirectory(new File(previous.getAbsolute()), new File(folder.getAbsolute())); log.warn(String.format("Move application support folder %s to Trash", previous)); try { final Trash trash = LocalTrashFactory.get(); trash.trash(previous); final Symlink symlink = LocalSymlinkFactory.get(); symlink.symlink(previous, folder.getAbsolute()); } catch(LocalAccessDeniedException e) { log.warn(String.format("Failure cleaning up previous application support directory. %s", e.getMessage())); } } catch(IOException e) { log.warn(String.format("Failure migrating %s to security application group directory %s. %s", previous, folder, e.getMessage())); } } else { log.debug(String.format("No previous application support folder found in %s", previous)); } return folder; } catch(AccessDeniedException e) { log.warn(String.format("Failure creating security application group directory. %s", e.getMessage())); } } } log.warn("Missing support for security application groups. Default to application support directory"); return new ApplicationSupportDirectoryFinder().find(); } SecurityApplicationGroupSupportDirectoryFinder();  SecurityApplicationGroupSupportDirectoryFinder(final String identifier); @Override Local find(); }
SecurityApplicationGroupSupportDirectoryFinder implements SupportDirectoryFinder { @Override public Local find() { final NSFileManager manager = NSFileManager.defaultManager(); if(manager.respondsToSelector(Foundation.selector("containerURLForSecurityApplicationGroupIdentifier:"))) { final NSURL group = manager .containerURLForSecurityApplicationGroupIdentifier(identifier); if(null == group) { log.warn("Missing com.apple.security.application-groups in sandbox entitlements"); } else { final String application = PreferencesFactory.get().getProperty("application.datafolder.name"); final Local folder = new FinderLocal(String.format("%s/Library/Application Support", group.path()), application); try { final Local previous = new ApplicationSupportDirectoryFinder().find(); if(previous.exists()) { log.warn(String.format("Migrate application support folder from %s to %s", previous, folder)); try { FileUtils.copyDirectory(new File(previous.getAbsolute()), new File(folder.getAbsolute())); log.warn(String.format("Move application support folder %s to Trash", previous)); try { final Trash trash = LocalTrashFactory.get(); trash.trash(previous); final Symlink symlink = LocalSymlinkFactory.get(); symlink.symlink(previous, folder.getAbsolute()); } catch(LocalAccessDeniedException e) { log.warn(String.format("Failure cleaning up previous application support directory. %s", e.getMessage())); } } catch(IOException e) { log.warn(String.format("Failure migrating %s to security application group directory %s. %s", previous, folder, e.getMessage())); } } else { log.debug(String.format("No previous application support folder found in %s", previous)); } return folder; } catch(AccessDeniedException e) { log.warn(String.format("Failure creating security application group directory. %s", e.getMessage())); } } } log.warn("Missing support for security application groups. Default to application support directory"); return new ApplicationSupportDirectoryFinder().find(); } SecurityApplicationGroupSupportDirectoryFinder();  SecurityApplicationGroupSupportDirectoryFinder(final String identifier); @Override Local find();  }