. Checkpoint of WCM ui work (nothing to see here, move along please, move along)

- "Websites" folder created under root of Company Home during bootstrap
 - Bootstrap properties and getter helper added to import-export-context & web-client
 - Beginnings of the Create Website wizard
 - Action definition added for Create Website action
 - Beginings of the model for avm webfolders and associated sub-structures

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3762 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2006-09-11 16:56:43 +00:00
parent 55c894aff0
commit 55ab249512
3 changed files with 453 additions and 0 deletions

View File

@@ -0,0 +1,175 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.web.bean.wcm;
import javax.faces.context.FacesContext;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.web.app.context.IContextListener;
import org.alfresco.web.app.context.UIContextService;
import org.alfresco.web.bean.BrowseBean;
import org.alfresco.web.bean.NavigationBean;
import org.alfresco.web.ui.common.component.data.UIRichList;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Bean backing up the AVM specific browse screens
*
* @author Kevin Roast
*/
public class AVMBrowseBean implements IContextListener
{
private static Log logger = LogFactory.getLog(AVMBrowseBean.class);
/** The NodeService to be used by the bean */
protected NodeService nodeService;
/** The DictionaryService bean reference */
protected DictionaryService dictionaryService;
/** The SearchService bean reference. */
protected SearchService searchService;
/** The NamespaceService bean reference. */
protected NamespaceService namespaceService;
/** The browse bean */
protected BrowseBean browseBean;
/** The NavigationBean bean reference */
protected NavigationBean navigator;
/**
* Default Constructor
*/
public AVMBrowseBean()
{
UIContextService.getInstance(FacesContext.getCurrentInstance()).registerBean(this);
//initFromClientConfig();
}
// ------------------------------------------------------------------------------
// Bean property getters and setters
/**
* @param nodeService The NodeService to set.
*/
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
/**
* @param dictionaryService The DictionaryService to set.
*/
public void setDictionaryService(DictionaryService dictionaryService)
{
this.dictionaryService = dictionaryService;
}
/**
* @param searchService The SearchService to set.
*/
public void setSearchService(SearchService searchService)
{
this.searchService = searchService;
}
/**
* @param namespaceService The NamespaceService to set.
*/
public void setNamespaceService(NamespaceService namespaceService)
{
this.namespaceService = namespaceService;
}
/**
* Sets the BrowseBean instance to use to retrieve the current document
*
* @param browseBean BrowseBean instance
*/
public void setBrowseBean(BrowseBean browseBean)
{
this.browseBean = browseBean;
}
/**
* @param navigator The NavigationBean to set.
*/
public void setNavigator(NavigationBean navigator)
{
this.navigator = navigator;
}
/**
* @param avmRichList The avmRichList to set.
*/
/*public void setAvmRichList(UIRichList avmRichList)
{
this.forumsRichList = forumsRichList;
if (this.forumsRichList != null)
{
// set the initial sort column and direction
this.forumsRichList.setInitialSortColumn(
this.viewsConfig.getDefaultSortColumn(PAGE_NAME_FORUMS));
this.forumsRichList.setInitialSortDescending(
this.viewsConfig.hasDescendingSort(PAGE_NAME_FORUMS));
}
}*/
/**
* @return Returns the forumsRichList.
*/
/*public UIRichList getForumsRichList()
{
return this.forumsRichList;
}*/
// ------------------------------------------------------------------------------
// IContextListener implementation
/**
* @see org.alfresco.web.app.context.IContextListener#contextUpdated()
*/
public void contextUpdated()
{
/*
// clear the value for the list components - will cause re-bind to it's data and refresh
if (this.forumsRichList != null)
{
this.forumsRichList.setValue(null);
if (this.forumsRichList.getInitialSortColumn() == null)
{
// set the initial sort column and direction
this.forumsRichList.setInitialSortColumn(
this.viewsConfig.getDefaultSortColumn(PAGE_NAME_FORUMS));
this.forumsRichList.setInitialSortDescending(
this.viewsConfig.hasDescendingSort(PAGE_NAME_FORUMS));
}
}
*/
}
}

View File

@@ -0,0 +1,37 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.web.bean.wcm;
/**
* @author Kevin Roast
*/
public class AVMConstants
{
/**
* Private constructor
*/
private AVMConstants()
{
}
public final static String STORE_STAGING = "-staging";
public final static String STORE_MAIN = "-main";
public final static String STORE_PREVIEW = "-preview";
public final static String DIR_APPBASE = "appBase";
public final static String DIR_WEBAPPS = "avm_webapps";
}

View File

@@ -0,0 +1,241 @@
/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.web.bean.wcm;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
import javax.faces.context.FacesContext;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.spaces.CreateSpaceWizard;
import org.alfresco.web.bean.wizard.BaseWizardBean;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* @author Kevin Roast
*/
public class CreateWebsiteWizard extends BaseWizardBean
{
private static Log logger = LogFactory.getLog(CreateWebsiteWizard.class);
protected String name;
protected String title;
protected String description;
private String websitesFolderId = null;
protected AVMService avmService;
// ------------------------------------------------------------------------------
// Wizard implementation
/**
* Initialises the wizard
*/
public void init(Map<String, String> parameters)
{
super.init(parameters);
this.name = null;
this.title = null;
this.description = null;
}
/**
* @see org.alfresco.web.bean.dialog.BaseDialogBean#finishImpl(javax.faces.context.FacesContext, java.lang.String)
*/
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
// create the website space in the correct parent folder
String websiteParentId = getWebsitesFolderId();
FileInfo fileInfo = this.fileFolderService.create(
new NodeRef(Repository.getStoreRef(), websiteParentId),
this.name,
ContentModel.TYPE_AVMWEBFOLDER);
NodeRef nodeRef = fileInfo.getNodeRef();
if (logger.isDebugEnabled())
logger.debug("Created website folder node with name: " + this.name);
// apply the uifacets aspect - icon, title and description props
Map<QName, Serializable> uiFacetsProps = new HashMap<QName, Serializable>(4);
uiFacetsProps.put(ContentModel.PROP_ICON, CreateSpaceWizard.DEFAULT_SPACE_ICON_NAME);
uiFacetsProps.put(ContentModel.PROP_TITLE, this.title);
uiFacetsProps.put(ContentModel.PROP_DESCRIPTION, this.description);
this.nodeService.addAspect(nodeRef, ContentModel.ASPECT_UIFACETS, uiFacetsProps);
// TODO: create layers for invited users
// TODO: invite users with appropriate permissions into this folder
// create the AVM store to represent the newly created location website
this.avmService.createAVMStore(this.name);
AVMStoreDescriptor avmStore = this.avmService.getAVMStore(this.name);
this.avmService.createDirectory("/", "appBase");
this.avmService.createDirectory("/appBase", "avm_webapps");
this.avmService.createDirectory("/appBase/avm_webapps", this.name);
// set the property on the node to reference the AVM store
this.nodeService.setProperty(nodeRef, ContentModel.PROP_AVMSTORE, this.name);
// navigate to the Websites folder so we can see the newly created folder
this.navigator.setCurrentNodeId(websiteParentId);
return "browse";
}
/**
* @param avmService The avmService to set.
*/
public void setAvmService(AVMService avmService)
{
this.avmService = avmService;
}
/**
* @return Returns the name.
*/
public String getName()
{
return name;
}
/**
* @param name The name to set.
*/
public void setName(String name)
{
this.name = name;
}
/**
* @return Returns the title.
*/
public String getTitle()
{
return title;
}
/**
* @param title The title to set.
*/
public void setTitle(String title)
{
this.title = title;
}
/**
* @return Returns the description.
*/
public String getDescription()
{
return description;
}
/**
* @param description The description to set.
*/
public void setDescription(String description)
{
this.description = description;
}
/**
* @return summary text for the wizard
*/
public String getSummary()
{
ResourceBundle bundle = Application.getBundle(FacesContext.getCurrentInstance());
return buildSummary(
new String[] {bundle.getString("name"),
bundle.getString("description")},
new String[] {this.name, this.description});
}
/**
* Helper to get the ID of the 'Websites' system folder
*
* @return ID of the 'Websites' system folder
*
* @throws AlfrescoRuntimeException if unable to find the required folder
*/
private String getWebsitesFolderId()
{
if (this.websitesFolderId == null)
{
// get the template from the special Content Templates folder
FacesContext fc = FacesContext.getCurrentInstance();
String xpath = Application.getRootPath(fc) + "/" + Application.getWebsitesFolderName(fc);
NodeRef rootNodeRef = this.nodeService.getRootNode(Repository.getStoreRef());
NamespaceService resolver = Repository.getServiceRegistry(fc).getNamespaceService();
List<NodeRef> results = this.searchService.selectNodes(rootNodeRef, xpath, null, resolver, false);
if (results.size() == 1)
{
this.websitesFolderId = results.get(0).getId();
}
else
{
throw new AlfrescoRuntimeException("Unable to find 'Websites' system folder at: " + xpath);
}
}
return this.websitesFolderId;
}
private void createStagingStore(String name)
{
String stagingStore = name + AVMConstants.STORE_STAGING;
this.avmService.createAVMStore(stagingStore);
String path = stagingStore + ":/";
this.avmService.createDirectory(path, AVMConstants.DIR_APPBASE);
path += '/' + AVMConstants.DIR_APPBASE;
this.avmService.createDirectory(path, AVMConstants.DIR_WEBAPPS);
}
private void createSandboxStores(String name, String username)
{
String sandboxStore = name + '-' + username + AVMConstants.STORE_MAIN;
this.avmService.createAVMStore(sandboxStore);
String path = sandboxStore + ":/";
this.avmService.createLayeredDirectory(name + AVMConstants.STORE_STAGING, path, AVMConstants.DIR_APPBASE);
String previewStore = name + AVMConstants.STORE_PREVIEW;
this.avmService.createAVMStore(previewStore);
path = previewStore + ":/";
this.avmService.createLayeredDirectory(name + AVMConstants.STORE_STAGING, path, AVMConstants.DIR_APPBASE);
}
}