. Fix to allow Take Ownership of a Space through the web-client (current you could only Take Ownership of a document!)

- this is required to solve AWC-442

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2258 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2006-01-31 12:05:36 +00:00
parent dd95515b5f
commit 0305e81055
4 changed files with 60 additions and 1 deletions

View File

@@ -22,9 +22,11 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.faces.model.SelectItem;
import javax.transaction.UserTransaction;
import org.alfresco.model.ContentModel;
import org.alfresco.model.ForumModel;
@@ -33,6 +35,7 @@ import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.TemplateImageResolver;
import org.alfresco.service.cmr.repository.TemplateNode;
import org.alfresco.service.cmr.security.OwnableService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.web.app.AlfrescoNavigationHandler;
@@ -52,6 +55,8 @@ import org.alfresco.web.ui.common.component.UIActionLink;
*/
public class SpaceDetailsBean
{
private static final String MSG_SUCCESS_OWNERSHIP = "success_ownership";
private static final String OUTCOME_RETURN = "showSpaceDetails";
/** BrowseBean instance */
@@ -63,6 +68,9 @@ public class SpaceDetailsBean
/** PermissionService bean reference */
private PermissionService permissionService;
/** OwnableService bean reference */
private OwnableService ownableService;
/** NodeServuce bean reference */
private NodeService nodeService;
@@ -107,6 +115,16 @@ public class SpaceDetailsBean
this.permissionService = permissionService;
}
/**
* Sets the ownable service instance the bean should use
*
* @param ownableService The OwnableService
*/
public void setOwnableService(OwnableService ownableService)
{
this.ownableService = ownableService;
}
/**
* Returns the Space this bean is currently representing
*
@@ -337,6 +355,37 @@ public class SpaceDetailsBean
return OUTCOME_RETURN;
}
/**
* Action Handler to take Ownership of the current Space
*/
public void takeOwnership(ActionEvent event)
{
UserTransaction tx = null;
try
{
tx = Repository.getUserTransaction(FacesContext.getCurrentInstance());
tx.begin();
this.ownableService.takeOwnership(getSpace().getNodeRef());
FacesContext context = FacesContext.getCurrentInstance();
String msg = Application.getMessage(context, MSG_SUCCESS_OWNERSHIP);
FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO, msg, msg);
context.addMessage(event.getComponent().getClientId(context), facesMsg);
// commit the transaction
tx.commit();
}
catch (Throwable e)
{
// rollback the transaction
try { if (tx != null) {tx.rollback();} } catch (Exception ex) {}
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), e.getMessage()), e);
}
}
/**
* Navigates to next item in the list of Spaces
*/