dpillot     2005/11/24 18:19:48 CET

  Modified files:
    core/src/java/org/jahia/data/beans ContainerBean.java 
  Log:
  fix npe & url of source
  
  Revision  Changes    Path
  1.28      +36 -19    
jahia/core/src/java/org/jahia/data/beans/ContainerBean.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/data/beans/ContainerBean.java.diff?r1=1.27&r2=1.28&f=h
  
  
  
  Index: ContainerBean.java
  ===================================================================
  RCS file: 
/home/cvs/repository/jahia/core/src/java/org/jahia/data/beans/ContainerBean.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- ContainerBean.java        24 Nov 2005 11:04:37 -0000      1.27
  +++ ContainerBean.java        24 Nov 2005 17:19:48 -0000      1.28
  @@ -38,7 +38,7 @@
    * <p>Company: Jahia Ltd</p>
    *
    * @author Serge Huber, Xavier Lawrence
  - * @version $Id: ContainerBean.java,v 1.27 2005/11/24 11:04:37 xlawrence Exp 
$
  + * @version $Id: ContainerBean.java,v 1.28 2005/11/24 17:19:48 dpillot Exp $
    */
   
   public class ContainerBean extends ContentBean implements 
PropertiesInterface {
  @@ -431,7 +431,8 @@
           final GuiBean guiBean = new GuiBean(processingContext);
           final HTMLToolBox htmlToolBox = new HTMLToolBox(guiBean, 
processingContext);
           completelyLocked = true;
  -
  +        final JahiaUser user = processingContext.getUser();
  +        final int siteID = processingContext.getSiteID();
           boolean isPicker = isPicker();
   
           try {
  @@ -442,40 +443,56 @@
   
               // action menu item to see the source of linked copy
               if (isPicker) {
  -
                   ContentObject pickedObject;// the source of the linked 
copy(the picked)
                   ContentContainer pickedContainer;
  -                //String pickedID="";
                   String pickedpageID;
  +                int pickedSiteID;
  +                boolean pagefound = false;
  +                boolean crosssite = false;
                   try {
                       pickedObject = theContainer.getPickedObject();
  +                    pickedSiteID = pickedObject.getSiteID();
                       pickedContainer = 
ContentContainer.getContainer(pickedObject.getID());
                       pickedpageID = 
String.valueOf(pickedContainer.getPageID());
  -                    final List l = (pickedContainer.getChilds(null, 
EntryLoadRequest.STAGED, null));
  +                    if (pickedpageID != null) {
  +                        logger.debug("pageID:" + pickedpageID);
  +                        pagefound=true;
  +                        if (pickedSiteID != siteID) {
  +                            logger.debug("cross-site");
  +                            crosssite=true;
  +                        }
  +                    }
  +                    final List l = pickedContainer.getChilds(null, 
EntryLoadRequest.STAGED, null);
                       for (final Iterator iterator1 = l.iterator(); 
iterator1.hasNext();) {
                           final Object o = iterator1.next();
                           if (!(o instanceof ContentPageField)) continue;
                           //defensive code relative to poor impl of exception 
catching/throwing of method getPage below
  -                        final JahiaPage page = ((ContentPageField) 
o).getPage(processingContext, processingContext.getEntryLoadRequest());
  -                        logger.debug("" + page.toString());
  +                        final JahiaPage page = ((ContentPageField) 
o).getPage(null, EntryLoadRequest.STAGED);
  +
                           if (page != null) {
  -                            pickedpageID = String.valueOf 
(((ContentPageField) o).getPage(processingContext, 
processingContext.getEntryLoadRequest()).getID());
  +                            logger.debug("" + page.toString());
  +                            pickedpageID = String.valueOf(page.getID());
                               logger.debug("found contentpagefield:" + 
pickedpageID);
  +                            pagefound = true;
                               break;
                           } else {
  -                            logger.warn("found inconsistent pid");
  +                            logger.debug("found inconsistent pid");
                               pickedpageID = "0";
  +                            pagefound = false;
                           }
  +
  +                    }
  +                    if (pagefound) {
  +                        final StringBuffer buff = new StringBuffer();
  +                        buff.append("document.location='");
  +                        buff.append(Jahia.getContextPath());
  +                        buff.append(Jahia.getServletPath());
  +                        buff.append("/pid/");
  +                        buff.append(pickedpageID);
  +                        buff.append("'");
  +                        curActionURIBean = new ActionURIBean("picker", "", 
buff.toString());
  +                        actionURIs.put(curActionURIBean.getName(), 
curActionURIBean);
                       }
  -                    final StringBuffer buff = new StringBuffer();
  -                    buff.append("document.location='");
  -                    buff.append(Jahia.getContextPath());
  -                    buff.append(Jahia.getServletPath());
  -                    buff.append("/op/edit/pid/");
  -                    buff.append(pickedpageID);
  -                    buff.append("'");
  -                    curActionURIBean = new ActionURIBean("picker", "", 
buff.toString());
  -                    actionURIs.put(curActionURIBean.getName(), 
curActionURIBean);
                   } catch (JahiaException e) {
                       logger.error(e);
                   }
  @@ -487,7 +504,7 @@
               curActionURIBean = new ActionURIBean("update", curURL, 
curLauncherURI);
               LockKey lockKey = 
LockKey.composeLockKey(LockKey.UPDATE_CONTAINER_TYPE, jahiaContainer.getID(),
                       jahiaContainer.getPageID());
  -            final JahiaUser user = processingContext.getUser();
  +
               if (!isPicker || jahiaContainer.checkAdminAccess(user)) {
                   if (!lockRegistry.isAcquireable(lockKey, user, 
user.getUserKey())) {
                       curActionURIBean.setLocked(true);
  

Reply via email to