jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From SalmasCM <sal...@criticalmass.com>
Subject Re: Workspaces in a cluster
Date Tue, 14 Apr 2009 15:11:00 GMT

But in this case I will not be able to administer the websites dynamically
from the admin server right? This is a requirement for my application so a
local PM is probably not the right choice for me?

I am still working on the problem that the  default workspace gets populated
whenever I save the preview workspace. I know I am saving the right session
since I print the workspace name In my repository config I have the path for
each workspace as and they have different names so I am assuming that the
indexes are being created in the right spots.

In my code I load the data into the default workspace of the admin
application and then create the preview workspace and merge it over. Would
this cause problems? Should I be doing something different? What is the
difference between clone and merge? Should I load the data into the default
workspace and then clone or merge it to preview?

Here is my code

public static void createWorkspace(String name,boolean
clone,ConnectionManager manager) {
      Workspace workspace = getSession().getWorkspace();

      JackrabbitWorkspace jws = (JackrabbitWorkspace) workspace;
      try {
          Node currentRoot = JCRUtil.getSession().getRootNode();
          //String srcAbsPath = currentRoot.getCorrespondingNodePath(srcWS);
         String[] workspaces = jws.getAccessibleWorkspaceNames();
         boolean hasWS = false;

         for (int i = 0; i < workspaces.length; i++) {
            if (workspaces[i].equals(name)) {
               hasWS = true;
               break;
            }
         }
         if (!hasWS) {
                if (jws != null && currentRoot != null) {
                    synchronized (jws) {
            jws.createWorkspace(name);
            if (clone) {
                NodeIterator nodes = currentRoot.getNodes();

                while (nodes.hasNext()) {
                    Node next = nodes.nextNode();
                    String nodeName = next.getName();
                    if (nodeName.indexOf("jcr:")==-1) {
                        getInstance().logger.info("merging " + nodeName);
                        JCRUtil.mergeToWorkspace(next, name);
                    } else {
                        getInstance().logger.info("skipping " + nodeName);
                    }
                }
            }
         }
                }
            }
         JCRUtil.saveSession();
      } catch (AccessDeniedException e) {
            getInstance().logger.error("RepositoryException
JCRUtil:createWorkspace ", e);
      } catch (NoSuchWorkspaceException e) {
            getInstance().logger.error("NoSuchWorkspaceException
JCRUtil:createWorkspace ", e);
      } catch (ConstraintViolationException e) {
            getInstance().logger.error("ConstraintViolationException
JCRUtil:createWorkspace ", e);
      } catch (VersionException e) {
            getInstance().logger.error("VersionException
JCRUtil:createWorkspace ", e);
      } catch (PathNotFoundException e) {
            getInstance().logger.error("PathNotFoundException
JCRUtil:createWorkspace ", e);
      } catch (ItemExistsException e) {
            getInstance().logger.error("ItemExistsException
JCRUtil:createWorkspace ", e);
      } catch (LockException e) {
            getInstance().logger.error("LockException
JCRUtil:createWorkspace ", e);
      } catch (RepositoryException e) {
            getInstance().logger.error("RepositoryException
JCRUtil:createWorkspace ", e);
      }
   }

   public static void mergeToWorkspace(Node node,String wsName) {
       try {
           if (node!=null) {
               synchronized(node) {
               NodeIterator failedNodes = node.merge(wsName, true);
               while (failedNodes.hasNext()) {
                   getInstance().logger.error("" +
failedNodes.nextNode().getName());
               }
               }
        }
    } catch (NoSuchWorkspaceException e) {
        getInstance().logger.error("mergeToProduction
:NoSuchWorkspaceException",e);
    } catch (AccessDeniedException e) {
        getInstance().logger.error("mergeToProduction
:AccessDeniedException",e);
    } catch (MergeException e) {
        getInstance().logger.error("mergeToProduction :MergeException",e);
    } catch (LockException e) {
        getInstance().logger.error("mergeToProduction :LockException",e);
    } catch (InvalidItemStateException e) {
        getInstance().logger.error("mergeToProduction
:InvalidItemStateException",e);
    } catch (RepositoryException e) {
        getInstance().logger.error("mergeToProduction
:RepositoryException",e);
    }
   }

Alexander Klimetschek wrote:
> 
> On Tue, Apr 14, 2009 at 3:54 PM, SalmasCM <salmas@criticalmass.com> wrote:
>> Thanks Alexander. I think its a bug in my code too. It helps to get
>> validation that I have the right approach.
>> What do you mean by a 'local' PM? I have a bundle PM for my websites and
>> don't say anything about it being local or not.
> 
> "Local" means that it is not part of the cluster. This typically means
> not to use the shared database for the clustering, but rather an
> embedded db like derby. This will also be faster.
> 
> Regards,
> Alex
> 
> -- 
> Alexander Klimetschek
> alexander.klimetschek@day.com
> 
> 

-- 
View this message in context: http://www.nabble.com/Workspaces-in-a-cluster-tp23032503p23041379.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Mime
View raw message