Ticket #2470: appletBinaries.patch
File appletBinaries.patch, 26.9 KB (added by mira, 15 years ago) |
---|
-
modules/org.sophie2.base.model.resources.r4/src/main/java/org/sophie2/base/model/resources/r4/access/cacheKey/ServerAccessCacheKey.java
### Eclipse Workspace Patch 1.0 #P sophie
1 1 package org.sophie2.base.model.resources.r4.access.cacheKey; 2 2 3 3 import org.sophie2.base.model.resources.r4.ResourceRefR4; 4 import org.sophie2.base.model.resources.r4.access.MasterTopAccess;5 4 import org.sophie2.base.model.resources.r4.access.ResourceAccess; 6 5 7 6 /** 8 * A key used for caching server {@link MasterTopAccess}es. It contains the 9 * {@link ResourceRefR4} and sesionId of the access. 7 * A container class that holds {@link ResourceRefR4} to server resource 8 * and sesionId for the facade communication. It is used to cache different 9 * thing. 10 10 * 11 11 * @author mira 12 12 */ -
modules/org.sophie2.reader/pom.xml
15 15 <packaging>bundle</packaging> 16 16 <description>Sophie 2 Reader Edition for only reading the books.</description> 17 17 <dependencies> 18 <dependency> 19 <groupId>org.sophie2</groupId> 20 <artifactId>org.sophie2.main.func.servers</artifactId> 21 <version>2.0.6</version> 22 </dependency> 18 23 <dependency> 19 24 <groupId>org.sophie2</groupId> 20 25 <artifactId>org.sophie2.core.modularity</artifactId> -
modules/org.sophie2.main.func.servers/src/main/java/org/sophie2/main/func/servers/resources/ServerResourceLocator.java
18 18 import org.sophie2.base.model.resources.r4.model.ResourceRevision; 19 19 import org.sophie2.base.model.resources.r4.model.RevisionId; 20 20 import org.sophie2.core.logging.SophieLog; 21 import org.sophie2.main.func.servers.MainFuncServersModule; 21 22 import org.sophie2.main.func.servers.ServerConnection; 22 23 23 24 /** … … 58 59 private final FacadeR4 facade; 59 60 private final ResourceRefR4 serverTopRef; 60 61 61 62 62 /** 63 63 * Creates a <code>ServerResourceLocator</code> instance by specified 64 64 * connection, accessOptions and parent. 65 65 * 66 * @param serverConnection67 * The connection to be used by the locator.66 * @param connection 67 * The ServerConnection to the server. 68 68 * @param accessOptions 69 69 * The access options for the locator. 70 70 * @param parentLocator 71 71 * The parent to delegate to. 72 72 */ 73 public ServerResourceLocator(ServerConnection serverConnection,73 public ServerResourceLocator(ServerConnection connection, 74 74 AccessOptions accessOptions, ResourceLocator parentLocator) { 75 75 super(accessOptions, parentLocator); 76 this.facade = serverConnection.getFacade(); 77 this.serverTopRef = ResourceRefR4.make( 78 serverConnection.account().get().getServerUrl()); 76 this.facade = connection.getFacade(); 77 this.serverTopRef = ResourceRefR4.make(connection.account().get().getServerUrl()); 78 } 79 80 /** 81 * Creates a <code>ServerResourceLocator</code> instance by specified 82 * the serverUrl, accessOptions and parent. 83 * 84 * @param serverUrl 85 * The server url. 86 * @param accessOptions 87 * The access options for the locator. 88 * @param parentLocator 89 * The parent to delegate to. 90 */ 91 public ServerResourceLocator(String serverUrl, 92 AccessOptions accessOptions, ResourceLocator parentLocator) { 93 super(accessOptions, parentLocator); 94 this.serverTopRef = ResourceRefR4.make(serverUrl); 95 this.facade = MainFuncServersModule.getFacade(serverUrl); 79 96 } 80 97 81 98 @Override … … 101 118 @Override 102 119 protected ResourceRefR4 getTopRef(ResourceRefR4 ref) { 103 120 String location = ref.getLocation(); 104 assert location.startsWith( LocationPrefix.SERVER);121 assert location.startsWith(this.serverTopRef.getLocation()); 105 122 return this.serverTopRef; 106 123 } 107 124 -
modules/org.sophie2.main.func.servers/src/main/java/org/sophie2/main/func/servers/ServerConnection.java
1 1 package org.sophie2.main.func.servers; 2 2 3 import org.sophie2.base.connectivity.Connector;4 3 import org.sophie2.base.connectivity.facade.FacadeR4; 5 4 import org.sophie2.base.connectivity.facade.Response; 6 5 import org.sophie2.base.model.resources.r4.ResourceRefR4; 7 6 import org.sophie2.base.model.security.UserR4; 8 7 import org.sophie2.core.logging.SophieLog; 9 import org.sophie2.core.modularity.SophieExtension;10 8 import org.sophie2.core.prolib.impl.AutoProperty; 11 9 import org.sophie2.core.prolib.impl.BaseProObject; 12 10 import org.sophie2.core.prolib.interfaces.Prop; … … 70 68 @Override 71 69 protected FacadeR4 compute() { 72 70 String serverUrl = account().get().getServerUrl(); 73 Connector connector = null; 74 for (SophieExtension<Connector> extension : MainFuncServersModule.get() 75 .getConnectorPoint().extensions().get()) { 76 Connector conn = extension.getObject(); 77 if (conn.supports(serverUrl)) { 78 // A suitable connector is found 79 connector = conn; 80 break; 81 } 82 } 83 84 if (connector == null) { 85 throw new RuntimeException( 86 "No suitable connector was found for url " + serverUrl); 87 } 88 FacadeR4 facade = connector.getFacade(serverUrl); 89 90 assert facade != null : "cannot get facade from connector"; 91 return facade; 71 return MainFuncServersModule.getFacade(serverUrl); 92 72 } 93 73 94 74 } -
modules/org.sophie2.main.func.servers/src/main/java/org/sophie2/main/func/servers/MainFuncServersModule.java
5 5 import org.sophie2.base.commons.util.ImageUtil; 6 6 import org.sophie2.base.connectivity.Connector; 7 7 import org.sophie2.base.connectivity.TransferManager; 8 import org.sophie2.base.connectivity.facade.FacadeR4; 8 9 import org.sophie2.base.dialogs.Dialog; 9 10 import org.sophie2.base.model.resources.r4.access.server.ResourceLocatorProvider; 10 11 import org.sophie2.base.model.resources.r4.resources.ResourceR4; … … 108 109 res.add(new SimpleSophieExtension<Persister>(Persister.class, 109 110 new PasswordPersister())); 110 111 111 AutoVisualProvider.fillExtensions(res, ServersTab.class); 112 AutoVisualProvider.fillExtensions(res, SaveToServerDialog.UploadResourceDialog.class); 113 114 res.add(SimpleVisualProvider.createExtension(SaveBookOnServerItem.class, 115 FileMenu.class, "file-menu-item", "eb-file-save-on-server-item")); 112 if (System.getProperties().get("sophie2.applet") == null) { 113 AutoVisualProvider.fillExtensions(res, ServersTab.class); 114 AutoVisualProvider.fillExtensions(res, SaveToServerDialog.UploadResourceDialog.class); 115 res.add(SimpleVisualProvider.createExtension(SaveBookOnServerItem.class, 116 FileMenu.class, "file-menu-item", "eb-file-save-on-server-item")); 117 res.add(new SimpleSophieExtension<Dialog>(Dialog.class, 118 new SaveToServerDialog())); 119 res.add(new SimpleSophieExtension<Dialog>(Dialog.class, new ServerLoginDialog())); 120 AutoVisualProvider.fillExtensions(res, SwingLoginDialog.class); 121 122 SimpleOperation.fillExtensions(res, ServersTabLogic.class); 123 SimpleOperation.fillExtensions(res, TransferLogic.class); 124 SimpleOperation.fillExtensions(res, ServerLoginDialogLogic.class); 125 126 SimpleOperation.fillExtensions(res, SaveToServerDialogLogic.class); 127 } 116 128 117 129 SimpleSkinPartsProvider provider = new SimpleSkinPartsProvider(); 118 130 provider.parts().add(makeSkinPart()); 119 131 provider.parts().add(makeLanguagePackPart()); 120 132 res.add(provider.asExtension()); 121 133 122 123 res.add(new SimpleSophieExtension<Dialog>(Dialog.class,124 new SaveToServerDialog()));125 134 res.add(getResourceLocatorExtension()); 126 135 res.add(SimpleVisualProvider.createExtension(SaveToServerDialog.UploadResourceDialog.class, 127 136 ConnectionsPalette.class, "save-on-server-dialog", "aaa-save-on-servers-dialog")); 128 137 129 138 res.add(new SimpleSophieExtension<TransferManager<?>> ( 130 139 (Class) TransferManager.class, new BinaryTransferManager())); 131 res.add(new SimpleSophieExtension<Dialog>(Dialog.class, new ServerLoginDialog()));132 AutoVisualProvider.fillExtensions(res, SwingLoginDialog.class);133 140 134 SimpleOperation.fillExtensions(res, ServersTabLogic.class);135 SimpleOperation.fillExtensions(res, TransferLogic.class);136 SimpleOperation.fillExtensions(res, ServerLoginDialogLogic.class);137 138 139 SimpleOperation.fillExtensions(res, SaveToServerDialogLogic.class);140 141 } 141 142 142 143 private BaseSkinPart makeSkinPart() { … … 197 198 } 198 199 199 200 } 201 202 /** 203 * Adds a handled server url by the first provider. 204 * 205 * @param serverUrl 206 * The server url. 207 */ 208 public void addHandledServerUrl(String serverUrl) { 209 //TODO There could be other locator providers. 210 ((ServerResourceLocatorProvider) getResourceLocatorExtension().getObject()).addHandledUrl(serverUrl); 211 } 212 213 /** 214 * Gets appropriate facade for this server url by a supporting it connector. 215 * 216 * @param serverUrl 217 * The server url. 218 * @return 219 * The appropriate facade to communicate with the server. 220 */ 221 public static FacadeR4 getFacade(String serverUrl) { 222 Connector connector = null; 223 for (SophieExtension<Connector> extension : MainFuncServersModule.get() 224 .getConnectorPoint().extensions().get()) { 225 Connector conn = extension.getObject(); 226 if (conn.supports(serverUrl)) { 227 // A suitable connector is found 228 connector = conn; 229 break; 230 } 231 } 232 233 if (connector == null) { 234 throw new RuntimeException( 235 "No suitable connector was found for url " + serverUrl); 236 } 237 FacadeR4 facade = connector.getFacade(serverUrl); 238 239 assert facade != null : "cannot get facade from connector"; 240 return facade; 241 } 200 242 } -
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( );49 WebAppModule.get().startServer(9016); 50 50 } 51 51 }); 52 52 -
modules/org.sophie2.main.func.servers/src/main/java/org/sophie2/main/func/servers/resources/ServerResourceLocatorProvider.java
6 6 import org.sophie2.base.model.resources.r4.LocationPrefix; 7 7 import org.sophie2.base.model.resources.r4.ResourceRefR4; 8 8 import org.sophie2.base.model.resources.r4.access.AccessOptions; 9 import org.sophie2.base.model.resources.r4.access.ResourceAccess;10 9 import org.sophie2.base.model.resources.r4.access.ResourceLocator; 10 import org.sophie2.base.model.resources.r4.access.cacheKey.ServerAccessCacheKey; 11 11 import org.sophie2.base.model.resources.r4.access.server.ResourceLocatorProvider; 12 12 import org.sophie2.main.func.servers.ConnectionStatus; 13 13 import org.sophie2.main.func.servers.ServerConnection; … … 20 20 */ 21 21 public class ServerResourceLocatorProvider implements ResourceLocatorProvider { 22 22 23 private Map<ServerConnection, ServerResourceLocator> connections = new LinkedHashMap<ServerConnection, ServerResourceLocator>(); 23 private Map<String, ServerResourceLocator> serverLocators = 24 new LinkedHashMap<String, ServerResourceLocator>(); 24 25 25 26 /** 26 * Adds a new connection with corresponding list of {@link ResourceAccess}es 27 * related to it. 27 * Adds a handled url for this resource locator provider. 28 28 * 29 29 * @param connection 30 * The {@link ServerConnection} tobe added.30 * The {@link ServerConnection} whose url should be added. 31 31 */ 32 32 public void addConnection(ServerConnection connection) { 33 33 assert ConnectionStatus.CONNECTED.equals(connection.status().get()); 34 assert !this.connections.containsKey(connection); 35 this.connections.put(connection, null); 34 String url = connection.account().get().getServerUrl(); 35 addHandledUrl(url); 36 } 37 38 /** 39 * Adds a new handled server url. 40 * 41 * @param serverUrl 42 * The serverUrl. 43 */ 44 public void addHandledUrl(String serverUrl) { 45 if (!this.serverLocators.containsKey(serverUrl)) { 46 this.serverLocators.put(serverUrl, null); 47 } 36 48 } 37 49 38 50 /** … … 43 55 */ 44 56 public void removeConnection(ServerConnection connection) { 45 57 assert ConnectionStatus.DISCONNECTED.equals(connection.status().get()); 46 ServerResourceLocator locator = this.connections.remove(connection); 47 if (locator != null) { 48 locator.close(); 49 } 58 String url = connection.account().get().getServerUrl(); 59 String sessionId = connection.sessionId().get(); 60 ServerAccessCacheKey cacheKey = 61 new ServerAccessCacheKey(ResourceRefR4.make(url), sessionId); 62 ServerResourceLocator locator = this.serverLocators.get(url); 63 locator.closeTopAccess(cacheKey); 50 64 } 51 65 52 66 public boolean canHandle(ResourceRefR4 target) { 53 return find Connection(target) != null;67 return findServerURL(target) != null; 54 68 } 55 56 private S erverConnection findConnection(ResourceRefR4 target) {69 70 private String findServerURL(ResourceRefR4 target) { 57 71 assert target.getLocation().startsWith(LocationPrefix.SERVER); 58 72 String targetUrl = target.getLocation(); 59 for (ServerConnection connection : this.connections.keySet()) { 60 if (ConnectionStatus.CONNECTED.equals(connection.status().get())) { 61 String serverUrl = connection.account().get().getServerUrl(); 62 if (targetUrl.startsWith(serverUrl)) { 63 return connection; 64 } 73 for (String serverUrl : this.serverLocators.keySet()) { 74 if (targetUrl.startsWith(serverUrl)) { 75 return serverUrl; 65 76 } 66 77 } 67 78 return null; 68 69 79 } 70 80 71 81 public ResourceLocator getLocator(ResourceRefR4 target, 72 82 AccessOptions accessOptions, ResourceLocator parent) { 73 S erverConnection connection = findConnection(target);74 if ( connection== null) {75 throw new RuntimeException("Cannot find connection for" + target);83 String serverUrl = findServerURL(target); 84 if (serverUrl == null) { 85 throw new RuntimeException("Cannot handle this target - " + target); 76 86 } 77 assert this.connections.containsKey(connection); 78 if (this.connections.get(connection) == null) { 87 if (this.serverLocators.get(serverUrl) == null) { 79 88 ServerResourceLocator locator = new ServerResourceLocator( 80 connection, accessOptions, parent);81 this. connections.put(connection, locator);89 serverUrl, accessOptions, parent); 90 this.serverLocators.put(serverUrl, locator); 82 91 } 83 return this.connections.get(connection); 92 93 return this.serverLocators.get(serverUrl); 84 94 } 85 95 86 96 } -
modules/org.sophie2.base.model.resources.r4/src/main/java/org/sophie2/base/model/resources/r4/access/BaseLocator.java
95 95 } 96 96 97 97 /** 98 * Closes a top access of this locator. 99 * 100 * @param key 101 * The {@link CacheKey} to find the access to close. 102 */ 103 public void closeTopAccess(CacheKey key) { 104 MasterTopAccess toClose = this.topAccessesCache.get(key); 105 if (toClose != null) { 106 toClose.close(); 107 } 108 } 109 110 /** 98 111 * Gets the top part of the ref. For example for ref with location 99 112 * "file://D:/MIRA/persisted_book.sjrb/Page_A" the top ref cloud be 100 113 * "file://D:/MIRA/persisted_book.sjrb" and for "mem://Book_A/ScrptA" … … 141 154 * The prefix of the {@link ResourceRefR4} that this root access can open. 142 155 */ 143 156 protected abstract String getHandledPrefix(); 144 157 145 158 } -
modules/org.sophie2.server.webui/src/main/resources/jsps/resource_book.jspx
26 26 <form name="appletParams"> 27 27 <input type="hidden" name="uwidth" value="${book.pageSize.width}"/> 28 28 <input type="hidden" name="uheight" value="${book.pageSize.height}"/> 29 <input type="hidden" name="usessionId" value="${sessionId}"/> 29 30 </form> 30 31 <c:choose> 31 32 <c:when test="${param.showApplet}"> … … 33 34 34 35 <script src="http://www.java.com/js/deployJava.js"><!-- --></script> 35 36 <script> 37 var serverUrl = "http://" + window.location.hostname + ":" + window.location.port; 36 38 var userWidth = document.forms['appletParams'].uwidth.value; 37 39 var userHeight = document.forms['appletParams'].uheight.value; 40 var userSessionId = document.forms['appletParams'].usessionId.value; 38 41 39 42 var width = parseInt(userWidth) + 300; 40 43 var height = parseInt(userHeight) + 200; 41 44 42 45 var href = window.location.href; 43 var bookRefValue = window.location.href + "&action=download"; 46 var qIndex = href.indexOf("?"); 47 href = href.substring(0, qIndex); 48 49 var separator = "|"; 50 var bookRefValue = href + separator + serverUrl + separator + userSessionId; 44 51 var attributes = { 45 52 code: "org.sophie2.launcher.AppletMain.class", 46 codebase: "http://s ophie2.org/sophie2-reader-applet/reader/",53 codebase: "http://straxil.asteasolutions.net/applet-demo/reader/", 47 54 archive: "org.sophie2.launcher-2.0.1.jar", 48 55 width: width, 49 56 height: height -
modules/org.sophie2.launcher/src/main/resources/reader-run/applet.bundles.config
3 3 org.sophie2.core.modularity started 4 4 org.sophie2.core.mvc started 5 5 org.sophie2.base.bound installed 6 org.sophie2.base.commons installed 6 org.sophie2.base.connectivity started 7 org.sophie2.base.commons started 7 8 org.sophie2.base.config started 8 9 org.sophie2.base.model.resources.r4 started 9 10 org.sophie2.base.dialogs installed … … 41 42 org.sophie2.main.func.templates started 42 43 org.sophie2.main.func.media started 43 44 org.sophie2.main.func.image started 45 org.sophie2.main.func.servers started 44 46 org.sophie2.main.func.resources started 45 47 org.sophie2.main.func.timelines started 46 48 org.sophie2.main.layout.mydoggy started 47 49 org.sophie2.main.scene.simple started 48 50 org.sophie2.main.skin.alternative started 51 org.sophie2.main.ws_connector started 49 52 org.sophie2.reader started 53 No newline at end of file -
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;8 3 import java.util.List; 9 4 import java.util.Timer; 10 5 import java.util.TimerTask; 11 6 12 7 import org.sophie2.base.commons.util.ImageUtil; 13 import org.sophie2.base.commons.util.bindata.BinData;14 8 import org.sophie2.base.commons.util.bindata.TmpChunksDirProvider; 9 import org.sophie2.base.connectivity.facade.FacadeR4; 10 import org.sophie2.base.connectivity.resources.ServerAccessOptions; 15 11 import org.sophie2.base.layout.BaseLayoutModule; 16 12 import org.sophie2.base.layout.LayoutEngine; 17 13 import org.sophie2.base.layout.model.MainWindow; 18 14 import org.sophie2.base.model.resources.r4.LocationPrefix; 19 15 import org.sophie2.base.model.resources.r4.ResourceRefR4; 16 import org.sophie2.base.model.resources.r4.access.AccessOptions; 20 17 import org.sophie2.base.skins.BaseSkinPart; 21 18 import org.sophie2.base.skins.SkinUtil; 22 19 import org.sophie2.base.skins.providers.SimpleSkinPartsProvider; … … 27 24 import org.sophie2.core.modularity.SophieModule; 28 25 import org.sophie2.main.app.commons.app.AppMainWindow; 29 26 import org.sophie2.main.app.commons.util.AppViewUtil; 27 import org.sophie2.main.func.servers.MainFuncServersModule; 30 28 31 29 /** 32 30 * Module class for Sophie Reader. … … 75 73 assert instance == null; 76 74 instance = this; 77 75 78 final ResourceRefR4 bookRef = checkStartupBook();79 76 80 77 new Timer().schedule(new TimerTask() { 81 78 @Override … … 99 96 engine.mainWindows().add(window); 100 97 System.setProperty("sophie2.loaded", "true"); 101 98 102 if (bookRef != null) { 103 AppViewUtil.openBook(window, bookRef, null, true); 99 ResourceAccessInfo bookInfo = checkStartupBook(); 100 if (bookInfo != null) { 101 AppViewUtil.openBook(window, bookInfo.getLocation(), bookInfo.getOptions(), true); 104 102 } 105 103 } 106 104 }); … … 118 116 * startup book or <code>null</code> if the system property is not 119 117 * set or is not a valid absolute URL. 120 118 */ 121 pr ivate ResourceRefR4checkStartupBook(){119 protected ResourceAccessInfo checkStartupBook(){ 122 120 String[] startUpBookFiles = (String[]) System.getProperties().get("sophie2.loadOnStartUpFiles"); 123 121 if (startUpBookFiles == null) { 124 122 return null; 125 123 } 126 //open only first book. 127 ResourceRefR4 bookRef; 128 if ( startUpBookFiles.length == 0 || startUpBookFiles[0] == null ) { 124 125 if (startUpBookFiles.length == 0 || startUpBookFiles[0] == null) { 129 126 return null; 130 127 } 131 if (startUpBookFiles[0].startsWith(LocationPrefix.FILE)) { 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); 128 //open only first book. 129 ResourceRefR4 bookRef; 130 AccessOptions options = AccessOptions.DEFAULT_ACCESS_OPTIONS.modifyViewId(); 131 String bookLocation = startUpBookFiles[0]; 132 if (bookLocation.startsWith(LocationPrefix.FILE)) { 133 bookRef = ResourceRefR4.make(bookLocation); 134 } else if (bookLocation.startsWith(LocationPrefix.SERVER)) { 135 String[] parts = bookLocation.split("\\|"); 136 if (parts.length < 2) { 137 SophieLog.warnf("Cannot open the server ref - %s ", bookLocation); 138 138 return null; 139 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 } 140 bookRef = ResourceRefR4.make(parts[0]); 141 String serverUrl = parts[1]; 142 MainFuncServersModule.get().addHandledServerUrl(serverUrl); 143 144 String sessionId; 145 if (parts.length > 2) { 146 sessionId = parts[2]; 147 } else { 148 FacadeR4 facade = MainFuncServersModule.getFacade(serverUrl); 149 sessionId = facade.openSession().extract(); 150 } 151 options = new ServerAccessOptions(options, sessionId); 165 152 } else { 166 bookRef = ResourceRefR4.make(LocationPrefix.FILE + startUpBookFiles[0]);153 bookRef = ResourceRefR4.make(LocationPrefix.FILE + bookLocation); 167 154 } 155 156 return new ResourceAccessInfo(bookRef, options); 157 } 158 159 /** 160 * Class used to encapsulate the information needed to acquire an access 161 * to a resource. 162 * 163 * @author mira 164 */ 165 class ResourceAccessInfo { 168 166 169 if (!bookRef.isAbsolute()) { 170 SophieLog.warnf("Cannot open non absolute ref %s.", bookRef); 171 return null; 167 private final ResourceRefR4 location; 168 private final AccessOptions options; 169 170 /** 171 * Constructor. 172 * 173 * @param location 174 * The location of the resource. 175 * @param options 176 * The access options used to acquire access to the resource. 177 */ 178 public ResourceAccessInfo(ResourceRefR4 location, AccessOptions options) { 179 this.location = location; 180 this.options = options; 181 } 182 183 /** 184 * Gets the location of the resource. 185 * 186 * @return 187 * ResourceRefR4 to the resource. 188 */ 189 public ResourceRefR4 getLocation() { 190 return this.location; 172 191 } 173 192 174 return bookRef; 193 /** 194 * Gets options to be used for opening appropriate access. 195 * 196 * @return 197 * {@link AccessOptions} for the access to the resource 198 */ 199 public AccessOptions getOptions() { 200 return this.options; 201 } 202 175 203 } 176 204 177 205 @Override … … 197 225 198 226 res.add(TmpChunksDirProvider.createExtension()); 199 227 } 228 200 229 } -
modules/org.sophie2.base.commons/src/main/java/org/sophie2/base/commons/util/bindata/TmpChunksDirProvider.java
51 51 52 52 this.chunksDir = new File(tmp, dirName); 53 53 54 assert this.chunksDir.mkdirs() : "No permissions to write in tmp??"; 54 boolean made = this.chunksDir.mkdirs(); 55 assert made : "No permissions to write in tmp??"; 55 56 this.chunksDir.deleteOnExit(); 56 57 } 57 58