bugfixes mainly...
[mir.git] / source / mircoders / storage / DatabaseImages.java
index 1a5df1c..e61ff38 100755 (executable)
@@ -22,7 +22,11 @@ public class DatabaseImages extends Database implements StorageObject{
        private static DatabaseImages instance;
        private static SimpleList publisherPopupData;
 
-       public static DatabaseImages getInstance() throws StorageObjectException
+  // the following *has* to be sychronized cause this static method
+  // could get preemted and we could end up with 2 instances of DatabaseFoo..
+  // see the "Singletons with needles and thread" article at JavaWorld -mh
+       public synchronized static DatabaseImages getInstance()
+    throws StorageObjectException
        {
                if (instance == null) {
                        instance = new DatabaseImages();
@@ -38,18 +42,17 @@ public class DatabaseImages extends Database implements StorageObject{
                this.theTable="images";
                this.theCoreTable="media";
                try {
-                       this.theEntityClass = Class.forName("mircoders.entity.EntityImage");
+                       this.theEntityClass = Class.forName("mircoders.entity.EntityImages");
                }
                catch (Exception e) { throw new StorageObjectException(e.toString());   }
        }
 
-       public SimpleList getPopupData() {
+       public SimpleList getPopupData() throws StorageObjectException {
                return getPopupData("title",true);
        }
 
        public void update(Entity theEntity) throws StorageObjectException
        {
-               theEntity.setValueForProperty("to_media_type","1");
                String date = theEntity.getValue("date");
                if (date==null){
                        date = StringUtil.date2webdbDate(new GregorianCalendar());
@@ -62,7 +65,6 @@ public class DatabaseImages extends Database implements StorageObject{
 
        public String insert(Entity theEntity) throws StorageObjectException
        {
-               theEntity.setValueForProperty("to_media_type","1");
                String date = theEntity.getValue("date");
                if (date==null){
                        date = StringUtil.date2webdbDate(new GregorianCalendar());