Ticket #2424: applet_fix.patch
File applet_fix.patch, 28.0 KB (added by meddle, 15 years ago) |
---|
-
modules/org.sophie2.base.model.book/src/main/java/org/sophie2/base/model/book/actions/SetKindAction.java
### Eclipse Workspace Patch 1.0 #P sophie
1 package org.sophie2.base.model.book.actions; 2 3 import org.sophie2.base.model.resources.r4.changes.AutoAction; 4 import org.sophie2.base.model.resources.r4.resources.ResourceR4; 5 import org.sophie2.base.skins.Message; 6 7 /** 8 * {@link AutoAction} for setting the kind of a resource. 9 * 10 * @author kyli 11 */ 12 public class SetKindAction extends AutoAction { 13 14 private final String kind; 15 16 /** 17 * Constructs the action with the new kind to set. 18 * 19 * @param description 20 * Description of the action. 21 * @param significant 22 * Significance of the action. 23 * @param kind 24 * The new kind. 25 */ 26 public SetKindAction(Message description, boolean significant, 27 String kind) { 28 super(description, significant); 29 30 this.kind = kind; 31 } 32 33 @Override 34 public void performAuto() { 35 getChanger().setRaw(ResourceR4.KEY_KIND, this.kind); 36 } 37 } -
modules/org.sophie2.base.model.book/src/main/java/org/sophie2/base/model/book/AutoActionsUtil.java
1 1 package org.sophie2.base.model.book; 2 2 3 import org.sophie2.base.model.book.actions.ChangeTitleAction; 3 4 import org.sophie2.base.model.resources.r4.access.ResourceAccess; 4 5 import org.sophie2.base.model.resources.r4.changes.AutoAction; 5 6 import org.sophie2.base.model.resources.r4.resources.ResourceH; 6 import org.sophie2.base.model.resources.r4.resources.ResourceR4;7 7 import org.sophie2.base.skins.Message; 8 8 9 9 /** … … 70 70 * The new title of the resource. 71 71 */ 72 72 public static void changeResourceTitle(ResourceH resource, final String newTitle) { 73 new AutoAction(Message.create(RES_TITLE, newTitle), true) { 74 75 @Override 76 public void performAuto() { 77 getChanger().setRaw(ResourceR4.KEY_TITLE, newTitle); 78 } 79 80 }.register(resource.getAccess()); 73 AutoAction action = new ChangeTitleAction(Message.create(RES_TITLE, newTitle), true, 74 newTitle); 75 action.register(resource.getAccess()); 81 76 } 82 77 } -
modules/org.sophie2.s2s/src/main/java/org/sophie2/s2s/ServerModule.java
46 46 ServerResourceHelper helper = resourceHelperExtension.getObject(); 47 47 helper.initialize(); 48 48 49 WebAppModule.get().startServer( 9090);49 WebAppModule.get().startServer(); 50 50 } 51 51 }); 52 52 -
modules/org.sophie2.base.model.book/src/main/java/org/sophie2/base/model/book/actions/RemoveSubElementAction.java
1 package org.sophie2.base.model.book.actions; 2 3 import org.sophie2.base.commons.util.ImmList; 4 import org.sophie2.base.model.book.interfaces.CompositeElement; 5 import org.sophie2.base.model.book.timelines.ActivationChannel; 6 import org.sophie2.base.model.resources.r4.ResourceRefR4; 7 import org.sophie2.base.model.resources.r4.changes.AutoAction; 8 import org.sophie2.base.skins.Message; 9 10 /** 11 * {@link AutoAction} for removing the sub elements of an element. 12 * 13 * @author kyli 14 */ 15 public class RemoveSubElementAction extends AutoAction { 16 17 private final ResourceRefR4 elementRef; 18 private final ImmList<ActivationChannel> children; 19 private final ResourceRefR4 element; 20 21 /** 22 * Constructs the action with the element to be removed. 23 * 24 * @param description 25 * Description of the action. 26 * @param significant 27 * Significance of the action. 28 * @param elementRef 29 * Relative reference to the element to be removed, 30 * @param children 31 * The current sub elements of the element which sub element will be removed. 32 * @param element 33 * Absolute reference to the element to b removed. 34 */ 35 public RemoveSubElementAction(Message description, boolean significant, 36 ResourceRefR4 elementRef, ImmList<ActivationChannel> children, ResourceRefR4 element) { 37 super(description, significant); 38 39 this.elementRef = elementRef; 40 this.children = children; 41 this.element = element; 42 } 43 44 @Override 45 public void performAuto() { 46 int index = -1; 47 for (int i = 0; i < this.children.size(); i++) { 48 ResourceRefR4 childRef = this.children.get(i) 49 .getElementResource(); 50 if (childRef.equals(this.element)) { 51 index = i; 52 break; 53 } 54 } 55 56 ImmList<ActivationChannel> newChildren = this.children.remove(index); 57 getChanger().setRaw(CompositeElement.KEY_SUB_ELEMENTS, 58 newChildren); 59 if (!this.elementRef.isAbsolute()) { 60 getChanger().removeResource(this.elementRef); 61 } 62 } 63 } -
modules/org.sophie2.base.model.book/src/main/java/org/sophie2/base/model/book/ElementH.java
14 14 import org.sophie2.base.commons.util.position.ImmSize; 15 15 import org.sophie2.base.commons.util.position.Position; 16 16 import org.sophie2.base.media.TimePos; 17 import org.sophie2.base.model.book.actions.RemoveSubElementAction; 17 18 import org.sophie2.base.model.book.frame.BoundMode; 18 19 import org.sophie2.base.model.book.frame.FrameR4; 19 20 import org.sophie2.base.model.book.frame.WrappingModes; … … 418 419 Message actionName, boolean significance) { 419 420 420 421 ResourceAccess access = getAccess(); 421 final ImmList<ActivationChannel> children = CompositeElement.KEY_SUB_ELEMENTS 422 .get(access); 423 424 final ResourceRefR4 frameRef = ResourceRefR4.makeChild(element 425 .getName()); 422 final ImmList<ActivationChannel> children = CompositeElement.KEY_SUB_ELEMENTS.get(access); 426 423 427 new AutoAction(actionName, significance) { 428 @Override 429 public void performAuto() { 430 int index = -1; 431 for (int i = 0; i < children.size(); i++) { 432 ResourceRefR4 childRef = children.get(i) 433 .getElementResource(); 434 if (childRef.equals(element)) { 435 index = i; 436 break; 437 } 438 } 424 final ResourceRefR4 elementRef = ResourceRefR4.makeChild(element.getName()); 439 425 440 ImmList<ActivationChannel> newChildren = children.remove(index); 441 getChanger().setRaw(CompositeElement.KEY_SUB_ELEMENTS, 442 newChildren); 443 if (!frameRef.isAbsolute()) { 444 getChanger().removeResource(frameRef); 445 } 446 } 447 }.register(access); 426 AutoAction action = new RemoveSubElementAction(actionName, significance, elementRef, 427 children, element); 428 action.register(access); 448 429 449 430 } 450 431 -
modules/org.sophie2.main.app.commons/src/main/java/org/sophie2/main/app/commons/util/AppViewUtil.java
16 16 import org.sophie2.base.model.resources.r4.resources.ResourceH; 17 17 import org.sophie2.base.model.resources.r4.resources.ResourceR4; 18 18 import org.sophie2.base.visual.VisualElement; 19 import org.sophie2.core.logging.SophieLog; 19 20 import org.sophie2.core.modularity.SophieExtension; 20 21 import org.sophie2.core.mvc.LogicR3; 21 22 import org.sophie2.core.prolib.errors.NotAvailableException; … … 275 276 try { 276 277 bookAccess = locator.open(bookRef, options); 277 278 } catch (SophieSourceNotFoundException e) { 279 SophieLog.error("Cannot open book from ref: " + bookRef); 278 280 DialogUtils.showErrorDialog(null, 279 281 "The specified file does not contain a book.", "Error"); 280 282 return false; … … 283 285 284 286 String resourceKind = ResourceR4.KEY_KIND.get(bookAccess); 285 287 if (!BookR4.KIND.equals(resourceKind)) { 288 SophieLog.error("Cannot open book from ref: " + bookRef + " with access: " + bookAccess + " with kind: " + resourceKind); 286 289 DialogUtils.showErrorDialog(null, 287 290 "The specified file does not contain a book.", "Error"); 288 291 return false; -
modules/org.sophie2.launcher/src/main/resources/reader-run/applet.bundles.config
4 4 org.sophie2.core.mvc started 5 5 org.sophie2.base.bound installed 6 6 org.sophie2.base.commons installed 7 org.sophie2.base.config started 7 8 org.sophie2.base.model.resources.r4 started 8 9 org.sophie2.base.dialogs installed 9 10 org.sophie2.base.dnd installed -
modules/org.sophie2.base.model.book/src/main/java/org/sophie2/base/model/book/actions/CreateTestFrameAction.java
1 package org.sophie2.base.model.book.actions; 2 3 import org.sophie2.base.commons.util.ImmList; 4 import org.sophie2.base.model.book.FrameH; 5 import org.sophie2.base.model.book.frame.FrameR4; 6 import org.sophie2.base.model.book.timelines.ActivationChannel; 7 import org.sophie2.base.model.resources.r4.ResourceRefR4; 8 import org.sophie2.base.model.resources.r4.changes.AutoAction; 9 import org.sophie2.base.skins.Message; 10 11 /** 12 * {@link AutoAction} for adding a new frame for testing to an element. 13 * 14 * @author meddle 15 */ 16 public class CreateTestFrameAction extends AutoAction { 17 18 private final ResourceRefR4 frameRef; 19 private final ImmList<ActivationChannel> children; 20 21 /** 22 * Constructs the action with a frame reference pointing to the new frame 23 * to be added and the current channels of the page to be modified. 24 * 25 * @param description 26 * Description of the action. 27 * @param significant 28 * Significance of the action. 29 * @param frameRef 30 * Reference to the frame to be added. 31 * @param children 32 * List with the current channels of the page which will contain the new frame. 33 */ 34 public CreateTestFrameAction(Message description, boolean significant, ResourceRefR4 frameRef, 35 ImmList<ActivationChannel> children) { 36 super(description, significant); 37 38 this.frameRef = frameRef; 39 this.children = children; 40 } 41 42 @Override 43 public void performAuto() { 44 FrameH.create(getChanger(), this.frameRef, FrameR4.DEFAULT_TITLE, 45 this.children, FrameR4.KIND, FrameH.DEFAULT_FRAME_LOCATION, 46 FrameR4.DEFAULT_FRAME_SIZE); 47 } 48 49 } -
modules/org.sophie2.base.model.book/src/main/java/org/sophie2/base/model/book/actions/ChangeTitleAction.java
1 package org.sophie2.base.model.book.actions; 2 3 import org.sophie2.base.model.resources.r4.changes.AutoAction; 4 import org.sophie2.base.model.resources.r4.resources.ResourceR4; 5 import org.sophie2.base.skins.Message; 6 7 /** 8 * {@link AutoAction} for changing the title of a resource. 9 * 10 * @author mira 11 */ 12 public class ChangeTitleAction extends AutoAction { 13 14 private final String newTitle; 15 16 /** 17 * Constructs the action with the new title of the resource. 18 * 19 * @param description 20 * Description of the action. 21 * @param significant 22 * Significance of the action. 23 * @param newTitle 24 * The new title, 25 */ 26 public ChangeTitleAction(Message description, boolean significant, String newTitle) { 27 super(description, significant); 28 29 this.newTitle = newTitle; 30 } 31 32 @Override 33 public void performAuto() { 34 getChanger().setRaw(ResourceR4.KEY_TITLE, this.newTitle); 35 } 36 } -
modules/org.sophie2.dev/src/test/java/org/sophie2/dev/author/TextChainingSystemTest.java
251 251 HeadTextFrameH.createTextFrameAction(curBook(), 252 252 curPageWorkArea().getRootPageView().model().get(), 253 253 text, ResourceRefR4.NONE_REF.toUri(), null, 254 Message.create(INSERT_FULL_TEXT_FRAME), true , true);254 Message.create(INSERT_FULL_TEXT_FRAME), true); 255 255 256 256 TextFrameView frameViewToSelect = 257 257 curPageWorkArea().getAll(TextFrameView.class).get(4); -
modules/org.sophie2.base.model.book/src/main/java/org/sophie2/base/model/book/BookH.java
7 7 import org.sophie2.base.commons.structures.ImmTreeList; 8 8 import org.sophie2.base.commons.util.ImmList; 9 9 import org.sophie2.base.commons.util.position.ImmSize; 10 import org.sophie2.base.model.book.actions.InitBookAction; 10 11 import org.sophie2.base.model.book.resource.AudioResourceH; 11 12 import org.sophie2.base.model.book.resource.r4.BookR4; 12 13 import org.sophie2.base.model.book.resource.r4.PageR4; … … 455 456 */ 456 457 public static AutoAction createInitAction(final ResourceRefR4 pageRef, 457 458 final String pageTitle) { 458 return new AutoAction(Message.create(CREATE_BLANK_PAGE), true) { 459 @Override 460 public void performAuto() { 461 BookH.addNewPage(getChanger(), pageRef, BookR4.KEY_PAGES 462 .getDefault(), pageTitle); 463 } 464 }; 459 return new InitBookAction(Message.create(CREATE_BLANK_PAGE), true, pageRef, pageTitle); 465 460 } 466 461 467 462 @Override -
modules/org.sophie2.base.model.book/src/main/java/org/sophie2/base/model/book/testing/ModelTestBase.java
12 12 import org.sophie2.base.model.book.BookH; 13 13 import org.sophie2.base.model.book.FrameH; 14 14 import org.sophie2.base.model.book.PageH; 15 import org.sophie2.base.model.book.frame.FrameR4; 15 import org.sophie2.base.model.book.actions.CreateTestFrameAction; 16 import org.sophie2.base.model.book.actions.CreateTestPageAction; 16 17 import org.sophie2.base.model.book.interfaces.CompositeElement; 17 18 import org.sophie2.base.model.book.resource.r4.BookR4; 18 19 import org.sophie2.base.model.book.resource.r4.PageR4; … … 128 129 book.getAccess().getHead().getModel().debugPrint(); 129 130 final ResourceRefList pages = book.get(BookR4.KEY_PAGES); 130 131 131 new AutoAction(Message.create(CREATE_TEST_PAGE), true) { 132 @Override 133 public void performAuto() { 134 BookH.addNewPage(getChanger(), pageRef, pages, PageR4.DEFAULT_TITLE); 135 } 136 }.register(bookAccess); 132 AutoAction action = new CreateTestPageAction(Message.create(CREATE_TEST_PAGE), true, 133 pageRef, pages); 134 action.register(bookAccess); 135 137 136 return ResourceH.getHelper(bookAccess.open(pageRef, 138 137 bookAccess.getAccessOptions()), PageH.class); 139 138 } … … 153 152 final ImmList<ActivationChannel> children = 154 153 CompositeElement.KEY_SUB_ELEMENTS.get(page.getAccess()); 155 154 156 new AutoAction(Message.create(CREATE_TEST_FRAME), true) { 157 @Override 158 public void performAuto() { 159 FrameH.create(getChanger(), frameRef, FrameR4.DEFAULT_TITLE, 160 children, FrameR4.KIND, FrameH.DEFAULT_FRAME_LOCATION, 161 FrameR4.DEFAULT_FRAME_SIZE); 162 } 163 }.register(pageAccess); 155 AutoAction action = new CreateTestFrameAction(Message.create(CREATE_TEST_FRAME), true, 156 frameRef, children); 157 action.register(pageAccess); 164 158 165 159 return ResourceH.getHelper(pageAccess.open(frameRef, 166 160 pageAccess.getAccessOptions()), FrameH.class); -
modules/org.sophie2.base.model.book/src/main/java/org/sophie2/base/model/book/FrameH.java
6 6 import org.sophie2.base.commons.util.position.ImmPoint; 7 7 import org.sophie2.base.commons.util.position.ImmSize; 8 8 import org.sophie2.base.media.TimePos; 9 import org.sophie2.base.model.book.actions.SetKindAction; 9 10 import org.sophie2.base.model.book.frame.BoundMode; 10 11 import org.sophie2.base.model.book.frame.FrameR4; 11 12 import org.sophie2.base.model.book.frame.WrappingModes; … … 242 243 && templateRef.equals(this.prevTemplate) 243 244 && ResourceFrame.KEY_MAIN_RESOURCE.getApplyKey().get(templateAccess)) { 244 245 245 new AutoAction(Message.create(CHANGE_KIND), true) { 246 247 @Override 248 public void performAuto() { 249 getChanger().setRaw(ResourceR4.KEY_KIND, templateKind); 250 } 251 252 }.register(getAccess()); 246 AutoAction action = new SetKindAction(Message.create(CHANGE_KIND), 247 true, templateKind); 248 action.register(getAccess()); 253 249 } 254 250 } 255 251 -
modules/org.sophie2.base.model.book/src/main/java/org/sophie2/base/model/book/actions/InitBookAction.java
1 package org.sophie2.base.model.book.actions; 2 3 import org.sophie2.base.model.book.BookH; 4 import org.sophie2.base.model.book.resource.r4.BookR4; 5 import org.sophie2.base.model.resources.r4.ResourceRefR4; 6 import org.sophie2.base.model.resources.r4.changes.AutoAction; 7 import org.sophie2.base.skins.Message; 8 9 /** 10 * {@link AutoAction} for creating an initial book. 11 * 12 * @author meddle 13 */ 14 public class InitBookAction extends AutoAction { 15 16 private final ResourceRefR4 pageRef; 17 private final String pageTitle; 18 19 20 /** 21 * Constructs the action the reference and the name of the first page 22 * and only page of the new book. 23 * 24 * @param description 25 * Description of the action. 26 * @param significant 27 * Significance of the action. 28 * @param pageRef 29 * Reference to the first page of the new book, 30 * @param pageTitle 31 * Title of the only page of the initial book. 32 */ 33 public InitBookAction(Message description, boolean significant, ResourceRefR4 pageRef, 34 String pageTitle) { 35 super(description, significant); 36 37 this.pageRef = pageRef; 38 this.pageTitle = pageTitle; 39 } 40 41 @Override 42 public void performAuto() { 43 BookH.addNewPage(getChanger(), this.pageRef, BookR4.KEY_PAGES.getDefault(), this.pageTitle); 44 } 45 } -
modules/org.sophie2.launcher/src/main/java/org/sophie2/launcher/Launcher.java
7 7 import java.net.URL; 8 8 import java.util.ArrayList; 9 9 import java.util.List; 10 import java.util.UUID; 10 11 11 12 import javax.swing.RootPaneContainer; 12 13 … … 129 130 } 130 131 131 132 // Create a temporary bundle cache directory. 132 this.cachedir = File.createTempFile("org.sophie2.applet.bundle-cache", null); 133 this.cachedir.delete(); 133 134 String tempDir = System.getProperty("java.io.tmpdir"); 135 this.cachedir = new File(tempDir, UUID.randomUUID() + "-sophie-cache"); 136 assert this.cachedir.mkdirs() : "Could not write in the temporary directory?"; 137 138 // this.cachedir.deleteOnExit(); 134 139 StringMap configMap = new StringMap(false); 135 140 136 141 System.setProperty("java.protocol.handler.pkgs", ""); … … 199 204 configMap.put(AutoActivator.AUTO_INSTALL_PROP + ".1", notStarted.toString()); 200 205 201 206 configMap.put(FelixConstants.LOG_LEVEL_PROP, "1"); 202 configMap.put(BundleCache.CACHE_PROFILE_DIR_PROP, this.cachedir 203 .getAbsolutePath()); 207 configMap.put(BundleCache.CACHE_PROFILE_DIR_PROP, this.cachedir.getAbsolutePath()); 204 208 205 209 // Create a list to hold custom framework activators. 206 210 List<BundleActivator> activatorList = new ArrayList<BundleActivator>(); … … 257 261 deleteFileOrDir(child); 258 262 } 259 263 } 264 260 265 file.delete(); 261 266 } 262 267 -
modules/org.sophie2.server.webui/src/main/resources/jsps/resource_book.jspx
23 23 <span>${book.pageCount}</span> 24 24 </li> 25 25 </ul> 26 <form name="appletParams"> 27 <input type="hidden" name="uwidth" value="${book.pageSize.width}"/> 28 <input type="hidden" name="uheight" value="${book.pageSize.height}"/> 29 </form> 26 30 <c:choose> 27 31 <c:when test="${param.showApplet}"> 28 32 <div style="width: 100%; overflow: auto"> 29 <fmt:setBundle basename="org.sophie2.server.webui.config" var="configBundle" /> 30 33 31 34 <script src="http://www.java.com/js/deployJava.js"><!-- --></script> 32 35 <script> 33 <fmt:message bundle="${configBundle}" key="applet.deploy_script"> 34 <fmt:param value="${book.pageSize.width}" /> 35 <fmt:param value="${book.pageSize.height}" /> 36 </fmt:message> 36 var userWidth = document.forms['appletParams'].uwidth.value; 37 var userHeight = document.forms['appletParams'].uheight.value; 38 39 var width = parseInt(userWidth) + 300; 40 var height = parseInt(userHeight) + 200; 41 42 var href = window.location.href; 43 var bookRefValue = window.location.href + "&action=download"; 44 var attributes = { 45 code: "org.sophie2.launcher.AppletMain.class", 46 codebase: "http://sophie2.org/sophie2-reader-applet/reader/", 47 archive: "org.sophie2.launcher-2.0.1.jar", 48 width: width, 49 height: height 50 }; 51 var parameters = { 52 edition: "reader", 53 bundlesConfigFile: "applet.bundles.config", 54 bookRef: bookRefValue, 55 separate_jvm: "true" 56 }; 57 var version = "1.5"; 58 deployJava.runApplet(attributes, parameters, version); 37 59 </script> 38 60 </div> 39 61 <a href="javascript:location.href=location.href.substring(0, location.href.length - location.search.length)">Hide applet</a> -
modules/org.sophie2.base.model.book/src/main/java/org/sophie2/base/model/book/actions/CreateTestPageAction.java
1 package org.sophie2.base.model.book.actions; 2 3 import org.sophie2.base.model.book.BookH; 4 import org.sophie2.base.model.book.resource.r4.PageR4; 5 import org.sophie2.base.model.resources.r4.ResourceRefList; 6 import org.sophie2.base.model.resources.r4.ResourceRefR4; 7 import org.sophie2.base.model.resources.r4.changes.AutoAction; 8 import org.sophie2.base.skins.Message; 9 10 /** 11 * {@link AutoAction} for adding a new page for testing to a book. 12 * 13 * @author meddle 14 */ 15 public class CreateTestPageAction extends AutoAction { 16 17 private final ResourceRefR4 pageRef; 18 private final ResourceRefList pages; 19 20 /** 21 * Constructs the action with a page reference pointing to the new page 22 * to be added and the current pages of the book to be modified. 23 * 24 * @param description 25 * Description of the action. 26 * @param significant 27 * Significance of the action. 28 * @param pageRef 29 * Reference to the page to be added. 30 * @param pages 31 * List with the current pages of the book which will contain the new page. 32 */ 33 public CreateTestPageAction(Message description, boolean significant, 34 ResourceRefR4 pageRef, ResourceRefList pages) { 35 super(description, significant); 36 37 this.pageRef = pageRef; 38 this.pages = pages; 39 } 40 41 @Override 42 public void performAuto() { 43 BookH.addNewPage(getChanger(), this.pageRef, this.pages, PageR4.DEFAULT_TITLE); 44 } 45 46 } -
modules/org.sophie2.reader/src/main/java/org/sophie2/reader/ReaderModule.java
1 1 package org.sophie2.reader; 2 2 3 import java.io.File; 4 import java.io.FileOutputStream; 5 import java.io.IOException; 6 import java.io.InputStream; 7 import java.net.URI; 3 8 import java.util.List; 4 9 import java.util.Timer; 5 10 import java.util.TimerTask; 6 11 7 12 import org.sophie2.base.commons.util.ImageUtil; 13 import org.sophie2.base.commons.util.bindata.BinData; 8 14 import org.sophie2.base.commons.util.bindata.TmpChunksDirProvider; 9 15 import org.sophie2.base.layout.BaseLayoutModule; 10 16 import org.sophie2.base.layout.LayoutEngine; … … 119 125 } 120 126 //open only first book. 121 127 ResourceRefR4 bookRef; 128 if ( startUpBookFiles.length == 0 || startUpBookFiles[0] == null) { 129 return null; 130 } 122 131 if (startUpBookFiles[0].startsWith(LocationPrefix.FILE)) { 123 132 bookRef = ResourceRefR4.make(startUpBookFiles[0]); 133 } else if (startUpBookFiles[0].startsWith(LocationPrefix.SERVER)) { 134 bookRef = ResourceRefR4.make(startUpBookFiles[0]); 135 URI uri = bookRef.toUri(); 136 if (!uri.isAbsolute()) { 137 SophieLog.warnf("Cannot open non absolute ref %s.", bookRef); 138 return null; 139 } 140 InputStream from = null; 141 FileOutputStream to = null; 142 try { 143 from = uri.toURL().openStream(); 144 // I do not believe in file entry manger so just use tmp folder. 145 File resourceFile = File.createTempFile("sophieStartupBook", ".book.s2"); 146 resourceFile.deleteOnExit(); 147 to = new FileOutputStream(resourceFile); 148 BinData.transport(from, to); 149 150 return ResourceRefR4.make(resourceFile); 151 } catch (IOException e) { 152 throw new RuntimeException(e); 153 } finally { 154 try { 155 if (to != null) { 156 to.close(); 157 } 158 if (from != null) { 159 from.close(); 160 } 161 } catch (IOException e) { 162 throw new RuntimeException(e); 163 } 164 } 124 165 } else { 125 166 bookRef = ResourceRefR4.make(LocationPrefix.FILE + startUpBookFiles[0]); 126 167 }