Ticket #2416: server-bugfixes.patch
File server-bugfixes.patch, 13.3 KB (added by meddle, 15 years ago) |
---|
-
modules/org.sophie2.main.app.commons/src/main/java/org/sophie2/main/app/commons/frame/FrameLogic.java
### Eclipse Workspace Patch 1.0 #P sophie
246 246 */ 247 247 protected static void refreshFrameView(ErrorManipulationView errorView) { 248 248 final FrameView view = errorView.parent().get(); 249 assert view != null :250 "The manipulation view can not be unattached!";251 252 SwingUtilities.invokeLater(new Runnable() {253 public void run() {254 view.resourceSourceProblem().set(null);255 } 256 } );249 250 if (view != null) { 251 SwingUtilities.invokeLater(new Runnable() { 252 public void run() { 253 view.resourceSourceProblem().set(null); 254 } 255 }); 256 } 257 257 } 258 258 259 259 /** -
modules/org.sophie2.server.core/src/main/java/org/sophie2/server/core/persistence/db/ResourceServiceDBImpl.java
53 53 // TODO make this constructor parameter. 54 54 private static final int DEFAUL_FETCH_SIZE = 20; 55 55 private static final Charset CHARSET = Charset.forName("UTF-8"); 56 56 57 57 /** 58 58 * The DAO used by this service to access the database. 59 59 */ … … 135 135 136 136 final String resourcePath = toResourcePath(this.prefix, ref); 137 137 138 ResourceVisitor resourceVisitor = new ResourceVisitor() { 139 private Map<String, Long> resourceIds = new HashMap<String, Long>(); 140 141 public void visitResource(String path) { 142 ensureResourceRevision(path); 143 } 138 if (effect.getWrites().keySet().isEmpty()) { 139 Long resourceId = this.dao.findResourceIdByPath(resourcePath); 144 140 145 public void ensureResourceRevision(String path) { 146 if (this.resourceIds.containsKey(path)) { 147 return; 148 } 141 this.dao.updateResourceRevision(resourceId, revisionId); 142 } else { 149 143 150 // not found in db... search for the parent. 151 int slashIndex = 152 path.lastIndexOf(ResourceRefR4.SEPARATOR, path.length() - 2); 144 ResourceVisitor resourceVisitor = new ResourceVisitor() { 145 private Map<String, Long> resourceIds = new HashMap<String, Long>(); 153 146 154 final String parentPath; 155 if (slashIndex == -1) { 156 // this is the root; 157 parentPath = path; 158 } else { 159 parentPath = path.substring(0, slashIndex + 1); 160 ensureResourceRevision(parentPath); 147 public void visitResource(String path) { 148 ensureResourceRevision(path); 161 149 } 162 150 163 Long resourceId = ResourceServiceDBImpl.this.dao.findResourceIdByPath(path); 164 if (resourceId == null) { 165 Long parentId = this.resourceIds.get(parentPath); 151 public void ensureResourceRevision(String path) { 152 if (this.resourceIds.containsKey(path)) { 153 return; 154 } 166 155 167 String resourceName = path.substring(slashIndex + 1, path.length() - 1); 168 resourceId = ResourceServiceDBImpl.this.dao.createResource( 169 revisionId, new DBResource(parentId, resourceName)); 170 } else { 171 ResourceServiceDBImpl.this.dao.updateResourceRevision( 172 resourceId, revisionId); 173 } 156 // not found in db... search for the parent. 157 int slashIndex = 158 path.lastIndexOf(ResourceRefR4.SEPARATOR, path.length() - 2); 174 159 175 this.resourceIds.put(path, resourceId); 176 } 160 final String parentPath; 161 if (slashIndex == -1) { 162 // this is the root; 163 parentPath = path; 164 } else { 165 parentPath = path.substring(0, slashIndex + 1); 166 ensureResourceRevision(parentPath); 167 } 168 169 Long resourceId = ResourceServiceDBImpl.this.dao.findResourceIdByPath(path); 170 if (resourceId == null) { 171 Long parentId = this.resourceIds.get(parentPath); 177 172 178 public void visitKey(String keyResourcePath, String keyPath, 179 Object value) { 180 ensureResourceRevision(keyResourcePath); 181 Long resourceId = this.resourceIds.get(keyResourcePath); 173 String resourceName = path.substring(slashIndex + 1, path.length() - 1); 174 resourceId = ResourceServiceDBImpl.this.dao.createResource( 175 revisionId, new DBResource(parentId, resourceName)); 176 } else { 177 ResourceServiceDBImpl.this.dao.updateResourceRevision( 178 resourceId, revisionId); 179 } 182 180 183 // The ensure method updates these keys... 184 if (RootKey.ROOT_ID.equals(keyPath) || ChildrenKey.CHILDREN_ID.equals(keyPath)) { 185 return; 181 this.resourceIds.put(path, resourceId); 186 182 } 187 183 188 Reader vlaueReader = null; 189 if (value != null) { 190 try { 191 vlaueReader = valueToReader(value); 192 } catch (IOException e) { 193 throw new RuntimeException("Failed to create value reader", e); 184 public void visitKey(String keyResourcePath, String keyPath, 185 Object value) { 186 ensureResourceRevision(keyResourcePath); 187 Long resourceId = this.resourceIds.get(keyResourcePath); 188 189 // The ensure method updates these keys... 190 if (RootKey.ROOT_ID.equals(keyPath) || ChildrenKey.CHILDREN_ID.equals(keyPath)) { 191 return; 194 192 } 195 }196 193 197 Long keyId = ResourceServiceDBImpl.this.dao.findOrCreateKey(keyPath); 198 DBKeyChange keyChange = new DBKeyChange(resourceId, keyId, 199 vlaueReader); 200 keyChanges.add(keyChange); 201 } 202 }; 194 Reader vlaueReader = null; 195 if (value != null) { 196 try { 197 vlaueReader = valueToReader(value); 198 } catch (IOException e) { 199 throw new RuntimeException("Failed to create value reader", e); 200 } 201 } 203 202 204 new ResourceChangeHierarchy(resourcePath, effect.getWrites()).accept(resourceVisitor); 203 Long keyId = ResourceServiceDBImpl.this.dao.findOrCreateKey(keyPath); 204 DBKeyChange keyChange = new DBKeyChange(resourceId, keyId, 205 vlaueReader); 206 keyChanges.add(keyChange); 207 } 208 }; 205 209 206 this.dao.changeKeys(revisionId, keyChanges); 210 new ResourceChangeHierarchy(resourcePath, effect.getWrites()).accept(resourceVisitor); 211 212 this.dao.changeKeys(revisionId, keyChanges); 213 } 214 207 215 this.dao.readKeys(revisionId, effect.getReads().asList()); 208 216 209 217 return nextRevisionId; … … 269 277 } 270 278 271 279 return result; 272 280 273 281 } 274 282 275 283 private static HistoryEntry convertToHistoryEntry(String revision, … … 401 409 throws ResponseException { 402 410 String nowRev = this.dao.findRevisionNotAfter(RevisionId.FUTURE.getId()); 403 411 RevisionId id = (nowRev == null) ? RevisionId.FUTURE : new RevisionId(nowRev); 404 412 405 413 return findValue(ref, key, id); 406 414 } 407 415 … … 418 426 public DBChangeContext getCurrentChangeContext(ResourceRefR4 ref) throws ResponseException { 419 427 String currentRevId = this.dao.findRevisionNotAfter(RevisionId.FUTURE.getId()); 420 428 RevisionId currentRevision = new RevisionId(currentRevId); 421 429 422 430 return new DBChangeContext(this.dao, toResourcePath(this.prefix, ref), currentRevision); 423 431 } 424 432 -
modules/org.sophie2.s2s/src/main/java/org/sophie2/s2s/ServerModule.java
44 44 ServerResourceHelper helper = ServerCoreModule.get().getResourceHelperExtension( 45 45 ).getObject(); 46 46 helper.initialize(); 47 47 48 WebAppModule.get().startServer(); 48 49 } 49 50 }); -
modules/org.sophie2.main.func.servers/src/main/java/org/sophie2/main/func/servers/logic/ServersTabLogic.java
100 100 AppMainWindow mainWindow = AppViewUtil.findMainWindow(palette); 101 101 List<DocView> docViews = mainWindow.documents().get(); 102 102 List<DocView> toRemove = new ArrayList<DocView>(); 103 104 boolean updateCurrent = false; 103 105 for (DocView docView : docViews) { 104 106 if (docView instanceof ResourceDocView) { 105 107 ResourceAccess access = ((ResourceDocView) docView).getAccess(); 106 108 if (access.isClosed()) { 107 109 if (mainWindow.currentDocument().get() == docView) { 108 mainWindow.currentDocument().set(null);110 updateCurrent = true; 109 111 } 110 112 toRemove.add(docView); 111 113 } 112 114 } 113 115 } 116 114 117 mainWindow.documents().get().removeAll(toRemove); 118 119 if (updateCurrent) { 120 mainWindow.currentDocument().set(null); 121 } 122 115 123 DialogManager.get().showDialog( 116 124 new MessageDialogInput(null, 117 125 "Succesfully disconected.")); … … 131 139 "Failed to connect.")); 132 140 } 133 141 } 142 134 143 ServerResourcesPalette resourcesPalette = 135 144 palette.findNearestElement(null, ServerResourcesPalette.class); 136 145 … … 142 151 } 143 152 144 153 updateResources(resourcesPalette, palette, account); 154 145 155 return true; 146 156 } 147 157 … … 592 602 if (serverResorcesDirectory == null) { 593 603 return; 594 604 } 605 595 606 ResourceRefList list = serverResorcesDirectory.getResources(); 596 607 Mapper<ResourceRefR4, ResourceRefR4> mapper = new Mapper<ResourceRefR4, ResourceRefR4>() { 597 608 public ResourceRefR4 map(ResourceRefR4 element) { 598 609 return serverResorcesDirectory.getRef().sub(element); 599 610 } 600 611 }; 612 601 613 resourcesPalette.resources().get().addAll(list.map(mapper).asList()); 602 614 } 603 615 -
modules/org.sophie2.base.commons/src/main/java/org/sophie2/base/commons/util/ImmImage.java
656 656 } 657 657 ImmImage other = (ImmImage) obj; 658 658 659 if (getSize() == null) { 660 if (other.getSize() != null) { 661 return false; 662 } 663 } else if (!getSize().equals(other.getSize())) { 664 return false; 665 } 659 BinData binData = getBinData(); 660 BinData otherBinData = other.getBinData(); 666 661 667 if ( getBinData()== null) {668 if (other .getBinData()!= null) {662 if (binData == null) { 663 if (otherBinData != null) { 669 664 return false; 670 665 } 671 } else if (!getBinData().equals(other.getBinData())) { 666 } else if (binData.getSize() != otherBinData.getSize()) { 667 return false; 668 } else if (!binData.equals(otherBinData)) { 672 669 return false; 673 670 } 674 671 -
modules/org.sophie2.main.func.servers/src/main/java/org/sophie2/main/func/servers/view/ConnectionsPalette.java
577 577 if (status == ConnectionStatus.CONNECTED) { 578 578 return true; 579 579 } 580 580 581 return false; 581 582 } 582 583 } -
modules/org.sophie2.main.app.halos/src/main/java/org/sophie2/main/app/halos/huds/appearance/ImagePickerHud.java
196 196 ResourceH selected = input.getSelectedItem(); 197 197 final ResourceRefR4 selectedRef; 198 198 if (selected != source.getEmptyItem()) { 199 selectedRef = selected.getRef(); 199 ResourceRefR4 absRef = selected.getRef(); 200 ResourceRefR4 elementRef = hud.access().get().getRef(); 201 202 selectedRef = ResourceRefR4.getRelativeRef(elementRef, absRef); 200 203 } else { 201 204 selectedRef = ResourceRefR4.NONE_REF; 202 205 } -
modules/org.sophie2.base.scene/src/main/java/org/sophie2/base/scene/helpers/ShapeElementHelper.java
12 12 13 13 import org.sophie2.base.commons.util.ImmColor; 14 14 import org.sophie2.base.commons.util.ImmFilling; 15 import org.sophie2.base.commons.util.bindata.BinSourceNotFoundException; 15 16 import org.sophie2.base.commons.util.position.ImmArea; 16 17 import org.sophie2.base.scene.interfaces.Scene; 17 18 import org.sophie2.base.scene.interfaces.SceneElement; … … 74 75 ImmFilling paint = getElement().filling().get(); 75 76 ImmColor color = getEffectiveColor(); 76 77 if (g2d != null) { 77 paint.transform(color).fill(g2d, shape); 78 try { 79 paint.transform(color).fill(g2d, shape); 80 } catch (BinSourceNotFoundException e) { 81 // Don't paint something that is not existing! 82 } 78 83 } 79 84 } 80 85