support operations that are always available
authorzapata <zapata>
Mon, 23 Dec 2002 16:46:42 +0000 (16:46 +0000)
committerzapata <zapata>
Mon, 23 Dec 2002 16:46:42 +0000 (16:46 +0000)
source/mircoders/localizer/basic/MirBasicAdminInterfaceLocalizer.java

index d7abc87..b385ed2 100755 (executable)
@@ -58,11 +58,11 @@ public class MirBasicAdminInterfaceLocalizer implements MirAdminInterfaceLocaliz
     simpleArticleOperationsMap = new HashMap();\r
 \r
     addSimpleArticleOperation(new ChangeArticleFieldOperation("newswire", "to_article_type", "0", "1", false));\r
-    addSimpleArticleOperation(new SetArticleFieldOperation("unhide", "is_published", "1", false));\r
-    addSimpleArticleOperation(new SetArticleFieldOperation("hide", "is_published", "0", false));\r
+    addSimpleArticleOperation(new ModifyArticleFieldOperation("unhide", "is_published", "1", false));\r
+    addSimpleArticleOperation(new ModifyArticleFieldOperation("hide", "is_published", "0", false));\r
 \r
-    addSimpleCommentOperation(new SetCommentFieldOperation("unhide", "is_published", "1"));\r
-    addSimpleCommentOperation(new SetCommentFieldOperation("hide", "is_published", "0"));\r
+    addSimpleCommentOperation(new ModifyCommentFieldOperation("unhide", "is_published", "1"));\r
+    addSimpleCommentOperation(new ModifyCommentFieldOperation("hide", "is_published", "0"));\r
   }\r
 \r
   public List simpleCommentOperations() {\r
@@ -174,7 +174,12 @@ public class MirBasicAdminInterfaceLocalizer implements MirAdminInterfaceLocaliz
       anEntity.setValueForProperty("is_produced", "0");\r
 \r
       if (logOperation) {\r
-        StringBuffer comment = new StringBuffer(anEntity.getValue("comment"));\r
+        StringBuffer comment = new StringBuffer();\r
+       try {\r
+          comment.append(StringRoutines.interpretAsString(anEntity.getValue("comment")));\r
+       }\r
+       catch (Throwable t) {\r
+       }\r
         if (comment.length()>0 && comment.charAt(comment.length()-1)!='\n') {\r
           comment.append('\n');\r
         }\r
@@ -207,6 +212,26 @@ public class MirBasicAdminInterfaceLocalizer implements MirAdminInterfaceLocaliz
     }\r
 \r
     protected boolean isAvailable(EntityComment aComment) {\r
+      return true;\r
+    }\r
+\r
+    protected void performModification(EntityAdapter aUser, EntityComment aComment) throws StorageObjectException {\r
+      aComment.setValueForProperty(field, value);\r
+    }\r
+  }\r
+\r
+  protected static class ModifyCommentFieldOperation extends CommentModifyingOperation {\r
+    private String field;\r
+    private String value;\r
+\r
+    public ModifyCommentFieldOperation(String aName, String aField, String aValue) {\r
+      super(aName);\r
+\r
+      field = aField;\r
+      value = aValue;\r
+    }\r
+\r
+    protected boolean isAvailable(EntityComment aComment) {\r
       return aComment.getValue(field) == null || !aComment.getValue(field).equals(value);\r
     }\r
 \r
@@ -227,6 +252,26 @@ public class MirBasicAdminInterfaceLocalizer implements MirAdminInterfaceLocaliz
     }\r
 \r
     protected boolean isAvailable(EntityContent anArticle) {\r
+      return true;\r
+    }\r
+\r
+    protected void performModification(EntityAdapter aUser, EntityContent anArticle) throws StorageObjectException {\r
+      anArticle.setValueForProperty(field, value);\r
+    }\r
+  }\r
+\r
+  protected static class ModifyArticleFieldOperation extends ArticleModifyingOperation {\r
+    private String field;\r
+    private String value;\r
+\r
+    public ModifyArticleFieldOperation(String aName, String aField, String aValue, boolean aLogOperation) {\r
+      super(aName, aLogOperation);\r
+\r
+      field = aField;\r
+      value = aValue;\r
+    }\r
+\r
+    protected boolean isAvailable(EntityContent anArticle) {\r
       return anArticle.getValue(field) == null || !anArticle.getValue(field).equals(value);\r
     }\r
 \r
@@ -256,4 +301,4 @@ public class MirBasicAdminInterfaceLocalizer implements MirAdminInterfaceLocaliz
       anArticle.setValueForProperty(field, newValue);\r
     }\r
   }\r
-}
\ No newline at end of file
+}\r