xlawrence    2005/04/27 16:12:52 CEST

  Modified files:        (Branch: JAHIA-4-1-BRANCH)
    src/java/org/jahia/blogs/actions AbstractAction.java 
                                     EditPostAction.java 
                                     NewPostAction.java 
  Log:
  Fixed language code setting bug when editing a container (post) + more debug 
msgs
  
  Revision  Changes    Path
  1.1.2.12  +8 -6      
jahia/src/java/org/jahia/blogs/actions/AbstractAction.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/src/java/org/jahia/blogs/actions/AbstractAction.java.diff?r1=1.1.2.11&r2=1.1.2.12&f=h
  1.1.2.11  +14 -8     
jahia/src/java/org/jahia/blogs/actions/EditPostAction.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/src/java/org/jahia/blogs/actions/EditPostAction.java.diff?r1=1.1.2.10&r2=1.1.2.11&f=h
  1.1.2.14  +36 -30    jahia/src/java/org/jahia/blogs/actions/NewPostAction.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/src/java/org/jahia/blogs/actions/NewPostAction.java.diff?r1=1.1.2.13&r2=1.1.2.14&f=h
  
  
  
  Index: AbstractAction.java
  ===================================================================
  RCS file: 
/home/cvs/repository/jahia/src/java/org/jahia/blogs/actions/Attic/AbstractAction.java,v
  retrieving revision 1.1.2.11
  retrieving revision 1.1.2.12
  diff -u -r1.1.2.11 -r1.1.2.12
  --- AbstractAction.java       26 Apr 2005 16:12:22 -0000      1.1.2.11
  +++ AbstractAction.java       27 Apr 2005 14:12:52 -0000      1.1.2.12
  @@ -213,8 +213,10 @@
                       JahiaException.WARNING_SEVERITY);
           }
           
  -        postContainer.setLanguageCode(languageCode);
  -        postContainer.fieldsStructureCheck(jParams);
  +        if (languageCode != null) {
  +            postContainer.setLanguageCode(languageCode);
  +            postContainer.fieldsStructureCheck(jParams);
  +        }
           return postContainer;
       }
       
  @@ -357,8 +359,8 @@
                       jParams, smc);
           }  
                 
  -        ActivationTestResults res = 
containerService.activateStagedContainer(languageCodes, containerID,
  -                user, saveVersion, jParams, smc); 
  +        ActivationTestResults res = containerService.activateStagedContainer(
  +                languageCodes, containerID, user, saveVersion, jParams, 
smc); 
           
           log.debug(res);      
           return res;
  @@ -388,8 +390,8 @@
                   new ContentContainerListKey(containerListID), languageCodes);
           smc.setDescendingInSubPages(false);
           
  -        ActivationTestResults res = 
containerService.activateStagedContainerLists(languageCodes,
  -                pageID, user, saveVersion, smc);
  +        ActivationTestResults res = 
containerService.activateStagedContainerLists(
  +                languageCodes, pageID, user, saveVersion, smc);
           
           log.debug(res);
           return res;
  
  
  
  Index: EditPostAction.java
  ===================================================================
  RCS file: 
/home/cvs/repository/jahia/src/java/org/jahia/blogs/actions/Attic/EditPostAction.java,v
  retrieving revision 1.1.2.10
  retrieving revision 1.1.2.11
  diff -u -r1.1.2.10 -r1.1.2.11
  --- EditPostAction.java       26 Apr 2005 09:26:27 -0000      1.1.2.10
  +++ EditPostAction.java       27 Apr 2005 14:12:52 -0000      1.1.2.11
  @@ -130,7 +130,7 @@
           
           // Load the Container and check the structure
           final JahiaContainer postContainer = super.getContainer(Integer.
  -                parseInt(postID), jParams.getLocale().toString());
  +                parseInt(postID));
           
           if (!postContainer.checkWriteAccess(user)) {
               throw new JahiaException(
  @@ -172,11 +172,15 @@
           }
           
           JahiaField field = postContainer.getField(fieldName);
  +        log.debug("Setting value of field: "+field.getID() +"; "+
  +                field.getLanguageCode());
           field.setValue(fieldValue);
           
           // set body field
           fieldName = super.containerNames.getValue(containerNames.POST_BODY);
           field = postContainer.getField(fieldName);
  +        log.debug("Setting value of field: "+field.getID() +"; "+
  +                field.getLanguageCode());
           super.setValue(field, content);
           
           // set posting date
  @@ -187,6 +191,8 @@
           // set the author of the message
           fieldName = 
super.containerNames.getValue(containerNames.POST_AUTHOR);
           field = postContainer.getField(fieldName);
  +        log.debug("Setting value of field: "+field.getID() +"; "+
  +                field.getLanguageCode());
           field.setValue(userName);
           
           // Used to publish all the ping tb containers
  @@ -222,7 +228,7 @@
               Vector tbURLs = (Vector)struct.get(MetaPostInfo.MT_TB_PING_URLS);
               
               if (tbURLs != null && tbURLs.size() > 0) {
  -            
  +                
                   JahiaContainerDefinition def = 
JahiaContainerDefinitionsRegistry.
                           getInstance().getDefinition(jParams.getSiteID(),
                           
containerNames.getValue(containerNames.BLOG_TB_PING_LIST));
  @@ -236,7 +242,7 @@
                   }
                   
                   Vector existingPings = getExistingPingURLs(pingURLs);
  -                for (int i=0; i<tbURLs.size(); i++) {       
  +                for (int i=0; i<tbURLs.size(); i++) {
                       String url = (String)tbURLs.get(i);
                       
                       // Ignore any empty or too short urls
  @@ -297,15 +303,15 @@
                           
super.activateContainerList(pingURLContainer.getListID(),
                                   user, pingURLContainer.getPageID());
                       }
  -
  +                    
                       if (publish) {
                           // publish the trackBack ping url container
                           super.activateContainer(pingURLContainer.getID(), 
user);
                       }
  -
  +                    
                       pingURLContainer = null;
                       url = null;
  -                }  
  +                }
               }
           }
           
  @@ -317,7 +323,7 @@
                           
containerNames.getValue(containerNames.BLOG_TB_PING_LIST));
                   if (pingURLs != null && pingURLs.getID() > 0) {
                       activatePingContainers(pingURLs, user);
  -                }                  
  +                }
               }
               
               super.activateContainer(postContainer.getID(), user);
  @@ -362,5 +368,5 @@
               JahiaContainer c = (JahiaContainer)en.nextElement();
               super.activateContainer(c.getID(), user);
           }
  -    } 
  +    }
   }
  
  
  
  Index: NewPostAction.java
  ===================================================================
  RCS file: 
/home/cvs/repository/jahia/src/java/org/jahia/blogs/actions/Attic/NewPostAction.java,v
  retrieving revision 1.1.2.13
  retrieving revision 1.1.2.14
  diff -u -r1.1.2.13 -r1.1.2.14
  --- NewPostAction.java        26 Apr 2005 09:26:27 -0000      1.1.2.13
  +++ NewPostAction.java        27 Apr 2005 14:12:52 -0000      1.1.2.14
  @@ -90,7 +90,7 @@
       
       private boolean isNewList;
       
  -    /** 
  +    /**
        * Creates a new instance of NewPostAction (Blogger API)
        */
       public NewPostAction(String appKey, String blogID,
  @@ -105,10 +105,10 @@
           this.publish = publish;
       }
       
  -    /** 
  +    /**
        * Creates a new instance of NewPostAction (MetaWeblog API)
        */
  -    public NewPostAction(String blogID, String userName, String password, 
  +    public NewPostAction(String blogID, String userName, String password,
               Hashtable struct, boolean publish) {
           
           super.userName = userName;
  @@ -130,8 +130,8 @@
           
           // First check that the user is registered to this site.
           JahiaUser user = super.checkLogin();
  -    
  -        // Set the correct page and check write access    
  +        
  +        // Set the correct page and check write access
           if 
(!super.changePage(Integer.parseInt(blogID)).checkWriteAccess(user)) {
               throw new JahiaException(
                       "You do not have write access to Blog: "+blogID,
  @@ -142,7 +142,7 @@
           
           // Name of the containerList containing all the posts of the blog
           final String containerListName = super.containerNames.getValue(
  -                containerNames.BLOG_POSTS_LIST_NAME);        
  +                containerNames.BLOG_POSTS_LIST_NAME);
           final int containerListID = containerService.getContainerListID(
                   containerListName, Integer.parseInt(blogID));
           
  @@ -156,8 +156,8 @@
           int containerID, listID, rank, aclID, versionID;
           containerID = listID = rank = aclID = versionID = 0;
           
  -        // If the ContainerList does not exist (== null), we are posting the 
  -        // very first post and all the container params have allready been 
set 
  +        // If the ContainerList does not exist (== null), we are posting the
  +        // very first post and all the container params have allready been 
set
           // above (= 0)
           if (entryList != null) {
               listID = entryList.getID();
  @@ -188,11 +188,11 @@
           log.debug("Saving Container for new Post: "+postContainer.getID());
           
           // Load the Container and check the structure
  -        postContainer = super.getContainer(postContainer.getID(), 
  -                jParams.getLocale().toString());      
  +        postContainer = super.getContainer(postContainer.getID(),
  +                jParams.getLocale().toString());
           log.debug("Loaded and working on Container: "+postContainer.getID());
           
  -        /* Set all the fields' value with the right data */                  
    
  +        /* Set all the fields' value with the right data */
           // set title field
           String fieldName = 
super.containerNames.getValue(containerNames.POST_TITLE);
           String fieldValue = "";
  @@ -216,25 +216,31 @@
               fieldValue = (String)struct.get(MetaPostInfo.TITLE);
               content = (String)struct.get(MetaPostInfo.DESCRIPTION);
               Vector categories = (Vector)struct.get(MetaPostInfo.CATEGORIES);
  -            super.setCategories(categories, postContainer); 
  +            super.setCategories(categories, postContainer);
           }
  -                          
  +        
           JahiaField field = postContainer.getField(fieldName);
  +        log.debug("Setting value of field: "+field.getID() +"; "+
  +                field.getLanguageCode());
           field.setValue(fieldValue);
  -
  +        
           // set body field
           fieldName = super.containerNames.getValue(containerNames.POST_BODY);
           field = postContainer.getField(fieldName);
  +        log.debug("Setting value of field: "+field.getID() +"; "+
  +                field.getLanguageCode());
           super.setValue(field, content);
           
           // set posting date
  -        fieldName = super.containerNames.getValue(containerNames.POST_DATE); 
 
  +        fieldName = super.containerNames.getValue(containerNames.POST_DATE);
           field = postContainer.getField(fieldName);
           field.setObject(Long.toString(System.currentTimeMillis()));
  -                  
  +        
           // set the author of the message
           fieldName = 
super.containerNames.getValue(containerNames.POST_AUTHOR);
           field = postContainer.getField(fieldName);
  +        log.debug("Setting value of field: "+field.getID() +"; "+
  +                field.getLanguageCode());
           field.setValue(userName);
           
           // check if extra Movable Type are present in the struct
  @@ -245,7 +251,7 @@
               if (struct.containsKey(MetaPostInfo.MT_EXCERPT)) {
                   String excerpt = (String)struct.get(MetaPostInfo.MT_EXCERPT);
                   
  -                if (excerpt != null && excerpt.length() > 0) { 
  +                if (excerpt != null && excerpt.length() > 0) {
                       field.setValue(excerpt);
                   }
               }
  @@ -266,32 +272,32 @@
               Vector tbURLs = (Vector)struct.get(MetaPostInfo.MT_TB_PING_URLS);
               
               if (tbURLs != null && tbURLs.size() > 0) {
  -                                
  +                
                   def = JahiaContainerDefinitionsRegistry.
                           getInstance().getDefinition(jParams.getSiteID(),
                           
containerNames.getValue(containerNames.BLOG_TB_PING_LIST));
                   
  -                JahiaContainerList pingURLs = null;       
  +                JahiaContainerList pingURLs = null;
                   int ctnListID = -1;
                   
  -                for (int i=0; i<tbURLs.size(); i++) { 
  +                for (int i=0; i<tbURLs.size(); i++) {
                       String url = (String)tbURLs.get(i);
                       
                       // Ignore any empty or too short urls
                       if (url.length() < 7) continue;
  -                     
  -                    if (i == 1) {   
  +                    
  +                    if (i == 1) {
                           pingURLs = containerService.loadContainerList(
                                   ctnListID, LoadFlags.ALL, jParams);
                       }
  -  
  +                    
                       if (pingURLs != null && pingURLs.getID() > 0) {
                           listID = pingURLs.getID();
                           aclID = pingURLs.getAclID();
                           
                       } else {
                           listID = aclID = 0;
  -                    }            
  +                    }
                       
                       JahiaContainer pingURLContainer = new JahiaContainer(
                               0, jParams.getJahiaID(), jParams.getPageID(),
  @@ -312,7 +318,7 @@
                       field = pingURLContainer.getField(containerNames.
                               getValue(containerNames.TB_PING_URL));
                       field.setValue(url);
  -                                       
  +                    
                       containerService.saveContainer(pingURLContainer,
                               postContainer.getID(), jParams);
                       
  @@ -323,15 +329,15 @@
                               fireAddContainer(theEvent);
                       
                       if (i == 0) {
  -                        
super.activateContainerList(pingURLContainer.getListID(), 
  +                        
super.activateContainerList(pingURLContainer.getListID(),
                                   user, pingURLContainer.getPageID());
                       }
  -                                  
  +                    
                       if (publish) {
                           // publish the trackBack ping url container
                           super.activateContainer(pingURLContainer.getID(), 
user);
                       }
  -
  +                    
                       pingURLContainer = null;
                       url = null;
                   }
  @@ -341,12 +347,12 @@
           containerService.saveContainer(postContainer, 0, jParams);
           
           if (isNewList) {
  -            super.activateContainerList(postContainer.getListID(), user, 
  +            super.activateContainerList(postContainer.getListID(), user,
                       postContainer.getPageID());
           }
           
           if (publish) {
  -            super.activateContainer(postContainer.getID(), user); 
  +            super.activateContainer(postContainer.getID(), user);
           }
           
           super.flushPageCacheThatDisplayContainer(postContainer);
  

Reply via email to