tdraier     2005/10/27 16:50:13 CEST

  Modified files:
    core/src/java/org/jahia/services/importexport 
                                                  ImportHandler.java 
  Log:
  locks, cache, acl and other stuff
  
  Revision  Changes    Path
  1.34      +57 -6     
jahia/core/src/java/org/jahia/services/importexport/ImportHandler.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/services/importexport/ImportHandler.java.diff?r1=1.33&r2=1.34&f=h
  
  
  
  Index: ImportHandler.java
  ===================================================================
  RCS file: 
/home/cvs/repository/jahia/core/src/java/org/jahia/services/importexport/ImportHandler.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- ImportHandler.java        25 Oct 2005 11:22:58 -0000      1.33
  +++ ImportHandler.java        27 Oct 2005 14:50:13 -0000      1.34
  @@ -1,10 +1,7 @@
   package org.jahia.services.importexport;
   
   import org.apache.log4j.Logger;
  -import org.jahia.content.ContentObject;
  -import org.jahia.content.ContentObjectKey;
  -import org.jahia.content.FieldDefinitionKey;
  -import org.jahia.content.ContentDefinition;
  +import org.jahia.content.*;
   import org.jahia.data.containers.*;
   import org.jahia.data.fields.*;
   import org.jahia.data.files.JahiaFileField;
  @@ -37,6 +34,8 @@
   import org.jahia.services.webdav.JahiaWebdavBaseService;
   import org.jahia.services.categories.Category;
   import org.jahia.services.categories.CategoryService;
  +import org.jahia.services.lock.LockService;
  +import org.jahia.services.lock.LockKey;
   import org.jahia.utils.LanguageCodeConverters;
   import org.springframework.transaction.PlatformTransactionManager;
   import org.springframework.transaction.TransactionStatus;
  @@ -74,6 +73,9 @@
       protected Locale oldLocale;
       protected EntryLoadRequest oldElr;
       protected JahiaSite site;
  +    protected LockKey lockKey;
  +    protected ContentObject topObjectWithAclChanged;
  +    protected String topAcl;
   
       private TransactionTemplate transactionTemplate = null;
   
  @@ -99,6 +101,16 @@
           
jParams.setCurrentLocale(LanguageCodeConverters.languageCodeToLocale(language));
           oldElr = jParams.getEntryLoadRequest();
           jParams.setEntryLoadRequest(elr);
  +
  +        LockService lock = ServicesRegistry.getInstance().getLockService();
  +        if (currentObject instanceof ContentContainerList) {
  +            lockKey = LockKey.composeLockKey(LockKey.ADD_CONTAINER_TYPE, 
currentObject.getID(), ((ContentContainerList)currentObject).getPageID());
  +        } else if (currentObject instanceof ContentContainer) {
  +            lockKey = LockKey.composeLockKey(LockKey.UPDATE_CONTAINER_TYPE, 
currentObject.getID(), ((ContentContainer)currentObject).getPageID());
  +        }
  +        if (!lock.acquire(lockKey, jParams.getUser(), 
jParams.getUser().getUserKey(), 3600)) {
  +            throw new SAXException("Cannot acquire lock");
  +        }
       }
   
       public void endDocument() throws SAXException {
  @@ -136,6 +148,8 @@
           } catch (JahiaException e) {
               throw new SAXException(e);
           }
  +        LockService lock = ServicesRegistry.getInstance().getLockService();
  +        lock.release(lockKey, jParams.getUser(), 
jParams.getUser().getUserKey());
       }
   
       public void startElement(final String namespaceURI, final String 
localName, final String qName, final Attributes atts) throws SAXException {
  @@ -170,13 +184,23 @@
                           }
                           logger.info("diff = " + diff);
                           if (op == VersioningDifferenceStatus.ADDED) {
  +                            boolean top = false;
                               if (objects.empty()) {
                                   objects.push(currentObject);
  +                                top = true;
                               }
                               ContentObject parent = (ContentObject) 
objects.peek();
                               if (parent != null) {
                                   currentObject = createObject(parent, 
namespaceURI, localName, atts);
                               }
  +                            if (top) {
  +                                topObjectWithAclChanged = currentObject;
  +                                topAcl = 
atts.getValue(ImportExportBaseService.JAHIA_URI, "acl");
  +                                JahiaBaseACL acl = currentObject.getACL();
  +                                acl.setInheritance(1);
  +                                acl.removeAllUserEntries();
  +                                acl.removeAllGroupEntries();
  +                            }
                           } else {
                               if (currentObject == null) {
                                   ContentObject parent = (ContentObject) 
objects.peek();
  @@ -275,6 +299,10 @@
       public void endElement(String namespaceURI, String localName, String 
qName) throws SAXException {
           lastObject = (ContentObject) objects.pop();
           logger.info("End element {" + namespaceURI + "}" +localName + " = 
"+lastObject);
  +
  +        if (lastObject == topObjectWithAclChanged) {
  +            fillAcl(topObjectWithAclChanged.getACL(), topAcl);
  +        }
       }
   
   
  @@ -420,6 +448,25 @@
                   htmlCache.invalidatePageEntries(Integer.toString(pageID));
               }
   
  +            if (parent instanceof ContentContainerList) {
  +                // since we have made modifications concerning this page, 
let's flush
  +                // the content cache for all the users and browsers as well 
as all
  +                // pages that display this containerList...
  +                Set containerPageRefs = ContentContainerListsXRefManager.
  +                        
getInstance().getAbsoluteContainerListPageIDs(parent.getID());
  +                if (containerPageRefs != null) {
  +                    Iterator pageRefIDs = containerPageRefs.iterator();
  +                    while (pageRefIDs.hasNext()) {
  +                        Integer curPageID = (Integer) pageRefIDs.next();
  +                        if (htmlCache != null) {
  +                            
htmlCache.invalidatePageEntries(curPageID.toString());
  +                        }
  +                    }
  +                } else {
  +                    logger.debug("Why is cross ref list empty ?");
  +                }
  +            }
  +
               String linkkey = 
atts.getValue(ImportExportBaseService.JAHIA_URI, "linkkey");
               if (linkkey != null) {
                   try {
  @@ -717,10 +764,14 @@
                       String principal = ace.substring(0, colonIndex);
                       if (principal.charAt(0) == 'u') {
                           JahiaUser user = 
ServicesRegistry.getInstance().getJahiaUserManagerService().lookupUser(principal.substring(2));
  -                        jAcl.setUserEntry (user, permissions);
  +                        if (user != null) {
  +                            jAcl.setUserEntry (user, permissions);
  +                        }
                       } else {
                           JahiaGroup group = 
ServicesRegistry.getInstance().getJahiaGroupManagerService().lookupGroup(principal.substring(2));
  -                        jAcl.setGroupEntry (group, permissions);
  +                        if (group != null) {
  +                            jAcl.setGroupEntry (group, permissions);
  +                        }
                       }
                   }
               }
  

Reply via email to