Ticket #2416: server-bugfixes.patch

File server-bugfixes.patch, 13.3 KB (added by meddle, 15 years ago)

server-bugfixes.patch

  • modules/org.sophie2.main.app.commons/src/main/java/org/sophie2/main/app/commons/frame/FrameLogic.java

    ### Eclipse Workspace Patch 1.0
    #P sophie
     
    246246         */ 
    247247        protected static void refreshFrameView(ErrorManipulationView errorView) { 
    248248                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                } 
    257257        } 
    258258 
    259259        /** 
  • modules/org.sophie2.server.core/src/main/java/org/sophie2/server/core/persistence/db/ResourceServiceDBImpl.java

     
    5353        // TODO make this constructor parameter. 
    5454        private static final int DEFAUL_FETCH_SIZE = 20; 
    5555        private static final Charset CHARSET = Charset.forName("UTF-8"); 
    56          
     56 
    5757        /** 
    5858         * The DAO used by this service to access the database. 
    5959         */ 
     
    135135 
    136136                final String resourcePath = toResourcePath(this.prefix, ref); 
    137137 
    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); 
    144140 
    145                         public void ensureResourceRevision(String path) { 
    146                                 if (this.resourceIds.containsKey(path)) { 
    147                                         return; 
    148                                 } 
     141                        this.dao.updateResourceRevision(resourceId, revisionId); 
     142                } else { 
    149143 
    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>(); 
    153146 
    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); 
    161149                                } 
    162150 
    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                                        } 
    166155 
    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); 
    174159 
    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); 
    177172 
    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                                        } 
    182180 
    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); 
    186182                                } 
    187183 
    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; 
    194192                                        } 
    195                                 } 
    196193 
    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                                        } 
    203202 
    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                        }; 
    205209 
    206                 this.dao.changeKeys(revisionId, keyChanges); 
     210                        new ResourceChangeHierarchy(resourcePath, effect.getWrites()).accept(resourceVisitor); 
     211 
     212                        this.dao.changeKeys(revisionId, keyChanges); 
     213                } 
     214                 
    207215                this.dao.readKeys(revisionId, effect.getReads().asList()); 
    208216 
    209217                return nextRevisionId; 
     
    269277                } 
    270278 
    271279                return result; 
    272                  
     280 
    273281        } 
    274282 
    275283        private static HistoryEntry convertToHistoryEntry(String revision, 
     
    401409        throws ResponseException { 
    402410                String nowRev = this.dao.findRevisionNotAfter(RevisionId.FUTURE.getId()); 
    403411                RevisionId id = (nowRev == null) ? RevisionId.FUTURE : new RevisionId(nowRev); 
    404                  
     412 
    405413                return findValue(ref, key, id); 
    406414        } 
    407415 
     
    418426        public DBChangeContext getCurrentChangeContext(ResourceRefR4 ref) throws ResponseException { 
    419427                String currentRevId = this.dao.findRevisionNotAfter(RevisionId.FUTURE.getId()); 
    420428                RevisionId currentRevision = new RevisionId(currentRevId); 
    421                  
     429 
    422430                return new DBChangeContext(this.dao, toResourcePath(this.prefix, ref), currentRevision); 
    423431        } 
    424432 
  • modules/org.sophie2.s2s/src/main/java/org/sophie2/s2s/ServerModule.java

     
    4444                                                ServerResourceHelper helper = ServerCoreModule.get().getResourceHelperExtension( 
    4545                                                                ).getObject(); 
    4646                                                helper.initialize(); 
     47 
    4748                                                WebAppModule.get().startServer(); 
    4849                                        } 
    4950                                }); 
  • modules/org.sophie2.main.func.servers/src/main/java/org/sophie2/main/func/servers/logic/ServersTabLogic.java

     
    100100                                        AppMainWindow mainWindow = AppViewUtil.findMainWindow(palette); 
    101101                                        List<DocView> docViews = mainWindow.documents().get(); 
    102102                                        List<DocView> toRemove = new ArrayList<DocView>(); 
     103                                         
     104                                        boolean updateCurrent = false; 
    103105                                        for (DocView docView : docViews) { 
    104106                                                if (docView instanceof ResourceDocView) { 
    105107                                                        ResourceAccess access = ((ResourceDocView) docView).getAccess(); 
    106108                                                        if (access.isClosed()) { 
    107109                                                                if (mainWindow.currentDocument().get() == docView) { 
    108                                                                         mainWindow.currentDocument().set(null); 
     110                                                                        updateCurrent = true; 
    109111                                                                } 
    110112                                                                toRemove.add(docView); 
    111113                                                        } 
    112114                                                } 
    113115                                        } 
     116                                         
    114117                                        mainWindow.documents().get().removeAll(toRemove); 
     118                                         
     119                                        if (updateCurrent) { 
     120                                                mainWindow.currentDocument().set(null); 
     121                                        } 
     122                                         
    115123                                        DialogManager.get().showDialog( 
    116124                                                        new MessageDialogInput(null, 
    117125                                                                        "Succesfully disconected.")); 
     
    131139                                                                                        "Failed to connect.")); 
    132140                                } 
    133141                        } 
     142                         
    134143                        ServerResourcesPalette resourcesPalette =  
    135144                                palette.findNearestElement(null, ServerResourcesPalette.class); 
    136145                         
     
    142151                        } 
    143152                         
    144153                        updateResources(resourcesPalette, palette, account); 
     154                         
    145155                        return true; 
    146156                } 
    147157 
     
    592602                if (serverResorcesDirectory == null) { 
    593603                        return; 
    594604                } 
     605                 
    595606                ResourceRefList list = serverResorcesDirectory.getResources(); 
    596607                Mapper<ResourceRefR4, ResourceRefR4> mapper = new Mapper<ResourceRefR4, ResourceRefR4>() { 
    597608                        public ResourceRefR4 map(ResourceRefR4 element) { 
    598609                                return serverResorcesDirectory.getRef().sub(element); 
    599610                        } 
    600611                }; 
     612                 
    601613                resourcesPalette.resources().get().addAll(list.map(mapper).asList()); 
    602614        } 
    603615 
  • modules/org.sophie2.base.commons/src/main/java/org/sophie2/base/commons/util/ImmImage.java

     
    656656                } 
    657657                ImmImage other = (ImmImage) obj; 
    658658                 
    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(); 
    666661                 
    667                 if (getBinData() == null) { 
    668                         if (other.getBinData() != null) { 
     662                if (binData == null) { 
     663                        if (otherBinData != null) { 
    669664                                return false; 
    670665                        } 
    671                 } else if (!getBinData().equals(other.getBinData())) { 
     666                } else if (binData.getSize() != otherBinData.getSize()) { 
     667                        return false; 
     668                } else if (!binData.equals(otherBinData)) { 
    672669                        return false; 
    673670                } 
    674671                 
  • modules/org.sophie2.main.func.servers/src/main/java/org/sophie2/main/func/servers/view/ConnectionsPalette.java

     
    577577                                        if (status == ConnectionStatus.CONNECTED) { 
    578578                                                return true; 
    579579                                        } 
     580 
    580581                                        return false; 
    581582                                } 
    582583                        } 
  • modules/org.sophie2.main.app.halos/src/main/java/org/sophie2/main/app/halos/huds/appearance/ImagePickerHud.java

     
    196196                                        ResourceH selected = input.getSelectedItem(); 
    197197                                        final ResourceRefR4 selectedRef; 
    198198                                        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); 
    200203                                        } else { 
    201204                                                selectedRef = ResourceRefR4.NONE_REF; 
    202205                                        } 
  • modules/org.sophie2.base.scene/src/main/java/org/sophie2/base/scene/helpers/ShapeElementHelper.java

     
    1212 
    1313import org.sophie2.base.commons.util.ImmColor; 
    1414import org.sophie2.base.commons.util.ImmFilling; 
     15import org.sophie2.base.commons.util.bindata.BinSourceNotFoundException; 
    1516import org.sophie2.base.commons.util.position.ImmArea; 
    1617import org.sophie2.base.scene.interfaces.Scene; 
    1718import org.sophie2.base.scene.interfaces.SceneElement; 
     
    7475                ImmFilling paint = getElement().filling().get(); 
    7576                ImmColor color = getEffectiveColor(); 
    7677                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                        } 
    7883                } 
    7984        }        
    8085