1 5 6 package org.exoplatform.services.jcr.impl.core; 7 8 9 import javax.jcr.RepositoryException; 10 import javax.jcr.Ticket; 11 import javax.jcr.Workspace; 12 13 import org.exoplatform.services.jcr.config.RepositoryServiceConfig; 14 import org.exoplatform.services.jcr.config.WorkspaceEntry; 15 import org.exoplatform.services.jcr.core.WorkspaceRegistry; 16 17 22 public class WorkspaceRegistryImpl implements WorkspaceRegistry { 23 24 private RepositoryServiceConfig repositoryServiceConfig; 25 26 public WorkspaceRegistryImpl(RepositoryServiceConfig repositoryServiceConfig) { 27 this.repositoryServiceConfig = repositoryServiceConfig; 28 } 29 30 public Workspace getWorkspace(Ticket ticket) throws RepositoryException { 31 WorkspaceEntry[] workspaceEntries = repositoryServiceConfig.getWorkspaceEntries(); 32 for (int i = 0; i < workspaceEntries.length; i++) { 33 WorkspaceEntry workspaceEntry = workspaceEntries[i]; 34 if(workspaceEntry.isBase()) 35 return createWorkspace(workspaceEntry.getName(), ticket); 36 } 37 return null; 38 } 39 40 public Workspace getWorkspace(String repositoryName, String workspaceName, Ticket ticket) throws RepositoryException { 41 WorkspaceEntry workspaceEntry = repositoryServiceConfig.getWorkspaceEntry(repositoryName, workspaceName); 42 if(workspaceEntry == null) 43 return getWorkspace(ticket); 44 else 45 return createWorkspace(workspaceName, ticket); 46 } 47 48 private Workspace createWorkspace(String workspaceName, Ticket ticket) throws RepositoryException { 49 return new WorkspaceImpl(workspaceName, ticket); 50 } 51 52 53 } 54 | Popular Tags |