Search in sources :

Example 1 with ClonedInputSource

use of org.apache.jackrabbit.core.xml.ClonedInputSource in project jackrabbit by apache.

the class RepositoryImpl method createWorkspace.

/**
     * Creates a workspace with the given name.
     *
     * @param workspaceName name of the new workspace
     * @throws RepositoryException if a workspace with the given name
     *                             already exists or if another error occurs
     * @see WorkspaceImpl#createWorkspace(String)
     */
protected void createWorkspace(String workspaceName) throws RepositoryException {
    synchronized (wspInfos) {
        if (wspInfos.containsKey(workspaceName)) {
            throw new RepositoryException("workspace '" + workspaceName + "' already exists.");
        }
        // needed to get newly created workspace config file content when
        // running in clustered environment
        StringBuffer workspaceConfigContent = null;
        if (context.getClusterNode() != null) {
            workspaceConfigContent = new StringBuffer();
        }
        // create the workspace configuration
        WorkspaceConfig config = repConfig.createWorkspaceConfig(workspaceName, workspaceConfigContent);
        WorkspaceInfo info = createWorkspaceInfo(config);
        wspInfos.put(workspaceName, info);
        if (workspaceConfigContent != null && createWorkspaceEventChannel != null) {
            // notify other cluster node that workspace has been created
            InputSource s = new InputSource(new StringReader(workspaceConfigContent.toString()));
            createWorkspaceEventChannel.workspaceCreated(workspaceName, new ClonedInputSource(s));
        }
    }
}
Also used : ClonedInputSource(org.apache.jackrabbit.core.xml.ClonedInputSource) InputSource(org.xml.sax.InputSource) ClonedInputSource(org.apache.jackrabbit.core.xml.ClonedInputSource) StringReader(java.io.StringReader) WorkspaceConfig(org.apache.jackrabbit.core.config.WorkspaceConfig) RepositoryException(javax.jcr.RepositoryException)

Example 2 with ClonedInputSource

use of org.apache.jackrabbit.core.xml.ClonedInputSource in project jackrabbit by apache.

the class RepositoryImpl method createWorkspace.

/**
     * Creates a workspace with the given name and given workspace configuration
     * template.
     *
     * @param workspaceName  name of the new workspace
     * @param configTemplate the workspace configuration template of the new
     *                       workspace
     * @throws RepositoryException if a workspace with the given name already
     *                             exists or if another error occurs
     * @see WorkspaceImpl#createWorkspace(String,InputSource)
     */
protected void createWorkspace(String workspaceName, InputSource configTemplate) throws RepositoryException {
    if (createWorkspaceEventChannel == null) {
        createWorkspaceInternal(workspaceName, configTemplate);
    } else {
        ClonedInputSource template = new ClonedInputSource(configTemplate);
        createWorkspaceInternal(workspaceName, template.cloneInputSource());
        createWorkspaceEventChannel.workspaceCreated(workspaceName, template);
    }
}
Also used : ClonedInputSource(org.apache.jackrabbit.core.xml.ClonedInputSource)

Aggregations

ClonedInputSource (org.apache.jackrabbit.core.xml.ClonedInputSource)2 StringReader (java.io.StringReader)1 RepositoryException (javax.jcr.RepositoryException)1 WorkspaceConfig (org.apache.jackrabbit.core.config.WorkspaceConfig)1 InputSource (org.xml.sax.InputSource)1